ESP_IOT v2.5
IOT ESP Coding
MainModule.h
Go to the documentation of this file.
1
2#ifndef MainModule_h
3#define MainModule_h
4
5#include "../../Defines.h"
6
7//!added 9.29.22 to support wildcards #196
8#include "TokenParser.h"
9
10//! always avaialble to others.. the model controller part of MVC. The View is in DisplayModule. The other part of Controller is the button clicks in ButtonProcess.h (but with this, there is no logic there..)
11#include "ModelController.h"
12
13//! preferences
15
16//! 3.29.25 add the TimerDelayClass
17#include "TimerDelayClass.h"
18
19//! 6.6.25 include to get the current one..
20#include "../M5AtomClassModule/M5AtomClassType.h"
21
22#ifdef TODO_CANT_GET_TO_COMPILE
23//! 6.6.25 get the current M5AtomClassType
25#else
26//! 6.7.25 hot air balloons over house..
27//! stops the motor
29//! gets if PTFeeder a surrogate for the M5Atom class
30boolean isPTFeeder_mainModule();
31#endif
32//! 10.10.25 #405 #406
33//! see if the device is a PTClicker if the M5Atom class is one..
34//! return the service name: PTClicker or PTFeeder
36
37//!THIS IS the setup() and loop() but using the "component" name, eg MQTTNetworking()
38//!This will perform preference initializtion as well
39//! called from the setup()
40void setup_mainModule();
41
42//! called for the loop() of this plugin
43void loop_mainModule();
44
45//!cleans the main module EPROM
47
48//!stop all loops... while OTA working..
50//! if stopped
52//!restart all loops... while OTA working..
54
55//! 8.18.24 setting this will check for the factory setting..
56void setClockwiseMotorDirection_mainModule(boolean isClockwiseFlag);
57
58#define PT_SERVICE_UUID "b0e6a4bf-cccc-ffff-330c-0000000000f0" //Pet Tutor feeder service for feed NOTE: Lower case for GEN3 compatability
59#define PT_CHARACTERISTIC_UUID "b0e6a4bf-cccc-ffff-330c-0000000000f1" //Pet Tutor feeder characteristic NOTE: Lower case for GEN3 compatability
60
61#ifdef ESP_M5
62#define LED 2
63#endif
64
65#define TOPIC_TO_SEND (char*)"usersP/bark"
66//#define GROUP_TOPIC_TO_SEND (char*)"/usersP/groups"
67//!returns a groupTopic to use as a topic
68char *groupTopicFullName(char *groupName);
69
70//!10000 == no poweroff
71#define NO_POWEROFF_AMOUNT_MAIN 10000
72#define NO_POWEROFF_AMOUNT_STRING_MAIN (char*)"10000"
73
74
75//! 1.12.24 add a temporary LUX dark
76//! threshholdKind = 0 (LIGHT), 1=(DARK) .. others might be 2=super dark
77#define THRESHOLD_KIND_LIGHT 0
78#define THRESHOLD_KIND_DARK 1
79void setLUXThreshold_mainModule(int thresholdKind, int luxVal);
80int getLUXThreshold_mainModule(int thresholdKind);
81
82//! processes a message that might save in the EPROM.. the cmd is still passed onto other (like the stepper module)
83//! returns true if finished processing, otherwise this can be sent onto other modules (like stepper)
84//void processClientCommand_mainModule(String message);
85//! single character version of processClientCommand (since many used that already)
87//! New RegisterCallback that works across a number of callback modules
88//!
89//! callbacksModuleId
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
95
96
97#define SINGLE_CLICK_BM 0
98#define MAX_CALLBACKS_BM 1
99
100//!register the callback based on the callbackType. use the callbacksModuleId for which one..
101void registerCallbackMain(int callbacksModuleId, int callbackType, void (*callback)(char*));
102//!performs the indirect callback based on the callbackType
103void callCallbackMain(int callbacksModuleId, int callbackType, char *message);
104
105//!adding a synchronous call to send a message over the network (assuming MQTT but not specified), this tacks on {device} and {t:time}
106void sendMessageString_mainModule(char *messageString);
107
108//!adding a synchronous call to send a message over the network (assuming MQTT but not specified), this tacks on {device} and {t:time}
109void sendMessageStringTopic_mainModule(char *messageString, char*topicString);
110
111//! 8.16.25 MQTT
112//!example callback: but the scope would have the pCharacteristic defined, etc..
113//!This is pased just before the setupMQTTNetworking() is called..
114void feedMessageCallback(char *message);
115
116//!supports turning on the solid light..
117void solidLightOnOff(boolean flag);
118
119//! main BEGIN and UPDATE .. everyone calls this .. and we can see if done too many times
120//! 7.26.26
121//! pass num to see if duplicates being called
122void espBegin_mainModule(int num);
123void espUpdate_mainModule(int num);
124
125//COMMON CALLBACKS
126//NOTE: This is where the true Object Oriented dynamic plug-in approaches would come in..
127// We are using #ifdef to bound the plug-in but there is still too much knowledge about wiring events to methods
128// in this code.. TODO, make more dynmaic event based..
129
130//*** The callback for "onWrite" of the bluetooth "onWrite'
131void onWriteBLEServerCallback(char *message);
132
133/*******************************BLE Server*************************************/
134//*** The callback for "onWrite" of the bluetooth "onWrite'
135void onBLEServerCallback(char *message);
136
137//! ** The callback for "status messages" of the bluetooth
138void onStatusMessageBLEServerCallback(char *message);
139
140//!prints the module configuration by looking at defines
141//! Eventually this might be an object returned letting the code
142//!know a capability is included for runtime (vs compile time) decisions
144
145//!called on single click
146//!NOTE: with BLE_CLIENT_NETWORKING, the right button and top button send a BLE command for feeding..
147void singleClickTouched(char *whichButton);
148
149//!callback for SOLID blinking led
150void solidLight(char *message);
151
152//!callback for blinking led
153void blinkMessageCallback(char *message);
154
155
156//!take a picture (calls the camera module).. what to do with picture??? TODO
157//void takePicture_MainModule();
158
159//!clean the SSID eprom (MQTT_CLEAN_SSID_EPROM)
160void cleanSSID_EPROM_MessageCallback(char *message);
161
162//!callback for SOLID blinking led
163void solidLightMessageCallback(char *message);
164
165//!clean the saved WIFI credential, otherwise the AP mode doesn't work (6.3.22)
167
168//!TESTING for saying credentials are filled in via BLE (while in AP mode), so kick out of AP and continue..
169//! set that the credentials are set. Called from the MQTT after processJSONMessage() found things were good..
170//! April 8, 2022
172
173//!retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
175
176//!! cycle through the next WIFI saved credential - return next one that isn't our current one..
178
179//! sets the WIFI and MQTT user/password. It's up to the code to decide who needs to know (currently this calls APmodule..)
180void main_updateMQTTInfo(char *ssid, char *ssid_password, char *username, char *password, char *guestPassword, char *deviceName, char * host, char * port, char *locationString);
181
182//! return the username and password
183//! 12.14.23 to support calling the SMART buttons (smrun) with parameters
184char *main_getUsername();
185//! return password
186char *main_getPassword();
187//! return devicename
189//! set the scanned device name
190void main_setScannedDeviceName(char *deviceName);
191//! set the scanned group name
192//! 1.7.24
193void main_setScannedGroupName(char *groupName);
194//! return groupname -- returns "" or nil if not set,
195//! or the FULL group name topic, or nil
197//! TODO: make this a registeration approach
198
199//! 3.21.22 these are to setup for the next time the main loop() runs to call these commands..
200//! The implementation is hard coded in the ESP_IO.ino
201#define ASYNC_CALL_OTA_UPDATE 0
202//! cleans out the credentials and restarts in AP (Access Point) mode.
203#define ASYNC_CALL_CLEAN_CREDENTIALS 1
204//!cleans the EPROM totally, and reboots
205#define ASYNC_CALL_CLEAN_EPROM 2
206//!sends a 'c' to the BLE end of the code (assuming a feeder is connected). Need to morph if a real feeder
207#define ASYNC_CALL_FEED_COMMAND 3
208//!sends a 'B' to the BLE end of the code (assuming a feeder is connected).
209#define ASYNC_CALL_BUZZ_ON 4
210//!sends a 'b' to the BLE end of the code (assuming a feeder is connected).
211#define ASYNC_CALL_BUZZ_OFF 5
212//!sends a message (like #FEED) on the users topic
213#define ASYNC_SEND_MQTT_FEED_MESSAGE 6
214//!sends the status from the main module URL
215#define ASYNC_SEND_MQTT_STATUS_URL_MESSAGE 7
216
217//!sets the GATEWAY mode on
218#define ASYNC_SET_GATEWAY_ON 8
219//!sets the GATEWAY mode off
220#define ASYNC_SET_GATEWAY_OFF 9
221
222//!sets the GATEWAY mode off
223#define ASYNC_REBOOT 10
224//!sets the GATEWAY mode off
225#define ASYNC_POWEROFF 11
226//!blank the screen
227#define ASYNC_BLANKSCREEN 12
228
229//! swaps WIFI 'w'
230#define ASYNC_SWAP_WIFI 13
231//! next WIFI 'n'
232#define ASYNC_NEXT_WIFI 14
233//! restarts the WIFI (after BLE interrupt over)
234#define ASYNC_RESTART_WIFI_MQTT 15
235//! 5.15.25 add a BUZZ command (or CLICK)
236#define ASYNC_CLICK_SOUND 16
237//! the max one greater than last one
238#define ASYNC_CALL_MAX 17 //don't forget to update this MAX (last one + 1)
239
240//!these are the async with a string parameter. This sends a BLE command unless MQTT
241#define ASYNC_CALL_BLE_CLIENT_PARAMETER 0
242//!these are the async with a string parameter
243#define ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER 1
244//!these are the async with a string parameter
245#define ASYNC_JSON_MESSAGE_PARAMETER 2
246//!these are the async with a string parameter
247#define ASYNC_JSON_MQTT_MESSAGE_PARAMETER 3
248//!send REST call
249#define ASYNC_REST_CALL_MESSAGE_PARAMETER 4
250//! the max one greater than last one
251#define ASYNC_CALL_PARAMETERS_MAX 5
252
253//! dispatches a call to the command specified. This is run on the next loop()
254void main_dispatchAsyncCommand(int asyncCallCommand);
255
256//!send an async call with a string parameter. This will set store the value and then async call the command (passing the parameter)
257//!These are the ASYNC_CALL_PARAMETERS_MAX
258void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter);
259
260//!storage for asyncCallCommands
261void initAsyncCallFlags();
262
263//!checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to false
265
266//! 5.16.25 Fountainhead, Raining cold weekend
267//! start SYNC calls starting with the SYNC_CLICK_SOUND
268#define SYNC_CLICK_SOUND 0
269#define SYNC_CALL_MAX 1
270//! the main sync command (no parameters yet)
271void main_dispatchSyncCommand(int syncCallCommand);
272
273//! 3.17.24 get the chip id
274uint32_t getChipId();
275//! 3.17.24 get the chip id as a string
276char* getChipIdString();
277
278// **** Helper Methods
279//!If nil it create one with just the null, so strlen = 0
280//!NOTE: the strdup() might be used later..
281char* createCopy(char * stringA);
282//!a char* version of startsWith (after skipping spaces)
283boolean startsWithChar(char *str, char c);
284//! if an empty string
285boolean isEmptyString(char *stringA);
286//!check if the string contains the other string (if substring is "" then no match)
287bool containsSubstring(String message, String substring);
288//!check if the string matches
289bool stringMatch(String message, String substring);
290//gets unix time..
292
293//!returns a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
295
296//!returns a string in in URL so: status&battery=84'&buzzon='off' } .. etc
297//!if fullStatus, return everything, else just the ATOM stuff
298char* main_currentStatusURL(boolean fullStatus);
299
300#ifdef UNUSED
301//!sets status parts cia a a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
302void main_setStatusJSON(const char* JSONString);
303//!sets status parts cia a a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
304void main_setStatusKeyValue(const char* key, const char* value);
305#endif
306
307//!retrieves the temperature in F.
309
310//!start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
312
313#ifdef NOT_USED
314//!see the external IP .. try 2.21.22
315void getExternalIP();
316#endif
317
318//!feedcount info..
320//increments .. and if MAX goes to 0 -- and sends a message on MQTT
322//! sets the feed count max
324
325//! called by the feed operation to say the device is still running.. and count it as a button click.
326//! Issue #145 8.8.22
328
329/*STEPPER feederType*/
330/*
331#define STEPPER_IS_UNO 1
332#define STEPPER_IS_MINI 2
333#define STEPPER_IS_TUMBLER 3
334 */
335//!get the feeder type (Sepper 1,2,3 ...)
337
338//!returns the max for this feeder
340
341//! shows a FEED (or whatever) then blanks the screen after N seconds
342//! NOTE: This will be a scrolling text as sometime ..
343void showText_mainModule(String text);
344
345//!SemanticMarker events
346//!This would see a DOCFollow message, and set the value.. then SM10 can display it..
347void setSemanticMarkerDocFollow_mainModule(char* SMDocFollowAddress);
348//!get the latest semantic marker for doc follow
350
351//!sends the SM on the DOCFOLLOW channel (publish it..)
352void sendSemanticMarkerDocFollow_mainModule(const char* SMDocFollowAddress);
353
354//!gets the device name
356
357//!power of devices
358//!reboot
360
361//!power off
363
364//!Semantic Marker definitions
365//! defines the semantic markers for now..
366//! Minimal 0..6 (max = 7)
367#define SM_home_simple 0 //tilt
368#define SM_home_simple_1 1 //buzz
369#define SM_home_simple_2 2 //FEED PAGE
370#define SM_home_simple_3 3 //advanced
371#define SM_HOME_SIMPLE_LAST SM_home_simple_3
372// update: MAX_SM_MIN_MODES when adding one..
373// and update the MINI-1 .. passed from MQTT to BUTTON
374
375//! //! homepage
376#define SM_smart_clicker_homepage 4
377//! //status
378#define SM_status 5
379//!WIFI ssid
380#define SM_WIFI_ssid 6
381//!guest page
382#define SM_guest_page 7
383
384//!AP MODE
385#define SM_ap_mode 8
386
387
388//!guest feed
389#define SM_guest_feed 9
390//!guest feed device
391#define SM_pair_dev 10
392//!HELP
393#define SM_help 11
394
395//! docfollow
396#define SM_doc_follow 12
397//! timer .. todo
398#define SM_timer 13
399//!REboot
400#define SM_reboot 14
401#define SM_LAST SM_reboot
402
403//!note for now, heep the max the same -- so only goes through zoom or not zoom
404//#define MAX_SM_MIN_MODES (SM_help + 1)
405#define MAX_SM_MIN_MODES (SM_HOME_SIMPLE_LAST + 1)
406#define MAX_SM_EXPANDED_MODES (SM_LAST + 1)
407
408
409//! This is needed now as message from external (not button pressing) causes a state change,
410//! but the button processing isn't knowing about it...
411//!sets the current screen mode .. which can be used by Button and Display processing
412//! whichSMMode 0..SM_LAST
413void setCurrentSMMode_mainModule(int whichSMMode);
414//!returns the current SM Mode
416//!increment the currentSMMode, wrapping and using the max menu
418//!increment the currentSMMode, wrapping and using the max menu
420
421//! returns the current max of the menu modes (using the setting of min or expanded) to determine
423//! returns the current max of the MIN menu modes (using the setting of min or expanded) to determine
425//!returns an index from 0..max of SM matching cmd, or -1 if none
426int whichSMMode_mainModule(char *cmd);
427//!returns if a match the mode. whichSMMode is 0..12 and == sm0 .. smn
428boolean matchesSMMode_mainModule(char *cmd, int whichSMMode);
429//!returns string form whichSMMode, sg "sm0", sm1 ...
430char* charSMMode_mainModule(int whichSMMode);
431//!returns which mode in (min or expanded)
433//!toggles the menu mode
435
436//! BLE Discovery Methods
437//! Connected to a BLE device with the advertised name. The syntax can include (PTFeeder:NAME) or just PTFeeder
438//! Being disconnected is already a flag isConnectedBLE ...
439void setConnectedBLEDevice_mainModule(char *deviceName, boolean isGEN3);
440//!whether the connected is a GEN3 (so the name isn't valid).
442//! returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name, or "" if nothing (not null)
444//!returns full name and address, and service.
446//!returns address part of name.
448
449//! 1.22.24 refactored to only ButtonModule knows about plugins..
450//! BUTTON PROCESSING abstraction (NOTE these are only for the M5 since the M5 Atom has it backwards)
451//!short press on buttonA (top button)
453//!long press on buttonA (top button)
455//!long long press on buttonA (top button)
457//!the long press of the side button
459//!the short press of the side button
461//!restarts all the menu states to the first one .. useful for getting a clean start. This doesn't care if the menu is being shown
463//! 1.22.24 add setup and loop at main so it can call appropriate plugs
465//! setup of buttons and sensors
467
468//!whether the string is TRUE, ON, 1
469boolean isTrueString_mainModule(String valCmdString);
470
471//! 8.28.23 Adding a way for others to get informed on messages that arrive
472//! for the set,val.
473//! 1.10.24 if deviceNameSpecified then this matches this device, otherwise for all.
474//! It's up to the receiver to decide if it has to be specified
475void messageSetVal_mainModule(char *setName, char* valValue, boolean deviceNameSpecified);
476//! 12.28.23, 8.28.23 Adding a way for others to get informed on messages that arrive
477//! for the set,val
478//! 5.21.25 SEND and CMD will be treated the same and put to "send"
479void messageSend_mainModule(char *sendValue, boolean deviceNameSpecified);
480//!TODO: have a callback regist approach
481
482
483//! 1.1.24 send status of this device after events..
485
486
487//! 2.21.25 add a way to change the button color (if any)
489
490//! 3.23.25 rainy weekend
491//! create a JSON string from the SemanticMarker
492//! https://semanticmarker.org/bot/setdevice/scott@konacurrents.com/PASS/M5AtomSocket/socket/on}
493//! Create a JSON knowing the "bot" syntax, eg. setdevice/USER/PASS/device/<set>/<flag>
494//! defined in TokenParser.h
495char *semanticMarkerToJSON_mainModule(char* semanticMarker);
496
497#pragma mark PIN_USE_STRUCT
498//! 5.3.25 add a central clearing house for defining PIN use
499//! central clearing house for all pins used to we can analyze if there are overlaps
500//! pin is the actual number, pinName is the local name (eg. IN1_PIN or VIN_PIN).
501//! moduleName is the module in the code,
502//! isI2C is whether this is a I2C bus (which we aren't using much yet)
503//! 7.13.26 Ballon morning .. field haying
504//! return Boolean saying the pin was Valid of Invalie
505boolean registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C);
506
507//! note these are the sets of pin use
508//! 8.18.25 OUCH>.. 10 .. now 20 max
509#define PIN_USE_MAX 20
510typedef struct {
512 //! string describing the module, etc
513 char *pinUseArray[PIN_USE_MAX];
514 //! each pin
515 long pinNumArray[PIN_USE_MAX];
517//! get the pin use array
519
520//! 8.20.25 Horses grazing if field first time for Mark and Bud
521//! add set/config
522//! PTStepper
523//! M5AtomCamera
524void setConfiguration_mainModule(char* configurationName);
525
526
527//!If nil it create one with just the null, so strlen = 0
528//!NOTE: the strdup() might be used later..
529char* createCopy2(const char * stringA);
530
531#pragma mark LED
532#ifdef M5UNIFIED
533//! 2 year breakthrough - 8.1.26
534//! create enum for our colors (so we user _RED or TFT_RED
535typedef enum {
536 RED_LED = TFT_RED,
537 BLUE_LED = TFT_BLUE,
538 GREEN_LED = TFT_GREEN,
539 CYAN_LED = TFT_CYAN,
540 YELLOW_LED = TFT_YELLOW,
541 WHITE_LED = TFT_WHITE
543#else
544//! create enum for our colors (so we user _RED or TFT_RED
545//! THis way the code works without knowning the TFT names..
546typedef enum {
547 RED_LED,
548 BLUE_LED,
549 GREEN_LED,
550 CYAN_LED,
554#endif
555//! 7.24.25 return a (semi) random color
557//! returns a string for the color int
558String getColorString(ColorsUnified color);
559
560//! uses colors.. _GREEN_LED to be typed values
561void setLEDColor(ColorsUnified color);
562
563#endif /* MainModule_h */
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.
Definition: MainModule.cpp:956
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
Definition: MainModule.cpp:541
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....
Definition: MainModule.cpp:881
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..
Definition: MainModule.cpp:724
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
Definition: MainModule.cpp:706
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()
Definition: MainModule.cpp:412
void main_dispatchSyncCommand(int syncCallCommand)
the main sync command (no parameters yet)
boolean stopAllProcesses_mainModule()
if stopped
Definition: MainModule.cpp:358
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
Definition: MainModule.cpp:918
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
#define PIN_USE_MAX
Definition: MainModule.h:509
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
Definition: MainModule.cpp:315
bool containsSubstring(String message, String substring)
check if the string contains the other string (if substring is "" then no match)
Definition: MainModule.cpp:765
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
Definition: MainModule.cpp:900
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
Definition: MainModule.cpp:308
void stopProcessesForOTAUpdate_mainModule()
stop all loops... while OTA working..
Definition: MainModule.cpp:348
void feedMessageCallback(char *message)
Definition: MainModule.cpp:977
void resetFeedCount_mainModule()
sets the feed count max
Definition: MainModule.cpp:759
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 ...)
Definition: MainModule.cpp:730
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()
Definition: MainModule.cpp:336
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
ColorsUnified
Definition: MainModule.h:535
@ CYAN_LED
Definition: MainModule.h:539
@ WHITE_LED
Definition: MainModule.h:541
@ BLUE_LED
Definition: MainModule.h:537
@ YELLOW_LED
Definition: MainModule.h:540
@ GREEN_LED
Definition: MainModule.h:538
@ RED_LED
Definition: MainModule.h:536
void restartProcessesForOTAUpdate_mainModule()
restart all loops... while OTA working..
Definition: MainModule.cpp:353
char * main_getScannedDeviceName()
return devicename
char * createCopy(char *stringA)
void main_printModuleConfiguration()
void messageSetVal_mainModule(char *setName, char *valValue, boolean deviceNameSpecified)
Definition: MainModule.cpp:929
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
Definition: MainModule.cpp:737
void espUpdate_mainModule(int num)
the Update aggrgate
Definition: MainModule.cpp:521
ColorsUnified getRandomColor()
7.24.25 return a (semi) random color
void espBegin_mainModule(int num)
Definition: MainModule.cpp:508
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
An mostly virtual class.