1#include "../../Defines.h"
7#define MenusModel_Help 0
8#define MenusModel_Settings 1
9#define MenusModel_Pairing 2
10#define MenusModel_APMode 3
11#define MenusModel_Timer 4
12#define MenusModel_Status 5
13#define MenusModel_Advanced 6
14#define MenusModel_WIFIShare 7
15#define MenusModel_GuestFeed 8
16#define MenusModel_GuestPage 9
17#define MenusModel_DocFollow 10
18#define MenusModel_Max 11
67 SerialMin.println(
" *** invalid menu item");
75ModelStateStruct _modelStateStructs[ModelKindEnumMax];
129 SerialCall.printf(
"initTimer: sec = %d\n",
_modelStateStructs[i].currentCounterSeconds);
130#if defined(ESP_M5_CAMERA) || defined(ESP_32)
147 SerialDebug.printf(
"setTimerDelaySeconds_mainModule(%d)\n", delaySeconds);
161 SerialDebug.printf(
"setTimerDelaySecondsMax_mainModule(%d)\n", delaySeconds);
186 SerialCall.printf(
"nextRandomTimeSeconds(%d,%d) = %d\n", timerModelStruct->
delaySeconds, timerModelStruct->
delaySecondsMax, nextRandomTimeSeconds);
200 SerialDebug.printf(
"startStopTimer_mainModule(%d, %d)\n", startTimer, timerModelStruct->
currentCounterSeconds);
215 SerialTemp.print(
"deviceState->pairedDeviceStateEnum: ");
220 SerialLots.println(
"pairedButNotConnectedEnum");
224 SerialLots.println(
"pairedAndConnectedEnum");
228 SerialLots.println(
"pairableAndConnectedEnum");
232 SerialLots.println(
"notConnectedEnum");
239 SerialTemp.println(
"deviceState = rebootModel ");
257 SerialTemp.println(
"deviceState = menusModel ");
262 SerialTemp.println(
"deviceState = timerModel ");
266 SerialTemp.printf(
"deviceState->maxItems (%d) \n", deviceState->
maxItems );
267 SerialTemp.printf(
"deviceState->currentItem (%d) \n", deviceState->
currentItem );
276 SerialCall.printf(
"getModel(%d) = %d\n", modelKind, model);
289 SerialCall.printf(
"hasModelForSM_Mode(%d) == yes\n", SM_Mode);
295 SerialCall.printf(
"hasModelForSM_Mode(%d) == NO\n", SM_Mode);
308 item = (item + 1) % max;
311 SerialCall.printf(
"incrementMenuState(%d) = %d \n", modelKind, item);;
318 SerialDebug.println(
"restartAllMenuStates");
339 char _smMessage_ModelController[30];
360#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
397 SerialLots.printf(
"invokePair(%s, gen3=%d)\n", deviceName, isGEN3);
410#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
435 SerialTemp.println(
" *** GEN3 only but connected to a non GEN3 .. so unpair **");
446 SerialCall.printf(
"updateMenuState(%d) \n", modelKind);
453 char pairedDeviceString[50];
454 char pairedDeviceAddressString[50];
462 SerialLots.printf(
"\nPAIRED_DEVICE_MODEL\n");
463 SerialLots.printf(
"isConnectedBLE(%d)\n", isConnectedBLE);
467 SerialLots.printf(
"gen3Only(%d)\n", gen3Only);
472 SerialLots.printf(
"gatewayOn(%d)\n", gatewayOn);
476 strcpy(pairedDeviceString, pairedDeviceTemp);
477 SerialLots.printf(
"pairedDevice(%s)\n", pairedDeviceString);
480 strcpy(pairedDeviceAddressString, pairedDeviceAddressTemp);
482 SerialLots.printf(
"pairedDeviceAddress(%s)\n", pairedDeviceAddressString);
486 SerialLots.printf(
"connectedBLEDeviceName(%s)\n", connectedBLEDeviceName);
489 SerialLots.printf(
"connectedBLEDeviceNameAddress(%s)\n", connectedBLEDeviceNameAddress);
492 boolean pairedAndConnected =
false;
493 boolean pairedButNotConnected =
false;
494 boolean pairableAndConnected =
false;
495 boolean unpaired =
false;
501 if (strcmp(pairedDeviceString,connectedBLEDeviceName)==0 ||
502 strcmp(pairedDeviceAddressString,connectedBLEDeviceNameAddress)==0)
504 pairedAndConnected =
true;
506 pairableAndConnected =
true;
509 else if (strlen(pairedDeviceString) > 0 || strlen(pairedDeviceAddressString) > 0)
511 if (strlen(pairedDeviceString) > 0 && strcmp(pairedDeviceString,(
char*)
"NONE")==0)
513 else if (strlen(pairedDeviceAddressString) > 0 && strcmp(pairedDeviceAddressString,(
char*)
"NONE")==0)
517 pairedButNotConnected =
true;
525 if (pairedButNotConnected)
526 SerialLots.printf(
"pairedButNotConnected(%d)\n", pairedButNotConnected);
527 if (pairedAndConnected)
528 SerialLots.printf(
"pairedAndConnected(%d)\n", pairedAndConnected);
529 if (pairableAndConnected)
530 SerialLots.printf(
"pairableAndConnected(%d)\n", pairableAndConnected);
532 SerialLots.printf(
"unpaired(%d)\n", unpaired);
534 if (pairedButNotConnected)
540 else if (pairedAndConnected)
546 else if (pairableAndConnected)
589 SerialCall.printf(
"updateMenuState timerRunning(%d)\n", deviceState->
delayRunning);
610 long currentTimeMillis =
millis();
611 SerialCall.printf(
"currentTimeMillis = %d\n", currentTimeMillis);
612 SerialCall.printf(
"delayStartMillis = %d\n", deviceState->
delayStartMillis);
623 SerialCall.printf(
"delayFinished \n");
667 SerialCall.printf(
"menuForState(%d,%d)\n", modelKind, item);
685 menu = (
char*)
"scan..";
689 menu = (
char*)
"unpair";
693 menu = (
char*)
"Gen3";
695 menu = (
char*)
"AnyBLE";
698 SerialMin.printf(
"a.**** Invalid item: %d\n",item);
706 menu = (
char*)
"feed";
709 menu = (
char*)
"unpair";
713 menu = (
char*)
"Gen3";
715 menu = (
char*)
"AnyBLE";
718 SerialMin.printf(
"b. **** Invalid item: %d\n",item);
726 menu = (
char*)
"feed";
729 menu = (
char*)
"skip";
732 menu = (
char*)
"pair";
736 menu = (
char*)
"Gen3";
738 menu = (
char*)
"AnyBLE";
741 SerialMin.printf(
"c. **** Invalid item: %d\n",item);
749 menu = (
char*)
"scan..";
753 menu = (
char*)
"Gen3";
755 menu = (
char*)
"AnyBLE";
758 SerialMin.printf(
"d. **** Invalid item: %d\n",item);
771 menu = (
char*)
"reboot";
774 menu = (
char*)
"poweroff";
778 menu = (
char*)
"blankscrn";
782 menu = (
char *)
"Set Uno";
785 menu = (
char *)
"Tumbler";
789 menu = (
char*)
"colorscrn";
792 menu = (
char*)
"SemMarker";
796 menu = (
char*)
"BLE+WIFI";
798 menu = (
char*)
"BLEOnly";
802 menu = (
char*)
"CycleScrn";
806 menu = (
char*)
"Wave+Page";
810 menu = (
char*)
"Wave+Strm";
815 menu = (
char*)
"PTClicker";
817 menu = (
char*)
"PTFeeder";
821 SerialMin.printf(
"e. **** Invalid item: %d\n",item);
848 menu = (
char*)
"BLEPair";
851 menu = (
char*)
"APMode";
854 menu = (
char*)
"WIFIShare";
857 menu = (
char*)
"Timer";
860 menu = (
char*)
"Advanced";
863 menu = (
char*)
"Status";
866 menu = (
char*)
"GuestPage";
869 menu = (
char*)
"GuestFeed";
872 menu = (
char*)
"Settings";
875 menu = (
char*)
"DocFollow";
878 menu = (
char*)
"Help";
882 SerialMin.printf(
"f. **** Invalid item: %d\n",item);
898 menu = (
char*)
"Stop";
900 menu = (
char*)
"Start";
925 menu = (
char*)
"Delay";
929 SerialMin.printf(
"g. **** Invalid item: %d\n",item);
943 boolean modelChanged =
false;
955 SerialCall.printf(
"pairedDeviceModel");
1010 modelChanged =
true;
1015 modelChanged =
true;
1020 modelChanged =
true;
1034 modelChanged =
true;
1044 SerialCall.println(
"*** rebootModel ***");
1073 modelChanged =
true;
1077 modelChanged =
true;
1108 char pubString[100];
1110 sprintf(pubString,(
char*)
"#followMe {AVM=https://SemanticMarker.org/bot/wave/%s?action=next}", deviceState->
waveName);
1127 char pubString[100];
1130 sprintf(pubString,(
char*)
"#followMe {AVM=https://SemanticMarker.org/bot/wave/%s?stream=%0d&page=0}", deviceState->
waveName, deviceState->
currentStreamNum+1);
1148 SerialMin.println(
"h, *** invalid item ***");
1155 modelChanged =
true;
1156 SerialCall.println(
"*** menusModel ***");
1179 SerialTemp.printf(
"*** timerModel (%d) *** %d\n", item, deviceState->
delayRunning);
1214 if (currentDelay == 5)
1216 else if (currentDelay == 30)
1218 else if (currentDelay == 60)
1220 else if (currentDelay == 120)
1224 SerialTemp.printf(
".. change delay = %d\n", currentDelay);
1242 if (currentDelay < deviceState->delaySeconds)
1259 SerialMin.println(
"i2. *** invalid item ***");
1265 return modelChanged;
1272 boolean modelChanged =
false;
1277 char *semanticMarker = NULL;
1279#ifdef NOTHING_YET_SAVE_SOME_MEMORY
1312 return semanticMarker;
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
void disconnect_BLEClientNetworking()
try to disconnect..
void skipNameOrAddress_BLEClientNetworking(char *nameOrAddress)
an address or name to skip (for at least 1 time)
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
void incrementScreenColor_displayModule()
void publishMQTTMessageDefaultTopic(char *message)
Wrapper of the mqttclient publish.
void sendMessageMQTT(char *message)
boolean processJSONMessageMQTT(char *ascii, char *topic)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not,...
void setConnectedBLEDevice_mainModule(char *deviceName, boolean isGEN3)
char * connectedBLEDeviceNameAddress_mainModule()
returns address part of name.
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
char * deviceName_mainModule()
gets the device name
boolean connectedBLEDeviceIsGEN3_mainModule()
whether the connected is a GEN3 (so the name isn't valid)
void processClientCommandChar_mainModule(char cmd)
single character version of processClientCommand (since many used that already)
int getCurrentSMMode_mainModule()
returns the current SM Mode
char * getFullBLEDeviceName_mainModule()
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
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 main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
#define SM_pair_dev
guest feed device
#define ASYNC_REBOOT
sets the GATEWAY mode off
#define SM_guest_feed
guest feed
#define SM_guest_page
guest page
#define ASYNC_SEND_MQTT_FEED_MESSAGE
sends a message (like FEED) on the users topic
#define SM_timer
timer .. todo
#define SM_status
//status
#define MAX_SM_EXPANDED_MODES
#define ASYNC_POWEROFF
sets the GATEWAY mode off
#define ASYNC_BLANKSCREEN
blank the screen
#define SM_doc_follow
docfollow
#define SM_smart_clicker_homepage
//! homepage
#define SM_WIFI_ssid
WIFI ssid.
#define SM_ap_mode
AP MODE.
void updateMenuState(ModelKindEnum modelKind)
updates the model for the menu state, this sets max etc
void invokeUnpairNoNameBASE_ModelController()
void incrementMenuState(ModelKindEnum modelKind)
increments the device states deviceState (wrapping around)
boolean invokeMenuState(ModelKindEnum modelKind)
invokes the menu state, return true if the model state has change enough to refreesh your View (such ...
void initMenuToSMMode()
init the mapping
void setTimerDelaySecondsMax_mainModule(int delaySeconds)
void invokeUnpair_ModelController(char *nameOrAddress)
performs the unpairing
void invokeFeed_ModelController()
performs the BLE feed
void invokePair_ModelController()
#define MenusModel_WIFIShare
void setTimerDelaySeconds_mainModule(int delaySeconds)
void invokeSkip_ModelController(char *nameOrAddress)
performs skip
void printDeviceState(ModelStateStruct *deviceState)
print it out..
#define MenusModel_Help
a pseudo Class
void startStopTimer_mainModule(boolean startTimer)
#define MenusModel_Status
char * menuForState(ModelKindEnum modelKind, int item)
returns the menu string for the deviceState's item number (use woudl go 0..maxItems -1
#define MenusModel_DocFollow
#define MenusModel_GuestFeed
#define MenusModel_Settings
void invokeUnpairNoName_ModelController()
ModelStateStruct * hasModelForSM_Mode(int SM_Mode)
retrieves the state model for the SM_Mode (SM_0 .. SM_LAST) null if none
#define MenusModel_Advanced
int _menuToSMMode[MenusModel_Max]
storage of mapping
char * getModelSemanticMarker(ModelKindEnum modelKind)
retrieves a semantic marker for the current selected item
ModelStateStruct * getModel(ModelKindEnum modelKind)
retrieves the state model for the modelKind
void initModelStructs_ModelController()
initialize the objects
void invokeFeedLocally()
storage..
#define MenusModel_APMode
#define MenusModel_GuestPage
#define MenusModel_Pairing
void invokeToggleGen3_ModelController()
toggles the GEN3 setting
void restartAllMenuStates_ModelController()
restarts all the menu states to the first one .. useful for getting a clean start....
ModelStateStruct _modelStateStructs[ModelKindEnumMax]
ModelKindEnum
a pseudo Class
@ pairedButNotConnectedEnum
@ notConnectedEnum
factory default but not connecte to anything..
@ pairableAndConnectedEnum
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int preference
boolean getDiscoverM5PTClicker()
get option
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
void setDiscoverM5PTClicker(boolean flag)
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
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 * 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_PAIRED_DEVICE_ADDRESS_SETTING
the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
#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_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCE_TIMER_MAX_INT_SETTING
the preference timer MAX (pairs with PREFERENCE_TIMER_INT_SETTING)
#define PREFERENCE_MAIN_GATEWAY_VALUE
#define PREFERENCE_TIMER_INT_SETTING
the preference timer
the struct for the models. Since this isn't straight OO, we are overlaying information....
ModelKindEnum modelKindEnum
What kind of model.
int currentCounterSeconds
current seconds (<= delaySeconds)
int currentPageState
for the next page state 0..n
boolean feedLocalOnly
feed local instead of MQTT or BLE..
int delaySecondsMax
11.29.23 max Delay Seconds .. if different than delay then next delay will be random() * (max-min) + ...
int delayStartMillis
Timer info - When the timer was started.
int counterLoopAbsoluteSeconds
int currentItem
the current item
int currentStreamNum
the stream number
char * waveName
which wave
int SM_Mode
which SM mode 0.. SM_LAST
boolean perfersBigText
a preference to the View that big text is desired
PairedDeviceStateEnum pairedDeviceStateEnum
boolean delayRunning
true if still waiting for delay to finish
int delaySeconds
length of delay (changable..)
int maxItems
the number of items in the model