Skip to content

Commit 5d162b8

Browse files
committed
Merge branch 'release_candidate' into pcUpdates
2 parents 71d8dc3 + 5e8192f commit 5d162b8

File tree

9 files changed

+129
-94
lines changed

9 files changed

+129
-94
lines changed

Firmware/RTK_Everywhere/System.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ void settingsToDefaults()
411411
// Periodically print information if enabled
412412
void printReports()
413413
{
414+
if (bluetoothCommandIsConnected() == true)
415+
return;
416+
414417
// Periodically print the position
415418
if (settings.enablePrintPosition && ((millis() - lastPrintPosition) > 15000))
416419
{

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ bool tasksStartGnssUart()
24232423

24242424
availableHandlerSpace = settings.gnssHandlerBufferSize;
24252425

2426-
// Reads data from ZED and stores data into circular buffer
2426+
// Reads data from GNSS and stores data into circular buffer
24272427
if (!task.gnssReadTaskRunning)
24282428
xTaskCreatePinnedToCore(gnssReadTask, // Function to call
24292429
"gnssRead", // Just for humans

Firmware/RTK_Everywhere/form.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// python main_js_zipper.py
2727

2828
static const uint8_t main_js[] PROGMEM = {
29-
0x1F, 0x8B, 0x08, 0x08, 0x64, 0xCE, 0xD1, 0x68, 0x02, 0xFF, 0x6D, 0x61, 0x69, 0x6E, 0x2E, 0x6A,
29+
0x1F, 0x8B, 0x08, 0x08, 0xA2, 0x42, 0xDC, 0x68, 0x02, 0xFF, 0x6D, 0x61, 0x69, 0x6E, 0x2E, 0x6A,
3030
0x73, 0x2E, 0x67, 0x7A, 0x69, 0x70, 0x00, 0xED, 0x7D, 0x7B, 0x5F, 0xDB, 0x48, 0xB2, 0xE8, 0xFF,
3131
0xF9, 0x14, 0xBD, 0xBE, 0x7B, 0xC7, 0x66, 0x31, 0x46, 0x36, 0x8F, 0x40, 0x08, 0x39, 0x97, 0x00,
3232
0x49, 0xB8, 0xCB, 0xEB, 0x62, 0x32, 0x33, 0x99, 0x6C, 0x0E, 0x47, 0x58, 0xC2, 0xE8, 0xC4, 0x96,
@@ -1082,7 +1082,7 @@ static const uint8_t main_js[] PROGMEM = {
10821082
// python index_html_zipper.py
10831083

10841084
static const uint8_t index_html[] PROGMEM = {
1085-
0x1F, 0x8B, 0x08, 0x08, 0x64, 0xCE, 0xD1, 0x68, 0x02, 0xFF, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x2E,
1085+
0x1F, 0x8B, 0x08, 0x08, 0xA2, 0x42, 0xDC, 0x68, 0x02, 0xFF, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x2E,
10861086
0x68, 0x74, 0x6D, 0x6C, 0x2E, 0x67, 0x7A, 0x69, 0x70, 0x00, 0xED, 0x7D, 0x59, 0x76, 0xDB, 0xCA,
10871087
0x92, 0xE0, 0xFF, 0x5D, 0x45, 0x16, 0xAB, 0xBB, 0x2C, 0x57, 0x8B, 0x14, 0x48, 0x4A, 0xB2, 0xAC,
10881088
0x67, 0xEB, 0x1C, 0x6A, 0xB0, 0xAD, 0x7E, 0xB2, 0xCC, 0x12, 0xE5, 0x77, 0x87, 0x3E, 0xDD, 0xF7,

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
char otaOutcome[21] = {0}; // Modified by otaUpdate(), used to respond to rtkRemoteFirmwareVersion commands
2-
int systemWriteLength = 0; // Modified by systemWrite(), used to calculate the size of LIST command for CLI
2+
int systemWriteCounts =
3+
0; // Modified by systemWrite(), used to calculate the number of items in the LIST command for CLI
34

45
void menuCommands()
56
{
@@ -268,22 +269,16 @@ t_cliResult processCommand(char *cmdBuffer)
268269
{
269270
// Respond with a list of variables, types, and current value
270271

271-
// First calculate the size of the LIST response
272+
// First calculate the lines in the LIST response
272273
PrintEndpoint originalPrintEndpoint = printEndpoint;
273274
printEndpoint = PRINT_ENDPOINT_COUNT;
274-
systemWriteLength = 0;
275+
systemWriteCounts = 0;
275276
printAvailableSettings();
276277
printEndpoint = originalPrintEndpoint;
277278

278-
// Use log10 to find the number of digits in systemWriteLength
279-
int systemWriteLengthDigits = floor(log10(systemWriteLength)) + 1;
280-
281-
// Adjust systemWriteLength to include the length of the list entry
282-
systemWriteLength = systemWriteLength + sizeof("$SPLST,list,int,*2A") + systemWriteLengthDigits;
283-
284-
// Print the list entry
285-
char settingValue[6]; // 12345
286-
snprintf(settingValue, sizeof(settingValue), "%d", systemWriteLength);
279+
// Print the list entry with the number of items in the list, including the list entry
280+
char settingValue[6]; // 12345
281+
snprintf(settingValue, sizeof(settingValue), "%d", systemWriteCounts + 1); // Add list command
287282
commandSendExecuteListResponse("list", "int", settingValue);
288283

289284
// Now actually print the list
@@ -501,8 +496,21 @@ void commandSendAllInterfaces(char *rxData)
501496

502497
// Don't re-direct if we're doing a count of the print output
503498
if (printEndpoint != PRINT_ENDPOINT_COUNT)
499+
{
504500
printEndpoint = PRINT_ENDPOINT_ALL;
505501

502+
// The LIST command dumps a large amount of data across the BLE link causing "esp_ble_gatts_send_ notify: rc=-1"
503+
// errors
504+
505+
// With debug=debug, 788 characters are printed locally that slow down the interface enough to avoid errors,
506+
// or 68.4ms at 115200
507+
// With debug=error, can we delay 70ms after every line print and avoid errors? Yes! Works
508+
// well. 50ms is good, 25ms works sometimes without error, 5 is bad.
509+
510+
if (bluetoothCommandIsConnected())
511+
delay(settings.cliBlePrintDelay_ms);
512+
}
513+
506514
systemPrint(rxData); // Send command output to BLE, SPP, and Serial
507515
printEndpoint = originalPrintEndpoint;
508516
}
@@ -679,8 +687,8 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
679687
settingValue = 0;
680688

681689
bool knownSetting = false;
682-
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command response.
683-
// Generally char arrays but some others.
690+
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command
691+
// response. Generally char arrays but some others.
684692

685693
// Loop through the valid command entries
686694
i = commandLookupSettingName(inCommands, settingName, truncatedName, sizeof(truncatedName), suffix, sizeof(suffix));
@@ -807,8 +815,8 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
807815

808816
// Update the profile name in the file system if necessary
809817
if (strcmp(settingName, "profileName") == 0)
810-
setProfileName(profileNumber); // Copy the current settings.profileName into the array of profile names
811-
// at location profileNumber
818+
setProfileName(profileNumber); // Copy the current settings.profileName into the array of profile
819+
// names at location profileNumber
812820
settingIsString = true;
813821
}
814822
break;
@@ -1919,9 +1927,9 @@ void createSettingsString(char *newSettings)
19191927
break;
19201928
case tUmConst: {
19211929
// Record UM980 Constellations
1922-
// um980Constellations are uint8_t, but here we have to convert to bool (true / false) so the web page
1923-
// check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer will
1924-
// probably fail...)
1930+
// um980Constellations are uint8_t, but here we have to convert to bool (true / false) so the web
1931+
// page check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer
1932+
// will probably fail...)
19251933
for (int x = 0; x < rtkSettingsEntries[i].qualifier; x++)
19261934
{
19271935
char tempString[50]; // um980Constellations.GLONASS=true
@@ -2086,9 +2094,9 @@ void createSettingsString(char *newSettings)
20862094
break;
20872095
case tLgConst: {
20882096
// Record LG290P Constellations
2089-
// lg290pConstellations are uint8_t, but here we have to convert to bool (true / false) so the web page
2090-
// check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer will
2091-
// probably fail...)
2097+
// lg290pConstellations are uint8_t, but here we have to convert to bool (true / false) so the web
2098+
// page check boxes are populated correctly. (We can't make it bool, otherwise the 254 initializer
2099+
// will probably fail...)
20922100
for (int x = 0; x < rtkSettingsEntries[i].qualifier; x++)
20932101
{
20942102
char tempString[50]; // lg290pConstellations.GLONASS=true
@@ -2487,8 +2495,8 @@ SettingValueResponse getSettingValue(bool inCommands, const char *settingName, c
24872495
void *var;
24882496

24892497
bool knownSetting = false;
2490-
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command response.
2491-
// Generally char arrays but some others.
2498+
bool settingIsString = false; // Goes true when setting needs to be surrounded by quotes during command
2499+
// response. Generally char arrays but some others.
24922500

24932501
// Loop through the valid command entries - but skip the priority settings and use the GNSS-specific types
24942502
i = commandLookupSettingNameAfterPriority(inCommands, settingName, truncatedName, sizeof(truncatedName), suffix,

Firmware/RTK_Everywhere/menuSystem.ino

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ void menuDebugHardware()
519519
systemPrint("19) Print CLI Debugging: ");
520520
systemPrintf("%s\r\n", settings.debugCLI ? "Enabled" : "Disabled");
521521

522+
systemPrintf("20) Delay between CLI LIST prints over BLE: %d\r\n", settings.cliBlePrintDelay_ms);
523+
522524
systemPrintln("e) Erase LittleFS");
523525

524526
systemPrintln("t) Test Screen");
@@ -590,7 +592,9 @@ void menuDebugHardware()
590592
else if (present.gnss_lg290p)
591593
{
592594
systemPrintln();
593-
systemPrintf("QGNSS must be connected to CH342 Port B at %dbps. Begin firmware update from QGNSS (hit the play button) then reset the LG290P.\r\n", settings.dataPortBaud);
595+
systemPrintf("QGNSS must be connected to CH342 Port B at %dbps. Begin firmware update from QGNSS (hit "
596+
"the play button) then reset the LG290P.\r\n",
597+
settings.dataPortBaud);
594598
gnssReset();
595599
delay(100);
596600
gnssBoot();
@@ -629,6 +633,15 @@ void menuDebugHardware()
629633
{
630634
settings.debugCLI ^= 1;
631635
}
636+
else if (incoming == 20)
637+
{
638+
systemPrintf("Enter millisecond delay (%d to %d) for CLI LIST command over BLE: ", 0, 1000);
639+
int newDelay = getUserInputNumber(); // Returns EXIT, TIMEOUT, or long
640+
if ((newDelay != INPUT_RESPONSE_GETNUMBER_EXIT) && (newDelay != INPUT_RESPONSE_GETNUMBER_TIMEOUT))
641+
{
642+
settings.cliBlePrintDelay_ms = newDelay;
643+
}
644+
}
632645

633646
else if (incoming == 'e')
634647
{

Firmware/RTK_Everywhere/settings.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,7 @@ struct Settings
11041104
bool enableNtripCaster = false; //When true, respond as a faux NTRIP Caster to incoming TCP connections
11051105
bool baseCasterOverride = false; //When true, user has put device into 'BaseCast' mode. Change settings, but don't save to NVM.
11061106
bool debugCLI = false; //When true, output BLE CLI interactions over serial
1107+
uint16_t cliBlePrintDelay_ms = 50; // Time delayed between prints during a LIST command to avoid overwhelming the BLE connection
11071108

11081109
// Add new settings to appropriate group above or create new group
11091110
// Then also add to the same group in rtkSettingsEntries below
@@ -1750,7 +1751,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
17501751
// g s x k 2 c h d d x 2 Type Qual Variable Name
17511752

17521753
// UM980 GNSS Receiver - TODO these apply to more than UM980
1753-
{ 1, 1, 0, 0, 0, 0, 1, 0, 0, NON, 0, _bool, 0, & settings.enableGalileoHas, "enableGalileoHas", },
1754+
{ 1, 1, 0, 0, 0, 0, 1, 0, 1, NON, 1, _bool, 0, & settings.enableGalileoHas, "enableGalileoHas", },
17541755
{ 1, 1, 0, 0, 0, 0, 1, 0, 0, ALL, 0, _bool, 3, & settings.enableMultipathMitigation, "enableMultipathMitigation", },
17551756
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, ALL, 0, _bool, 0, & settings.enableImuCompensationDebug, "enableImuCompensationDebug", },
17561757
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, ALL, 0, _bool, 0, & settings.enableImuDebug, "enableImuDebug", },
@@ -1817,6 +1818,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
18171818
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.enableNtripCaster, "enableNtripCaster", },
18181819
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.baseCasterOverride, "baseCasterOverride", },
18191820
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _bool, 0, & settings.debugCLI, "debugCLI", },
1821+
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, ALL, 1, _uint16_t, 0, & settings.cliBlePrintDelay_ms, "cliBlePrintDelay_ms", },
18201822

18211823

18221824
// Add new settings to appropriate group above or create new group

Firmware/RTK_Everywhere/support.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void systemWrite(const uint8_t *buffer, uint16_t length)
6464
// We're just adding up the size of the list, don't pass along to serial port
6565
else if (printEndpoint == PRINT_ENDPOINT_COUNT)
6666
{
67-
systemWriteLength += length;
67+
systemWriteCounts++;
6868
}
6969
}
7070

Firmware/Test Sketches/ESPNOW_Receive/ESPNOW_Receive.ino

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,58 @@
66
A receiver does not need to have the broadcastMac added to its peer list. It will receive a broadcast
77
no matter what.
88
9-
If desired, onDataRecieve should check the received MAC against the list of friendly/paired MACs
9+
If desired, onDataRecieve should check the received MAC against the list of friendly/paired MACs
1010
in order to throw out broadcasted packets that may not be valid data.
11+
12+
Add peers
13+
Add callback to deal with allowed incoming data
14+
Update test sketches
1115
*/
1216

1317
#include <esp_now.h>
14-
#include <WiFi.h>
18+
#include <esp_mac.h> //Needed for esp_read_mac()
19+
#include <WiFi.h> //Needed because ESP-NOW requires WiFi.mode()
1520

16-
void onDataRecieve(const uint8_t *mac_addr, const uint8_t *incomingData, int len)
21+
void onDataReceive(const esp_now_recv_info *mac, const uint8_t *incomingData, int len)
1722
{
18-
Serial.printf("Bytes received: %d", len);
19-
Serial.printf(" from peer: 0x%02X%02X%02X%02X%02X%02X\r\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
23+
// typedef struct esp_now_recv_info {
24+
// uint8_t * src_addr; // Source address of ESPNOW packet
25+
// uint8_t * des_addr; // Destination address of ESPNOW packet
26+
// wifi_pkt_rx_ctrl_t * rx_ctrl; // Rx control info of ESPNOW packet
27+
// } esp_now_recv_info_t;
28+
29+
// Display the packet info
30+
Serial.printf(
31+
"RX from MAC %02X:%02X:%02X:%02X:%02X:%02X, %d bytes - ",
32+
mac->des_addr[0], mac->des_addr[1], mac->des_addr[2], mac->des_addr[3], mac->des_addr[4], mac->des_addr[5],
33+
len);
34+
35+
//Print what was received - it might be binary gobbly-de-gook
36+
char toPrint[len + 1];
37+
snprintf(toPrint, sizeof(toPrint), "%s", incomingData);
38+
Serial.println(toPrint);
2039
}
2140

2241
void setup()
2342
{
2443
Serial.begin(115200);
25-
delay(500);
26-
Serial.println("Point to Point Receiver - No WiFi");
44+
delay(250);
45+
Serial.println("Remote to Central - This is Central");
2746

28-
uint8_t unitMACAddress[6]; //Use MAC address in BT broadcast and display
47+
uint8_t unitMACAddress[6];
2948
esp_read_mac(unitMACAddress, ESP_MAC_WIFI_STA);
30-
Serial.print("WiFi MAC Address:");
31-
for (int x = 0 ; x < 6 ; x++)
32-
{
33-
Serial.print(" 0x");
34-
if (unitMACAddress[x] < 0x10) Serial.print("0");
35-
Serial.print(unitMACAddress[x], HEX);
36-
}
37-
Serial.println();
49+
Serial.printf("Hi! My MAC address is: {0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X}\r\n",
50+
unitMACAddress[0], unitMACAddress[1], unitMACAddress[2], unitMACAddress[3], unitMACAddress[4], unitMACAddress[5]);
3851

39-
// Set device as a Wi-Fi Station
52+
//ESP-NOW must have WiFi initialized
4053
WiFi.mode(WIFI_STA);
4154

42-
if (esp_now_init() != ESP_OK) {
55+
if (esp_now_init() != ESP_OK)
4356
Serial.println("Error initializing ESP-NOW");
44-
return;
45-
}
46-
47-
esp_now_register_recv_cb(onDataRecieve);
57+
else
58+
Serial.println("ESP-NOW started");
4859

60+
esp_now_register_recv_cb(onDataReceive);
4961
}
5062

5163
void loop()
@@ -63,26 +75,19 @@ void loop()
6375

6476
// Add a given MAC address to the peer list
6577
esp_err_t espnowAddPeer(uint8_t *peerMac)
66-
{
67-
return (espnowAddPeer(peerMac, true)); // Encrypt by default
68-
}
69-
70-
esp_err_t espnowAddPeer(uint8_t *peerMac, bool encrypt)
7178
{
7279
esp_now_peer_info_t peerInfo;
7380

7481
memcpy(peerInfo.peer_addr, peerMac, 6);
7582
peerInfo.channel = 0;
7683
peerInfo.ifidx = WIFI_IF_STA;
77-
// memcpy(peerInfo.lmk, "RTKProductsLMK56", 16);
78-
// peerInfo.encrypt = encrypt;
7984
peerInfo.encrypt = false;
8085

8186
esp_err_t result = esp_now_add_peer(&peerInfo);
8287
if (result != ESP_OK)
83-
{
84-
Serial.printf("Failed to add peer: 0x%02X%02X%02X%02X%02X%02X\r\n", peerMac[0], peerMac[1], peerMac[2],
85-
peerMac[3], peerMac[4], peerMac[5]);
86-
}
88+
Serial.printf("Failed to add peer: 0x%02X%02X%02X%02X%02X%02X\r\n", peerMac[0], peerMac[1], peerMac[2], peerMac[3], peerMac[4], peerMac[5]);
89+
else
90+
Serial.printf("Added peer: 0x%02X%02X%02X%02X%02X%02X\r\n", peerMac[0], peerMac[1], peerMac[2], peerMac[3], peerMac[4], peerMac[5]);
91+
8792
return (result);
8893
}

0 commit comments

Comments
 (0)