2#include "../../Defines.h"
5#define USE_NEW_M5ATOMCLASS
7#ifdef USE_NEW_M5ATOMCLASS
9#include "../M5AtomClassModule/M5AtomClassType.h"
11#include "../M5AtomClassModule/M5Atom_SocketModuleClass.h"
12#include "../M5AtomClassModule/M5Atom_QRCodeModuleClass.h"
13#include "../M5AtomClassModule/M5Atom_HDriverModuleClass.h"
15#include "../M5AtomClassModule/M5Atom_Core2ModuleClass.h"
17#include "../M5AtomClassModule/M5Atom_TinyGPSModuleClass.h"
19#include "../M5AtomClassModule/M5Atom_CameraModuleClass.h"
24#include "../ATOM_LED_Module/M5Display.h"
46#define NUM_M5ATOM_CLASS 6
56#define USE_SENSOR_CLASS
57#ifdef USE_SENSOR_CLASS
59#include "../SensorClass/SensorClassType.h"
60#include "../SensorClass/BuzzerSensorClass.h"
61#include "../SensorClass/KeyUnitSensorClass.h"
63#define NUM_SENSOR_CLASS 2
72 SerialDebug.println(
" *** initSensorClassTypeArray ***");
83 for (
int i=0; i< count; i++)
86 if (strcmp(sensor->
sensorName,
"BuzzerSensorClass")==0)
101 for (
int i=0; i< count; i++)
107 SerialDebug.printf(
"Missing class definition: %s\n", sensor->
sensorName);
111 SerialDebug.println(
"Finish initSensorClassTypeArray");
171#define MESSAGE_STORAGE_MAX 500
213 SerialMin.println(
"setup_mainModule");
214#ifdef BOOTSTRAP_CLEAN
239 SerialMin.println(
"FIRST TIME TURNING off the BLE_SERVER for the M5");
268#if defined(ESP_M5_CAMERA) || defined(ESP_32)
270int _mainLoopCounter = 0;
282#if defined(ESP_M5_CAMERA) || defined(ESP_32)
285 if (_mainLoopCounter++ > 30)
290 _mainLoopCounter = 0;
295#pragma mark Serial Input Processor
302 if (Serial.available())
305 String command = Serial.readStringUntil(
'\n');
307 SerialDebug.println(command);
311 if (command ==
"help")
313 SerialDebug.println(
"Enter any Single Char or JSON msg, type '.' for commands");
314 SerialDebug.println(
"r -- reboot");
315 SerialDebug.println(
". -- shows single char commands");
316 SerialDebug.println(
"Example JSON to change WIFI (copy and modify with your values)");
317 SerialDebug.println(
" supports single quotes for values");
318 SerialDebug.println(
"{'ssid':'Bob', 'ssidPassword':'scott'}");
321 else if (command ==
"r")
370 SerialTemp.println(
"incrementFeedCount_mainModule");
398 if (substring.length() == 0 )
400 bool found = strstr(&message[0], &substring[0]);
401 SerialLots.printf(
"containsSubstring-%d - %s in: %s\n", found, &substring[0], &message[0]);
406#include "../MQTTModule/MQTTNetworking.h"
409#include "../BLEServerModule/BLEServerNetworking.h"
412#include "../BLEClientModule/BLEClientNetworking.h"
413#ifdef USE_BUTTON_MODULE
414#include "../ButtonModule/ButtonProcessing.h"
420#define CALLBACKS_MQTT 0
421#define CALLBACKS_BUTTON_MODULE 1
422#define CALLBACKS_BLE_CLIENT 2
423#define CALLBACKS_BLE_SERVER 3
429void callCallbackMain(
int callbacksModuleId,
int callbackType,
char *message);
434#define CALLBACKS_MAX_MQTT MQTT_MAX_CALLBACKS
435#define CALLBACKS_MAX_BUTTON_MODULE MAX_CALLBACKS_BM
436#define CALLBACKS_MAX_BLE_CLIENT BLE_CLIENT_MAX_CALLBACKS
437#define CALLBACKS_MAX_BLE_SERVER BLE_SERVER_MAX_CALLBACKS
443 SerialLots.printf(
"No callback defined .. %s\n", message);
467 SerialLots.printf(
"creatingCallbacks %d size: %d\n", max,
sizeof(
callbackSignature *));
469 for (
int i=0; i< max; i++)
473 return callbackArray;
497#ifdef USE_BUTTON_MODULE
514 SerialDebug.printf(
"registerCallbackMain %d, %d\n", callbacksModuleId, callbackType);
520 if (callbackType < 0 || callbackType >= max)
522 SerialError.printf(
"#### Error outside callback range - 1, %d\n", callbackType);
537 if (callbackType < 0 || callbackType >= max)
539 SerialError.printf(
"#### Error outside callback range - 2, %d\n", callbackType);
543 void (*callbackFunction)(
char *) =
_allCallbacks[callbacksModuleId][callbackType];
544 (*callbackFunction)(message);
551 return valCmdString.equalsIgnoreCase(
"on") ||
552 valCmdString.equalsIgnoreCase(
"1") ||
553 valCmdString.equalsIgnoreCase(
"true");
562 SerialCall.printf(
"messageSetVal(%s,%s)\n", setName, valValue);
586#pragma mark USE_NEW_M5ATOMCLASS
605 SerialTemp.print(
"feedMessageCallback_main: ");
606 SerialTemp.println(message);
607 char * rxValue = (
char*)
"c";
624 SerialTemp.print(
"Paired Device: ");
627 SerialTemp.printf(
"Gateway: Feeding over the BLE CLIENT network .. if connected: %d\n",
isConnectedBLEClient());
633 SerialLots.println(
"after send feed via ble");
644 SerialDebug.println(
" *** main_credentialsUpdated .. setDoneWIFI_APModuleFlag **");
654 SerialCall.print(
"onWriteBLEServerCallback: ");
655 SerialCall.println(message);
661 SerialCall.print(
"onStatusMessageBLEServerCallback");
662 SerialCall.print(message);
671 SerialDebug.print(
"onWriteBLEServerCallback_main: ");
672 SerialDebug.println(message);
676 if (strlen(message) == 1)
679 if (strcmp(message,
"#MSG_START")==0)
687 if (strcmp(message,
"#MSG_END")==0)
709 message = (
char*)
"s";
713 message = (
char*)
"B";
717 message = (
char*)
"b";
737 SerialDebug.printf(
"Perform BLE Command '%s'\n", message);
739 char cmd = message[0];
751 SerialDebug.println(
"*********");
759#define TRY_ASYNC_BLE_PROCESSING
760#ifdef TRY_ASYNC_BLE_PROCESSING
775#ifdef USE_BUTTON_MODULE
777 refreshDelayButtonTouched_ButtonProcessing();
811 boolean isValid = pairedDevice && strlen(pairedDevice)>0 && strcmp(pairedDevice,
"NONE")!= 0;
815 isValid = pairedDeviceAddress && strlen(pairedDeviceAddress)>0 && strcmp(pairedDeviceAddress,
"NONE")!= 0;
816 SerialLots.printf(
"isValidDeviceAddress(%s,%d)\n", pairedDeviceAddress?pairedDeviceAddress:(
char*)
"NULL", isValid);
818 SerialLots.printf(
"isValidPairedDevice_mainModule(%s,%d)\n", pairedDevice?pairedDevice:(
char*)
"NULL", isValid);
828 if (pairedDevice && strlen(pairedDevice)>0 && strcmp(pairedDevice,
"NONE")!= 0)
830 SerialLots.printf(
"getPairedDeviceOrAddress_mainModule(%s)\n", pairedDevice);
834 if (pairedDeviceAddress && strlen(pairedDeviceAddress)>0 && strcmp(pairedDeviceAddress,
"NONE")!= 0)
836 SerialLots.printf(
"getPairedDeviceOrAddress_mainModule(%s)\n", pairedDeviceAddress);
837 return pairedDeviceAddress;
864 SerialTemp.println(
" **** POWEROFF ***");
869#ifndef ESP_M5_ATOM_S3
882 SerialDebug.println(
"CLEANING EPROM PREFERENCES");
895 SerialDebug.println(
"REBOOTING...");
921 if (strcmp(credential,
"NONE")==0)
925 SerialTemp.print(
"main_nextJSONWIFICredential:");
926 SerialTemp.println(credential);
931 SerialTemp.print(
"main_nextJSONWIFICredential:");
941 SerialMin.print(
"main_saveWIFICredentials");
950 if (strcmp(credential,
"NONE")==0)
969 SerialMin.println(
"main_cleanSavedWIFICredentials");
1010 SerialDebug.printf(
"main_setScannedDeviceName(%s)\n", deviceName);
1017 SerialDebug.printf(
"main_setScannedGroupName(%s)\n", groupName);
1019 if (groupName && strlen(groupName)>0)
1041void main_updateMQTTInfo(
char *ssid,
char *ssid_password,
char *username,
char *password,
char *guestPassword,
char *deviceName,
char * host,
char * port,
char *locationString)
1043 SerialMin.printf(
"main_updateMQTTInfo(%s,%s,%s,%s,%s, %s, d=%s)\n", ssid?ssid:
"NULL", ssid_password?ssid_password:
"NULL", username?username:
"NULL", password?password:
"NULL", guestPassword?guestPassword:
"NULL", locationString?locationString:
"NULL", deviceName?deviceName:
"NULL");
1065 switch (syncCallCommand)
1081 SerialDebug.println(
"NO BuzzerSensorClass defined");
1124 SerialError.printf(
"ERROR: async call out of range: %d\n", asyncCallCommand);
1129 SerialTemp.printf(
"1.main_dispatchAsyncCommand: %d\n", asyncCallCommand);
1144 SerialError.printf(
"ERROR: async call out of range: %d\n", asyncCallCommand);
1149 SerialTemp.print(
"2.main_dispatchAsyncCommandWithString:");
1150 SerialTemp.print(asyncCallCommand);
1151 SerialTemp.print(
": ");
1160 SerialDebug.println(
"SYNC_REBOOT");
1176 SerialCall.printf(
"invokeAsyncCommands(%d)\n", i);
1181 SerialTemp.print(
"ASYNC_CALL_BLE_CLIENT_PARAMETER: ");
1191 SerialTemp.print(
"ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER: ");
1199 char httpAddress[100];
1207 if (thirdSlash == 3)
1212 hostname[i] = (char)0;
1214 strcpy(httpAddress,a);
1219 SerialTemp.print(
"will performOTAUpdate: ");
1220 SerialTemp.print(hostname);
1221 SerialTemp.print(
" with httpAddress: ");
1222 SerialTemp.println(httpAddress);
1229 SerialDebug.print(
"ASYNC_JSON_MESSAGE_PARAMETER: ");
1241 SerialDebug.print(
"ASYNC_JSON_MQTT_MESSAGE_PARAMETER: ");
1258 SerialDebug.print(
"ASYNC_REST_CALL_MESSAGE_PARAMETER: ");
1260#ifdef USE_REST_MESSAGING
1280 SerialLots.println(
"ASYNC_CALL_OTA_UPDATE");
1285 SerialTemp.println(
"ASYNC_CALL_CLEAN_CREDENTIALS");
1291 SerialTemp.println(
"ASYNC_CALL_CLEAN_EPROM");
1295 SerialLots.println(
"ASYNC_CALL_FEED_COMMAND");
1303 SerialTemp.println(
"ASYNC_SEND_MQTT_FEED_MESSAGE");
1305 SerialCall.println(
"async_send_feed.1");
1313 char pubString[100];
1315 boolean isPaired = paired && strlen(paired)>0;
1317 SerialTemp.printf(
"Paired = %s\n", paired?paired:(
char*)
"none");
1326 strcat(pubString,
",'cmd':'feed'}");
1346 SerialTemp.println(
" *** NO BLE connected so send wifi ASYNC_SEND_MQTT_FEED_MESSAGE");
1351 SerialCall.println(
"async_send_feed.2");
1375 SerialTemp.println(
"ASYNC_CLICK_SOUND");
1387 SerialDebug.printf(
"ASYNC_CALL_BUZZ %d\n",isBuzzOn);
1390 cmdToSend =
"{'cmd':'buzzon'}";
1392 cmdToSend =
"{'cmd':'buzzoff'}";
1403 SerialLots.println(
"async_call_buzz_on/off -- not BLE connected.. send MQTT");
1419 SerialLots.println(
"async_call_buzz_on -- not BLE connected.. send MQTT");
1426 SerialLots.println(
"async_call_buzz_on -- YES BLE connected.. send BLE");
1438 SerialLots.println(
"ASYNC_SET_GATEWAY_ON");
1444 SerialLots.println(
"ASYNC_SET_GATEWAY_OFF");
1450 SerialDebug.println(
"ASYNC_REBOOT");
1456 SerialDebug.println(
"ASYNC_POWEROFF");
1461 SerialDebug.println(
"ASYNC_BLANKSCREEN");
1473 SerialDebug.print(
" ASYNC_SEND_MQTT_STATUS_URL: ");
1474 SerialDebug.println(statusURL);
1478#ifdef M5BUTTON_MODULE
1482 statusM5ButtonModule();
1507 SerialLots.printf(
"NO COMMAND: %s", i);
1515#ifdef M5BUTTON_MODULE
1516 SerialDebug.println(
"changeButtonColor_MainModule");
1532 for (
int i = 0; i < 17; i = i + 8) {
1557 switch (thresholdKind)
1570 switch (thresholdKind)
1585#define GROUP_TOPIC_TO_SEND (char*)"usersP/groups"
1620 SerialLots.println(
"solidLightMessageCallback..");
1625 boolean lightOn =
true;
1626 lightOn = strstr(&message[0],
_ON_LIGHT);
1670 SerialLots.println(
"solidLight..");
1673 boolean lightOn = onOff;
1684 SerialDebug.println(
" ** #define Module Configuration **");
1685 SerialDebug.println(PARTITION_SCHEME);
1686 SerialDebug.printf(
"M5Stack Version = %s\n", (
char*)M5STACK_VERSION);
1688 SerialDebug.println(
" ** BUILDS **");
1692 SerialMin.println(
"[x] ESP_M5");
1694 SerialMin.println(
"[ ] ESP_M5");
1698 SerialMin.println(
"[x] ESP_M5_CAMERA");
1700 SerialMin.println(
"[ ] ESP_M5_CAMERA");
1704 SerialMin.println(
"[x] ESP_32");
1706 SerialMin.println(
"[ ] ESP_32");
1708#ifdef M5CORE2_MODULE
1710 SerialMin.println(F(
"[x] M5CORE2_MODULE"));
1712 SerialMin.println(F(
"[ ] M5CORE2_MODULE"));
1715#ifdef ESP_M5_SMART_CLICKER_CONFIGURATION
1716 SerialMin.println(F(
"[x] ESP_M5_SMART_CLICKER_CONFIGURATION"));
1718 SerialMin.println(F(
"[ ] ESP_M5_SMART_CLICKER_CONFIGURATION"));
1720#ifdef ESP_M5_ATOM_LITE
1721 SerialMin.println(F(
"[x] ESP_M5_ATOM_LITE"));
1723 SerialMin.println(F(
"[ ] ESP_M5_ATOM_LITE"));
1726 SerialDebug.println(F(
" ** MQTT BLE NETWORKING **"));
1730 SerialMin.println(
"[x] USE_MQTT_NETWORKING");
1734 SerialMin.println(
"[x] USE_BLE_SERVER_NETWORKING");
1738 SerialMin.println(F(
"[x] USE_BLE_CLIENT_NETWORKING"));
1743 SerialMin.println(F(
"[x] USE_WIFI_AP_MODULE"));
1746#ifdef USE_BUTTON_MODULE
1748 SerialMin.println(
"[x] USE_BUTTON_MODULE");
1750 SerialMin.println(
"[ ] USE_BUTTON_MODULE");
1753#ifdef M5BUTTON_MODULE
1755 SerialMin.println(
"[x] M5BUTTON_MODULE");
1757 SerialMin.println(
"[ ] M5BUTTON_MODULE");
1761#ifdef USE_STEPPER_MODULE
1762 SerialMin.println(
"[x] USE_STEPPER_MODULE");
1764 SerialMin.println(
"[ ] USE_STEPPER_MODULE");
1768 SerialMin.println(
"[x] USE_UI_MODULE");
1770 SerialMin.println(
"[ ] USE_UI_MODULE");
1773#ifdef USE_DISPLAY_MODULE
1774 SerialMin.println(
"[x] USE_DISPLAY_MODULE");
1776 SerialMin.println(
"[ ] USE_DISPLAY_MODULE");
1780 SerialMin.println(F(
"[x] BOARD"));
1782 SerialMin.println(F(
"[ ] BOARD"));
1784#ifdef USE_SPIFF_MODULE
1787 SerialMin.println(
"[ ] USE_SPIFF_MODULE");
1789#ifdef USE_SPIFF_MQTT_SETTING
1792#ifdef USE_SPIFF_QRATOM_SETTING
1797 SerialMin.println(F(
"[x] USE_FAST_LED"));
1799 SerialMin.println(F(
"[ ] USE_FAST_LED"));
1801#ifdef KEY_UNIT_SENSOR_CLASS
1802 SerialMin.println(F(
"[x] KEY_UNIT_SENSOR_CLASS"));
1804 SerialMin.println(F(
"[ ] KEY_UNIT_SENSOR_CLASS"));
1806#ifdef USE_LED_BREATH
1807 SerialMin.println(F(
"[x] USE_LED_BREATH"));
1809 SerialMin.println(F(
"[ ] USE_LED_BREATH"));
1812#if (SERIAL_DEBUG_ERROR)
1813 SerialMin.println(F(
"[x] SERIAL_DEBUG_ERROR"));
1815#if (SERIAL_DEBUG_DEBUG)
1816 SerialMin.println(F(
"[x] SERIAL_DEBUG_DEBUG"));
1818#if (SERIAL_DEBUG_INFO)
1819 SerialMin.println(F(
"[x] SERIAL_DEBUG_INFO"));
1821#if (SERIAL_DEBUG_MINIMAL)
1822 SerialMin.println(F(
"[x] SERIAL_DEBUG_MINIMAL"));
1834 return strdup(stringA);
1846 else if (strlen(stringA) == 0)
1857 if (!str)
return false;
1860 while (i < strlen(str))
1877 float batVoltage = 1;
1878 float batPercentage = 100;
1880#ifndef M5STICKCPLUS2
1884#elif defined(M5CORE2_MODULE)
1886 batVoltage = M5.Axp.GetBatVoltage();
1887 batPercentage = (batVoltage < 3.2) ? 0 : ( batVoltage - 3.2 ) * 100;
1889 batVoltage = M5.Axp.GetBatVoltage();
1890 batPercentage = (batVoltage < 3.2) ? 0 : ( batVoltage - 3.2 ) * 100;
1894 uint16_t vbatData = M5.Axp.GetVbatData();
1895 double vbat = vbatData * 1.1 / 1000;
1896 batPercentage = 100.0 * ((vbat - 3.0) / (4.07 - 3.0));
1901 if (batPercentage > 100.0)
1902 batPercentage = 100.0;
1903 return batPercentage;
1913 SerialDebug.printf(
"sendMessageString_mainModule(%s)\n", messageString);
1914 if (strlen(messageString) > 0 && messageString[0] ==
'{')
1935 SerialDebug.printf(
"sendMessageStringTopic_mainModule(%s) - topic=%s\n", messageString, topicString);
1936 if (strlen(messageString) > 0 && messageString[0] ==
'{')
1960#ifndef M5STICKCPLUS2
1961 M5.IMU.getTempData(&temperature);
1965#ifdef USER_THE_MAX_TEMP_FEATURE
1967 if (temperature > maxtemp)
1977 SerialTemp.println(
" *** This would poweroff .. but you can send message");
1984 float temperature = 10.0;
1986 return temperature ;
2030#pragma mark USE_NEW_M5ATOMCLASS
2036#ifdef M5CORE2_MODULE
2042 return (
char*)
"'tbd':'x'";
2054 sprintf(buf,
"&%s=%s", key, val);
2082#ifdef OVERLOADS_TIME_T
2110#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
2150 sprintf(
_fullStatusString,
"status?T=%d&v=%s&dev=%s",time, VERSION_SHORT, deviceName);
2153#pragma mark USE_NEW_M5ATOMCLASS
2174void main_setStatusJSON(
const char* JSONString)
2179void main_setStatusKeyValue(
const char* key,
const char* value)
2213 SerialDebug.printf(
"factoryMotorClockwise = %d, isClockwiseFlag = %d\n",factoryMotorClockwise, isClockwiseFlag);
2215 if (factoryMotorClockwise && isClockwiseFlag)
2217 SerialDebug.println(
"setClockwiseMotorDirection -- same so no change");
2219 else if (factoryMotorClockwise && !isClockwiseFlag)
2222 isClockwiseFlag = !isClockwiseFlag;
2226 else if (!factoryMotorClockwise && isClockwiseFlag)
2229 isClockwiseFlag = !isClockwiseFlag;
2233 else if (!factoryMotorClockwise && !isClockwiseFlag)
2235 SerialDebug.println(
"setClockwiseMotorDirection -- same so no change");
2248 boolean sendToStepperModule =
false;
2249 SerialDebug.printf(
"***** processClientCommand_mainModule(%c) from client*****\n", cmd);
2261 sendToStepperModule =
true;
2266 SerialDebug.println(
"cmd=a startTimer");
2274 SerialDebug.println(
"cmd=A stopTimer");
2282 sendToStepperModule =
true;
2283 SerialLots.println(
"Setting FeedState = JACKPOT_FEED");
2289 SerialDebug.println(
"Setting feederType = UNO");
2302 SerialDebug.println(
"Setting feederType = MINI");
2313 SerialDebug.println(
"Setting feederType = Tumbler");
2326 sendToStepperModule =
true;
2327 SerialDebug.println(
"Setting buzzStatus = BUZZON");
2333 sendToStepperModule =
true;
2335 SerialDebug.println(
"Setting buzzStatus = BUZZOFF");
2340 SerialDebug.println(
"*** Setting tilt = ON");
2345 SerialDebug.println(
"Setting tilt = OFF");
2350 SerialDebug.println(
"Clean Credentials");
2355#ifdef NOT_SUPPORTED_RIGHT_NOW
2358 SerialDebug.println(
"OTA Update.. ");
2365 SerialDebug.println(
"Clean EPROM.. ");
2371 SerialDebug.println(
"Clean SSID from EPROM.. ");
2372 char cleanWIFI[100];
2373 strcpy(cleanWIFI,
"{'ssid':'','ssidPassword':''}");
2374 SerialDebug.println(cleanWIFI);
2384 SerialDebug.println(
"Setting Gateway = ON");
2389 SerialDebug.println(
"Setting Gateway = OFF");
2395 SerialDebug.println(
"unused cmd '_'");
2397#ifdef OLD_FOR_M5_DISPLAY
2400 sendToStepperModule =
false;
2402 SerialDebug.println(
"Setting SM Zoom = zoomed");
2407 sendToStepperModule =
false;
2409 SerialDebug.println(
"Setting SM Zoom = full SM");
2419 SerialDebug.println(
"clean SPIFF file");
2426 SerialDebug.println(
"upload SPIFF to web");
2443 spiffFlag = !spiffFlag;
2445 SerialDebug.printf(
"Changing current USE_SPIFF = %s\n", spiffFlag?
"NOYES":
"NO");
2473 SerialDebug.println(
"w for swapWifi");
2481 SerialDebug.printf(
"PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING true");
2491 SerialDebug.printf(
"PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING false");
2498 SerialDebug.printf(
"PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING counter clockwise");
2506 SerialDebug.printf(
"PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING clockwise");
2514 SerialDebug.printf(
"PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING reverse direction");
2519 currentDirection = !currentDirection;
2525 SerialDebug.printf(
"PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING false");
2534 SerialDebug.printf(
"PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING true");
2544 SerialDebug.println(
"REBOOT ...");
2551 SerialDebug.printf(
"(%c) POWEROFF ...", cmd);
2559 SerialDebug.println(
"Clearing Sensors");
2570 SerialDebug.println(
"Default L9110S_DCStepperClass");
2601 SerialDebug.println(
"Default ULN2003_StepperClass");
2627 SerialDebug.println(
"Default PTStepperClass");
2651 SerialDebug.println(
"Default M5AtomCamera");
2666 SerialDebug.println(
" *** performing m5atom OTA Update");
2669 performOTAUpdate((
char*)
"http://KnowledgeShark.org", (
char*)
"OTA/TEST/M5Atom/ESP_IOT.ino.m5stick_c_plus.bin");
2674 SerialDebug.println(
" *** performing m5atom OTA Update - DAILY");
2677 performOTAUpdate((
char*)
"http://KnowledgeShark.org", (
char*)
"OTA/TEST/M5Atom/daily/ESP_IOT.ino.m5stick_c_plus.bin");
2681 SerialDebug.println(
" *** performing m5atom OTA Update - BOOTSTRAP");
2684 performOTAUpdate((
char*)
"http://KnowledgeShark.org", (
char*)
"OTA/Bootstrap/ESP_M5_BOOTSTRAP.ino.m5stack_stickc_plus.bin");
2690 SerialDebug.println(
"Default M5AtomTinyGPS");
2705 SerialDebug.println(
" *** performing m5atom OTA Update - M5Clicker");
2708 performOTAUpdate((
char*)
"http://KnowledgeShark.org", (
char*)
"OTA/Bootstrap/ESP_M5_BOOTSTRAP.ino.m5stack_stickc_plus.bin");
2712 SerialDebug.println(
"'C' change color touched");
2722 char sendCapture[100];
2723 strcpy(sendCapture,
"{'send':'capture'}");
2724 SerialDebug.println(sendCapture);
2740 SerialMin.println(
"Valid Commands: ");
2741 SerialMin.println(
" . = help, this message");
2742 SerialMin.println(
" p = poweroff if can");
2743 SerialMin.println(
" 0x0, s, c == Single Feed ");
2744 SerialMin.println(
" a == AutoFeed On");
2745 SerialMin.println(
" A == AutoFeed Off");
2746 SerialMin.println(
" u == UNO ");
2747 SerialMin.println(
" m == MINI ");
2748 SerialMin.println(
" L == tumbler");
2749 SerialMin.println(
" H == autoMotorDirection on");
2750 SerialMin.println(
" h == autoMotorDirection off");
2751 SerialMin.println(
" D == FACTORY counter clockwise motor direction");
2752 SerialMin.println(
" d == FACTORY clockwise motor direction");
2753 SerialMin.println(
" Q == change motor direction opposite of current");
2755 SerialMin.println(
" B == Buzzer On");
2756 SerialMin.println(
" b == Buzzer Off");
2757 SerialMin.println(
" G == Gateway On");
2758 SerialMin.println(
" g == Gateway Off");
2759 SerialMin.println(
" R == clean credentials");
2760 SerialMin.println(
" X == clean EPROM");
2761 SerialMin.println(
" x == clean SSID from EPROM");
2762 SerialMin.println(
" r == reboot ");
2765 SerialMin.println(
" T == tiltOn");
2766 SerialMin.println(
" t == tiltOff");
2767 SerialMin.println(
" N == send WIFI Credential to BLEServer");
2768 SerialMin.println(
" n == next WIFI Credential");
2769 SerialMin.println(
" W == retry WIFI");
2770 SerialMin.println(
" w == swap WIFI");
2771 SerialMin.println(
" C == change m5 atom to random color");
2772 SerialMin.println(
" i == take pic, {send:capture}");
2774 SerialMin.println(
" SPIFF internal memory ");
2775#ifndef OLD_FOR_M5_DISPLAY
2776 SerialMin.println(
" Z == clean SPIFF file");
2777 SerialMin.println(
" z == upload SPIFF to web");
2779 SerialMin.println(
" P == print SPIFF");
2780 SerialMin.printf (
" S == toggle SPIFF %s\n", spiffFlag?
"OFF":
"ON");
2782 SerialMin.println(
" BLE Naming ");
2784 SerialMin.println(
" E == use only PTFeeder naming");
2785 SerialMin.println(
" e == use naming PTFeeder:name");
2786#ifdef OLD_FOR_M5_DISPLAY
2787 SerialMin.println(
" Z == Setting SM Zoom = zoomed");
2788 SerialMin.println(
" z == Setting SM Zoom = full SM");
2790 SerialMin.println(
" Configurations of M5Atom ");
2792 SerialMin.println(
" 0 == no sensors");
2793 SerialMin.println(
" 1 == L9100S_DCStepper (current main)");
2794 SerialMin.println(
" 2 == ULN2002 Stepper (new test 8.13.25)");
2795 SerialMin.println(
" 3 == *** PTStepperClass (original code - with M5");
2796 SerialMin.printf (
" 4 == M5AtomCamera\n");
2797 SerialMin.println(
" 8 == M5TinyGPS");
2799#ifdef NOT_SUPPORTED_RIGHT_NOW
2800 SerialMin.println(
" O == OTA update");
2802 SerialMin.println(
" OTA Updates of M5Atom ");
2803 SerialMin.println(
" 5 == m5atom DEV OTA update");
2804 SerialMin.println(
" 6 == m5atom DAILY TEST DEV OTA update");
2805 SerialMin.println(
" 7 == go back to m5atom BOOTSTRAP");
2808 SerialMin.println();
2809 SerialMin.println(
"Full API at: https://github.com/konacurrents/SemanticMarkerAPI");
2810 SerialMin.println();
2820 SerialMin.printf(
"*****invalid command '%c' from client (use '.' for help) *****\n", cmd);
2824#ifdef USE_STEPPER_MODULE
2825 if (sendToStepperModule)
2845 SerialMin.printf(
"Unix Time: %d\n", now);
2857 if (strncmp(cmd,
"sm",2) == 0)
2860 char *p = strchr(cmd,
'm');
2866 SerialLots.print(
"whichSMMode: ");
2867 SerialLots.print(cmd);
2868 SerialLots.print(
" => " );
2869 SerialLots.println(num);
2882 return (strcasecmp(cmd,mode)==0);
2888 SerialLots.printf(
"charSMMode_mainModule: %d\n", whichSMMode);
2928 SerialLots.print(
"setCurrentSMMode_mainModule:");
2929 SerialLots.println(whichSMMode);
2954 SerialTemp.print(
"incrementSMMode_mainModule:");
2994 SerialTemp.printf(
"auto-settingGateway(%d)\n", isGEN3);
3001 SerialCall.printf(
"setConnectedBLEDevice_mainModule: %s\n", deviceName);
3007 char *colon = index(deviceName,
':');
3009 colon = index(colon,
':');
3013 while (*colon && *colon !=
',')
3026 SerialTemp.print(
"connectedBLEName= ");
3031 seems to be crashing..
3033 char connectMessage[300];
3035 SerialTemp.println(connectMessage);
3051 colon += strlen(
"Address:");
3053 while (*colon && *colon ==
' ')
3058 while (*colon && *colon !=
',')
3071 SerialTemp.print(
"_connectedBLEDeviceAddress= ");
3085 nameToUse = (
char*)
"";
3125#ifdef USE_BUTTON_MODULE
3127 loop_ButtonProcessing();
3131#ifdef M5CORE2_MODULE
3133#elif defined(M5_ATOM)
3135#pragma mark USE_NEW_M5ATOMCLASS
3144 SerialDebug.println(
"*** _whichM5AtomClassType NULL ***");
3150#elif defined(M5BUTTON_MODULE)
3151 loop_M5ButtonModule();
3158 SerialDebug.println(
"setup_Sensors_mainModule");
3159#ifdef USE_BUTTON_MODULE
3161 setup_ButtonProcessing();
3165 SerialDebug.println(
" ***** M5_ATOM define ****");
3167#ifdef M5CORE2_MODULE
3174#ifdef USE_NEW_M5ATOMCLASS
3184 int whichM5AtomIndex = 0;
3185 SerialDebug.println(
"setup_M5Atoms");
3199 SerialDebug.printf(
"**** sensors are more than max .. FIX CODE");
3201 SerialDebug.printf(
"Created %d M5AtomClassTypes\n", whichM5AtomIndex);
3214 SerialDebug.println(
"NULL M5AtomClassType");
3227 SerialDebug.printf(
"** Found M5AtomClass = %s\n", atomKind);
3231 SerialDebug.printf(
"****^^^ Cannot find M5AtomClass = %s\n", atomKind);
3233 SerialDebug.println(
"Defaulting to _M5Atom_HDriverModuleClass");
3241#pragma mark USE_NEW_M5ATOMCLASS
3248#elif defined(M5BUTTON_MODULE)
3249 setup_M5ButtonModule();
3256#ifdef USE_BUTTON_MODULE
3257 buttonA_ShortPress();
3259#ifdef M5CORE2_MODULE
3261#elif defined(M5_ATOM)
3262#pragma mark USE_NEW_M5ATOMCLASS
3267#elif defined(M5BUTTON_MODULE)
3268 buttonA_ShortPress_M5ButtonModule();
3276#ifdef USE_BUTTON_MODULE
3277 buttonA_LongPress();
3279#ifdef M5CORE2_MODULE
3281#elif defined(M5_ATOM)
3283#pragma mark USE_NEW_M5ATOMCLASS
3289#elif defined(M5BUTTON_MODULE)
3290 buttonA_LongPress_M5ButtonModule();
3298#ifdef USE_BUTTON_MODULE
3299 buttonB_LongPress();
3301#ifdef M5BUTTON_MODULE
3303 buttonB_LongPress_M5ButtonModule();
3309#ifdef USE_BUTTON_MODULE
3310 buttonB_ShortPress();
3313#ifdef M5BUTTON_MODULE
3315 buttonB_ShortPress_M5ButtonModule();
3345#pragma mark PIN USE to see if overlaps.
3372 char pinUseSample[100];
3373 sprintf(pinUseSample,
"PIN_USE: %2d = %s, %s %s", pin, pinName.c_str(), moduleName.c_str(), isI2C?
"(I2C)":
"");
3375 char *pinUse = (
char*)calloc(strlen(pinUseSample)+1,
sizeof(char));
3376 strcpy(pinUse, pinUseSample);
3384 SerialError.printf(
"*** ERROR .. too many PINS defined ***");
3389 SerialDebug.printf(
"** PIN_USE: %s = %d, module=%s %s\n", pinName.c_str(), pin, moduleName.c_str(), isI2C?
"(I2C)":
"");
void sendCommandBLEClient(String cmdString)
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
void sendFeedCommandBLEClient()
sends the "feed" command over bluetooth to the connected device..
boolean useBLEClient()
returns if the BLEClient is turned on.. note, if connected to a BLE device, then disconnect
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
void sendBLEMessageACKMessage()
send ACK over bluetooth, this right now is 0x01
char * getServiceName_BLEServerNetworking()
retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc)
#define BLE_SERVER_CALLBACK_ONWRITE
void addToTextMessages_displayModule(String text)
void redrawSemanticMarker_displayModule(boolean startNew)
redraws the Semantic Marker image..
void blankScreen_displayModule()
blanks the screen
int getLoopTimer_displayModule()
returns the loop timer (just a timer..)
void setup_M5Core2Module()
void loop_M5Core2Module()
called for the loop() of this plugin
char * currentStatusJSON_M5Core2Module()
void messageSend_M5Core2Module(char *sendValue)
void messageSetVal_M5Core2Module(char *setName, char *valValue, boolean deviceNameSpecified)
void buttonA_ShortPress_M5Core2Module()
CRGB getRandomColor()
7.24.25 return a (semi) random color
void fillpix(CRGB Color)
color the button light
void publishMQTTMessageDefaultTopic(char *message)
Wrapper of the mqttclient publish.
void cleanEPROM_MQTTNetworking()
cleans the eprom info
void sendMessageNoChangeMQTT_Topic(char *message, char *topic)
just send a message but without any extras
void sendMessageMQTT(char *message)
void sendStatusMessageMQTT(const char *semanticMarker)
sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status rep...
boolean processJSONMessageMQTT(char *ascii, char *topic)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not,...
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
void sendMessageNoChangeMQTT(char *message)
just send a message but without any extras
boolean isConnectedMQTT_MQTTState()
value of MQTT connected
char * getDeviceNameMQTT()
called for things like the advertisement
boolean isConnectedWIFI_MQTTState()
value of WIFI connected
void restartWIFI_MQTTState()
restart the WIFI and then MQTT connection
#define MQTT_CALLBACK_FEED
8.16.25 MQTT
void cleanEpromPreferences()
cleans the EPROM
void sendSemanticMarkerDocFollow_mainModule(const char *SMDocFollowAddress)
sends the SM on the DOCFOLLOW channel (publish it..)
void initCallbacksMain()
init the callbacks to dummy callbacks
#define MESSAGE_STORAGE_MAX
global for others to use..
boolean _connecteBLEisGEN3
whether connected GEN3
void setAsyncCallOTAUpdate(bool flag)
sets the async OTA flag (for next loop)
void main_cleanSavedWIFICredentials()
clean the saved WIFI credential, otherwise the AP mode doesn't work (6.3.22)
void messageSend_mainModule(char *sendValue, boolean deviceNameSpecified)
TODO: have a callback regist approach.
boolean _asyncCallOTAUpdateFlag
3.28.22 .. implemented in ESP_IOT.ino
boolean _stopAllProcessing
testing..
M5Atom_Core2ModuleClass * _M5Atom_Core2ModuleClass
#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...
void setConnectedBLEDevice_mainModule(char *deviceName, boolean isGEN3)
char _fullBLEDeviceName[100]
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
#define CALLBACKS_MAX_BLE_SERVER
KeyUnitSensorClass * _KeyUnitSensorClass
char * connectedBLEDeviceNameAddress_mainModule()
returns address part of name.
void cleanSSID_EPROM_MessageCallback(char *message)
clean the SSID eprom (MQTT_CLEAN_SSID_EPROM)
callbackSignature * createMemory(int max)
return dyamically created array of max
void toggleMinimalMenuMode_mainModule()
toggles the menu mode
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
char * main_getUsername()
char * groupTopicFullName(char *groupName)
returns a groupTopic to use as a topic
char _smMode_MainModule[10]
current smMode
void loop_mainModule()
called for the loop() of this plugin
char * getSemanticMarkerDocFollow_mainModule()
gets the semanticAddress SemanticMarker™
void main_setScannedGroupName(char *groupName)
void registerCallbackMain(int callbacksModuleId, int callbackType, void(*callback)(char *))
register the callback based on the callbackType. use the callbacksModuleId for which one....
M5Atom_HDriverModuleClass * _M5Atom_HDriverModuleClass
char * deviceName_mainModule()
gets the device name
int getLUXThreshold_mainModule(int thresholdKind)
get the threshold val
void dummyCallbackMain(char *message)
example callback
#define CALLBACKS_MAX_MQTT
void initGlobals_mainModule()
init globals strings
void sendStatusMQTT_mainModule()
1.1.24 send status of this device after events..
PinUseStruct _pinUseStruct
7.31.25 add this for a status, saw that QRCode was using 22 also .. so buzer didn't work.
char _deviceNameSave[50]
saved deviceName storage..
void initSensorClassTypeArray()
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
#define CALLBACKS_BLE_SERVER
boolean _asyncCallFlags[ASYNC_CALL_MAX]
storage for asyncCallCommands
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)
char _scannedDeviceName[100]
int getFeedCount_mainModule()
feedcount info..
void onStatusMessageBLEServerCallback(char *message)
The callback for "status messages" of the bluetooth.
char * main_JSONStringForWIFICredentials()
retrieve a JSON string for the ssid and ssid_password: {'ssid':<ssid>,'ssidPassword':<pass>"}
int feedCountMax_mainModule()
returns the max for this feeder
char _scannedGroupTopicName[100]
M5Atom_CameraModuleClass * _M5Atom_CameraModuleClass
void setClockwiseMotorDirection_mainModule(boolean isClockwiseFlag)
8.18.24 setting this will check for the factory setting..
void solidLightOnOff(boolean onOff)
callback for SOLID blinking led
void sendMessageStringTopic_mainModule(char *messageString, char *topicString)
adding a synchronous call to send a message over the network (assuming MQTT but not specified),...
char * main_getScannedGroupNameTopic()
uint32_t _chipID_MainModule
3.17.24 the unqiue chip id
void main_credentialsUpdated()
moved here 4.25.22 (entirely from ESP_IOT.ino)
void setup_mainModule()
called from the setup()
void main_dispatchSyncCommand(int syncCallCommand)
the main sync command (no parameters yet)
boolean stopAllProcesses_mainModule()
if stopped
void restartAllMenuStates_mainModule()
restarts all the menu states to the first one .. useful for getting a clean start....
void setSemanticMarkerDocFollow_mainModule(char *SMDocFollowAddress)
sed the address to follow
boolean isTrueString_mainModule(String valCmdString)
whether the string is TRUE, ON, 1
char * main_getPassword()
return password
int whichSMMode_mainModule(char *cmd)
************** SM Mode Processing ***************
M5Atom_SocketModuleClass * _M5Atom_SocketModuleClass
5.6.25 use the M5Atom ClassType
void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter)
void initAsyncCallFlags()
initialize the async call flags (with and without parameters)
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
void solidLightMessageCallback(char *message)
callback for SOLID blinking led
M5AtomClassType * _M5AtomClassTypes[NUM_M5ATOM_CLASS]
3.31.25 create array of plugs
M5AtomClassType * _whichM5AtomClassType
use this one...
boolean isEmptyString(char *stringA)
informs if null or empty string
void rebootDevice_mainModule()
void poweroff_mainModule()
power off
int maxMenuModes_mainModule()
returns the current max of the menu modes (using the setting of min or expanded) to determine
void buttonB_ShortPress_mainModule()
the short press of the side button
#define GROUP_TOPIC_TO_SEND
boolean isPTFeeder_mainModule()
gets if PTFeeder a surrogate for the M5Atom class
bool containsSubstring(String message, String substring)
check if the string contains the other string. This is a poor man's grammer checker
void decrementSMMode_mainModule()
increment the currentSMMode, wrapping and using the max menu
M5Atom_QRCodeModuleClass * _M5Atom_QRCodeModuleClass
void onWriteBLEServerCallbackFinish(char *message)
The FINISH of callback for "onWrite" of the bluetooth "onWrite'.
void callCallbackMain(int callbacksModuleId, int callbackType, char *message)
performs the indirect callback based on the callbackType
int getCurrentSMMode_mainModule()
returns the current SM Mode
boolean _waitingForBigMessageEnd
store a big message #MSG_START .. #MSG_END
void stopMotor_mainModule()
added 9.29.22 to support wildcards #196
void stopProcessesForOTAUpdate_mainModule()
stop all loops... while OTA working..
void feedMessageCallback(char *message)
void resetFeedCount_mainModule()
sets the feed count max
boolean asyncCallOTAUpdate()
performs an async OTA update
void sendMessageString_mainModule(char *messageString)
adding a synchronous call to send a message over the network (assuming MQTT but not specified),...
char * main_currentStatusJSON()
status in JSON format, needs to return something as a ',' is already added before calling this....
M5AtomClassType * whichM5AtomClassType()
6.6.25 get the current M5AtomClassType
void(* callbackSignature)(char *)
void changeButtonColor_MainModule()
2.21.25 add a way to change the button color (if any)
void setup_Sensors_mainModule()
1.22.24 setup of buttons
char * getFullBLEDeviceName_mainModule()
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
char _groupTopicName[100]
int getFeederType_mainModule()
get the feeder type (Sepper 1,2,3 ...)
char _connectedBLEDeviceName[50]
saved BLE connected name 8.26.22
char * _lastSemanticMarkerDocFollow
char _connectedBLEDeviceAddress[50]
full: ""Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
void addMoreStatusQueryString()
void buttonA_LongPress_mainModule()
long press on buttonA (top button)
void addStatusBooleanFlag(const char *key, boolean flag)
adds to _fullStatusString a query string "&key=value"
void invokeAsyncCommands()
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
#define CALLBACKS_MAX_BLE_CLIENT
boolean startsWithChar(char *str, char c)
a char* version of startsWith (after skipping spaces)
void showText_mainModule(String text)
callbackSignature * _allCallbacks[CALLBACKS_MODULE_MAX]
array of known size (CALLBACKS_MODULE_MAX) of callbackSignatures
void setCurrentSMMode_mainModule(int whichSMMode)
sets the current screen mode .. which can be used by Button and Display processing
char * getPairedDeviceOrAddress_mainModule()
returns if the paired device is not NONE .. returns address or device
char _chipIdString_MainModule[15]
string like: 10311304
char * getPairedDevice_mainModule()
returns if the paired device is not NONE
void onWriteBLEServerCallback(char *message)
The callback for "onWrite" of the bluetooth "onWrite'.
char * _MQTT_Password
12.14.23
void setLUXThreshold_mainModule(int thresholdKind, int luxVal)
set the threshold val
boolean _callbacksInitializedMain
flag for initializing if not yes
#define CALLBACKS_BLE_CLIENT
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 _JSONStringForWIFICredentials[200]
global to store credentials when ever they are stored..
boolean matchesSMMode_mainModule(char *cmd, int whichSMMode)
returns if a match the mode. whichSMMode is 0..12 and == sm0 .. smn
int _feedCount_mainModule
5.3.22 added a feed count approach.. (NOTE: there is a _feedCount in Dispence.cpp ....
BuzzerSensorClass * _BuzzerSensorClass
int _saveWhichSMMode
the saved SMMode
char * getChipIdString()
3.17.24 get the chip id as a string
void refreshDelayButtonTouched_MainModule()
called by the feed operation to say the device is still running.. and count it as a button click.
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
uint32_t getChipId()
3.17.24 get the chip id
boolean isMinimalMenuMode_mainModule()
returns which mode in (min or expanded)
char _asyncParameter[500]
the parameter being sent to those commands passing an argument
void loop_Sensors_mainModule()
1.22.24 add setup and loop at main so it can call appropriate plugs
int getTimeStamp_mainModule()
void buttonB_LongPress_mainModule()
the long press of the side button
void blinkMessageCallback(char *message)
callback for blinking led
void restartProcessesForOTAUpdate_mainModule()
restart all loops... while OTA working..
char * main_getScannedDeviceName()
return devicename
char * createCopy(char *stringA)
#define CALLBACKS_MAX_BUTTON_MODULE
boolean _asyncCallFlagsParameters[ASYNC_CALL_PARAMETERS_MAX]
array of async flags for the different ASYNC_CALl values
char _fullStatusString[500]
status string (URL query format)
void main_printModuleConfiguration()
M5Atom_TinyGPSModuleClass * _M5Atom_TinyGPSModuleClass
void messageSetVal_mainModule(char *setName, char *valValue, boolean deviceNameSpecified)
void singleClickTouched(char *whichButton)
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
void onBLEServerCallback(char *message)
The callback for "onWrite" of the bluetooth "onWrite'.
void addStatusStringFlag(const char *key, char *val)
adds a query string "&key=value"
void incrementSMMode_mainModule()
increment the currentSMMode, wrapping and using the max menu
#define CALLBACKS_BUTTON_MODULE
char _messageStorage[MESSAGE_STORAGE_MAX]
void incrementFeedCount_mainModule()
increments .. and if MAX goes to 0 – and sends a message on MQTT
PinUseStruct getPinUseStruct_mainModule()
get the pin use array
void main_saveWIFICredentials(char *ssid, char *ssid_password)
save the WIFI credential
void readPreferences_mainModule()
reads the preferences. Save is everytime the savePreference is called
char * getPairedDeviceAddress_mainModule()
returns if the paired device is not NONE
float getBatPercentage_mainModule()
start of the sensor updates ... TODO: tie these to the MQTT messaging as well..
int _callbacksFunctionsMAXS[CALLBACKS_MODULE_MAX]
the array of callback functions
#define ASYNC_CALL_FEED_COMMAND
sends a 'c' to the BLE end of the code (assuming a feeder is connected). Need to morph if a real feed...
#define MAX_SM_MIN_MODES
note for now, heep the max the same – so only goes through zoom or not zoom
void cleanEPROM_mainModule()
cleans the main module EPROM
#define ASYNC_CALL_MAX
the max one greater than last one
#define THRESHOLD_KIND_DARK
#define ASYNC_REBOOT
sets the GATEWAY mode off
#define ASYNC_CALL_BLE_CLIENT_PARAMETER
these are the async with a string parameter. This sends a BLE command unless MQTT
#define ASYNC_REST_CALL_MESSAGE_PARAMETER
send REST call
#define ASYNC_SEND_MQTT_FEED_MESSAGE
sends a message (like FEED) on the users topic
#define CALLBACKS_MODULE_MAX
#define ASYNC_JSON_MQTT_MESSAGE_PARAMETER
these are the async with a string parameter
#define ASYNC_CALL_CLEAN_CREDENTIALS
cleans out the credentials and restarts in AP (Access Point) mode.
#define ASYNC_SWAP_WIFI
swaps WIFI 'w'
#define ASYNC_SET_GATEWAY_ON
sets the GATEWAY mode on
#define MAX_SM_EXPANDED_MODES
#define ASYNC_RESTART_WIFI_MQTT
restarts the WIFI (after BLE interrupt over)
#define THRESHOLD_KIND_LIGHT
#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_BLANKSCREEN
blank the screen
#define ASYNC_CALL_PARAMETERS_MAX
the max one greater than last one
#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 ASYNC_NEXT_WIFI
next WIFI 'n'
#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)
#define ASYNC_JSON_MESSAGE_PARAMETER
these are the async with a string parameter
void updateMenuState(ModelKindEnum modelKind)
updates the model for the menu state, this sets max etc
void startStopTimer_mainModule(boolean startTimer)
void initModelStructs_ModelController()
initialize the objects
void restartAllMenuStates_ModelController()
restarts all the menu states to the first one .. useful for getting a clean start....
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
SensorsStruct * getSensors_mainModule()
return the sensors defined
void setSensorsString_mainModule(char *sensorsString)
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 togglePreferenceBoolean_mainModule(int preferenceID)
toggles a preference boolean
char * getPreferenceATOMKind_MainModule()
new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner)
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...
int getM5ATOMKind_MainModule()
new 1.4.24 setting ATOM kind (eg. ATOM_KIND_M5_SCANNER, ATOM_KIND_M5_SOCKET)
int getPreferenceInt_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
char * getPreference_mainModule(int preferenceID)
SensorStruct * getSensor_mainModule(char *sensorName)
return the sensor specified or null
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_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_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_STEPPER_JACKPOT_FEED_VALUE
#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 STEPPER_IS_TUMBLER
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCE_WIFI_CREDENTIAL_1_SETTING
#define PREFERENCE_USE_SPIFF_MQTT_SETTING
#define WIFI_CREDENTIALS_MAX
for now, save 2 WIFI Credentials
#define PREFERENCE_FIRST_TIME_FEATURE_SETTING
a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
#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_STEPPER_ANGLE_FLOAT_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_ATOM_KIND_SETTING
1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
void sendStrings_SPIFFModule(int numberOfLines)
sends SPIFF module strings over MQTT, starting at the number back specified. This will use the curren...
void printFile_SPIFFModule()
prints the spiff file to the SerialDebug output
void deleteFiles_SPIFFModule()
delete the spiff files..
void stepperModule_ProcessClientCmdFinal(char cmd)
the Blink the LED - and it will use the latest BUZZER status (so MQTT could set buzzer on....
void setup_tokenParser_mainModule()
setup a test ..
char * semanticMarkerToJSON_TokenParser(char *semanticMarker)
void blinkLED_UIModule()
blink the LED
void solidLightOnOff_UIModule(boolean onOff)
turns on/off a solid light
void clean_SSID_WIFICredentials()
returns true if the SSID is set, false otherwise. If set, then just exit..
void WIFI_APModule_updateMQTTInfo(char *ssid, char *ssid_password, char *username, char *password, char *guestPassword, char *deviceName, char *host, char *port, char *locationString)
sets the MQTT user/password. It's up to the code to decide who needs to know
boolean doneWIFI_APModule_Credentials()
called to see if the WIFIModule has finished bootstrapping..
void cleanEPROM_WIFI_APModule()
cleans the eprom info
void setDoneWIFI_APModuleFlag(boolean flag)
called to set the done flag
void setup()
Pure Virtual Function.
virtual void messageSend_M5AtomClassType(char *sendValue, boolean deviceNameSpecified)=0
virtual void loop_M5AtomClassType()=0
loop the PTStepper (so timer can run)
boolean isPTFeeder_M5AtomClassType()
virtual void buttonA_ShortPress_M5AtomClassType()=0
virtual char * currentStatusJSON_M5AtomClassType()=0
virtual void buttonA_LongPress_M5AtomClassType()=0
long press on buttonA (top button)
virtual void messageSetVal_M5AtomClassType(char *setName, char *valValue, boolean deviceNameSpecified)=0
these are from the ATOM
virtual void setup_M5AtomClassType()=0
setup the PTStepper
virtual void stop_M5AtomClassType()=0
stop the motor
virtual char * currentStatusURL_M5AtomClassType()=0
void setPinValues(int pin1, int pin2)
virtual void messageLocal_SensorClassType(char *message)
5.15.25 try a special command local to this class
char * pinUseArray[PIN_USE_MAX]
SensorClassType * sensorClassType
and the pointer to matching SensorClassType
SensorStruct * sensors
array of sensorStruct