ESP_IOT v2.5
IOT ESP Coding
|
#include "../../Defines.h"
#include "../MQTTModule/MQTTNetworking.h"
#include "../BLEServerModule/BLEServerNetworking.h"
#include "../ButtonModule/ButtonModule.h"
Go to the source code of this file.
Macros | |
#define | MESSAGE_STORAGE_MAX 400 |
global for others to use.. More... | |
#define | CALLBACKS_MQTT 0 |
#define | CALLBACKS_BUTTON_MODULE 1 |
#define | CALLBACKS_BLE_CLIENT 2 |
#define | CALLBACKS_BLE_SERVER 3 |
#define | CALLBACKS_MAX_MQTT MQTT_MAX_CALLBACKS |
#define | CALLBACKS_MAX_BUTTON_MODULE MAX_CALLBACKS_BM |
#define | CALLBACKS_MAX_BLE_CLIENT BLE_CLIENT_MAX_CALLBACKS |
#define | CALLBACKS_MAX_BLE_SERVER BLE_SERVER_MAX_CALLBACKS |
#define | TRY_ASYNC_BLE_PROCESSING |
#define | TRY_WIFI_FIRST |
Typedefs | |
typedef void(* | callbackSignature) (char *) |
Functions | |
void | readPreferences_mainModule () |
MainModule More... | |
void | stopProcessesForOTAUpdate_mainModule () |
stop all loops... while OTA working.. More... | |
void | restartProcessesForOTAUpdate_mainModule () |
restart all loops... while OTA working.. More... | |
boolean | stopAllProcesses_mainModule () |
if stopped More... | |
void | initGlobals_mainModule () |
init globals strings More... | |
void | setup_mainModule () |
called from the setup() More... | |
void | loop_mainModule () |
called for the loop() of this plugin More... | |
int | feedCountMax_mainModule () |
returns the max for this feeder More... | |
int | getFeedCount_mainModule () |
feedcount info.. More... | |
int | getFeederType_mainModule () |
get the feeder type (Sepper 1,2,3 ...) More... | |
void | incrementFeedCount_mainModule () |
increments .. and if MAX goes to 0 – and sends a message on MQTT More... | |
void | resetFeedCount_mainModule () |
sets the feed count max More... | |
bool | containsSubstring (String message, String substring) |
check if the string contains the other string. This is a poor man's grammer checker More... | |
void | registerCallbackMain (int callbacksModuleId, int callbackType, void(*callback)(char *)) |
register the callback based on the callbackType. use the callbacksModuleId for which one.. More... | |
void | callCallbackMain (int callbacksModuleId, int callbackType, char *message) |
performs the indirect callback based on the callbackType More... | |
void | dummyCallbackMain (char *message) |
example callback More... | |
callbackSignature * | createMemory (int max) |
return dyamically created array of max More... | |
void | initCallbacksMain () |
init the callbacks to dummy callbacks More... | |
void | feedMessageCallback (char *message) |
void | main_credentialsUpdated () |
moved here 4.25.22 (entirely from ESP_IOT.ino) More... | |
void | onBLEServerCallback (char *message) |
The callback for "onWrite" of the bluetooth "onWrite'. More... | |
void | onStatusMessageBLEServerCallback (char *message) |
The callback for "status messages" of the bluetooth. More... | |
void | onWriteBLEServerCallbackFinish (char *message) |
The FINISH of callback for "onWrite" of the bluetooth "onWrite'. More... | |
void | onWriteBLEServerCallback (char *message) |
The callback for "onWrite" of the bluetooth "onWrite'. More... | |
void | takePicture_MainModule () |
take a picture (calls the camera module).. what to do with picture??? TODO More... | |
void | refreshDelayButtonTouched_MainModule () |
called by the feed operation to say the device is still running.. and count it as a button click. More... | |
boolean | asyncCallOTAUpdate () |
performs an async OTA update More... | |
void | setAsyncCallOTAUpdate (bool flag) |
sets the async OTA flag (for next loop) More... | |
char * | getPairedDevice_mainModule () |
returns if the paired device is not NONE More... | |
char * | getPairedDeviceAddress_mainModule () |
returns if the paired device is not NONE More... | |
boolean | isValidPairedDevice_mainModule () |
returns if the paired device is not NONE. Note, the paired Name might be an address now (see below) More... | |
char * | getPairedDeviceOrAddress_mainModule () |
returns if the paired device is not NONE .. returns address or device More... | |
char * | deviceName_mainModule () |
gets the device name More... | |
void | rebootDevice_mainModule () |
void | poweroff_mainModule () |
power off More... | |
void | cleanEpromPreferences () |
cleans the EPROM More... | |
char * | main_JSONStringForWIFICredentials () |
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"} More... | |
char * | main_nextJSONWIFICredential () |
! cycle through the next WIFI saved credential More... | |
void | main_saveWIFICredentials (char *ssid, char *ssid_password) |
save the WIFI credential More... | |
void | main_cleanSavedWIFICredentials () |
clean the saved WIFI credential, otherwise the AP mode doesn't work (6.3.22) More... | |
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 (below, maybe in future a register approach) to decide who needs to know More... | |
void | initAsyncCallFlags () |
initialize the async call flags (with and without parameters) More... | |
void | main_dispatchAsyncCommand (int asyncCallCommand) |
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to false More... | |
void | main_dispatchAsyncCommandWithString (int asyncCallCommand, char *parameter) |
void | invokeAsyncCommands () |
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to false More... | |
void | blinkMessageCallback (char *message) |
callback for blinking led More... | |
void | solidLightMessageCallback (char *message) |
callback for SOLID blinking led More... | |
void | cleanSSID_EPROM_MessageCallback (char *message) |
clean the SSID eprom (MQTT_CLEAN_SSID_EPROM) More... | |
void | singleClickTouched (char *whichButton) |
void | solidLightOnOff (boolean onOff) |
callback for SOLID blinking led More... | |
void | main_printModuleConfiguration () |
char * | createCopy (char *stringA) |
boolean | isEmptyString (char *stringA) |
informs if null or empty string More... | |
boolean | startsWithChar (char *str, char c) |
a char* version of startsWith (after skipping spaces) More... | |
float | getBatPercentage_mainModule () |
start of the sensor updates ... TODO: tie these to the MQTT messaging as well.. More... | |
void | sendMessageString_mainModule (char *messageString) |
adding a synchronous call to send a message over the network (assuming MQTT but not specified), this tacks on {device} and {t:time} More... | |
float | getTemperature_mainModule () |
retrieves the temperature . More... | |
Variables | |
boolean | _stopAllProcessing = false |
testing.. More... | |
char | _asyncParameter [500] |
the parameter being sent to those commands passing an argument More... | |
char | _JSONStringForWIFICredentials [200] |
global to store credentials when ever they are stored.. More... | |
char | _messageStorage [MESSAGE_STORAGE_MAX] |
char | _fullStatusString [300] |
status string (URL query format) More... | |
char | _smMode_MainModule [10] |
current smMode More... | |
char | _deviceNameSave [50] |
saved deviceName storage.. More... | |
boolean | _waitingForBigMessageEnd = false |
store a big message #MSG_START .. #MSG_END More... | |
char | _bigMessage [500] |
char | _connectedBLEDeviceName [50] |
saved BLE connected name 8.26.22 More... | |
char | _fullBLEDeviceName [100] |
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead" More... | |
char | _connectedBLEDeviceAddress [50] |
full: ""Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead" More... | |
int | _mainLoopCounter = 0 |
a couinter to slow down the loop doing things.. More... | |
int | _feedCount_mainModule = 0 |
5.3.22 added a feed count approach.. (NOTE: there is a _feedCount in Dispence.cpp ... and no linker error!!! ) More... | |
int | _callbacksFunctionsMAXS [CALLBACKS_MODULE_MAX] |
the array of callback functions More... | |
boolean | _callbacksInitializedMain = false |
flag for initializing if not yes More... | |
callbackSignature * | _allCallbacks [CALLBACKS_MODULE_MAX] |
array of known size (CALLBACKS_MODULE_MAX) of callbackSignatures More... | |
boolean | _asyncCallOTAUpdateFlag = false |
3.28.22 .. implemented in ESP_IOT.ino More... | |
boolean | _asyncCallFlags [ASYNC_CALL_MAX] |
storage for asyncCallCommands More... | |
boolean | _asyncCallFlagsParameters [ASYNC_CALL_PARAMETERS_MAX] |
array of async flags for the different ASYNC_CALl values More... | |
char * | _ON_LIGHT = (char*)"ON" |
char * | _OFF_LIGHT = (char*)"OFF" |
/password/status?BLE:on&numfeeds=8&WIFI:on&AP:off | |
NEW: 4.30.22 returns a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc as a URL: SemanticMarker.org/bot/sample/scott | |
char * | _lastSemanticMarkerDocFollow = NULL |
int | _saveWhichSMMode = 0 |
the saved SMMode More... | |
boolean | _connecteBLEisGEN3 = false |
whether connected GEN3 More... | |
char * | main_currentStatusJSON () |
returns a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc More... | |
void | addStatusStringFlag (const char *key, char *val) |
adds a query string "&key=value" More... | |
void | addStatusBooleanFlag (const char *key, boolean flag) |
adds to _fullStatusString a query string "&key=value" More... | |
void | addMoreStatusQueryString () |
char * | main_currentStatusURL () |
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc More... | |
void | setSemanticMarkerDocFollow_mainModule (char *SMDocFollowAddress) |
sed the address to follow More... | |
char * | getSemanticMarkerDocFollow_mainModule () |
gets the semanticAddress SemanticMarker™ More... | |
void | sendSemanticMarkerDocFollow_mainModule (const char *SMDocFollowAddress) |
sends the SM on the DOCFOLLOW channel (publish it..) More... | |
void | processClientCommandChar_mainModule (char cmd) |
single character version of processClientCommand (since many used that already) More... | |
int | getTimeStamp_mainModule () |
int | whichSMMode_mainModule (char *cmd) |
************** SM Mode Processing *************** More... | |
boolean | matchesSMMode_mainModule (char *cmd, int whichSMMode) |
returns if a match the mode. whichSMMode is 0..12 and == sm0 .. smn More... | |
char * | charSMMode_mainModule (int whichSMMode) |
returns string form whichSMMode, sg "sm0", sm1 ... More... | |
boolean | isMinimalMenuMode_mainModule () |
returns which mode in (min or expanded) More... | |
void | toggleMinimalMenuMode_mainModule () |
toggles the menu mode More... | |
int | minMenuModesMax_mainModule () |
returns the current max of the MIN menu modes (using the setting of min or expanded) to determine More... | |
int | maxMenuModes_mainModule () |
returns the current max of the menu modes (using the setting of min or expanded) to determine More... | |
void | setCurrentSMMode_mainModule (int whichSMMode) |
sets the current screen mode .. which can be used by Button and Display processing More... | |
int | getCurrentSMMode_mainModule () |
returns the current SM Mode More... | |
void | incrementSMMode_mainModule () |
increment the currentSMMode, wrapping and using the max menu More... | |
void | decrementSMMode_mainModule () |
increment the currentSMMode, wrapping and using the max menu More... | |
char * | getFullBLEDeviceName_mainModule () |
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead" More... | |
boolean | connectedBLEDeviceIsGEN3_mainModule () |
whether the connected is a GEN3 (so the name isn't valid) More... | |
void | setConnectedBLEDevice_mainModule (char *deviceName, boolean isGEN3) |
char * | connectedBLEDeviceName_mainModule () |
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name, or "" if nothing (not null) More... | |
char * | connectedBLEDeviceNameAddress_mainModule () |
returns address part of name. More... | |
void | buttonA_ShortPress_mainModule () |
void | buttonA_LongPress_mainModule () |
long press on buttonA (top button) More... | |
void | buttonB_LongPress_mainModule () |
the long press of the side button More... | |
void | buttonB_ShortPress_mainModule () |
the short press of the side button More... | |
void | restartAllMenuStates_mainModule () |
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 More... | |
#define CALLBACKS_BLE_CLIENT 2 |
Definition at line 223 of file MainModule.cpp.
#define CALLBACKS_BLE_SERVER 3 |
Definition at line 224 of file MainModule.cpp.
#define CALLBACKS_BUTTON_MODULE 1 |
Definition at line 222 of file MainModule.cpp.
#define CALLBACKS_MAX_BLE_CLIENT BLE_CLIENT_MAX_CALLBACKS |
Definition at line 237 of file MainModule.cpp.
#define CALLBACKS_MAX_BLE_SERVER BLE_SERVER_MAX_CALLBACKS |
Definition at line 238 of file MainModule.cpp.
#define CALLBACKS_MAX_BUTTON_MODULE MAX_CALLBACKS_BM |
Definition at line 236 of file MainModule.cpp.
#define CALLBACKS_MAX_MQTT MQTT_MAX_CALLBACKS |
make sure these are the number of callbacks.. 0..n These values are from the respective .h of the modules
Definition at line 235 of file MainModule.cpp.
#define CALLBACKS_MQTT 0 |
New RegisterCallback that works across a number of callback modules
callbacksModuleId
Definition at line 221 of file MainModule.cpp.
#define MESSAGE_STORAGE_MAX 400 |
global for others to use..
Definition at line 35 of file MainModule.cpp.
#define TRY_ASYNC_BLE_PROCESSING |
#define TRY_WIFI_FIRST |
typedef void(* callbackSignature) (char *) |
Definition at line 262 of file MainModule.cpp.
void addMoreStatusQueryString | ( | ) |
sets the "Module Status" in queryString == name=val&name=val ...
value of WIFI connected
not done is what we look for ..
add a bleS=PTFeeder:name
show Z for buZZ
show G for gateway
P = paired
Definition at line 1606 of file MainModule.cpp.
void addStatusBooleanFlag | ( | const char * | key, |
boolean | flag | ||
) |
adds to _fullStatusString a query string "&key=value"
Definition at line 1599 of file MainModule.cpp.
void addStatusStringFlag | ( | const char * | key, |
char * | val | ||
) |
adds a query string "&key=value"
TODO: fix syntax. If just sensor sensor status: .... https://SemanticMarker.org/bot/sensor/scott@konacurrents.com/doggy/status?v=v2&dev=M5Ski&b=68&temp=66&c=0&t=8&W=on&M=on&B=on&C=on&A=off&T=on&S=on&Z=off&t=8 not working just added Z=on/off length = 157 going to remove the username/password to shorten..
Definition at line 1592 of file MainModule.cpp.
boolean asyncCallOTAUpdate | ( | ) |
performs an async OTA update
Definition at line 546 of file MainModule.cpp.
void blinkMessageCallback | ( | char * | message | ) |
callback for blinking led
Definition at line 1226 of file MainModule.cpp.
void buttonA_LongPress_mainModule | ( | ) |
long press on buttonA (top button)
Definition at line 2245 of file MainModule.cpp.
void buttonA_ShortPress_mainModule | ( | ) |
BUTTON PROCESSING abstraction short press on buttonA (top button)
Definition at line 2238 of file MainModule.cpp.
void buttonB_LongPress_mainModule | ( | ) |
the long press of the side button
Definition at line 2252 of file MainModule.cpp.
void buttonB_ShortPress_mainModule | ( | ) |
the short press of the side button
Definition at line 2259 of file MainModule.cpp.
void callCallbackMain | ( | int | callbacksModuleId, |
int | callbackType, | ||
char * | message | ||
) |
performs the indirect callback based on the callbackType
Definition at line 333 of file MainModule.cpp.
char * charSMMode_mainModule | ( | int | whichSMMode | ) |
returns string form whichSMMode, sg "sm0", sm1 ...
returns string form whichSMMode, sg "sm0", sm1 ... This can (and is) called by multiple places (like ButtonProcessing and MainModule
Definition at line 2010 of file MainModule.cpp.
void cleanEpromPreferences | ( | ) |
cleans the EPROM
reboot
Definition at line 638 of file MainModule.cpp.
void cleanSSID_EPROM_MessageCallback | ( | char * | message | ) |
clean the SSID eprom (MQTT_CLEAN_SSID_EPROM)
call the already defined solid led defined in Dispense.cpp
clean_SSID_WIFICredentials(); now register an async call..
Definition at line 1260 of file MainModule.cpp.
boolean connectedBLEDeviceIsGEN3_mainModule | ( | ) |
whether the connected is a GEN3 (so the name isn't valid)
whether the connected is a GEN3 (so the name isn't valid).
Definition at line 2109 of file MainModule.cpp.
char * connectedBLEDeviceName_mainModule | ( | ) |
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name, or "" if nothing (not null)
ISSUE: if BLE, can only return the address.. it's up to the caller to know it might not match the Paired Name (eg DukeGEN3) returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name
Definition at line 2194 of file MainModule.cpp.
char * connectedBLEDeviceNameAddress_mainModule | ( | ) |
returns address part of name.
Definition at line 2219 of file MainModule.cpp.
bool containsSubstring | ( | String | message, |
String | substring | ||
) |
check if the string contains the other string. This is a poor man's grammer checker
check if the string contains the other string (if substring is "" then no match)
Definition at line 196 of file MainModule.cpp.
char * createCopy | ( | char * | stringA | ) |
If nil it create one with just the null, so strlen = 0 NOTE: the strdup() might be used later..
Definition at line 1431 of file MainModule.cpp.
callbackSignature * createMemory | ( | int | max | ) |
return dyamically created array of max
Definition at line 266 of file MainModule.cpp.
void decrementSMMode_mainModule | ( | ) |
increment the currentSMMode, wrapping and using the max menu
Definition at line 2083 of file MainModule.cpp.
char * deviceName_mainModule | ( | ) |
gets the device name
Definition at line 607 of file MainModule.cpp.
void dummyCallbackMain | ( | char * | message | ) |
example callback
Definition at line 242 of file MainModule.cpp.
int feedCountMax_mainModule | ( | ) |
returns the max for this feeder
Definition at line 137 of file MainModule.cpp.
void feedMessageCallback | ( | char * | message | ) |
example callback: but the scope would have the pCharacteristic defined, etc.. This is passed just before the setupMQTTNetworking() is called..
sends this single character to the StepperModule
increment the feed count .. TODO .. see if this is good place..
the FEED was send over MQTT, now what to do? WIth the StepperModule – it just performs the feeding internalls if using the BLE_CLIENT then we have the potential to send to over BLE to the server (another feeder, GEN3 or ESP32). The issue is that ESP32 feeders are receiving the same MQTT message (usually unless MQTT turned off So the gatewayMode can be set (or in the EPROM) using {'cmd':'gatewayOn'}
Definition at line 352 of file MainModule.cpp.
float getBatPercentage_mainModule | ( | ) |
start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
Definition at line 1475 of file MainModule.cpp.
int getCurrentSMMode_mainModule | ( | ) |
returns the current SM Mode
Definition at line 2065 of file MainModule.cpp.
int getFeedCount_mainModule | ( | ) |
feedcount info..
Definition at line 155 of file MainModule.cpp.
int getFeederType_mainModule | ( | ) |
get the feeder type (Sepper 1,2,3 ...)
Definition at line 161 of file MainModule.cpp.
char * getFullBLEDeviceName_mainModule | ( | ) |
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
returns full name and address, and service.
Definition at line 2093 of file MainModule.cpp.
char * getPairedDevice_mainModule | ( | ) |
returns if the paired device is not NONE
Definition at line 557 of file MainModule.cpp.
char * getPairedDeviceAddress_mainModule | ( | ) |
returns if the paired device is not NONE
Definition at line 563 of file MainModule.cpp.
char * getPairedDeviceOrAddress_mainModule | ( | ) |
returns if the paired device is not NONE .. returns address or device
Definition at line 588 of file MainModule.cpp.
char * getSemanticMarkerDocFollow_mainModule | ( | ) |
gets the semanticAddress SemanticMarker™
get the latest semantic marker for doc follow
Definition at line 1706 of file MainModule.cpp.
float getTemperature_mainModule | ( | ) |
retrieves the temperature .
retrieves the temperature in F.
Definition at line 1514 of file MainModule.cpp.
int getTimeStamp_mainModule | ( | ) |
On the esp32, sec is all we can handle. We can return as a double if milisecond resolution is needed. This is the time since app started.. https://randomnerdtutorials.com/epoch-unix-time-esp32-arduino/
Definition at line 1965 of file MainModule.cpp.
void incrementFeedCount_mainModule | ( | ) |
increments .. and if MAX goes to 0 – and sends a message on MQTT
NOTE: don't send "feed" as it might trigger a FEED ...
called by the feed operation to say the device is still running.. and count it as a button click. Issue #145 8.8.22
Definition at line 168 of file MainModule.cpp.
void incrementSMMode_mainModule | ( | ) |
increment the currentSMMode, wrapping and using the max menu
Definition at line 2071 of file MainModule.cpp.
void initAsyncCallFlags | ( | ) |
initialize the async call flags (with and without parameters)
storage for asyncCallCommands
Definition at line 770 of file MainModule.cpp.
void initCallbacksMain | ( | ) |
init the callbacks to dummy callbacks
only place for #ifdef (NOTE some can be 0 based on the #ifdef module not being included..
Definition at line 280 of file MainModule.cpp.
void initGlobals_mainModule | ( | ) |
init globals strings
NOTE: this is definitely needed, as grabbing strings willy nilly can bomb or corrupt stuff..
Definition at line 55 of file MainModule.cpp.
void invokeAsyncCommands | ( | ) |
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to false
The FINISH of callback for "onWrite" of the bluetooth "onWrite'
now process those that don't have a string parameter
register the 2 callbacks for now..
this is a sending of the message
9.30.22 IF SET .. send a feed but to all devices except ours and our pair (if any) uses new wildcard syntax either ! OUR NAME [ & ! OUR_CONNECTED_NAME
set the persistence (Note, this is locally saved. If sending elsewhere .. then they have to set their value)
OK: issue. if we are an ESP feeder, the STEPPER is on .. so we're good, if an M5 - then either send over BLE or MQTT
we are not BLE_CLIENT .. so local
setGatewayOn/Off called from the processJSON message in MQTT or via the EPROM setting (TODO)
sends the status from the main module URL
NO MORE: sendDocFollowMessageMQTT(statusURL);
These are the ASYNC_CALL_PARAMETERS_MAX NO: just change our credentials ...
Restarts (or attempts) a restart of the WIFI using the existing credentials – vs the 'n' command
Definition at line 829 of file MainModule.cpp.
boolean isEmptyString | ( | char * | stringA | ) |
informs if null or empty string
if an empty string
Definition at line 1440 of file MainModule.cpp.
boolean isMinimalMenuMode_mainModule | ( | ) |
returns which mode in (min or expanded)
Definition at line 2020 of file MainModule.cpp.
boolean isValidPairedDevice_mainModule | ( | ) |
returns if the paired device is not NONE. Note, the paired Name might be an address now (see below)
returns if the paired device is not NONE
Definition at line 569 of file MainModule.cpp.
void loop_mainModule | ( | ) |
called for the loop() of this plugin
only do this menu update if there is no DisplayModule running the MVC loop
9.2.22 new .. update the timer. This is on blank screen as well .. so don't check _semanticMarkerShown
Definition at line 114 of file MainModule.cpp.
void main_cleanSavedWIFICredentials | ( | ) |
clean the saved WIFI credential, otherwise the AP mode doesn't work (6.3.22)
go through the saved WIFI credentials and empty them with "" (vs null)
cannot null but can make stringlen=0
Definition at line 726 of file MainModule.cpp.
void main_credentialsUpdated | ( | ) |
moved here 4.25.22 (entirely from ESP_IOT.ino)
new 4.8.22 .. trying to kick out of AP mode if the credentials are good..
April 8, 2022 set that the credentials are set. Called from the MQTT after processJSONMessage() found things were good..
Definition at line 392 of file MainModule.cpp.
char * main_currentStatusJSON | ( | ) |
returns a string in JSON format, such that {'battery':'84'}, {'buzzon':'off'} .. etc
Sample format: {"status": [ { "BLE": "on" }, { "numfeeds": "8", "maxfeeds": "16" }, { "battery": "87" }, { "buzzon": "on" }, { "MQTT": "on" }, { "WIFI": "on" }, { "AP": "off" }, { "tilt": "55" } ] }
Definition at line 1577 of file MainModule.cpp.
char * main_currentStatusURL | ( | ) |
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc
returns a string in in URL so: status&battery=84'&buzzon='off' } .. etc
TODO: make sure no spaces ... unless escaped
TODO: put these somewhere somehow (expandable easily..architecturally. eg. setStatus("battery","87") key,val the JSON DB supports db["battery"]=87 like syntax..
Definition at line 1655 of file MainModule.cpp.
void main_dispatchAsyncCommand | ( | int | asyncCallCommand | ) |
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to false
dispatches a call to the command specified. This is run on the next loop()
this just sets the flag, it's the next loop that makes the call
Definition at line 789 of file MainModule.cpp.
void main_dispatchAsyncCommandWithString | ( | int | asyncCallCommand, |
char * | parameter | ||
) |
send an async call with a string parameter. This will set store the value and then async call the command (passing the parameter) These are the ASYNC_CALL_PARAMETERS_MAX
store in the parameter mailbox
this just sets the flag, it's the next loop that makes the call
Definition at line 807 of file MainModule.cpp.
char * main_JSONStringForWIFICredentials | ( | ) |
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
Definition at line 663 of file MainModule.cpp.
char * main_nextJSONWIFICredential | ( | ) |
! cycle through the next WIFI saved credential
! cycle through the next WIFI saved credential - return next one that isn't our current one..
WIFI_CREDENTIALS_MAX
jump out of loop if no match.. so index is valid
Definition at line 669 of file MainModule.cpp.
void main_printModuleConfiguration | ( | ) |
prints the module configuration by looking at #defines Eventually this might be an object returned letting the code know a capability is included for runtime (vs compile time) decisions
Module Configuration
[x] ESP_32
[x] USE_MQTT_NETWORKING
[x] USE_BLE_SERVER_NETWORKING
[x] USE_WIFI_AP_MODULE
and print any preferences to show
Definition at line 1316 of file MainModule.cpp.
void main_saveWIFICredentials | ( | char * | ssid, |
char * | ssid_password | ||
) |
save the WIFI credential
store the JSON version of these credentials..
look for an non matching slot.. if none, then use the first
jump out of loop if no match.. so index is valid, or NONE (which is the placeholder)
save in chosen index
Definition at line 696 of file MainModule.cpp.
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 (below, maybe in future a register approach) to decide who needs to know
sets the WIFI and MQTT user/password. It's up to the code to decide who needs to know (currently this calls APmodule..)
store the device name
store the JSON version of these credentials..
Definition at line 741 of file MainModule.cpp.
boolean matchesSMMode_mainModule | ( | char * | cmd, |
int | whichSMMode | ||
) |
returns if a match the mode. whichSMMode is 0..12 and == sm0 .. smn
Definition at line 2003 of file MainModule.cpp.
int maxMenuModes_mainModule | ( | ) |
returns the current max of the menu modes (using the setting of min or expanded) to determine
Definition at line 2038 of file MainModule.cpp.
int minMenuModesMax_mainModule | ( | ) |
returns the current max of the MIN menu modes (using the setting of min or expanded) to determine
Definition at line 2032 of file MainModule.cpp.
void onBLEServerCallback | ( | char * | message | ) |
The callback for "onWrite" of the bluetooth "onWrite'.
Definition at line 404 of file MainModule.cpp.
void onStatusMessageBLEServerCallback | ( | char * | message | ) |
The callback for "status messages" of the bluetooth.
** The callback for "status messages" of the bluetooth
2.2.22 send this over bluetooth.. TODO.
Definition at line 411 of file MainModule.cpp.
void onWriteBLEServerCallback | ( | char * | message | ) |
The callback for "onWrite" of the bluetooth "onWrite'.
send an async call with a string parameter. This will set store the value and then async call the command (passing the parameter) These are the ASYNC_CALL_PARAMETERS_MAX
Definition at line 511 of file MainModule.cpp.
void onWriteBLEServerCallbackFinish | ( | char * | message | ) |
The FINISH of callback for "onWrite" of the bluetooth "onWrite'.
client never sends these wrapped messages of length 1, so process normally.. gets us out of potential infinite wait
we are done.. send big message to ourself..
Issue: the message is arriving via BLE, but if we call the MQTT process, it might call us back to send the message over BLE. This hangs things up! So short optimization for 'feed' will be to look for cmd and feed in message {cmd:feed} 8.19.22 issue #162
the MQTTNetwork.processJSONMessage() will return true if the message was JSON and was processes, false otherwise.
processed by the MQTTNetworking code..
perform feed...
look for ** sensor commands..
Definition at line 420 of file MainModule.cpp.
void poweroff_mainModule | ( | ) |
power off
Definition at line 623 of file MainModule.cpp.
void processClientCommandChar_mainModule | ( | char | cmd | ) |
single character version of processClientCommand (since many used that already)
Keep ProcessClientCmd short to let the callback run. instead change the feeder state flag processes a message that might save in the EPROM.. the cmd is still passed onto other (like the stepper module)
the sentToStepper is only needed if there are 'actions' on the command, versus just setting persistent EPROM data. Like feed, buzzer, etc.. Thus we don't need to know much of their implementation.. or we just pass anyway!
only process things that are stored persistently..
start timer..
start timer..
dispatches a call to the command specified. This is run on the next loop()
dispatches a call to the command specified. This is run on the next loop()
dispatches a call to the command specified. This is run on the next loop()
NOTE: the gateway is auto selected for now. A future version might manually set it in other situations (eg. my iPhone app should have a flag to not be a gateway at time)
These are the ASYNC_CALL_PARAMETERS_MAX
NOTE: this is almost the same as 'w' except there might be more WIFI than 2 (so swap is different).
Restarts (or attempts) a restart of the WIFI using the existing credentials – vs the 'n' command
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
print out stuff
Definition at line 1723 of file MainModule.cpp.
void readPreferences_mainModule | ( | ) |
reads the preferences. Save is everytime the savePreference is called
clean the cached, and initialize what are cached..
intiialize the preferences arrays from EPROM. This also updates the defaults BUT: the caches below are from the value retrieved (and defult if need be)
start the read-write of the EPROM
check some of the boolean ones to cache .. so don't have to go to the EPROM everytime..
CACHE SETTINGS (int)
Close the Preferences
set onbootPreferences
Definition at line 298 of file PreferencesController.cpp.
void rebootDevice_mainModule | ( | ) |
power of devices reboot
Definition at line 616 of file MainModule.cpp.
void refreshDelayButtonTouched_MainModule | ( | ) |
called by the feed operation to say the device is still running.. and count it as a button click.
called by the feed operation to say the device is still running.. and count it as a button click. Issue #145 8.8.22
calls the button processing control
Definition at line 536 of file MainModule.cpp.
void registerCallbackMain | ( | int | callbacksModuleId, |
int | callbackType, | ||
void(*)(char *) | callback | ||
) |
register the callback based on the callbackType. use the callbacksModuleId for which one..
Definition at line 316 of file MainModule.cpp.
void resetFeedCount_mainModule | ( | ) |
sets the feed count max
Definition at line 190 of file MainModule.cpp.
void restartAllMenuStates_mainModule | ( | ) |
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
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
Definition at line 2267 of file MainModule.cpp.
void restartProcessesForOTAUpdate_mainModule | ( | ) |
restart all loops... while OTA working..
Definition at line 16 of file MainModule.cpp.
void sendMessageString_mainModule | ( | char * | messageString | ) |
adding a synchronous call to send a message over the network (assuming MQTT but not specified), this tacks on {device} and {t:time}
NOTE: the # has to be there, otherwise the sendMessageMQTT ignores it..
send this message over MQTT
Definition at line 1500 of file MainModule.cpp.
void sendSemanticMarkerDocFollow_mainModule | ( | const char * | SMDocFollowAddress | ) |
sends the SM on the DOCFOLLOW channel (publish it..)
Definition at line 1713 of file MainModule.cpp.
void setAsyncCallOTAUpdate | ( | bool | flag | ) |
sets the async OTA flag (for next loop)
Definition at line 551 of file MainModule.cpp.
void setConnectedBLEDevice_mainModule | ( | char * | deviceName, |
boolean | isGEN3 | ||
) |
BLE Discovery Methods Connected to a BLE device with the advertised name. The syntax can include (PTFeeder:NAME) or just PTFeeder Being disconnected is already a flag isConnectedBLE ...
set the isGEN3 flag
now set the gateway based on if GEN3
seems device name = "Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead Note: the Address, eg "7c:9e:bd:48:af:92" is unique somehow.. lets use that to skip one.. parse out the 2nd half of name go past the : empty name (just PTFeeder) parse for the address too.. strcpy(_fullBLEDeviceName, deviceName); seems device name = "Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead Note: the Address, eg "7c:9e:bd:48:af:92" is unique somehow.. lets use that to skip one..
parse out the 2nd half of name
empty name (just PTFeeder)
Definition at line 2117 of file MainModule.cpp.
void setCurrentSMMode_mainModule | ( | int | whichSMMode | ) |
sets the current screen mode .. which can be used by Button and Display processing
This is needed now as message from external (not button pressing) causes a state change, but the button processing isn't knowing about it... sets the current screen mode .. which can be used by Button and Display processing whichSMMode 0..SM_LAST
Definition at line 2051 of file MainModule.cpp.
void setSemanticMarkerDocFollow_mainModule | ( | char * | SMDocFollowAddress | ) |
sed the address to follow
SemanticMarker events This would see a DOCFollow message, and set the value.. then SM10 can display it..
Definition at line 1699 of file MainModule.cpp.
void setup_mainModule | ( | ) |
called from the setup()
added 9.29.22 to support wildcards #196
setup for the token parser (really just for testing) – an
init globals like strings (but nothing that needs preferences)
read the preferences from EPROM
must initialize the structs NOTE: this has to ber AFTER the preferences are read in..
a first time feature .. to get EPROM changed to a different default
7.12.22 {'dev':'m5",'cmd':'bleserveron'} or bleserveroff will work later.. #issue 117 .. turn off the BLE_Server for the M5
Definition at line 72 of file MainModule.cpp.
void singleClickTouched | ( | char * | whichButton | ) |
called on single click NOTE: with BLE_CLIENT_NETWORKING, the right button and top button send a BLE command for feeding..
for now, only send the FEED command via BLE_CLIENT if turned on. No reboot to AP mode yet..
Definition at line 1274 of file MainModule.cpp.
void solidLightMessageCallback | ( | char * | message | ) |
callback for SOLID blinking led
call the already defined solid led defined in Dispense.cpp
Definition at line 1246 of file MainModule.cpp.
void solidLightOnOff | ( | boolean | onOff | ) |
callback for SOLID blinking led
supports turning on the solid light..
call the already defined solid led defined in Dispense.cpp
Definition at line 1299 of file MainModule.cpp.
boolean startsWithChar | ( | char * | str, |
char | c | ||
) |
a char* version of startsWith (after skipping spaces)
find first non space character, and if not '{' then return false
jump out if not a space, and 'i' will be the thing to look for
Definition at line 1455 of file MainModule.cpp.
boolean stopAllProcesses_mainModule | ( | ) |
if stopped
try to disconnect..
Definition at line 21 of file MainModule.cpp.
void stopProcessesForOTAUpdate_mainModule | ( | ) |
stop all loops... while OTA working..
Definition at line 11 of file MainModule.cpp.
void takePicture_MainModule | ( | ) |
take a picture (calls the camera module).. what to do with picture??? TODO
Definition at line 528 of file MainModule.cpp.
void toggleMinimalMenuMode_mainModule | ( | ) |
toggles the menu mode
Definition at line 2026 of file MainModule.cpp.
int whichSMMode_mainModule | ( | char * | cmd | ) |
************** SM Mode Processing ***************
returns an index from 0..max of SM matching cmd, or -1 if none
Definition at line 1979 of file MainModule.cpp.
callbackSignature* _allCallbacks[CALLBACKS_MODULE_MAX] |
array of known size (CALLBACKS_MODULE_MAX) of callbackSignatures
Definition at line 277 of file MainModule.cpp.
boolean _asyncCallFlags[ASYNC_CALL_MAX] |
storage for asyncCallCommands
3.21.22 these are to setup for the next time the main loop() runs to call these commands.. The implementation is hard coded in the ESP_IO.ino TODO: make this a registeration approach
Definition at line 764 of file MainModule.cpp.
boolean _asyncCallFlagsParameters[ASYNC_CALL_PARAMETERS_MAX] |
array of async flags for the different ASYNC_CALl values
Definition at line 766 of file MainModule.cpp.
boolean _asyncCallOTAUpdateFlag = false |
3.28.22 .. implemented in ESP_IOT.ino
Definition at line 544 of file MainModule.cpp.
char _asyncParameter[500] |
the parameter being sent to those commands passing an argument
Definition at line 31 of file MainModule.cpp.
char _bigMessage[500] |
Definition at line 46 of file MainModule.cpp.
int _callbacksFunctionsMAXS[CALLBACKS_MODULE_MAX] |
the array of callback functions
the max of each module .. hard coded (or 0 if module not there)
Definition at line 256 of file MainModule.cpp.
boolean _callbacksInitializedMain = false |
flag for initializing if not yes
Definition at line 259 of file MainModule.cpp.
boolean _connecteBLEisGEN3 = false |
whether connected GEN3
Definition at line 2107 of file MainModule.cpp.
char _connectedBLEDeviceAddress[50] |
full: ""Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
Definition at line 52 of file MainModule.cpp.
char _connectedBLEDeviceName[50] |
saved BLE connected name 8.26.22
Definition at line 48 of file MainModule.cpp.
char _deviceNameSave[50] |
saved deviceName storage..
Definition at line 42 of file MainModule.cpp.
int _feedCount_mainModule = 0 |
5.3.22 added a feed count approach.. (NOTE: there is a _feedCount in Dispence.cpp ... and no linker error!!! )
Definition at line 135 of file MainModule.cpp.
char _fullBLEDeviceName[100] |
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
Definition at line 50 of file MainModule.cpp.
char _fullStatusString[300] |
status string (URL query format)
Definition at line 38 of file MainModule.cpp.
char _JSONStringForWIFICredentials[200] |
global to store credentials when ever they are stored..
Definition at line 33 of file MainModule.cpp.
char* _lastSemanticMarkerDocFollow = NULL |
SemanticMarker events This would see a DOCFollow message, and set the value.. then SM10 can display it..
Definition at line 1697 of file MainModule.cpp.
int _mainLoopCounter = 0 |
a couinter to slow down the loop doing things..
Definition at line 110 of file MainModule.cpp.
char _messageStorage[MESSAGE_STORAGE_MAX] |
Definition at line 36 of file MainModule.cpp.
char* _OFF_LIGHT = (char*)"OFF" |
Definition at line 1223 of file MainModule.cpp.
char* _ON_LIGHT = (char*)"ON" |
Definition at line 1222 of file MainModule.cpp.
int _saveWhichSMMode = 0 |
the saved SMMode
Definition at line 2049 of file MainModule.cpp.
char _smMode_MainModule[10] |
current smMode
Definition at line 40 of file MainModule.cpp.
boolean _stopAllProcessing = false |
testing..
Definition at line 9 of file MainModule.cpp.
boolean _waitingForBigMessageEnd = false |
store a big message #MSG_START .. #MSG_END
Definition at line 45 of file MainModule.cpp.