5#include "../../Defines.h"
20#include "../M5AtomClassModule/M5AtomClassType.h"
22#ifdef TODO_CANT_GET_TO_COMPILE
58#define PT_SERVICE_UUID "b0e6a4bf-cccc-ffff-330c-0000000000f0"
59#define PT_CHARACTERISTIC_UUID "b0e6a4bf-cccc-ffff-330c-0000000000f1"
65#define TOPIC_TO_SEND (char*)"usersP/bark"
71#define NO_POWEROFF_AMOUNT_MAIN 10000
72#define NO_POWEROFF_AMOUNT_STRING_MAIN (char*)"10000"
77#define THRESHOLD_KIND_LIGHT 0
78#define THRESHOLD_KIND_DARK 1
90#define CALLBACKS_MQTT 0
91#define CALLBACKS_BUTTON_MODULE 1
92#define CALLBACKS_BLE_CLIENT 2
93#define CALLBACKS_BLE_SERVER 3
94#define CALLBACKS_MODULE_MAX 4
97#define SINGLE_CLICK_BM 0
98#define MAX_CALLBACKS_BM 1
103void callCallbackMain(
int callbacksModuleId,
int callbackType,
char *message);
180void main_updateMQTTInfo(
char *ssid,
char *ssid_password,
char *username,
char *password,
char *guestPassword,
char *deviceName,
char * host,
char * port,
char *locationString);
201#define ASYNC_CALL_OTA_UPDATE 0
203#define ASYNC_CALL_CLEAN_CREDENTIALS 1
205#define ASYNC_CALL_CLEAN_EPROM 2
207#define ASYNC_CALL_FEED_COMMAND 3
209#define ASYNC_CALL_BUZZ_ON 4
211#define ASYNC_CALL_BUZZ_OFF 5
213#define ASYNC_SEND_MQTT_FEED_MESSAGE 6
215#define ASYNC_SEND_MQTT_STATUS_URL_MESSAGE 7
218#define ASYNC_SET_GATEWAY_ON 8
220#define ASYNC_SET_GATEWAY_OFF 9
223#define ASYNC_REBOOT 10
225#define ASYNC_POWEROFF 11
227#define ASYNC_BLANKSCREEN 12
230#define ASYNC_SWAP_WIFI 13
232#define ASYNC_NEXT_WIFI 14
234#define ASYNC_RESTART_WIFI_MQTT 15
236#define ASYNC_CLICK_SOUND 16
238#define ASYNC_CALL_MAX 17
241#define ASYNC_CALL_BLE_CLIENT_PARAMETER 0
243#define ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER 1
245#define ASYNC_JSON_MESSAGE_PARAMETER 2
247#define ASYNC_JSON_MQTT_MESSAGE_PARAMETER 3
249#define ASYNC_REST_CALL_MESSAGE_PARAMETER 4
251#define ASYNC_CALL_PARAMETERS_MAX 5
268#define SYNC_CLICK_SOUND 0
269#define SYNC_CALL_MAX 1
302void main_setStatusJSON(
const char* JSONString);
304void main_setStatusKeyValue(
const char* key,
const char* value);
367#define SM_home_simple 0
368#define SM_home_simple_1 1
369#define SM_home_simple_2 2
370#define SM_home_simple_3 3
371#define SM_HOME_SIMPLE_LAST SM_home_simple_3
376#define SM_smart_clicker_homepage 4
380#define SM_WIFI_ssid 6
382#define SM_guest_page 7
389#define SM_guest_feed 9
391#define SM_pair_dev 10
396#define SM_doc_follow 12
401#define SM_LAST SM_reboot
405#define MAX_SM_MIN_MODES (SM_HOME_SIMPLE_LAST + 1)
406#define MAX_SM_EXPANDED_MODES (SM_LAST + 1)
497#pragma mark PIN_USE_STRUCT
509#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.
char * createCopy2(const char *stringA)
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)
boolean registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
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 solidLightMessageCallback(char *message)
callback for SOLID blinking led
boolean isEmptyString(char *stringA)
if an empty string
void rebootDevice_mainModule()
void setConfiguration_mainModule(char *configurationName)
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 buttonA_LongLongPress_mainModule()
long long press on buttonA (top button)
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 ...
String getColorString(ColorsUnified color)
returns a string for the color int
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'.
char * getServerServiceName_mainModule()
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
PinUseStruct * getPinUseStruct_mainModule()
get the pin use array
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
void espUpdate_mainModule(int num)
the Update aggrgate
ColorsUnified getRandomColor()
7.24.25 return a (semi) random color
void espBegin_mainModule(int num)
float getBatPercentage_mainModule()
start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
void setLEDColor(ColorsUnified color)
uses colors.. _GREEN_LED to be typed values