5#include "../../Defines.h"
20#include "../M5AtomClassModule/M5AtomClassType.h"
22#ifdef TODO_CANT_GET_TO_COMPILE
54#define PT_SERVICE_UUID "b0e6a4bf-cccc-ffff-330c-0000000000f0"
55#define PT_CHARACTERISTIC_UUID "b0e6a4bf-cccc-ffff-330c-0000000000f1"
61#define TOPIC_TO_SEND (char*)"usersP/bark"
67#define NO_POWEROFF_AMOUNT_MAIN 10000
68#define NO_POWEROFF_AMOUNT_STRING_MAIN (char*)"10000"
73#define THRESHOLD_KIND_LIGHT 0
74#define THRESHOLD_KIND_DARK 1
86#define CALLBACKS_MQTT 0
87#define CALLBACKS_BUTTON_MODULE 1
88#define CALLBACKS_BLE_CLIENT 2
89#define CALLBACKS_BLE_SERVER 3
90#define CALLBACKS_MODULE_MAX 4
93#define SINGLE_CLICK_BM 0
94#define MAX_CALLBACKS_BM 1
99void callCallbackMain(
int callbacksModuleId,
int callbackType,
char *message);
170void main_updateMQTTInfo(
char *ssid,
char *ssid_password,
char *username,
char *password,
char *guestPassword,
char *deviceName,
char * host,
char * port,
char *locationString);
191#define ASYNC_CALL_OTA_UPDATE 0
193#define ASYNC_CALL_CLEAN_CREDENTIALS 1
195#define ASYNC_CALL_CLEAN_EPROM 2
197#define ASYNC_CALL_FEED_COMMAND 3
199#define ASYNC_CALL_BUZZ_ON 4
201#define ASYNC_CALL_BUZZ_OFF 5
203#define ASYNC_SEND_MQTT_FEED_MESSAGE 6
205#define ASYNC_SEND_MQTT_STATUS_URL_MESSAGE 7
208#define ASYNC_SET_GATEWAY_ON 8
210#define ASYNC_SET_GATEWAY_OFF 9
213#define ASYNC_REBOOT 10
215#define ASYNC_POWEROFF 11
217#define ASYNC_BLANKSCREEN 12
220#define ASYNC_SWAP_WIFI 13
222#define ASYNC_NEXT_WIFI 14
224#define ASYNC_RESTART_WIFI_MQTT 15
226#define ASYNC_CLICK_SOUND 16
228#define ASYNC_CALL_MAX 17
231#define ASYNC_CALL_BLE_CLIENT_PARAMETER 0
233#define ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER 1
235#define ASYNC_JSON_MESSAGE_PARAMETER 2
237#define ASYNC_JSON_MQTT_MESSAGE_PARAMETER 3
239#define ASYNC_REST_CALL_MESSAGE_PARAMETER 4
241#define ASYNC_CALL_PARAMETERS_MAX 5
258#define SYNC_CLICK_SOUND 0
259#define SYNC_CALL_MAX 1
292void main_setStatusJSON(
const char* JSONString);
294void main_setStatusKeyValue(
const char* key,
const char* value);
357#define SM_home_simple 0
358#define SM_home_simple_1 1
359#define SM_home_simple_2 2
360#define SM_home_simple_3 3
361#define SM_HOME_SIMPLE_LAST SM_home_simple_3
366#define SM_smart_clicker_homepage 4
370#define SM_WIFI_ssid 6
372#define SM_guest_page 7
379#define SM_guest_feed 9
381#define SM_pair_dev 10
386#define SM_doc_follow 12
391#define SM_LAST SM_reboot
395#define MAX_SM_MIN_MODES (SM_HOME_SIMPLE_LAST + 1)
396#define MAX_SM_EXPANDED_MODES (SM_LAST + 1)
494#define PIN_USE_MAX 20
M5AtomClassType * whichM5AtomClassType()
6.6.25 get the current M5AtomClassType
void sendSemanticMarkerDocFollow_mainModule(const char *SMDocFollowAddress)
sends the SM on the DOCFOLLOW channel (publish it..)
void cleanEPROM_mainModule()
cleans the main module EPROM
void main_cleanSavedWIFICredentials()
clean the saved WIFI credential, otherwise the AP mode doesn't work (6.3.22)
void messageSend_mainModule(char *sendValue, boolean deviceNameSpecified)
TODO: have a callback regist approach.
void main_updateMQTTInfo(char *ssid, char *ssid_password, char *username, char *password, char *guestPassword, char *deviceName, char *host, char *port, char *locationString)
sets the WIFI and MQTT user/password. It's up to the code to decide who needs to know (currently this...
void setConnectedBLEDevice_mainModule(char *deviceName, boolean isGEN3)
char * connectedBLEDeviceNameAddress_mainModule()
returns address part of name.
void cleanSSID_EPROM_MessageCallback(char *message)
take a picture (calls the camera module).. what to do with picture??? TODO
void toggleMinimalMenuMode_mainModule()
toggles the menu mode
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
char * main_getUsername()
char * groupTopicFullName(char *groupName)
returns a groupTopic to use as a topic
bool stringMatch(String message, String substring)
check if the string matches
void loop_mainModule()
called for the loop() of this plugin
char * getSemanticMarkerDocFollow_mainModule()
get the latest semantic marker for doc follow
void main_setScannedGroupName(char *groupName)
void registerCallbackMain(int callbacksModuleId, int callbackType, void(*callback)(char *))
register the callback based on the callbackType. use the callbacksModuleId for which one....
char * deviceName_mainModule()
gets the device name
int getLUXThreshold_mainModule(int thresholdKind)
get the threshold val
void sendStatusMQTT_mainModule()
TODO: have a callback regist approach.
boolean connectedBLEDeviceIsGEN3_mainModule()
whether the connected is a GEN3 (so the name isn't valid).
char * semanticMarkerToJSON_mainModule(char *semanticMarker)
char * main_currentStatusURL(boolean fullStatus)
int minMenuModesMax_mainModule()
returns the current max of the MIN menu modes (using the setting of min or expanded) to determine
void main_setScannedDeviceName(char *deviceName)
set the scanned device name
void processClientCommandChar_mainModule(char cmd)
single character version of processClientCommand (since many used that already)
int getFeedCount_mainModule()
feedcount info..
void onStatusMessageBLEServerCallback(char *message)
** The callback for "status messages" of the bluetooth
char * main_JSONStringForWIFICredentials()
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
int feedCountMax_mainModule()
returns the max for this feeder
void solidLight(char *message)
callback for SOLID blinking led
void setClockwiseMotorDirection_mainModule(boolean isClockwiseFlag)
8.18.24 setting this will check for the factory setting..
void sendMessageStringTopic_mainModule(char *messageString, char *topicString)
adding a synchronous call to send a message over the network (assuming MQTT but not specified),...
char * main_getScannedGroupNameTopic()
void main_credentialsUpdated()
moved here 4.25.22 (entirely from ESP_IOT.ino)
void setup_mainModule()
called from the setup()
void main_dispatchSyncCommand(int syncCallCommand)
the main sync command (no parameters yet)
boolean stopAllProcesses_mainModule()
if stopped
void restartAllMenuStates_mainModule()
restarts all the menu states to the first one .. useful for getting a clean start....
void setSemanticMarkerDocFollow_mainModule(char *SMDocFollowAddress)
sed the address to follow
boolean isTrueString_mainModule(String valCmdString)
whether the string is TRUE, ON, 1
char * main_getPassword()
return password
int whichSMMode_mainModule(char *cmd)
returns an index from 0..max of SM matching cmd, or -1 if none
void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter)
void initAsyncCallFlags()
storage for asyncCallCommands
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
void solidLightMessageCallback(char *message)
callback for SOLID blinking led
boolean isEmptyString(char *stringA)
if an empty string
void rebootDevice_mainModule()
void poweroff_mainModule()
power off
int maxMenuModes_mainModule()
returns the current max of the menu modes (using the setting of min or expanded) to determine
void buttonB_ShortPress_mainModule()
the short press of the side button
boolean isPTFeeder_mainModule()
gets if PTFeeder a surrogate for the M5Atom class
bool containsSubstring(String message, String substring)
check if the string contains the other string (if substring is "" then no match)
void decrementSMMode_mainModule()
increment the currentSMMode, wrapping and using the max menu
void callCallbackMain(int callbacksModuleId, int callbackType, char *message)
performs the indirect callback based on the callbackType
int getCurrentSMMode_mainModule()
returns the current SM Mode
void stopMotor_mainModule()
added 9.29.22 to support wildcards #196
void stopProcessesForOTAUpdate_mainModule()
stop all loops... while OTA working..
void feedMessageCallback(char *message)
void resetFeedCount_mainModule()
sets the feed count max
void sendMessageString_mainModule(char *messageString)
adding a synchronous call to send a message over the network (assuming MQTT but not specified),...
char * main_currentStatusJSON()
returns a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
void changeButtonColor_MainModule()
2.21.25 add a way to change the button color (if any)
void setup_Sensors_mainModule()
setup of buttons and sensors
char * getFullBLEDeviceName_mainModule()
returns full name and address, and service.
int getFeederType_mainModule()
get the feeder type (Sepper 1,2,3 ...)
void buttonA_LongPress_mainModule()
long press on buttonA (top button)
void invokeAsyncCommands()
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
boolean startsWithChar(char *str, char c)
a char* version of startsWith (after skipping spaces)
void showText_mainModule(String text)
void setCurrentSMMode_mainModule(int whichSMMode)
sets the current screen mode .. which can be used by Button and Display processing
void onWriteBLEServerCallback(char *message)
The callback for "onWrite" of the bluetooth "onWrite'.
void setLUXThreshold_mainModule(int thresholdKind, int luxVal)
set the threshold val
void main_dispatchAsyncCommand(int asyncCallCommand)
dispatches a call to the command specified. This is run on the next loop()
boolean matchesSMMode_mainModule(char *cmd, int whichSMMode)
returns if a match the mode. whichSMMode is 0..12 and == sm0 .. smn
char * getChipIdString()
3.17.24 get the chip id as a string
void refreshDelayButtonTouched_MainModule()
called by the feed operation to say the device is still running.. and count it as a button click.
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
uint32_t getChipId()
3.17.24 get the chip id
boolean isMinimalMenuMode_mainModule()
returns which mode in (min or expanded)
void loop_Sensors_mainModule()
1.22.24 add setup and loop at main so it can call appropriate plugs
int getTimeStamp_mainModule()
void buttonB_LongPress_mainModule()
the long press of the side button
void blinkMessageCallback(char *message)
callback for blinking led
void restartProcessesForOTAUpdate_mainModule()
restart all loops... while OTA working..
char * main_getScannedDeviceName()
return devicename
char * createCopy(char *stringA)
void main_printModuleConfiguration()
void messageSetVal_mainModule(char *setName, char *valValue, boolean deviceNameSpecified)
void solidLightOnOff(boolean flag)
supports turning on the solid light..
void singleClickTouched(char *whichButton)
float getTemperature_mainModule()
retrieves the temperature in F.
void buttonA_ShortPress_mainModule()
char * main_nextJSONWIFICredential()
! cycle through the next WIFI saved credential - return next one that isn't our current one....
void onBLEServerCallback(char *message)
The callback for "onWrite" of the bluetooth "onWrite'.
void incrementSMMode_mainModule()
increment the currentSMMode, wrapping and using the max menu
void incrementFeedCount_mainModule()
increments .. and if MAX goes to 0 – and sends a message on MQTT
PinUseStruct getPinUseStruct_mainModule()
get the pin use array
float getBatPercentage_mainModule()
start of the sensor updates ... TODO: tie these to the MQTT messaging as well..