15#include "../../Defines.h"
17#ifdef USE_CAMERA_MODULE_XXX
18#include <HTTPClient.h>
25#include <libb64/cdecode.h>
57#define ESP_EPROM_NAME "ESP32"
72#include <ArduinoJson.h>
75#include <Preferences.h>
77#ifdef USE_REST_MESSAGING
78#include <WiFiClientSecure.h>
82#include <PubSubClient.h>
94void setupWIFI(
char * arg_ssid,
char * arg_password);
99#define MAXglobalMQTTAttempts 10
101#define MAX_MQTT_ATTEMPTS 10
104#define MAX_WIFI_CONNECT_ATTEMPTS 30
111void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString);
140#define STATUS "#STATUS"
142#define REMOTEME "#remoteMe"
143#define REMOTE2 "#REMOTE"
145#define FEED_2 "#feedme"
146#define ACK_FEED "#actMe"
147#define ACK_FEED2 "#ackMe"
148#define CONNECTED "#connectedMe"
149#define NOT_CONNECTED "#noconnectedMe"
150#define NO_ACK_FEED "#noactMe"
151#define PLAY_ME "#playMe"
152#define DOCFOLLOW "#docFollow"
153#define DOCFOLLOW2 "#DOCFOLLOW"
154#define DOCSYNC "#docSync"
155#define NO_CAN "#NO_CAN"
158#define FOLLOW_ME "#followMe"
200 int len = strlen(
"Version-(3.7)-3.22.24")+3;
222#ifdef PROCESS_SMART_BUTTON_JSON
224#define MAX_MESSAGE 2024
227#define MAX_MESSAGE 1024
229#define MAX_MESSAGE 600
234#define MAX_MESSAGE_DOCFOLLOW 300
248#define _preferencesJSONName "JSONPrefs"
277 boolean skip =
false;
296#define TRY_MORE_ASYNC_PROCESSING
297#ifdef TRY_MORE_ASYNC_PROCESSING
303 SerialMin.printf(
"Publish message(%s): %s\n",topic, message);
306 SerialMin.println(
" *** MQTT not connected .. message will queue until connected (hopefully)" );
329 SerialMin.printf(
"publishSMRunMessage: %s\n", smrunMessage);
330#ifdef ATOM_QRCODE_MODULE
338 WiFiClient postClient;
340 String serverName =
"knowledgeshark.me";
342 String serverPath =
"/examples/servlets/servlet/RequestParamExample";
344 int serverPort = 8080;
345 SerialDebug.println(
"2. Connecting to server: " + serverName);
349 if (postClient.connect(serverName.c_str(), serverPort))
351 String firstname = smrunMessage;
353 firstname.replace(
"&",
"%26");
356 firstname.replace(
"smart",
"smrun");
357 firstname.replace(
"smflowinfo",
"smrun");
361 SerialDebug.printf(
"RequstParamExample Connection successful! \n");
362 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"firstname\"\r\nContent-Type: image/jpeg\r\n\r\n";
363 String tail =
"\r\n--KonaCurrents--\r\n";
366 head =
"firstname=" + firstname;
368 uint32_t imageLen = 0;
369 uint32_t extraLen = head.length() + tail.length();
370 uint32_t totalLen = imageLen + extraLen;
372 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
373 postClient.println(
"Host: " + serverName);
375 postClient.println(
"Content-Type: application/x-www-form-urlencoded");
376 postClient.println(
"Content-Length: " + String(totalLen));
378 postClient.println();
379 postClient.print(head);
380 postClient.print(tail);
387 SerialTemp.println(
"POST " + serverPath +
" HTTP/1.1");
388 SerialTemp.println(
"Host: " + serverName);
389 SerialTemp.println(
"Content-Type: application/x-www-form-urlencoded");
390 SerialTemp.println(
"Content-Length: " + String(totalLen));
391 SerialTemp.println();
392 SerialTemp.print(head);
393 SerialTemp.println(tail);
398 SerialDebug.printf(
"Connection NOT successful! ");
406#ifdef USE_CAMERA_MODULE_XXX
409#include "esp_camera.h"
417 SerialMin.printf(
"Publish binary file(%s), len=%d\n", topic, len);
429 WiFiClient postClient;
431 String serverName =
"knowledgeshark.me";
433 String serverPath =
"/examples/servlets/UploadServlet";
435 int serverPort = 8080;
436 SerialDebug.println(
"2. Connecting to server: " + serverName);
438 if (postClient.connect(serverName.c_str(), serverPort))
440 SerialDebug.printf(
"Connection successful! len = %d\n", len);
442 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
443 filename +
"\"\r\nContent-Type: image/jpeg\r\n\r\n";
444 String tail =
"\r\n--KonaCurrents--\r\n";
446 uint32_t imageLen = len;
447 uint32_t extraLen = head.length() + tail.length();
448 uint32_t totalLen = imageLen + extraLen;
450 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
451 postClient.println(
"Host: " + serverName);
452 postClient.println(
"Content-Length: " + String(totalLen));
453 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
454 postClient.println();
455 postClient.print(head);
457 uint8_t *fbBuf = buf;
459 for (
size_t n=0; n<fbLen; n=n+1024)
463 postClient.write(fbBuf, 1024);
466 else if (fbLen%1024>0)
468 size_t remainder = fbLen%1024;
469 postClient.write(fbBuf, remainder);
472 postClient.print(tail);
494 SerialDebug.printf(
"Connection NOT successful! ");
505#ifdef USE_SPIFF_MODULE
514 char *fileExtension = (
char*)
"json";
516 SerialMin.printf(
"publishSPIFFFile topic=%s, file(%s) len = %d\n", topic, path, len);
524 WiFiClient postClient;
526 String serverName =
"knowledgeshark.me";
528 String serverPath =
"/examples/servlets/UploadServlet";
530 int serverPort = 8080;
531 SerialDebug.println(
"2. Connecting to server: " + serverName);
534 char *addFront = (
char*)
"[";
535 char *addBack = (
char*)
"{}]";
536 len = len + strlen(addFront) + strlen(addBack);
538 if (postClient.connect(serverName.c_str(), serverPort))
540 SerialDebug.printf(
"Connection successful! len = %d\n", len);
542 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
543 filename +
"\"\r\nContent-Type: file/JSON\r\n\r\n";
544 String tail =
"\r\n--KonaCurrents--\r\n";
546 uint32_t imageLen = len;
547 uint32_t extraLen = head.length() + tail.length();
548 uint32_t totalLen = imageLen + extraLen;
550 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
551 postClient.println(
"Host: " + serverName);
552 postClient.println(
"Content-Length: " + String(totalLen));
553 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
554 postClient.println();
555 postClient.print(head);
563 File file =
fs.open(path);
564 if(!file || file.isDirectory()){
565 SerialDebug.println(
"- failed to open file for reading");
570 postClient.write(addFront, strlen(addFront));
572 SerialDebug.println(head);
575 while(file.available())
577 String line = file.readString();
582 line.replace(
"'",
"\"");
584 SerialDebug.println(line);
588 postClient.write(line.c_str(), line.length());
591 SerialDebug.println(tail);
594 postClient.write(addBack, strlen(addBack));
599 postClient.print(tail);
618 SerialDebug.printf(
"Connection NOT successful! ");
639#define TRY_READING_BACK
640#ifdef TRY_READING_BACK
645 SerialDebug.print(
"Reading.12 EPROM JSON = ");
667 if (!savedDeviceName)
668 savedDeviceName = NOTSET_STRING;
686 for (
int i = 0; i < 17; i = i + 8) {
687 _chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
695 Serial.printf(
"ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
696 Serial.printf(
"This chip has %d cores\n", ESP.getChipCores());
698 Serial.print(
"Chip Name: "); Serial.println(
_chipName);
717 SerialLots.print(
"getDynamicStatusFunc: ");
761 SerialLots.print(
"setLastMessageStatus: ");
762 SerialLots.println(token);
774 if (strcasecmp(token,
"FEED")==0)
776 else if (strcasecmp(token,
"STATUS")==0)
816 SerialTemp.print(
"getDynamicMessageFunc: ");
823#define WIFI_MQTT_STATES
824#ifdef WIFI_MQTT_STATES
870#define USE_TIMER_DELAY_CLASS
872#ifdef USE_TIMER_DELAY_CLASS
893unsigned long _delayStart_WIFI_MQTTState;
895boolean _delayRunning_WIFI_MQTTState =
false;
897float _delaySeconds_WIFI_MQTTState;
902 SerialLots.printf(
"startDelay_WIFI_MQTTState(%f)\n", seconds);
903 _delayStart_WIFI_MQTTState =
millis();
904 _delayRunning_WIFI_MQTTState =
true;
905 _delaySeconds_WIFI_MQTTState = seconds;
911 if (_delayRunning_WIFI_MQTTState && ((
millis() - _delayStart_WIFI_MQTTState) >= (_delaySeconds_WIFI_MQTTState * 1000)))
913 _delayRunning_WIFI_MQTTState =
false;
922 _delayRunning_WIFI_MQTTState =
false;
934#ifdef USE_SPIFF_MODULE
935#ifdef USE_SPIFF_MQTT_SETTING_NOT_NOW
975#ifdef ESP_M5_TOO_MUCH
992 SerialDebug.println(
"setup_MQTTNetworking");
997 SerialDebug.println(
"setupMQTTNetworking already setup..");
1005 SerialDebug.println(
" .. continue setup_MQTTNetworking");
1019 SerialTemp.println();
1035 SerialLots.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
1040 SerialTemp.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
1064 SerialDebug.println(
"loop_MQTTNetworking .. null ssid");
1117 switch (WiFi.status())
1119 case WL_NO_SHIELD:
return (
char*)
"WL_NO_SHIELD";
1120 case WL_IDLE_STATUS:
return (
char*)
"WL_IDLE_STATUS";
1121 case WL_NO_SSID_AVAIL:
return (
char*)
"WL_NO_SSID_AVAIL";
1122 case WL_SCAN_COMPLETED:
return (
char*)
"WL_SCAN_COMPLETED";
1123 case WL_CONNECTED :
return (
char*)
"WL_CONNECTED";
1124 case WL_CONNECT_FAILED:
return (
char*)
"WL_CONNECT_FAILED";
1125 case WL_CONNECTION_LOST:
return (
char*)
"WL_CONNECTION_LOST";
1127 case WL_DISCONNECTED:
return (
char*)
"WL_DISCONNECTED";
1145 SerialCall.printf(
"startdelayCheckWIFI_MQTTNetworking: %d\n", seconds);
1172 SerialCall.println(
"delayCheckWIFIFinished_MQTTNetworking..");
1182 SerialCall.println(
"stopDelayCheckWIFI_MQTTNetworking _delayRunning=false");
1208 SerialMin.printf(
"checkAndReconnectWIFI_MQTTState: %s\n",
wifiStatus_MQTT());
1209 boolean tryReconnect =
true;
1210 switch (WiFi.status())
1214 case WL_IDLE_STATUS:
1216 case WL_NO_SSID_AVAIL:
1219 case WL_SCAN_COMPLETED:
1230 tryReconnect =
true;
1232 tryReconnect =
false;
1234 case WL_CONNECT_FAILED:
1241 case WL_CONNECTION_LOST:
1249 case WL_DISCONNECTED:
1276 SerialMin.println(
"reconnectAttempt");
1302 SerialDebug.printf(
"1. Connecting to '%s' password = '%s'\n", arg_ssid?arg_ssid:
"NULL", arg_password?arg_password:
"");
1319 if (!arg_ssid || (arg_ssid && strlen(arg_ssid)==0))
1321 SerialDebug.println(
" NULL SSID in setupWIFI .. so leaving");
1340 WiFi.mode(WIFI_STA);
1341 WiFi.begin(arg_ssid, arg_password?arg_password:
"");
1343 SerialDebug.println(
"WIF_STA mode..");
1364 if (WiFi.status() == WL_CONNECTED)
1366 SerialDebug.println(
"WiFi.status() == WL_CONNECTED()");
1367#ifdef STORE_DEBUG_INFO
1375 WiFi.setAutoReconnect(
true);
1382#ifdef STORE_DEBUG_INFO
1405 SerialDebug.println(
"WIFI **** Cannot connect .. try bluetooth update ... ");
1407#ifdef STORE_DEBUG_INFO
1409 SerialTemp.println(
"Before storePref");
1413 SerialTemp.println(
"after 1. storePref");
1416 SerialTemp.println(
"After storePref");
1425#ifdef GO_BACK_TO_ORIGINAL
1448String _WIFIInfoString;
1452 long rssi = WiFi.RSSI();
1454 _WIFIInfoString =
"IP Address: " + WiFi.localIP();
1455 _WIFIInfoString +=
"\n WIFI SSID" + String(WiFi.SSID());
1456 _WIFIInfoString +=
"\n RSSI" + rssi;
1459 SerialDebug.println(_WIFIInfoString.c_str());
1460 return _WIFIInfoString;
1466 sprintf(buf,
"%s",WiFi.SSID());
1467 return "\n WIFI SSID: " + String(WiFi.SSID());
1480 SerialMin.println(
"WiFi connected");
1481 SerialMin.print(
"IP Address: ");
1482 SerialMin.println(WiFi.localIP());
1483 SerialMin.print(
"WiFi SSID:");
1484 SerialMin.println(WiFi.SSID());
1485 long rssi = WiFi.RSSI();
1486 SerialMin.print(
"signal strength (RSSI):");
1487 SerialMin.print(rssi);
1488 SerialMin.println(
" dBm");
1496 SerialMin.println(
"finishWIFI_Setup()");
1499 randomSeed(micros());
1523 SerialDebug.println(
"setupMQTTNetworking_WIFI done..");
1589 if (strcmp(topic,
"usersP/dawgpack")==0)
1591 else if (strcmp(topic,
"usersP/bark") == 0)
1597 SerialDebug.printf(
"Group Topic: %s\n", topic);
1606 SerialDebug.print(
"Topic = ");
1610 SerialDebug.println(
"userTopic");
1614 SerialDebug.println(
"dawgPackTopic");
1618 SerialDebug.println(
"superTopic");
1622 SerialDebug.println(
"groupTopic");
1635 SerialLots.printf(
"callbackMQTTHandler topic: %s\n", topic);
1653 SerialDebug.printf(
"MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1665 SerialDebug.printf(
"NOT PRocessing as PREFERENCE_SUPPORT_GROUPS_SETTING not set");
1672 SerialDebug.printf(
"2.NOT Processing as topic not in Include Group: %s", topic);
1683#ifdef TRY_MORE_ASYNC_PROCESSING
1686 SerialLots.printf(
"MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1701 SerialLots.println(
" -- DONE processsBarkletMessage ----");
1715 SerialDebug.println(
" *** No ssid or password");
1727 SerialDebug.println(
"reconnectMQTT_loop: _mqttClient.connected()");
1728#ifdef STORE_DEBUG_INFO
1738#ifdef STORE_DEBUG_INFO
1756#ifdef NOT_IN_ORIGINAL
1768 SerialInfo.println(
"FAILED MQTT .. so lets try connecting to WIFI again..");
1769 SerialInfo.println(
"Setting WIFI from JSON parameters");
1771#ifdef STORE_DEBUG_INFO
1781#ifdef USE_REST_MESSAGING
1791#ifdef STORE_DEBUG_INFO
1801 String clientId =
"espM5-";
1804 String clientId =
"esp32-";
1806 clientId += String(random(0xffff), HEX);
1808 SerialDebug.printf(
"attempt _mqttClient.connect(%s)\n", clientId);
1823#ifdef STORE_DEBUG_INFO
1828 SerialInfo.println(
"MQTT CONNECTED");
1836 sprintf(
_fullMessageOut,
"%s {%s}{'mqttUser':'%s','location':'%s','uptime':'%d',%s,'v':'%s'}",
REMOTEME,
_deviceNameString?
_deviceNameString:
"NULL",
_mqttUserString?
_mqttUserString:
"NULL",
_jsonLocationString?
_jsonLocationString:
"somewhere",
getUptime(),
main_currentStatusJSON(),
shortVersion());
1840#ifdef TRY_MORE_ASYNC_PROCESSING
1847#ifdef NOT_NOW_ONLY_DOCFOLLOW
1848#ifdef TRY_MORE_ASYNC_PROCESSING
1866 SerialDebug.printf(
"Subscribing to groups as PREFERENCE_SUPPORT_GROUPS_SETTING was set: %s\n", groupNames);
1868 if (strlen(groupNames)==0 || strcmp(groupNames,
"#")== 0)
1873 SerialTemp.printf(
"Subscribe usersP/groups/#\n");
1891 char *str = groupNames;
1894 for (token = strtok_r(str,
",",&rest); token != NULL; token = strtok_r(NULL,
",", &rest))
1896 sprintf(groupSub,
"usersP/groups/%s", token);
1898 SerialTemp.printf(
"Subscribe %s\n", groupSub);
1931#ifdef STORE_DEBUG_INFO
1940 SerialTemp.printf(
"FAILED, rc=%d, trying again in 0.2 seconds\n",
_mqttClient.state());
1951void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString)
1953 SerialTemp.println(
"**** setupMQTT *****");
1954#ifdef STORE_DEBUG_INFO
1963 if (mqttServerString && mqttPortString && mqttPasswordString && mqttUserString)
1966 int port = atoi(mqttPortString);
1991#ifdef STORE_DEBUG_INFO
1996 SerialInfo.println(
" *** No MQTT Server/Port Specified ** abort");
2000#ifdef STORE_DEBUG_INFO
2002 SerialTemp.println(
"done setupMQTT");
2014#ifdef TRY_MORE_ASYNC_PROCESSING
2027#define COLLECT_SENSOR_STATUS_turn_off_for_now
2028#ifdef COLLECT_SENSOR_STATUS
2041 sprintf(nameCurly,
"{%s}", connectedBLEDeviceName);
2051 sprintf(
_fullMessageOut,
"#%s Buzzer=%s", connectedBLEDeviceName, buzzerOn?
"on":
"off");
2080 return strcmp(&message[0], &substring[0]) == 0;
2092 SerialDebug.println(
"cleanEPROM_MQTTNetworking");
2117#ifdef TRY_MORE_ASYNC_PROCESSING
2142#ifdef TRY_MORE_ASYNC_PROCESSING
2165#ifdef TRY_MORE_ASYNC_PROCESSING
2190#ifdef TRY_MORE_ASYNC_PROCESSING
2202 SerialTemp.println(
"sendStatusMessageMQTT..");
2204 sprintf(
_fullMessageOut,
"#remoteMe {%s} {AVM=%s}", deviceName, semanticMarker);
2210#ifdef TRY_MORE_ASYNC_PROCESSING
2227 SerialCall.println(
"sendDocFollowMessageMQTT..");
2231#ifdef ESP_M5_ATOM_LITE
2242#ifdef TRY_MORE_ASYNC_PROCESSING
2260 char *messageString = &message[0];
2262 bool messageValidToSendBack =
false;
2263 SerialCall.print(
"processBarkletMessage: ");
2264 SerialCall.print(message);
2265 SerialCall.print(
" topic=");
2266 SerialCall.println(topic);
2294 char pairedDevice[100];
2302 strcpy(pairedDevice,
"none");
2308 if (isConnectedBLE && isGateway)
2312 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','v':'%s','ble':'%s,%s}",
2333#ifdef TRY_MORE_ASYNC_PROCESSING
2344 SerialTemp.println(
"Sending on DawgPack too..");
2347#ifdef TRY_MORE_ASYNC_PROCESSING
2363 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','ble':'%s','v':'%s','k':'%s','chipid':'%s','ssid':'%s',%s",
2365 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','ble':'%s','v':'%s','k':'%s','chipid':'%s','ssid':'%s'}",
2424 messageValidToSendBack =
true;
2442 boolean performFeed =
true;
2444 performFeed =
false;
2469 SerialTemp.println(
" *** Feeding via our gateway ***");
2474 SerialDebug.println(
" ** Not feeding as not our paired device either ***");
2475 performFeed =
false;
2482 SerialDebug.printf(
"**NOT Perform FEED as deviceName doesn't ours: %s\n",
_deviceNameString );
2484 performFeed =
false;
2496 messageValidToSendBack =
false;
2509 char *indexOfEqual = index(&message[0],
'=');
2510 if (strlen(indexOfEqual)>2)
2515 while (*indexOfEqual && *indexOfEqual !=
'}')
2533 if (strlen(JSON_String) > 0)
2536 char * my_argument =
const_cast<char*
> (topic.c_str());
2546 messageValidToSendBack =
true;
2548#ifdef PASS_ONTO_PLUGS
2552#ifdef ESP_M5_CAMERA_not_here
2554 takePicture_MainModule();
2557#ifdef M5_CAPTURE_SCREEN
2564 messageValidToSendBack =
false;
2581 messageValidToSendBack =
true;
2626 sprintf(
_fullMessageOut,
"over the air binary image update from version: %s", VERSION);
2638 sprintf(
_fullMessageOut,
"over the air NOT updating as not matching string: %s",
2653 SerialDebug.println(
"DAWGPACK unsupported message");
2656 if (messageValidToSendBack)
2661#ifdef TRY_MORE_ASYNC_PROCESSING
2673 SerialTemp.println(
"2.Sending on DawgPack too..");
2676#ifdef TRY_MORE_ASYNC_PROCESSING
2688#ifdef TRY_MORE_ASYNC_PROCESSING
2705 sprintf(
_fullMessageOut,
"over the air binary image update, replacing our version: %s", VERSION);
2712#ifdef REALLY_DO_IT_BOMBS
2745 SerialDebug.println(
"Perform FEED internally, calling callbackFunction.. 2");
2760#define ACK_FOR_PAIR_TOO
2761 char pairedDevice[100];
2765 strcpy(pairedDevice,
"none");
2776 if (isConnectedBLE && isGateway)
2779 SerialTemp.print(
"PairedDevice: ");
2780 SerialTemp.println(pairedDevice);
2781 sprintf(
_fullMessageOut,
"%s {%s} {'T':'%d','temp':'%2.0f','topic':'%s','user':'%s','v':'%s','location':'%s'}",
ACK_FEED, pairedDevice, time, temp, &topic[0],
_mqttUserString, VERSION_SHORT,
_jsonLocationString?
_jsonLocationString:
"somewhere");
2786#ifdef TRY_MORE_ASYNC_PROCESSING
2800#ifdef TRY_MORE_ASYNC_PROCESSING
2812#ifdef TRY_MORE_ASYNC_PROCESSING
2822 sprintf(
_fullMessageOut,
"%s {%s} {'T':'%d','temp':'%2.0f','topic':'%s','user':'%s','v':'%s','location':'%s','paired':'%s', 'ble':'%s','connected':'%s','gateway':'%s','chipid':'%s','ssid':'%s'",
ACK_FEED,
_deviceNameString, time, temp, &topic[0]?&topic[0]:
"NULL",
_mqttUserString, VERSION_SHORT,
_jsonLocationString?
_jsonLocationString:
"somewhere",pairedDevice, isConnectedBLE?
"c":
"x",
connectedBLEDeviceName_mainModule()?
connectedBLEDeviceName_mainModule():
"none", isGateway?
"on":
"off",
getChipIdString(),
get_WIFI_SSID().c_str());
2830 if (moreStatus && strlen(moreStatus) > 0)
2848#ifdef TRY_MORE_ASYNC_PROCESSING
2863#ifdef TRY_MORE_ASYNC_PROCESSING
2875#ifdef TRY_MORE_ASYNC_PROCESSING
2894 SerialDebug.println(
"MQTT.readPreferences");
2899 SerialDebug.println(
"BOOTSTRAP device with our own WIFI and MQTT");
2901 char* BOOT_mqtt_server = (
char*)
"iDogWatch.com";
2904 char* BOOT_mqtt_port = (
char*)
"1883";
2905 char* BOOT_ssid = (
char*)
"SunnyWhiteriver";
2906 char* BOOT_ssid_password = (
char*)
"sunny2021";
2907 char *BOOT_mqtt_user = (
char*)
"test";
2908 char *BOOT_mqtt_password = (
char*)
"test";
2909 char *BOOT_mqtt_guestPassword = (
char*)
"test";
2913 char *BOOT_mqtt_topic = (
char*)
"usersP/bark/test";
2915 char *BOOT_deviceName = (
char*)
"name-of-feeder";
2916 char *BOOT_uuidString = (
char*)
"unused";
2917 char *BOOT_jsonHeaderString = (
char*)
"WIFI+MQTT";
2918 char *BOOT_jsonVersionString = (
char*)
"BOOTSTRAP 1.3";
2919 char *BOOT_jsonLocationString = (
char*)
"PetLand";
2938 DynamicJsonDocument myObject(1024);
2940 myObject[
"ssid"] = BOOT_ssid;
2941 myObject[
"ssidPassword"] = BOOT_ssid_password;
2942 myObject[
"mqtt_server"] = BOOT_mqtt_server;
2943 myObject[
"mqtt_port"] = BOOT_mqtt_port;
2944 myObject[
"mqtt_password"] = BOOT_mqtt_password;
2945 myObject[
"mqtt_guestPassword"] = BOOT_mqtt_guestPassword;
2947 myObject[
"mqtt_user"] = BOOT_mqtt_user;
2948 myObject[
"mqtt_topic"] = BOOT_mqtt_topic;
2949 myObject[
"deviceName"] = BOOT_deviceName;
2950 myObject[
"uuid"] = BOOT_uuidString;
2951 myObject[
"jsonHeader"] = BOOT_jsonHeaderString;
2952 myObject[
"jsonVersion"] = BOOT_jsonVersionString;
2953 myObject[
"location"] = BOOT_jsonLocationString;
2960 SerialDebug.print(
"Writing EPROM JSON = ");
2963 serializeJson(myObject, output1);
2964 SerialDebug.println(output1);
2974 SerialDebug.print(
"Reading.3 EPROM JSON = ");
2986#ifdef BOOTSTRAP_AP_MODE_STARTUP
2987 SerialDebug.println(
"*** STARTUP in AP MODE ***");
3000 SerialDebug.print(
"Reading.1 EPROM JSON = ");
3012 SerialDebug.println(
"*** no JSON in preferences, probably first time. use Bootstrap, or BLE update ***");
3018 DynamicJsonDocument myObject(1024);
3021 SerialDebug.print(
"JSON parsed.1 = ");
3023 serializeJson(myObject, output1);
3024 SerialDebug.println(output1);
3035 const char* a1 = myObject[
"ssid"];
3037 if (a1 && strlen(a1)>0)
3050 SerialDebug.println(
"ssid == NULL");
3055 SerialDebug.println(
"No SSID set, try BLE update again.. ");
3083 const char* a2 = myObject[
"ssidPassword"];
3096 const char* a3 = myObject[
"mqtt_server"];
3108 const char* a4 = myObject[
"mqtt_port"];
3119 const char* a5 = myObject[
"mqtt_password"];
3131 const char* a6 = myObject[
"mqtt_user"];
3142 const char* a7 = myObject[
"deviceName"];
3158 const char* a8 = myObject[
"uuid"];
3163 SerialDebug.print(
"UUID: ");
3172 const char* a9 = myObject[
"mqtt_topic"];
3183 const char* a10 = myObject[
"jsonHeader"];
3195 const char* a11 = myObject[
"jsonVersion"];
3206 const char* a12 = myObject[
"location"];
3217 const char* a13 = myObject[
"mqtt_guestPassword"];
3237 return valCmdString.equalsIgnoreCase(
"on") ||
3238 valCmdString.equalsIgnoreCase(
"1") ||
3239 valCmdString.equalsIgnoreCase(
"true");
3243function isFalseString(String valCmdString)
3245 return valCmdString.equalsIgnoreCase(
"off") ||
3246 valCmdString.equalsIgnoreCase(
"0") ||
3247 valCmdString.equalsIgnoreCase(
"false");
3268 SerialTemp.println(
" *** processJSONMessageMQTT ***");
3273 boolean foundCommand;
3295 SerialDebug.printf(
"NOT Processing as PREFERENCE_SUPPORT_GROUPS_SETTING not set");
3302 SerialDebug.printf(
"NOT Processing as topic not in Include Group: %s", topic);
3314 SerialLots.printf(
"processJSONMessageMQTT(%s) -> return false, not JSON\n", ascii);
3319 SerialDebug.printf(
"processJSONMessageMQTT: '%s'\n", ascii);
3323 SerialLots.printf(
"Ascii before deserializeJson: %s\n", ascii);
3325#ifdef PROCESS_SMART_BUTTON_JSON
3326 DynamicJsonDocument myObject(2024);
3329 DynamicJsonDocument myObject(1024);
3331 DynamicJsonDocument myObject(1024);
3335 deserializeJson(myObject, ascii);
3336 serializeJsonPretty(myObject, Serial);
3339 SerialDebug.print(
"\nJSON parsed = ");
3342 serializeJson(myObject, output1);
3343 SerialDebug.println(output1);
3344 SerialLots.printf(
"Ascii after deserializeJson: %s\n", ascii);
3350 const char* cmd = myObject[
"cmd"];
3351 const char* semanticMarkerCmd = myObject[
"sm"];
3352 const char* guestCmd = myObject[
"guest"];
3355 const char *set64Cmd = myObject[
"set64"];
3357 const char *setCmd = myObject[
"set"];
3358 const char *valCmd = myObject[
"val"];
3360 const char *sendCmd = myObject[
"send"];
3362 const char *devName = myObject[
"dev"];
3364 boolean processCommands =
false;
3365 if (cmd || semanticMarkerCmd || guestCmd || setCmd || sendCmd || set64Cmd)
3366 processCommands =
true;
3368#ifdef PROCESS_SMART_BUTTON_JSON
3373 SerialTemp.printf(
"SMARTButton = %d\n", processSMARTButton);
3375 if (processSMARTButton)
3376 processCommands =
true;
3384 String guestPassword =
"pettutor";
3405 if (processCommands)
3410 char* setCmdString =
const_cast<char*
>(setCmd);
3411 char* valCmdString =
const_cast<char*
>(valCmd);
3413 if (setCmd && strcasecmp(setCmd,
"semanticMarker")==0)
3415 SerialDebug.printf(
"DAWGPACK supported message: %s\n", setCmd);
3419 SerialDebug.println(
"DAWGPACK unsupported message");
3427 boolean deviceNameSpecified = devName != NULL;
3429 boolean processMessageOrGateway =
true;
3430 if (deviceNameSpecified)
3433 processMessageOrGateway =
false;
3434#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3436 parseQueryLine_mainModule((char*)devName);
3439 SerialTemp.printf(
"Query: %s *** Matches our dev name: %s\n", devName,
_deviceNameString);
3440 processMessageOrGateway =
true;
3446 SerialTemp.printf(
"ChipID: %s *** Matches our ChipID name: %s\n", devName,
getChipIdString());
3447 processMessageOrGateway =
true;
3454 SerialTemp.println(
" .. our own device ..");
3455 processMessageOrGateway =
true;
3463#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3467 processMessageOrGateway =
true;
3472 SerialTemp.println(
" .. our paired device ..");
3473 processMessageOrGateway =
true;
3486#ifdef PROCESS_SMART_BUTTON_JSON
3490 if (processMessageOrGateway && processSMARTButton)
3492 StaticJsonDocument<2024> smartButtonObject;
3494 deserializeJson(smartButtonObject, myObject[
"SMARTButton"]);
3496 return processJSONSMARTButton(smartButtonObject);
3500 if (!processMessageOrGateway)
3503 SerialTemp.print(
"Disregard as Device Specified: ");
3504 SerialTemp.print(devName);
3507 SerialTemp.print(
" not ours: ");
3511#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3517 SerialTemp.print(
" .. And not paired device:");
3532 SerialTemp.printf(
"MQTT or BLE CMD = '%s'\n", cmd);
3535 if (whichSMMode >= 0)
3541 SerialDebug.printf(
"currentSMMode = %d whichSMMode = %d\n", currentSMMode, whichSMMode);
3549 if (currentSMMode != whichSMMode)
3551 SerialDebug.println(
" *** Not changing page as in DOCFOLLOW mode ***");
3555 SerialDebug.println(
" *** SM_doc_follow and changing to the same page ***");
3561 boolean markerAlreadyShown =
false;
3562 switch (whichSMMode)
3568 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3569 title =
"MINI CLICKER";
3577 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3585 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3593 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3607 title =
"WIFI FEED";
3617 markerAlreadyShown =
true;
3641 markerAlreadyShown =
true;
3648 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage";
3649 title =
"Guest Page";
3655 baseString = (
char*)
"https://iDogWatch.com/bot/feedguest";
3656 title =
"Feed Guest";
3662 baseString = (
char*)
"https://iDogWatch.com/bot/feedguestdevice";
3693 title =
"Help Info";
3701 title =
"DOC FOLLOW";
3706 SM =
"https://SemanticMarker.org";
3732 if (!markerAlreadyShown)
3742 SerialDebug.println(
"OTA via BLE");
3748 else if (strcasecmp(cmd,
"click")==0)
3754 else if (strcasecmp(cmd,
"blink")==0)
3759 else if (strcasecmp(cmd,
"clean")==0 && !
isGroupTopic())
3761 SerialDebug.println(
"CLEAN via BLE");
3765 else if (strcasecmp(cmd,
"feed")==0)
3767 SerialDebug.printf(
"FEED via BLE (%s)\n",topic?topic:
"NULL TOPIC!!");
3770 else if (strcasecmp(cmd,
"resettimer")==0)
3774 else if (strcasecmp(cmd,
"status")==0)
3776 SerialDebug.println(
"STATUS via BLE");
3795 SerialLots.println(
"cmd == status");
3799 else if (strcasecmp(cmd,
"erase")==0 && !
isGroupTopic())
3801 SerialDebug.println(
"ERASE via BLE");
3806 else if (strcasecmp(cmd,
"buzzon")==0)
3808 SerialDebug.println(
"BUZZON via BLE");
3811 else if (strcasecmp(cmd,
"buzzoff")==0)
3813 SerialDebug.println(
"BUZZOFF via BLE");
3818 else if (strcasecmp(cmd,
"gatewayOn")==0)
3820 if (deviceNameSpecified)
3822 SerialDebug.println(
"ASYNC_SET_GATEWAY_ON via BLE");
3826 else if (strcasecmp(cmd,
"gatewayOff")==0)
3828 if (deviceNameSpecified)
3830 SerialDebug.println(
"ASYNC_SET_GATEWAY_OFF via BLE");
3835 else if (strcasecmp(cmd,
"resetfirsttime")==0)
3837 if (deviceNameSpecified)
3839 SerialDebug.println(
"PREFERENCE_FIRST_TIME_FEATURE_SETTING ON via BLE");
3846 else if (strcasecmp(cmd,
"bleclientOn")==0 && !
isGroupTopic())
3848 if (deviceNameSpecified)
3850 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE ON via BLE");
3856 else if (strcasecmp(cmd,
"bleclientOff")==0 && !
isGroupTopic())
3858 if (deviceNameSpecified)
3860 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE OFF via BLE");
3866 else if (strcasecmp(cmd,
"bleserverOn")==0 && !
isGroupTopic())
3868 if (deviceNameSpecified)
3870 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE ON via BLE");
3876 else if (strcasecmp(cmd,
"bleserverOff")==0 && !
isGroupTopic())
3878 if (deviceNameSpecified)
3880 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE OFF via BLE");
3886 else if (strcasecmp(cmd,
"reboot")==0 && !
isGroupTopic())
3888 if (deviceNameSpecified)
3890 SerialDebug.println(
"REBOOT via BLE");
3895 else if (strcasecmp(cmd,
"tiltOn")==0)
3897 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE ON via BLE");
3900 else if (strcasecmp(cmd,
"tiltOff")==0)
3902 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE OFF via BLE");
3906 else if (strcasecmp(cmd,
"zoomSMOn")==0)
3911 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
3922 else if (strcasecmp(cmd,
"zoomSMOff")==0)
3926 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
3944 else if (strcasecmp(cmd,
"poweroff")==0 && !
isGroupTopic())
3946 SerialDebug.println(
"ASYNC_POWEROFF OFF via BLE");
3950 else if (strcasecmp(cmd,
"wifi")==0)
3952 SerialDebug.println(
"cmd=wifi via BLE");
3955 else if (strcasecmp(cmd,
"swapwifi")==0)
3957 SerialDebug.println(
"cmd=swapwifi via BLE");
3968#ifdef USE_SPIFF_MODULE
3970 else if (strcasecmp(cmd,
"readspiff")==0)
3972 SerialDebug.println(
"readspiff...");
3976 else if (strcasecmp(cmd,
"sendspiff")==0)
3980 else if (strcasecmp(cmd,
"deletespiff")==0 && !
isGroupTopic())
3985 else if (strcasecmp(cmd,
"capture")==0)
3994 else if (strcasecmp(cmd,
"help")==0)
3999 sprintf(
_fullMessageOut,
"Syntax {\'cmd': \'[ota|clean|feed|erase|status|buzzon|buzzoff| MORE..help]\'} ");
4002#ifdef TRY_MORE_ASYNC_PROCESSING
4016 char* sendCmdString =
const_cast<char*
>(cmd);
4030 else if (semanticMarkerCmd)
4033 char* baseString = (
char*)
"https://SemanticMarker.org/bot/";
4037 boolean showSM =
true;
4039 showSM = deviceNameSpecified;
4045 SerialDebug.println(
"Not showing SemanticMarker ");
4050 else if (setCmd && valCmd)
4053 char* setCmdString =
const_cast<char*
>(setCmd);
4054 char* valCmdString =
const_cast<char*
>(valCmd);
4055 SerialTemp.print(
"Set: ");
4056 SerialTemp.print(setCmdString);
4057 SerialTemp.print(
", Val: ");
4058 SerialTemp.println(valCmdString);
4073 if (strcasecmp(setCmdString,
"hightemp")==0)
4079 else if (strcasecmp(setCmdString,
"cmd")==0)
4081 if (strcasecmp(valCmdString,
"feed")==0)
4083 SerialCall.printf(
"feed via set,cmd (%s)\n",topic?topic:
"NULL TOPIC!!");
4086 else if (strcasecmp(valCmdString,
"status")==0)
4088 SerialCall.println(
"status via set,cmd");
4092 else if (strcasecmp(valCmdString,
"resettimer")==0)
4099 SerialTemp.printf(
"1.Unknown cmd: %s\n", valCmdString);
4102#pragma mark COPIED FROM BELOW .. so can set without DEVICE name
4103#define USE_WITHOUT_DEVICE_NAME
4115 {"set":"sensors","val":"BuzzerSensorClass,19,22,L9110S_DCStepperClass,21,25"}
4118#ifdef USE_WITHOUT_DEVICE_NAME
4120 else if (strcasecmp(setCmdString,
"stepperangle")==0)
4122 SerialDebug.printf(
"stepperAngle: %s\n", valCmdString);
4125 foundCommand =
true;
4131 else if (strcasecmp(setCmdString,
"stepperRPM")==0)
4133 SerialDebug.printf(
"stepperRPM: %s\n", valCmdString);
4136 foundCommand =
true;
4141 else if (strcasecmp(setCmdString,
"2feed")==0)
4143 SerialDebug.printf(
"2feed: %d\n", flag);
4146 foundCommand =
true;
4151 else if (strcasecmp(setCmdString,
"sensorPlugs")==0)
4155 SerialDebug.printf(
"sensorPlugs: %s\n", valCmdString);
4156 foundCommand =
true;
4164 else if (strcasecmp(setCmdString,
"sensors")==0)
4172 foundCommand =
true;
4175 else if (strcasecmp(setCmdString,
"M5AtomKind")==0)
4180 foundCommand =
true;
4186 else if (strcasecmp(setCmdString,
"BLEUseDeviceName")==0)
4192 foundCommand =
true;
4200#pragma mark Device Name and Not Group
4204 foundCommand =
true;
4206 if (strcasecmp(setCmdString,
"devOnlySM")==0)
4217 else if (strcasecmp(setCmdString,
"toggle")==0)
4220 if (strcasecmp(valCmdString,
"buzzer")==0)
4224 SerialDebug.printf(
"connectedBLEDeviceName = %s\n", connectedBLEDeviceName);
4226 SerialDebug.printf(
"Call Toggle Buzzer via BLE: 'F' - dev=%s\n", connectedBLEDeviceName);
4227 if (connectedBLEDeviceName)
4239 else if (strcasecmp(valCmdString,
"socket")==0)
4250 else if (strcasecmp(setCmdString,
"autoMotorDirection")==0)
4256 else if (strcasecmp(setCmdString,
"config")==0)
4266 else if (strcasecmp(setCmdString,
"includeGroups")==0)
4272 else if (strcasecmp(setCmdString,
"ble+wifi")==0)
4277 else if (strcasecmp(setCmdString,
"factoryreset")==0)
4284 else if (strcasecmp(setCmdString,
"restartmodels")==0)
4290 else if (strcasecmp(setCmdString,
"screentimeout")==0)
4295 else if (strcasecmp(setCmdString,
"stepperangle")==0)
4297 SerialDebug.printf(
"stepperAngle: %s\n", valCmdString);
4304 else if (strcasecmp(setCmdString,
"stepperRPM")==0)
4306 SerialDebug.printf(
"stepperRPM: %s\n", valCmdString);
4312 else if (strcasecmp(setCmdString,
"2feed")==0)
4314 SerialDebug.printf(
"2feed: %d\n", flag);
4318 else if (strcasecmp(setCmdString,
"noclick")==0)
4323 else if (strcasecmp(setCmdString,
"gateway")==0)
4329 else if (strcasecmp(setCmdString,
"DiscoverM5PTClicker")==0)
4334 else if (strcasecmp(setCmdString,
"usespiff")==0 && !
isGroupTopic())
4338#ifdef USE_SPIFF_MODULE
4347 else if (strcasecmp(setCmdString,
"usespiff_mqtt")==0 && !
isGroupTopic())
4352 else if (strcasecmp(setCmdString,
"usespiff_qratom")==0 && !
isGroupTopic())
4360 else if (strcasecmp(setCmdString,
"PIR_UseSM")==0 && !
isGroupTopic())
4366 else if (strcasecmp(setCmdString,
"AtomSocketGlobalOnOff")==0 && !
isGroupTopic())
4372 else if (strcasecmp(setCmdString,
"LUXdark")==0 && !
isGroupTopic())
4378 else if (strcasecmp(setCmdString,
"scannedGroup")==0 && !
isGroupTopic())
4385 else if (strcasecmp(setCmdString,
"scannedDevice")==0 && !
isGroupTopic())
4393 else if (strcasecmp(setCmdString,
"timerdelay")==0)
4395 int timerdelay = atoi(valCmdString);
4399 SerialDebug.printf(
"timerdelay: %d\n", timerdelay);
4403 else if (strcasecmp(setCmdString,
"timerdelayMax")==0)
4405 int timerdelay = atoi(valCmdString);
4409 SerialDebug.printf(
"timerdelayMax: %d\n", timerdelay);
4412 else if (strcasecmp(setCmdString,
"starttimer")==0)
4417 SerialDebug.printf(
"startTimer: %d\n", flag);
4422 else if (strcasecmp(setCmdString,
"sensorPlugs")==0)
4426 SerialDebug.printf(
"sensorPlugs: %s\n", valCmdString);
4434 else if (strcasecmp(setCmdString,
"sensors")==0)
4443 else if (strcasecmp(setCmdString,
"stepper")==0)
4447 float stepperAngle = 22.5;
4450 if (strcasecmp(valCmdString,
"mini")==0)
4454 stepperAngle = 45.0;
4457 else if (strcasecmp(valCmdString,
"tumbler")==0)
4460 stepperAngle = 200.0;
4470 SerialDebug.printf(
"stepper = %d, stepperAngle = %f\n", feederType, stepperAngle);
4481 else if (strcasecmp(setCmdString,
"factoryClockwiseMotor")==0)
4483 SerialCall.println(
" *** Setting factory clockwise motor");
4489 else if (strcasecmp(setCmdString,
"clockwiseMotor")==0)
4491 SerialCall.println(
" *** Setting clockwise motor");
4499 else if (strcasecmp(setCmdString,
"toggleMotor")==0)
4507 currentDirection = !currentDirection;
4511 else if (strcasecmp(setCmdString,
"otafile")==0)
4517 else if (strcasecmp(setCmdString,
"location")==0 && !
isGroupTopic())
4527 else if (strcasecmp(setCmdString,
"pairnow")==0)
4540 else if (strcasecmp(setCmdString,
"pairdev")==0)
4543 if (strcasecmp(valCmdString,previousName)!=0)
4567#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
4568 if (strlen(valCmdString)==0)
4579 else if (strcasecmp(setCmdString,
"usegroups")==0)
4588 else if (strcasecmp(setCmdString,
"groups")==0)
4598 foundCommand =
false;
4600#pragma mark END of device and not group
4605 if (strcasecmp(setCmdString,
"device")==0 && !
isGroupTopic())
4617 else if (strcasecmp(setCmdString,
"screencolor")==0)
4620 int screenColor = atoi(valCmdString);
4627 else if (strcasecmp(setCmdString,
"gen3only")==0)
4639 else if (strcasecmp(setCmdString,
"BLEUsePairedDeviceName")==0)
4643#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
4651 else if (strcasecmp(setCmdString,"BLEUseDeviceName")==0)
4667 else if (strcasecmp(setCmdString,
"minMenu")==0)
4669 SerialDebug.println(
"PREFERENCE_IS_MINIMAL_MENU_SETTING via BLE");
4684 else if (strcasecmp(setCmdString,
"addwifi")==0)
4691 strcpy(str,valCmdString);
4694 char* ssid = strtok_r(rest,
":", &rest);
4695 char* password = strtok_r(rest,
":", &rest);
4696 SerialDebug.printf(
"addwifi %s, %s\n", ssid?ssid:
"null", password?password:
"");
4703 char credentials[100];
4705 sprintf(credentials,
"{'ssid':'%s','ssidPassword':'%s'}", ssid?ssid:
"NULL", password?password:
"");
4707 SerialMin.println(credentials);
4721 else if (strcasecmp(setCmdString,
"usedocfollow")==0)
4723 SerialDebug.printf(
"PREFERENCE_USE_DOC_FOLLOW_SETTING %s\n", valCmdString);
4728 else if (strcasecmp(setCmdString,
"semanticMarker")==0)
4730 SerialDebug.printf(
"SemanticMarker: %s\n", valCmdString);
4734 boolean showSM =
true;
4736 showSM = deviceNameSpecified;
4742 SerialDebug.println(
"Not showing SemanticMarker ");
4746 else if (strcasecmp(setCmdString,
"blankscreen")==0)
4759 else if (strcasecmp(setCmdString,
"SubDawgpack")==0)
4763 SerialDebug.println(
"PREFERENCE_SUB_DAWGPACK_SETTING via BLE");
4777 _mqttClient.unsubscribe((
char*)
"usersP/dawgpack");
4783 else if (strcasecmp(setCmdString,
"buzz")==0 && !
isGroupTopic())
4789 SerialDebug.println(
"BUZZ:ON via BLE");
4794 SerialDebug.println(
"BUZZ:OFF via BLE");
4801 else if (strcasecmp(setCmdString,
"bleclient")==0)
4805 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE via BLE");
4813 else if (strcasecmp(setCmdString,
"bleserver")==0)
4817 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE via BLE");
4823 else if (strcasecmp(setCmdString,
"tilt")==0)
4827 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE via BLE");
4833 else if (strcasecmp(setCmdString,
"zoomSm")==0)
4841 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
4856 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
4876 else if (strcasecmp(setCmdString,
"buttonA")==0)
4878 if (strcasecmp(valCmdString,
"longpress")==0)
4880 else if (strcasecmp(valCmdString,
"shortpress")==0)
4883 else if (strcasecmp(setCmdString,
"buttonB")==0)
4885 if (strcasecmp(valCmdString,
"longpress")==0)
4887 else if (strcasecmp(valCmdString,
"shortpress")==0)
4890 else if (strcasecmp(setCmdString,
"M5AtomKind")==0 && !
isGroupTopic())
4899 else if (strcasecmp(setCmdString,
"disk")==0)
4901 SerialDebug.printf(
"Cloud DISK space = %s\n", valCmdString);
4903 else if (strcasecmp(setCmdString,
"feedcount")==0)
4905 SerialDebug.printf(
"Global feed count = %s\n", valCmdString);
4909 SerialMin.printf(
"2.Unknown cmd: %s (isGroupTopic=%d)\n", setCmdString,
isGroupTopic());
4919 char* sendCmdString =
const_cast<char*
>(sendCmd);
4923 if (strcasecmp(sendCmdString,
"temp")==0)
4925 SerialCall.println(
"sendCmd == temp");
4929 else if (strcasecmp(sendCmdString,
"status")==0)
4931 SerialCall.println(
"sendCmd == status");
4936 else if (strcasecmp(sendCmdString,
"capture")==0)
4938 SerialCall.println(
"sendCmd == capture");
4945 else if (strcasecmp(sendCmdString,
"volume")==0)
4947 SerialCall.println(
"sendCmd == volume (not implemented)");
4954 SerialTemp.print(
"Unknown send request: ");
4955 SerialTemp.println(sendCmdString);
4964 char* setCmdString =
const_cast<char*
>(set64Cmd);
4965 char* valCmdString =
const_cast<char*
>(valCmd);
4967 char plaintext_out[200];
4968 int len = strlen(valCmdString);
4971 SerialError.println(
"Length too long to base64 decode: 200");
4975 int status = base64_decode_chars(valCmdString, len, plaintext_out);
4976 String decoded = String(plaintext_out);
4983 SerialDebug.println(decoded);
4985 if (strcasecmp(setCmdString,
"semanticMarker")==0 && !
isGroupTopic())
4991 boolean showSM =
true;
4993 showSM = deviceNameSpecified;
5004 SerialDebug.println(
"Not showing SemanticMarker ");
5006 else if (strcasecmp(setCmdString,
"PIR_SM_JSON")==0 && !
isGroupTopic())
5019 else if (strcasecmp(setCmdString,
"PIR_OFF_SM_JSON")==0 && !
isGroupTopic())
5035 else if (strcasecmp(setCmdString,
"ScannedSemanticMarker")==0)
5042 char * my_argument =
const_cast<char*
> (decoded.c_str());
5094#ifdef ONLY_NULL_IF_THERE
5095 SerialDebug.println(
" *** processMQTT .. treat like credentials");
5097 const char* a1 = myObject[
"ssid"];
5104 SerialTemp.printf(
"myObject[ssid] = '%s'\n", a1?a1:
"EMPTY");
5110 const char* a2 = myObject[
"ssidPassword"];
5119 SerialDebug.println(
" *** processMQTT .. treat like credentials");
5121 const char* a1 = myObject[
"ssid"];
5122 if (a1 && strlen(a1)>0)
5129 SerialTemp.printf(
"myObject[ssid] = '%s'\n", a1?a1:
"EMPTY");
5135 const char* a2 = myObject[
"ssidPassword"];
5136 if (a2 && strlen(a2)>0)
5153 const char* a3 = myObject[
"mqtt_server"];
5163 const char* a4 = myObject[
"mqtt_port"];
5174 const char* a5 = myObject[
"mqtt_password"];
5185 const char* a6 = myObject[
"mqtt_user"];
5196 const char* a7 = myObject[
"deviceName"];
5197 if (a7 && strlen(a7)>0)
5206 const char* a8 = myObject[
"uuid"];
5208 if (a8 && strlen(a8)>0)
5220 const char* a9 = myObject[
"mqtt_topic"];
5222 if (a9 && strlen(a9)>0)
5235 const char* a10 = myObject[
"mqtt_guestPassword"];
5237 if (a10 && strlen(a10)>0)
5250 const char* a11 = myObject[
"location"];
5251 if (a11 && strlen(a11)>0)
5263 boolean saveJSONPreferences =
true;
5267 SerialDebug.println(
"Setting WIFI from JSON parameters");
5278 SerialDebug.println(
" ***** ERROR .. no ssidString *** ");
5282 saveJSONPreferences =
false;
5287 if (!saveJSONPreferences)
5289 SerialDebug.println(
"**** Not saving JSON in preferences ***");
5319 SerialDebug.println(
"set disconnectedWIFI and stopDelay");
5334 SerialDebug.println(
"cleanMQTTpasswordsUpdateInEPROM");
5348 DynamicJsonDocument myObject(1024);
5384 serializeJson(myObject, output2);
5388 SerialDebug.print(
"MQTTNetworking.Writing EPROM JSON = '");
5389 SerialDebug.print(output2);
5390 SerialDebug.println(
"'");
5399#define NO_NEED_AND_GRU_CRASH
5400#ifdef NO_NEED_AND_GRU_CRASH
5405 SerialDebug.print(
"Reading.2 EPROM JSON = ");
5420 s.replace(
"%20",
" ");
5421 s.replace(
"+",
" ");
5422 s.replace(
"%21",
"!");
5423 s.replace(
"%22",
"\"");
5424 s.replace(
"%23",
"#");
5425 s.replace(
"%24",
"$");
5426 s.replace(
"%25",
"%");
5427 s.replace(
"%26",
"&");
5428 s.replace(
"%27",
"\'");
5429 s.replace(
"%28",
"(");
5430 s.replace(
"%29",
")");
5431 s.replace(
"%30",
"*");
5432 s.replace(
"%31",
"+");
5433 s.replace(
"%2C",
",");
5434 s.replace(
"%2E",
".");
5435 s.replace(
"%2F",
"/");
5436 s.replace(
"%2C",
",");
5437 s.replace(
"%3A",
":");
5438 s.replace(
"%3B",
";");
5439 s.replace(
"%3C",
"<");
5440 s.replace(
"%3D",
"=");
5441 s.replace(
"%3E",
">");
5442 s.replace(
"%3F",
"?");
5443 s.replace(
"%40",
"@");
5444 s.replace(
"%5B",
"[");
5445 s.replace(
"%5C",
"\\");
5446 s.replace(
"%5D",
"]");
5447 s.replace(
"%5E",
"^");
5448 s.replace(
"%5F",
"-");
5449 s.replace(
"%60",
"`");
5450 s.replace(
"%7B",
"{");
5451 s.replace(
"%7D",
"}");
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
void disconnect_BLEClientNetworking()
try to disconnect..
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
char * getServiceName_BLEServerNetworking()
retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc)
void showSemanticMarkerFunc_displayModule(String semanticMarkerAddressBase, String title, const char *(*getStatusFunc)(void))
the function to call to get the 'status', return char*
void addToTextMessages_displayModule(String text)
void wakeupScreen_displayModule()
wakes up the screen
void showText_displayModule(String text)
void redrawSemanticMarker_displayModule(boolean startNew)
redraws the Semantic Marker image..
void setScreenColor_displayModule(int screenColor)
cache for getting the screen color 0..n. Will reset the cache as well
void showSemanticMarker_displayModule(String semanticMarkerAddress, String title)
displays the Semantic Marker (a super QR code) on the M5 screen (title = to display)
void blankScreen_displayModule()
blanks the screen
void resetLoopTimer_displayModule()
reset the loop timer .. useful for testing,
void blinkBlueLightMQTT()
blinks the blue light
void startDelayCheckWIFI_MQTTNetworking(int seconds)
init the delay
void publishBinaryFile(char *topic, uint8_t *buf, size_t len, String fileExtension)
boolean delayFinished_WIFI_MQTTState()
boolean bluetoothOnline()
! should be a definition that the bluetooth is ONLINE
#define MAXglobalMQTTAttempts
boolean isSuperTopic()
helper to know it's a superuser topic (and not process in most cases).
void emptyLastMessageStatus()
empty the status message
char _fullMessageIn[MAX_MESSAGE]
message received on subscription
void processBarkletMessage(String message, String topic)
process an MQTT message looking for keywords (barklet language)
void publishMQTTMessageDefaultTopic(char *message)
Wrapper of the mqttclient publish.
void printTopicType()
prints the topic on debug
boolean _delayCheckWIFIRunning_MQTTNetworking
true if still waiting for delayCheckWIFI to finish
char * _ssidPasswordString
void finishWIFI_Setup()
end of WIFI loop..
void checkAndReconnectWIFI_MQTTNetworking()
print a SPIFF timestamp..
char _fullMessageOut[MAX_MESSAGE]
message to send out
int _startTimestamp
uptime since last reboot.
void updatePreferencesInEPROM()
just update the EPROM, and send that to the WIFI_AP module as well
char * _jsonVersionString
boolean _setupMQTTNetworkingAlready
try a flag so setupMQTTnetworking only called 1 times..
void cleanEPROM_MQTTNetworking()
cleans the eprom info
char * wifiStatus_MQTT()
show the status in string form (from Library/Adruino... WiFiType.h)
void sendStatusMessageMQTT_deviceName(char *deviceName, const char *semanticMarker)
sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status rep...
bool stringMatch(String message, String substring)
check if the string matches
void MQTTModule_readPreferences()
setup the WIFI
void cleanSSID_EPROM_Method()
calls the method for cleaning the SSID eprom. This calls the WIFI_APModule callback
String get_WIFIInfoString()
retrieve the WIFIInfoString
boolean isTrueString(String valCmdString)
whether the string is TRUE, ON, 1
void publishMQTTMessage(char *topic, char *message)
Wrapper of the mqttclient publish. NOTE: this might need to be in the loop as well,...
boolean skipMessageProcessing()
this is sent from the backend as a message {'guest':'guest password'} .. but lets' add to the credent...
void sendMessageNoChangeMQTT_Topic(char *message, char *topic)
just send a message but without any extras
void publishSPIFFFile_MQTT(char *topic, char *path, int len)
int _delayCheckWIFISeconds_MQTTNetworking
length of delay
String _topic
the topic the new message came in on..
void setupWIFI_loop()
the loop part of WIFI
void sendMessageMQTT(char *message)
char _lastDocFollowSemanticMarker[MAX_MESSAGE_DOCFOLLOW]
storage for last doc follow semantic marker
char * _jsonLocationString
void checkDelaySinceWIFICheck_MQTTNetworking()
checks delay for the WIFI connectivity
boolean delayCheckWIFIFinished_MQTTNetworking()
if finished..
WiFiClient _espClient
The WIFI client.
#define MAX_WIFI_CONNECT_ATTEMPTS
#define MAX_MQTT_ATTEMPTS
void setupMQTT(char *mqttServerString, char *mqttPortString, char *mqttPasswordString, char *mqttUserString, char *deviceNameString, char *uuidString)
setup the MQTT server
#define ESP_EPROM_NAME
9.27.23 to decode a base64 string (a Semantic Marker)
const char * getDynamicMessageFunc()
used by the displayModule to call this for each new status
float _WIFI_MQTTStateDelays[]
the delay in seconds for each state
boolean _newMQTTMessageArrived
void callPreSetupMQTT()
called to setup the MQTT (which is really the _mqttClient setup). Done on it's own thread....
String getJSONConfigString()
retrieve the Configuration JSON string in JSON format..
void setup_MQTTNetworking()
setup the MQTT part of networking
const char * _ntpServer
define here as well.. NOTE: this could be passed is as well... TODO
void performOTAUpdateMethod()
perform the OTA update. This calls the OTAImageUpdate methods (via preformOTAUpdateSimple())
WIFI_MQTTStates
state variables
void stopDelayCheckWIFI_MQTTNetworking()
stop the delay (not called)
void sendStatusMessageMQTT(const char *semanticMarker)
sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status rep...
void stopDelay_WIFI_MQTTState()
char * shortVersion()
return a short version of VERSION
void getChipInfo()
create a unique ID (but it needs to be stored.. otherwise it's unique each time??
boolean isGroupTopic()
helper to know it's a superuser topic (and not process in most cases).
char * _mqttPasswordString
void loop_MQTTNetworking()
called for the loop() of this plugin
char * getLastDocFollowSemanticMarker_MQTTNetworking()
char _shortVersion[30]
the short version
void classifyTopic(char *topic)
classify a topic
void setLastMessageStatus(char *token)
char * currentMessageStatusURL()
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc
int _countSinceLastChangedMessageStatus
a counter to erase the last message if not changed in N calls..
const char * getDynamicStatusFunc()
void setupWIFI(char *arg_ssid, char *arg_password)
setup the WIFI using ssid and password
void printWIFIInfo()
print the WIFI info
void startDelay_WIFI_MQTTState()
void invokeCurrentSMModePage(char *topic)
send message to ourself to change to current specifed SM Mode
enum MQTTMessageTopicType _MQTTMessageTopicType
void cleanMQTTpasswordsUpdateInEPROM()
9.18.23 LA (after Eagle Rock bike ride, Van Morrison tomorrow)
WIFI_MQTTStates _WIFI_MQTTState
the state we are in..
TimerDelayClass * _timerDelayClass_WIFI_MQTTState
3.29.25 RaiiiinIeeeeR Beer movie
int _counterLoop
CONNECTION counters.
char _lastGroupTopic[100]
saves the group topic .. to write back on ..
void initAllArrayStorage()
Put all the storage initialization here..
boolean processJSONMessageMQTT(char *ascii, char *topic)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not,...
PubSubClient _mqttClient(_espClient)
The PubSub MQTT Client.
String get_WIFI_SSID()
3.22.24 get the WIFI SSID for the status
void sendMessageMQTT_Topic(char *message, char *topic)
for now only send if it start message starts with "#"
void sendDocFollowMessageMQTT(const char *semanticMarker)
sends the semantic marker as a doc follow message
unsigned long _delayCheckWIFIStart_MQTTNetworking
the time the delay started
#define MAX_MESSAGE_DOCFOLLOW
void restartDelayCheckWIFI_MQTTNetworking()
starts the delay for WIFI checking, called at startup, and each time the timer finished....
char _semanticMarkerString[MAX_MESSAGE]
Preferences _preferencesMQTTNetworking
8.16.25 MQTT
void setLastDocFollowSemanticMarker_MQTTNetworking(char *semanticMarker)
sets the last DocFollow SemanticMarker
String MQTT_urlDecode(String input)
Decode the URL (copied from WIFI_APModule. Easier than breaking modules)
boolean isDawgpackTopic()
helper to know it's a dawgpack topic (and not process in most cases). Only support DOCFOLLOW for now....
void sendMessageNoChangeMQTT(char *message)
just send a message but without any extras
void callbackMQTTHandler(char *topic, byte *payload, unsigned int length)
called when data on the MQTT socket
boolean isConnectedMQTT_MQTTState()
value of MQTT connected
void checkMQTTMessages_loop()
check for MQTT messages, called from the main loop()
int getDelayCheckWIFISeconds_MQTTNetworking()
get the delay values
char _lastMessageStatusURL[MAX_MESSAGE_DOCFOLLOW]
storage of the last message status
int getUptime()
returns seconds since first booted
MQTTMessageTopicType
break up the MQTT Handler 8.12.22 as per "My guess is that you have your data collection (from some I...
char * getDeviceNameMQTT()
called for things like the advertisement
void performFeedMethod(char *topic)
calls the FEED message via the callback (which calls the BLE code)
boolean isConnectedWIFI_MQTTState()
value of WIFI connected
void restartWIFI_MQTTState()
restart the WIFI and then MQTT connection
char * _mqttGuestPasswordString
#define _preferencesJSONName
Points to strings read from JSON (limited to 15 char key name)
void reconnectMQTT_loop()
String _fullJSONString
storage for the full JSON message string to send around..
void publishSMRunMessage(char *smrunMessage)
void initShortVersion()
init short version
#define MQTT_CALLBACK_TEMP
#define MQTT_CLEAN_SSID_EPROM
#define MQTT_CALLBACK_BLINK
#define MQTT_CALLBACK_FEED
8.16.25 MQTT
#define MQTT_CALLBACK_SOLID_LIGHT
void messageSend_mainModule(char *sendValue, boolean deviceNameSpecified)
TODO: have a callback regist approach.
#define CALLBACKS_MQTT
8.16.25 MQTT
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...
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
void main_setScannedGroupName(char *groupName)
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)
void setClockwiseMotorDirection_mainModule(boolean isClockwiseFlag)
8.18.24 setting this will check for the factory setting..
void main_credentialsUpdated()
moved here 4.25.22 (entirely from ESP_IOT.ino)
void restartAllMenuStates_mainModule()
restarts all the menu states to the first one .. useful for getting a clean start....
int whichSMMode_mainModule(char *cmd)
************** SM Mode Processing ***************
void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter)
boolean isEmptyString(char *stringA)
informs if null or empty string
void rebootDevice_mainModule()
void setConfiguration_mainModule(char *configurationName)
void buttonB_ShortPress_mainModule()
the short press of the side button
bool containsSubstring(String message, String substring)
check if the string contains the other string. This is a poor man's grammer checker
void callCallbackMain(int callbacksModuleId, int callbackType, char *message)
performs the indirect callback based on the callbackType
int getCurrentSMMode_mainModule()
returns the current SM Mode
char * main_currentStatusJSON()
status in JSON format, needs to return something as a ',' is already added before calling this....
void changeButtonColor_MainModule()
2.21.25 add a way to change the button color (if any)
int getFeederType_mainModule()
get the feeder type (Sepper 1,2,3 ...)
void buttonA_LongPress_mainModule()
long press on buttonA (top button)
boolean startsWithChar(char *str, char c)
a char* version of startsWith (after skipping spaces)
void setCurrentSMMode_mainModule(int whichSMMode)
sets the current screen mode .. which can be used by Button and Display processing
char * getPairedDevice_mainModule()
returns if the paired device is not NONE
void setLUXThreshold_mainModule(int thresholdKind, int luxVal)
set the threshold val
void main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
char * getChipIdString()
3.17.24 get the chip id as a string
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
int getTimeStamp_mainModule()
void buttonB_LongPress_mainModule()
the long press of the side button
char * createCopy(char *stringA)
void messageSetVal_mainModule(char *setName, char *valValue, boolean deviceNameSpecified)
float getTemperature_mainModule()
retrieves the temperature .
void buttonA_ShortPress_mainModule()
boolean isValidPairedDevice_mainModule()
returns if the paired device is not NONE. Note, the paired Name might be an address now (see below)
char * main_nextJSONWIFICredential()
! cycle through the next WIFI saved credential
#define SM_pair_dev
guest feed device
#define THRESHOLD_KIND_DARK
#define SM_guest_feed
guest feed
#define SM_guest_page
guest page
#define SM_timer
timer .. todo
#define SM_status
//status
#define ASYNC_SET_GATEWAY_ON
sets the GATEWAY mode on
#define ASYNC_CALL_BUZZ_ON
sends a 'B' to the BLE end of the code (assuming a feeder is connected).
#define ASYNC_POWEROFF
sets the GATEWAY mode off
#define ASYNC_CALL_CLEAN_EPROM
cleans the EPROM totally, and reboots
#define ASYNC_SEND_MQTT_STATUS_URL_MESSAGE
sends the status from the main module URL
#define ASYNC_SET_GATEWAY_OFF
sets the GATEWAY mode off
#define ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER
these are the async with a string parameter
#define ASYNC_CALL_OTA_UPDATE
TODO: make this a registeration approach.
#define SM_doc_follow
docfollow
#define SM_smart_clicker_homepage
//! homepage
#define SM_WIFI_ssid
WIFI ssid.
#define SM_ap_mode
AP MODE.
#define ASYNC_CALL_BUZZ_OFF
sends a 'b' to the BLE end of the code (assuming a feeder is connected).
#define ASYNC_CLICK_SOUND
5.15.25 add a BUZZ command (or CLICK)
void setTimerDelaySecondsMax_mainModule(int delaySeconds)
void invokePair_ModelController()
void setTimerDelaySeconds_mainModule(int delaySeconds)
void startStopTimer_mainModule(boolean startTimer)
void invokeUnpairNoName_ModelController()
void performOTAUpdateSimple()
retrieves from constant location
void performOTAUpdate(char *hostname, char *httpAddress)
8.16.25 MQTT
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int preference
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
void savePreferenceATOMKind_MainModule(String value)
returned from mainModule
void appendPreference_mainModule(int preferenceID, String preferenceValue)
called to append to a a preference (which will be an identifier and a string, which can be converted ...
void setDiscoverM5PTClicker(boolean flag)
void setSensorsString_mainModule(char *sensorsString)
void resetAllPreferences_mainModule()
resets preferences.. Currently only reset all, but eventually reset(groups..)
boolean getPreferenceBoolean_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
void storePreference_mainModule(int preferenceID, String preferenceValue)
called to append to a a preference (which will be an identifier and a string, which can be converted ...
void savePreferenceFloat_mainModule(int preferenceID, float val)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
void savePreferenceIntFromString_mainModule(int preferenceID, char *val)
sets an int, but only if a valid integer, and no signs. If bad, then a 0 is stored
boolean topicInIncludeGroup(char *topic)
char * getPreference_mainModule(int preferenceID)
void setIncludeGroups(char *groups)
8.2.24 set the include group (and cache it), called from MQTT
char * getPreferenceString_mainModule(int preferenceID)
returns the preference but in it's own string buffer. As long as you use it before calling getPrefere...
void printPreferenceValues_mainModule()
print the preferences to SerialDebug
void savePreference_mainModule(int preferenceID, String preferenceValue)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
#define PREFERENCE_USE_SPIFF_SETTING
8.22.22 to turn on/off SPIFF use (more below..)
#define PREFERENCE_PAIRED_DEVICE_ADDRESS_SETTING
the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
#define PREFERENCE_STEPPER_KIND_VALUE
uses STEPPER type
#define PREFERENCE_SENSOR_TILT_VALUE
Sensor preferences.
#define PREFERENCE_SUB_DAWGPACK_SETTING
8.17.22 to turn on/off subscribing to the dawgpack topic
#define PREFERENCE_SM_COMMAND_PIR_OFF_SETTING
1.11.24 The Semantic Marker command is sent on PIR, and the Command to send on OFF (or opposite)
#define PREFERENCE_SENSOR_PLUGS_SETTING
#define PREFERENCE_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
#define PREFERENCE_ONLY_GEN3_CONNECT_SETTING
if true, only BLEClient connect to GEN3 feeders..
#define PREFERENCE_SENDWIFI_WITH_BLE
sends the WIFI to all except current device if set
#define PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING
#define PREFERENCE_SUPPORT_GROUPS_SETTING
the preference for supporting GROUPS (default true)
#define PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_WIFI_CREDENTIAL_2_SETTING
#define PREFERENCE_STEPPER_RPM_SETTING
#define PREFERENCE_MAIN_BLE_SERVER_VALUE
#define PREFERENCE_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define PREFERENCE_STEPPER_BUZZER_VALUE
stepper preferences
#define PREFERENCE_DEV_ONLY_SM_SETTING
adding AP_DEBUG_MODE to let others know that DEBUG eprom is available. Turn this OFF for non dev
#define STEPPER_IS_TUMBLER
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCE_USE_DOC_FOLLOW_SETTING
for
#define PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING
1.12.24 Whether the AtomSocket accepts global on/off messages
#define PREFERENCE_USE_SPIFF_MQTT_SETTING
#define PREFERENCE_DEBUG_INFO_SETTING
a place to put some kind of Last Will of what went wrong .. for now (> max tries)
#define PREFERENCE_FIRST_TIME_FEATURE_SETTING
a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
#define PREFERENCE_DISPLAY_SCREEN_TIMEOUT_VALUE
sets the timeout value
#define PREFERENCE_IS_MINIMAL_MENU_SETTING
sets the max temp for a poweroff
#define PREFERENCE_USE_SPIFF_QRATOM_SETTING
For MQTT writing to the QRATOM.
#define PREFERENCE_DEVICE_NAME_SETTING
the device name itself (6.6.22)
#define PREFERENCE_HIGH_TEMP_POWEROFF_VALUE
sets the max temp for a poweroff
#define PREFERENCE_GROUP_NAMES_SETTING
the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wi...
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
#define PREFERENCE_STEPPER_2FEED_SETTING
#define PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING
#define PREFERENCE_MAIN_GATEWAY_VALUE
#define PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define PREFERENCE_MAIN_BLE_CLIENT_VALUE
#define PREFERENCE_SM_ON_PIR_SETTING
1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
#define PREFERENCE_ATOM_KIND_SETTING
1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
#define PREFERENCE_SM_COMMAND_PIR_SETTING
1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
#define PREFERENCE_SENSORS_SETTING
void println_SPIFFModule(char *string)
The SPIFF module is for storing messages that are retrievable later as it stores on a folder area of ...
void sendStrings_SPIFFModule(int numberOfLines)
sends SPIFF module strings over MQTT, starting at the number back specified. This will use the curren...
void printTimestamp_SPIFFModule()
prints a timestamp time: <time> :
void printFile_SPIFFModule()
prints the spiff file to the SerialDebug output
void deleteFiles_SPIFFModule()
delete the spiff files..
void println_SPIFFModule_JSON(char *attribute, char *value)
4.4.24 output a line in JSON format adding timestamp as well
void setup_SPIFFModule()
the setup for this module
void saveScreen_SPIFFModule()
save the screen to a file on the SPIFF
boolean queryMatchesName_mainModule(char *name)
void startDelay(float delayAmountSeconds)
starts delay calculation
boolean delayFinished()
whether the currently delay is finished, false if not running at all
void stopDelay()
stops delay