-
Notifications
You must be signed in to change notification settings - Fork 11
/
menuMain.ino
761 lines (637 loc) · 27.2 KB
/
menuMain.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
// Check to see if we've received serial over USB
// Report status if ~ received, otherwise present config menu
void terminalUpdate()
{
char buffer[128];
static uint32_t lastPeriodicDisplay;
int length;
static bool passRtcmToGnss;
static uint32_t rtcmTimer;
// Determine which items are periodically displayed
if ((millis() - lastPeriodicDisplay) >= settings.periodicDisplayInterval)
{
lastPeriodicDisplay = millis();
periodicDisplay = settings.periodicDisplay;
}
// Check for USB serial input
if (systemAvailable())
{
byte incoming = systemRead();
// Is this the start of an RTCM correction message
if (incoming == 0xd3)
{
// Enable RTCM reception
passRtcmToGnss = true;
// Start the RTCM timer
rtcmTimer = millis();
rtcmLastPacketReceived = rtcmTimer;
// Tell the display about the serial RTCM message
usbSerialIncomingRtcm = true;
// Read the beginning of the RTCM correction message
buffer[0] = incoming;
length = Serial.readBytes(&buffer[1], sizeof(buffer) - 1) + 1;
// Push RTCM to GNSS module over I2C / SPI
if (correctionLastSeen(CORR_USB))
gnss->pushRawData((uint8_t *)buffer, length);
}
// Does incoming data consist of RTCM correction messages
if (passRtcmToGnss && ((millis() - rtcmTimer) < RTCM_CORRECTION_INPUT_TIMEOUT))
{
// Renew the RTCM timer
rtcmTimer = millis();
rtcmLastPacketReceived = rtcmTimer;
// Tell the display about the serial RTCM message
usbSerialIncomingRtcm = true;
// Read more of the RTCM correction message
buffer[0] = incoming;
length = Serial.readBytes(&buffer[1], sizeof(buffer) - 1) + 1;
// Push RTCM to GNSS module over I2C / SPI
if (correctionLastSeen(CORR_USB))
gnss->pushRawData((uint8_t *)buffer, length);
}
else
{
// Allow regular serial input
passRtcmToGnss = false;
if (incoming == '~')
{
// Output custom GNTXT message with all current system data
printCurrentConditionsNMEA();
}
else
{
// When outputting GNSS data to USB serial, check for +++
if (!forwardGnssDataToUsbSerial)
menuMain(); // Present user menu
else
{
static uint32_t plusTimeout;
static uint8_t plusCount;
// Reset plusCount on timeout
if ((millis() - plusTimeout) > PLUS_PLUS_PLUS_TIMEOUT)
plusCount = 0;
// Check for + input
if (incoming != '+')
// Must start over looking for +++
plusCount = 0;
else
{
// + entered, check for the +++ sequence
plusCount++;
if (plusCount < 3)
// Restart the timeout
plusTimeout = millis();
else
// +++ was entered, display the main menu
menuMain(); // Present user menu
}
}
}
}
}
}
// Display the main menu configuration options
void menuMain()
{
// Redirect menu output, status and debug messages to the USB serial port
forwardGnssDataToUsbSerial = false;
inMainMenu = true;
displaySerialConfig(); // Display 'Serial Config' while user is configuring
if (settings.debugGnss == true)
{
// Turn off GNSS debug while in config menus
gnss->debuggingDisable();
}
// Check for remote app config entry into command mode
if (runCommandMode == true)
{
runCommandMode = false;
menuCommands();
return;
}
if (configureViaEthernet)
{
while (1)
{
systemPrintln();
char versionString[21];
getFirmwareVersion(versionString, sizeof(versionString), true);
RTKBrandAttribute * brandAttributes = getBrandAttributeFromBrand(present.brand);
systemPrintf("%s RTK %s %s\r\n", brandAttributes->name, platformPrefix, versionString);
systemPrintln("\r\n** Configure Via Ethernet Mode **\r\n");
systemPrintln("Menu: Main");
systemPrintln("r) Restart Base");
systemPrintln("x) Exit");
byte incoming = getUserInputCharacterNumber();
if (incoming == 'r')
{
displayConfigViaEthStarting(1000);
ethernetWebServerStopESP32W5500();
settings.updateGNSSSettings = false; // On the next boot, no need to update the GNSS on this profile
settings.lastState = STATE_BASE_NOT_STARTED; // Record the _next_ state for POR
recordSystemSettings();
ESP.restart();
}
else if (incoming == 'x')
break;
else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_EMPTY)
break;
else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_TIMEOUT)
break;
else
printUnknown(incoming);
}
}
else
{
while (1)
{
systemPrintln();
char versionString[21];
getFirmwareVersion(versionString, sizeof(versionString), true);
RTKBrandAttribute * brandAttributes = getBrandAttributeFromBrand(present.brand);
systemPrintf("%s RTK %s %s\r\n", brandAttributes->name, platformPrefix, versionString);
#ifdef COMPILE_BT
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP_AND_BLE)
systemPrint("** Bluetooth SPP and BLE broadcasting as: ");
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
systemPrint("** Bluetooth SPP broadcasting as: ");
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
systemPrint("** Bluetooth Low-Energy broadcasting as: ");
systemPrint(deviceName);
systemPrintln(" **");
#else // COMPILE_BT
systemPrintln("** Bluetooth Not Compiled **");
#endif // COMPILE_BT
systemPrintln("Menu: Main");
systemPrintln("1) Configure GNSS Receiver");
systemPrintln("2) Configure GNSS Messages");
systemPrintln("3) Configure Base");
systemPrintln("4) Configure Ports");
if (productVariant != RTK_TORCH) // Torch does not have logging
systemPrintln("5) Configure Logging");
#ifdef COMPILE_WIFI
systemPrintln("6) Configure WiFi");
#else // COMPILE_WIFI
systemPrintln("6) **WiFi Not Compiled**");
#endif // COMPILE_WIFI
#ifdef COMPILE_NETWORK
systemPrintln("7) Configure TCP/UDP");
#else // COMPILE_NETWORK
systemPrintln("7) **TCP/UDP Not Compiled**");
#endif // COMPILE_NETWORK
#ifdef COMPILE_ETHERNET
if (present.ethernet_ws5500 == true)
systemPrintln("e) Configure Ethernet");
#endif // COMPILE_ETHERNET
systemPrintln("f) Firmware Update");
systemPrintln("i) Configure Corrections Priorities");
#ifdef COMPILE_ETHERNET
if (present.ethernet_ws5500 == true)
systemPrintln("n) Configure NTP");
#endif // COMPILE_ETHERNET
systemPrintln("p) Configure PointPerfect");
systemPrintln("r) Configure Radios");
systemPrintln("s) Configure System");
if (present.imu_im19)
systemPrintln("t) Configure Instrument Setup");
systemPrintln("u) Configure User Profiles");
if (btPrintEcho)
systemPrintln("b) Exit Bluetooth Echo mode");
systemPrintln("+) Enter Command line mode");
systemPrintln("x) Exit");
byte incoming = getUserInputCharacterNumber();
if (incoming == 1)
menuGNSS();
else if (incoming == 2)
gnss->menuMessages();
else if (incoming == 3)
menuBase();
else if (incoming == 4)
menuPorts();
else if (incoming == 5 && productVariant == RTK_FACET_MOSAIC)
menuLogMosaic();
else if (incoming == 5 && productVariant != RTK_TORCH) // Torch does not have logging
menuLog();
else if (incoming == 6)
menuWiFi();
else if (incoming == 7)
menuTcpUdp();
else if (incoming == 'e' && (present.ethernet_ws5500 == true))
menuEthernet();
else if (incoming == 'f')
menuFirmware();
else if (incoming == 'i')
menuCorrectionsPriorities();
else if (incoming == 'n' && (present.ethernet_ws5500 == true))
menuNTP();
else if (incoming == 'u')
menuUserProfiles();
else if (incoming == 'p')
menuPointPerfect();
else if (incoming == 'r')
menuRadio();
else if (incoming == 's')
menuSystem();
else if ((incoming == 't') && present.imu_im19)
menuInstrument();
else if (incoming == 'b' && btPrintEcho == true)
{
printEndpoint = PRINT_ENDPOINT_SERIAL;
systemPrintln("BT device has exited echo mode");
btPrintEcho = false;
break; // Exit config menu
}
else if (incoming == '+')
menuCommands();
else if (incoming == 'x')
break;
else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_EMPTY)
break;
else if (incoming == INPUT_RESPONSE_GETCHARACTERNUMBER_TIMEOUT)
break;
else
printUnknown(incoming);
}
}
if (!configureViaEthernet)
{
// Reboot as base only if currently operating as a base station
if (restartBase == true && inBaseMode() == true)
{
restartBase = false;
requestChangeState(STATE_BASE_NOT_STARTED); // Restart base upon exit for latest changes to take effect
}
if (restartRover == true && inRoverMode() == true)
{
restartRover = false;
requestChangeState(STATE_ROVER_NOT_STARTED); // Restart rover upon exit for latest changes to take effect
}
gnss->saveConfiguration();
recordSystemSettings(); // Once all menus have exited, record the new settings to LittleFS and config file
}
if (settings.debugGnss == true)
{
// Re-enable GNSS debug once we exit config menus
gnss->debuggingEnable();
}
clearBuffer(); // Empty buffer of any newline chars
btPrintEchoExit = false; // We are out of the menu system
inMainMenu = false;
// Change the USB serial output behavior if necessary
//
// The mosaic-X5 has separate USB COM ports. NMEA and RTCM will be output on USB1 if
// settings.enableGnssToUsbSerial is true. forwardGnssDataToUsbSerial is never set true.
if (!present.gnss_mosaicX5)
forwardGnssDataToUsbSerial = settings.enableGnssToUsbSerial;
// While in LoRa mode, we need to know when the last serial interaction was
loraLastIncomingSerial = millis();
}
// Change system wide settings based on current user profile
// Ways to change the ZED settings:
// Menus - we apply ZED changes at the exit of each sub menu
// Settings file - we detect differences between NVM and settings txt file and updateGNSSSettings = true
// Profile - Before profile is changed, set updateGNSSSettings = true
// AP - once new settings are parsed, set updateGNSSSettings = true
// Setup button -
// Factory reset - updatesZEDSettings = true by default
void menuUserProfiles()
{
uint8_t originalProfileNumber = profileNumber;
bool forceReset =
false; // If we reset a profile to default, the profile number has not changed, but we still need to reset
while (1)
{
systemPrintln();
systemPrintln("Menu: User Profiles");
// List available profiles
for (int x = 0; x < MAX_PROFILE_COUNT; x++)
{
if (activeProfiles & (1 << x))
systemPrintf("%d) Select %s", x + 1, profileNames[x]);
else
systemPrintf("%d) Select (Empty)", x + 1);
if (x == profileNumber)
systemPrint(" <- Current");
systemPrintln();
}
systemPrintf("%d) Edit profile name: %s\r\n", MAX_PROFILE_COUNT + 1, profileNames[profileNumber]);
systemPrintf("%d) Set profile '%s' to factory defaults\r\n", MAX_PROFILE_COUNT + 2,
profileNames[profileNumber]);
systemPrintf("%d) Delete profile '%s'\r\n", MAX_PROFILE_COUNT + 3, profileNames[profileNumber]);
systemPrintln("x) Exit");
int incoming = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
if (incoming >= 1 && incoming <= MAX_PROFILE_COUNT)
{
changeProfileNumber(incoming - 1); // Align inputs to array
}
else if (incoming == MAX_PROFILE_COUNT + 1)
{
systemPrint("Enter new profile name: ");
getUserInputString(settings.profileName, sizeof(settings.profileName));
recordSystemSettings(); // We need to update this immediately in case user lists the available profiles
// again
setProfileName(profileNumber);
}
else if (incoming == MAX_PROFILE_COUNT + 2)
{
systemPrintf("\r\nReset profile '%s' to factory defaults. Press 'y' to confirm:",
profileNames[profileNumber]);
byte bContinue = getUserInputCharacterNumber();
if (bContinue == 'y')
{
settingsToDefaults(); // Overwrite our current settings with defaults
recordSystemSettings(); // Overwrite profile file and NVM with these settings
// Get bitmask of active profiles
activeProfiles = loadProfileNames();
forceReset = true; // Upon exit of menu, reset the device
}
else
systemPrintln("Reset aborted");
}
else if (incoming == MAX_PROFILE_COUNT + 3)
{
systemPrintf("\r\nDelete profile '%s'. Press 'y' to confirm:", profileNames[profileNumber]);
byte bContinue = getUserInputCharacterNumber();
if (bContinue == 'y')
{
// Remove profile from LittleFS
if (LittleFS.exists(settingsFileName))
LittleFS.remove(settingsFileName);
// Remove profile from SD if available
if (online.microSD == true)
{
if (sd->exists(settingsFileName))
sd->remove(settingsFileName);
}
recordProfileNumber(0); // Move to Profile1
profileNumber = 0;
snprintf(settingsFileName, sizeof(settingsFileName), "/%s_Settings_%d.txt", platformFilePrefix,
profileNumber); // Update file name with new profileNumber
// We need to load these settings from file so that we can record a profile name change correctly
bool responseLFS = loadSystemSettingsFromFileLFS(settingsFileName);
bool responseSD = loadSystemSettingsFromFileSD(settingsFileName);
// If this is an empty/new profile slot, overwrite our current settings with defaults
if (responseLFS == false && responseSD == false)
{
settingsToDefaults();
}
// Get bitmask of active profiles
activeProfiles = loadProfileNames();
}
else
systemPrintln("Delete aborted");
}
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
break;
else if (incoming == INPUT_RESPONSE_GETNUMBER_TIMEOUT)
break;
else
printUnknown(incoming);
}
if (originalProfileNumber != profileNumber || forceReset == true)
{
systemPrintln("Rebooting to apply new profile settings. Goodbye!");
delay(2000);
ESP.restart();
}
// A user may edit the name of a profile, but then switch back to original profile.
// Thus, no reset, and activeProfiles is not updated. Do it here.
// Get bitmask of active profiles
activeProfiles = loadProfileNames();
clearBuffer(); // Empty buffer of any newline chars
}
// Change the active profile number, without unit reset
void changeProfileNumber(byte newProfileNumber)
{
settings.updateGNSSSettings = true; // When this profile is loaded next, force system to update GNSS settings.
recordSystemSettings(); // Before switching, we need to record the current settings to LittleFS and SD
recordProfileNumber(newProfileNumber);
profileNumber = newProfileNumber;
setSettingsFileName(); // Load the settings file name into memory (enabled profile name delete)
// We need to load these settings from file so that we can record a profile name change correctly
bool responseLFS = loadSystemSettingsFromFileLFS(settingsFileName);
bool responseSD = loadSystemSettingsFromFileSD(settingsFileName);
// If this is an empty/new profile slot, overwrite our current settings with defaults
if (responseLFS == false && responseSD == false)
{
systemPrintln("No profile found: Applying default settings");
settingsToDefaults();
}
}
// Erase all settings. Upon restart, unit will use defaults
void factoryReset(bool alreadyHasSemaphore)
{
displaySytemReset(); // Display friendly message on OLED
tasksStopGnssUart();
// Attempt to write to file system. This avoids collisions with file writing from other functions like
// recordSystemSettingsToFile() and gnssSerialReadTask() if (settings.enableSD && online.microSD)
// Don't check settings.enableSD - it could be corrupt
if (online.microSD)
{
if (alreadyHasSemaphore == true || xSemaphoreTake(sdCardSemaphore, fatSemaphore_longWait_ms) == pdPASS)
{
// Remove this specific settings file. Don't remove the other profiles.
sd->remove(settingsFileName);
sd->remove(stationCoordinateECEFFileName); // Remove station files
sd->remove(stationCoordinateGeodeticFileName);
xSemaphoreGive(sdCardSemaphore);
} // End sdCardSemaphore
else
{
char semaphoreHolder[50];
getSemaphoreFunction(semaphoreHolder);
// An error occurs when a settings file is on the microSD card and it is not
// deleted, as such the settings on the microSD card will be loaded when the
// RTK reboots, resulting in failure to achieve the factory reset condition
log_d("sdCardSemaphore failed to yield, held by %s, menuMain.ino line %d\r\n", semaphoreHolder, __LINE__);
}
}
tiltSensorFactoryReset();
systemPrintln("Formatting internal file system...");
LittleFS.format();
if (online.gnss == true)
gnss->factoryReset();
systemPrintln("Settings erased successfully. Rebooting. Goodbye!");
delay(2000);
ESP.restart();
}
// Configure the internal radio, if available
void menuRadio()
{
while (1)
{
systemPrintln();
systemPrintln("Menu: Radios");
#ifndef COMPILE_ESPNOW
systemPrintln("1) **ESP-Now Not Compiled**");
#else // COMPILE_ESPNOW
if (settings.enableEspNow == false)
systemPrintln("1) ESP-NOW Radio: Disabled");
else // ESP-NOW enabled
{
systemPrint("1) ESP-NOW Radio: Enabled - MAC ");
for (int x = 0; x < 5; x++)
systemPrintf("%02X:", wifiMACAddress[x]);
systemPrintf("%02X\r\n", wifiMACAddress[5]);
if (settings.espnowPeerCount > 0)
{
systemPrintln(" Paired Radios: ");
for (int x = 0; x < settings.espnowPeerCount; x++)
{
systemPrint(" ");
for (int y = 0; y < 5; y++)
systemPrintf("%02X:", settings.espnowPeers[x][y]);
systemPrintf("%02X\r\n", settings.espnowPeers[x][5]);
}
}
else
systemPrintln(" No Paired Radios - Broadcast Enabled");
systemPrintln("2) Pair radios");
systemPrintln("3) Forget all radios");
systemPrintf("4) Current channel: %d\r\n", espnowGetChannel());
if (settings.debugEspNow == true)
{
systemPrintln("5) Add dummy radio");
systemPrintln("6) Send dummy data");
systemPrintln("7) Broadcast dummy data");
}
}
#endif // COMPILE_ESPNOW
if (present.radio_lora == true)
{
if (settings.enableLora == false)
{
systemPrintln("10) LoRa Radio: Disabled");
}
else
{
loraGetVersion();
if (strlen(loraFirmwareVersion) < 3)
{
strncpy(loraFirmwareVersion, "Unknown", sizeof(loraFirmwareVersion));
systemPrintf("10) LoRa Radio: Enabled - Firmware Unknown\r\n");
}
else
systemPrintf("10) LoRa Radio: Enabled - Firmware v%s\r\n", loraFirmwareVersion);
systemPrintf("11) LoRa Coordination Frequency: %0.3f\r\n", settings.loraCoordinationFrequency);
systemPrintf("12) Seconds without user serial that must elapse before LoRa radio goes into dedicated "
"listening mode: %d\r\n",
settings.loraSerialInteractionTimeout_s);
}
}
systemPrintln("x) Exit");
int incoming = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
if (incoming == 1)
{
settings.enableEspNow ^= 1;
// Start ESP-NOW so that getChannel runs correctly
if (settings.enableEspNow == true)
espnowStart();
else
espnowStop();
}
else if (settings.enableEspNow == true && incoming == 2)
{
espnowStaticPairing();
}
else if (settings.enableEspNow == true && incoming == 3)
{
systemPrintln("\r\nForgetting all paired radios. Press 'y' to confirm:");
byte bContinue = getUserInputCharacterNumber();
if (bContinue == 'y')
{
if (espnowState > ESPNOW_OFF)
{
for (int x = 0; x < settings.espnowPeerCount; x++)
espnowRemovePeer(settings.espnowPeers[x]);
}
settings.espnowPeerCount = 0;
systemPrintln("Radios forgotten");
}
}
else if (settings.enableEspNow == true && incoming == 4)
{
if (wifiIsRunning() == false)
{
if (getNewSetting("Enter the WiFi channel to use for ESP-NOW communication", 1, 14,
&settings.wifiChannel) == INPUT_RESPONSE_VALID)
espnowSetChannel(settings.wifiChannel);
}
else
{
systemPrintln("ESP-NOW channel can't be modified while WiFi is connected.");
}
}
else if (settings.enableEspNow == true && incoming == 5 && settings.debugEspNow == true)
{
if (espnowState == ESPNOW_OFF)
espnowStart();
uint8_t peer1[] = {0xB8, 0xD6, 0x1A, 0x0D, 0x8F, 0x9C}; // Random MAC
#ifdef COMPILE_ESPNOW
if (esp_now_is_peer_exist(peer1) == true)
log_d("Peer already exists");
else
{
// Add new peer to system
espnowAddPeer(peer1);
// Record this MAC to peer list
memcpy(settings.espnowPeers[settings.espnowPeerCount], peer1, 6);
settings.espnowPeerCount++;
settings.espnowPeerCount %= ESPNOW_MAX_PEERS;
recordSystemSettings();
}
espnowSetState(ESPNOW_PAIRED);
#endif
}
else if (settings.enableEspNow == true && incoming == 6 && settings.debugEspNow == true)
{
if (espnowState == ESPNOW_OFF)
espnowStart();
uint8_t espnowData[] =
"This is the long string to test how quickly we can send one string to the other unit. I am going to "
"need a much longer sentence if I want to get a long amount of data into one transmission. This is "
"nearing 200 characters but needs to be near 250.";
#ifdef COMPILE_ESPNOW
esp_now_send(0, (uint8_t *)&espnowData, sizeof(espnowData)); // Send packet to all peers
#endif
}
else if (settings.enableEspNow == true && incoming == 7 && settings.debugEspNow == true)
{
if (espnowState == ESPNOW_OFF)
espnowStart();
uint8_t espnowData[] =
"This is the long string to test how quickly we can send one string to the other unit. I am going to "
"need a much longer sentence if I want to get a long amount of data into one transmission. This is "
"nearing 200 characters but needs to be near 250.";
uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
#ifdef COMPILE_ESPNOW
esp_now_send(broadcastMac, (uint8_t *)&espnowData, sizeof(espnowData)); // Send packet over broadcast
#endif
}
else if (present.radio_lora == true && incoming == 10)
{
settings.enableLora ^= 1;
}
else if (present.radio_lora == true && settings.enableLora == true && incoming == 11)
{
getNewSetting("Enter the frequency used to coordinate radios in MHz", 903.0, 927.0,
&settings.loraCoordinationFrequency);
}
else if (present.radio_lora == true && settings.enableLora == true && incoming == 12)
{
getNewSetting("Enter the number of seconds without user serial that must elapse before LoRa radio goes "
"into dedicated listening mode",
10, 600, &settings.loraSerialInteractionTimeout_s);
}
else if (incoming == INPUT_RESPONSE_GETNUMBER_EXIT)
break;
else if (incoming == INPUT_RESPONSE_GETNUMBER_TIMEOUT)
break;
else
printUnknown(incoming);
}
espnowStart();
// LoRa radio state machine will start/stop radio upon next updateLora in loop()
clearBuffer(); // Empty buffer of any newline chars
}