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//COMMON CALLBACKS
120//NOTE: This is where the true Object Oriented dynamic plug-in approaches would come in..
121// We are using #ifdef to bound the plug-in but there is still too much knowledge about wiring events to methods
122// in this code.. TODO, make more dynmaic event based..
123
124//*** The callback for "onWrite" of the bluetooth "onWrite'
125void onWriteBLEServerCallback(char *message);
126
127/*******************************BLE Server*************************************/
128//*** The callback for "onWrite" of the bluetooth "onWrite'
129void onBLEServerCallback(char *message);
130
131//! ** The callback for "status messages" of the bluetooth
132void onStatusMessageBLEServerCallback(char *message);
133
134//!prints the module configuration by looking at defines
135//! Eventually this might be an object returned letting the code
136//!know a capability is included for runtime (vs compile time) decisions
138
139//!called on single click
140//!NOTE: with BLE_CLIENT_NETWORKING, the right button and top button send a BLE command for feeding..
141void singleClickTouched(char *whichButton);
142
143//!callback for SOLID blinking led
144void solidLight(char *message);
145
146//!callback for blinking led
147void blinkMessageCallback(char *message);
148
149
150//!take a picture (calls the camera module).. what to do with picture??? TODO
151//void takePicture_MainModule();
152
153//!clean the SSID eprom (MQTT_CLEAN_SSID_EPROM)
154void cleanSSID_EPROM_MessageCallback(char *message);
155
156//!callback for SOLID blinking led
157void solidLightMessageCallback(char *message);
158
159//!clean the saved WIFI credential, otherwise the AP mode doesn't work (6.3.22)
161
162//!TESTING for saying credentials are filled in via BLE (while in AP mode), so kick out of AP and continue..
163//! set that the credentials are set. Called from the MQTT after processJSONMessage() found things were good..
164//! April 8, 2022
166
167//!retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
169
170//!! cycle through the next WIFI saved credential - return next one that isn't our current one..
172
173//! sets the WIFI and MQTT user/password. It's up to the code to decide who needs to know (currently this calls APmodule..)
174void main_updateMQTTInfo(char *ssid, char *ssid_password, char *username, char *password, char *guestPassword, char *deviceName, char * host, char * port, char *locationString);
175
176//! return the username and password
177//! 12.14.23 to support calling the SMART buttons (smrun) with parameters
178char *main_getUsername();
179//! return password
180char *main_getPassword();
181//! return devicename
183//! set the scanned device name
184void main_setScannedDeviceName(char *deviceName);
185//! set the scanned group name
186//! 1.7.24
187void main_setScannedGroupName(char *groupName);
188//! return groupname -- returns "" or nil if not set,
189//! or the FULL group name topic, or nil
191//! TODO: make this a registeration approach
192
193//! 3.21.22 these are to setup for the next time the main loop() runs to call these commands..
194//! The implementation is hard coded in the ESP_IO.ino
195#define ASYNC_CALL_OTA_UPDATE 0
196//! cleans out the credentials and restarts in AP (Access Point) mode.
197#define ASYNC_CALL_CLEAN_CREDENTIALS 1
198//!cleans the EPROM totally, and reboots
199#define ASYNC_CALL_CLEAN_EPROM 2
200//!sends a 'c' to the BLE end of the code (assuming a feeder is connected). Need to morph if a real feeder
201#define ASYNC_CALL_FEED_COMMAND 3
202//!sends a 'B' to the BLE end of the code (assuming a feeder is connected).
203#define ASYNC_CALL_BUZZ_ON 4
204//!sends a 'b' to the BLE end of the code (assuming a feeder is connected).
205#define ASYNC_CALL_BUZZ_OFF 5
206//!sends a message (like #FEED) on the users topic
207#define ASYNC_SEND_MQTT_FEED_MESSAGE 6
208//!sends the status from the main module URL
209#define ASYNC_SEND_MQTT_STATUS_URL_MESSAGE 7
210
211//!sets the GATEWAY mode on
212#define ASYNC_SET_GATEWAY_ON 8
213//!sets the GATEWAY mode off
214#define ASYNC_SET_GATEWAY_OFF 9
215
216//!sets the GATEWAY mode off
217#define ASYNC_REBOOT 10
218//!sets the GATEWAY mode off
219#define ASYNC_POWEROFF 11
220//!blank the screen
221#define ASYNC_BLANKSCREEN 12
222
223//! swaps WIFI 'w'
224#define ASYNC_SWAP_WIFI 13
225//! next WIFI 'n'
226#define ASYNC_NEXT_WIFI 14
227//! restarts the WIFI (after BLE interrupt over)
228#define ASYNC_RESTART_WIFI_MQTT 15
229//! 5.15.25 add a BUZZ command (or CLICK)
230#define ASYNC_CLICK_SOUND 16
231//! the max one greater than last one
232#define ASYNC_CALL_MAX 17 //don't forget to update this MAX (last one + 1)
233
234//!these are the async with a string parameter. This sends a BLE command unless MQTT
235#define ASYNC_CALL_BLE_CLIENT_PARAMETER 0
236//!these are the async with a string parameter
237#define ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER 1
238//!these are the async with a string parameter
239#define ASYNC_JSON_MESSAGE_PARAMETER 2
240//!these are the async with a string parameter
241#define ASYNC_JSON_MQTT_MESSAGE_PARAMETER 3
242//!send REST call
243#define ASYNC_REST_CALL_MESSAGE_PARAMETER 4
244//! the max one greater than last one
245#define ASYNC_CALL_PARAMETERS_MAX 5
246
247//! dispatches a call to the command specified. This is run on the next loop()
248void main_dispatchAsyncCommand(int asyncCallCommand);
249
250//!send an async call with a string parameter. This will set store the value and then async call the command (passing the parameter)
251//!These are the ASYNC_CALL_PARAMETERS_MAX
252void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter);
253
254//!storage for asyncCallCommands
255void initAsyncCallFlags();
256
257//!checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to false
259
260//! 5.16.25 Fountainhead, Raining cold weekend
261//! start SYNC calls starting with the SYNC_CLICK_SOUND
262#define SYNC_CLICK_SOUND 0
263#define SYNC_CALL_MAX 1
264//! the main sync command (no parameters yet)
265void main_dispatchSyncCommand(int syncCallCommand);
266
267//! 3.17.24 get the chip id
268uint32_t getChipId();
269//! 3.17.24 get the chip id as a string
270char* getChipIdString();
271
272// **** Helper Methods
273//!If nil it create one with just the null, so strlen = 0
274//!NOTE: the strdup() might be used later..
275char* createCopy(char * stringA);
276//!a char* version of startsWith (after skipping spaces)
277boolean startsWithChar(char *str, char c);
278//! if an empty string
279boolean isEmptyString(char *stringA);
280//!check if the string contains the other string (if substring is "" then no match)
281bool containsSubstring(String message, String substring);
282//!check if the string matches
283bool stringMatch(String message, String substring);
284//gets unix time..
286
287//!returns a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
289
290//!returns a string in in URL so: status&battery=84'&buzzon='off' } .. etc
291//!if fullStatus, return everything, else just the ATOM stuff
292char* main_currentStatusURL(boolean fullStatus);
293
294#ifdef UNUSED
295//!sets status parts cia a a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
296void main_setStatusJSON(const char* JSONString);
297//!sets status parts cia a a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
298void main_setStatusKeyValue(const char* key, const char* value);
299#endif
300
301//!retrieves the temperature in F.
303
304//!start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
306
307#ifdef NOT_USED
308//!see the external IP .. try 2.21.22
309void getExternalIP();
310#endif
311
312//!feedcount info..
314//increments .. and if MAX goes to 0 -- and sends a message on MQTT
316//! sets the feed count max
318
319//! called by the feed operation to say the device is still running.. and count it as a button click.
320//! Issue #145 8.8.22
322
323/*STEPPER feederType*/
324/*
325#define STEPPER_IS_UNO 1
326#define STEPPER_IS_MINI 2
327#define STEPPER_IS_TUMBLER 3
328 */
329//!get the feeder type (Sepper 1,2,3 ...)
331
332//!returns the max for this feeder
334
335//! shows a FEED (or whatever) then blanks the screen after N seconds
336//! NOTE: This will be a scrolling text as sometime ..
337void showText_mainModule(String text);
338
339//!SemanticMarker events
340//!This would see a DOCFollow message, and set the value.. then SM10 can display it..
341void setSemanticMarkerDocFollow_mainModule(char* SMDocFollowAddress);
342//!get the latest semantic marker for doc follow
344
345//!sends the SM on the DOCFOLLOW channel (publish it..)
346void sendSemanticMarkerDocFollow_mainModule(const char* SMDocFollowAddress);
347
348//!gets the device name
350
351//!power of devices
352//!reboot
354
355//!power off
357
358//!Semantic Marker definitions
359//! defines the semantic markers for now..
360//! Minimal 0..6 (max = 7)
361#define SM_home_simple 0 //tilt
362#define SM_home_simple_1 1 //buzz
363#define SM_home_simple_2 2 //FEED PAGE
364#define SM_home_simple_3 3 //advanced
365#define SM_HOME_SIMPLE_LAST SM_home_simple_3
366// update: MAX_SM_MIN_MODES when adding one..
367// and update the MINI-1 .. passed from MQTT to BUTTON
368
369//! //! homepage
370#define SM_smart_clicker_homepage 4
371//! //status
372#define SM_status 5
373//!WIFI ssid
374#define SM_WIFI_ssid 6
375//!guest page
376#define SM_guest_page 7
377
378//!AP MODE
379#define SM_ap_mode 8
380
381
382//!guest feed
383#define SM_guest_feed 9
384//!guest feed device
385#define SM_pair_dev 10
386//!HELP
387#define SM_help 11
388
389//! docfollow
390#define SM_doc_follow 12
391//! timer .. todo
392#define SM_timer 13
393//!REboot
394#define SM_reboot 14
395#define SM_LAST SM_reboot
396
397//!note for now, heep the max the same -- so only goes through zoom or not zoom
398//#define MAX_SM_MIN_MODES (SM_help + 1)
399#define MAX_SM_MIN_MODES (SM_HOME_SIMPLE_LAST + 1)
400#define MAX_SM_EXPANDED_MODES (SM_LAST + 1)
401
402
403//! This is needed now as message from external (not button pressing) causes a state change,
404//! but the button processing isn't knowing about it...
405//!sets the current screen mode .. which can be used by Button and Display processing
406//! whichSMMode 0..SM_LAST
407void setCurrentSMMode_mainModule(int whichSMMode);
408//!returns the current SM Mode
410//!increment the currentSMMode, wrapping and using the max menu
412//!increment the currentSMMode, wrapping and using the max menu
414
415//! returns the current max of the menu modes (using the setting of min or expanded) to determine
417//! returns the current max of the MIN menu modes (using the setting of min or expanded) to determine
419//!returns an index from 0..max of SM matching cmd, or -1 if none
420int whichSMMode_mainModule(char *cmd);
421//!returns if a match the mode. whichSMMode is 0..12 and == sm0 .. smn
422boolean matchesSMMode_mainModule(char *cmd, int whichSMMode);
423//!returns string form whichSMMode, sg "sm0", sm1 ...
424char* charSMMode_mainModule(int whichSMMode);
425//!returns which mode in (min or expanded)
427//!toggles the menu mode
429
430//! BLE Discovery Methods
431//! Connected to a BLE device with the advertised name. The syntax can include (PTFeeder:NAME) or just PTFeeder
432//! Being disconnected is already a flag isConnectedBLE ...
433void setConnectedBLEDevice_mainModule(char *deviceName, boolean isGEN3);
434//!whether the connected is a GEN3 (so the name isn't valid).
436//! returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name, or "" if nothing (not null)
438//!returns full name and address, and service.
440//!returns address part of name.
442
443//! 1.22.24 refactored to only ButtonModule knows about plugins..
444//! BUTTON PROCESSING abstraction (NOTE these are only for the M5 since the M5 Atom has it backwards)
445//!short press on buttonA (top button)
447//!long press on buttonA (top button)
449//!long long press on buttonA (top button)
451//!the long press of the side button
453//!the short press of the side button
455//!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
457//! 1.22.24 add setup and loop at main so it can call appropriate plugs
459//! setup of buttons and sensors
461
462//!whether the string is TRUE, ON, 1
463boolean isTrueString_mainModule(String valCmdString);
464
465//! 8.28.23 Adding a way for others to get informed on messages that arrive
466//! for the set,val.
467//! 1.10.24 if deviceNameSpecified then this matches this device, otherwise for all.
468//! It's up to the receiver to decide if it has to be specified
469void messageSetVal_mainModule(char *setName, char* valValue, boolean deviceNameSpecified);
470//! 12.28.23, 8.28.23 Adding a way for others to get informed on messages that arrive
471//! for the set,val
472//! 5.21.25 SEND and CMD will be treated the same and put to "send"
473void messageSend_mainModule(char *sendValue, boolean deviceNameSpecified);
474//!TODO: have a callback regist approach
475
476
477//! 1.1.24 send status of this device after events..
479
480
481//! 2.21.25 add a way to change the button color (if any)
483
484//! 3.23.25 rainy weekend
485//! create a JSON string from the SemanticMarker
486//! https://semanticmarker.org/bot/setdevice/scott@konacurrents.com/PASS/M5AtomSocket/socket/on}
487//! Create a JSON knowing the "bot" syntax, eg. setdevice/USER/PASS/device/<set>/<flag>
488//! defined in TokenParser.h
489char *semanticMarkerToJSON_mainModule(char* semanticMarker);
490
491#pragma mark PIN_USE_STRUCT
492//! 5.3.25 add a central clearing house for defining PIN use
493//! central clearing house for all pins used to we can analyze if there are overlaps
494//! pin is the actual number, pinName is the local name (eg. IN1_PIN or VIN_PIN).
495//! moduleName is the module in the code,
496//! isI2C is whether this is a I2C bus (which we aren't using much yet)
497void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C);
498
499//! note these are the sets of pin use
500//! 8.18.25 OUCH>.. 10 .. now 20 max
501#define PIN_USE_MAX 20
502typedef struct {
504 //! string describing the module, etc
505 char *pinUseArray[PIN_USE_MAX];
506 //! each pin
507 long pinNumArray[PIN_USE_MAX];
509//! get the pin use array
511
512//! 8.20.25 Horses grazing if field first time for Mark and Bud
513//! add set/config
514//! PTStepper
515//! M5AtomCamera
516void setConfiguration_mainModule(char* configurationName);
517
518
519//!If nil it create one with just the null, so strlen = 0
520//!NOTE: the strdup() might be used later..
521char* createCopy2(const char * stringA);
522
523#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:873
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)
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:533
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:800
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:643
void onStatusMessageBLEServerCallback(char *message)
** The callback for "status messages" of the bluetooth
Definition: MainModule.cpp:954
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:625
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)
Definition: MainModule.cpp:936
void setup_mainModule()
called from the setup()
Definition: MainModule.cpp:451
void main_dispatchSyncCommand(int syncCallCommand)
the main sync command (no parameters yet)
boolean stopAllProcesses_mainModule()
if stopped
Definition: MainModule.cpp:397
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:837
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
#define PIN_USE_MAX
Definition: MainModule.h:501
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:354
bool containsSubstring(String message, String substring)
check if the string contains the other string (if substring is "" then no match)
Definition: MainModule.cpp:684
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:819
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:347
void stopProcessesForOTAUpdate_mainModule()
stop all loops... while OTA working..
Definition: MainModule.cpp:387
void feedMessageCallback(char *message)
Definition: MainModule.cpp:894
void resetFeedCount_mainModule()
sets the feed count max
Definition: MainModule.cpp:678
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:649
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'.
char * getServerServiceName_mainModule()
Definition: MainModule.cpp:375
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..
Definition: MainModule.cpp:392
char * main_getScannedDeviceName()
return devicename
char * createCopy(char *stringA)
void main_printModuleConfiguration()
void messageSetVal_mainModule(char *setName, char *valValue, boolean deviceNameSpecified)
Definition: MainModule.cpp:848
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'.
Definition: MainModule.cpp:947
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:656
float getBatPercentage_mainModule()
start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
An mostly virtual class.