Skip to content

Commit fa5bf57

Browse files
authored
Merge pull request #296 from LeeLeahy2/bt-test
Move Bluetooth test into Debug menu
2 parents 47bec82 + 6053f12 commit fa5bf57

File tree

2 files changed

+52
-39
lines changed

2 files changed

+52
-39
lines changed

Firmware/RTK_Surveyor/Bluetooth.ino

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,52 @@ void bluetoothStop()
183183
bluetoothIncomingRTCM = false;
184184
}
185185

186+
//Test the bidirectional communication through UART2
187+
void bluetoothTest(bool runTest)
188+
{
189+
//Verify the ESP UART2 can communicate TX/RX to ZED UART1
190+
const char * bluetoothStatusText;
191+
if (online.gnss == true)
192+
{
193+
if (runTest && (zedUartPassed == false))
194+
{
195+
stopUART2Tasks(); //Stop absoring ZED serial via task
196+
197+
i2cGNSS.setSerialRate(460800, COM_PORT_UART1); //Defaults to 460800 to maximize message output support
198+
serialGNSS.begin(460800); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
199+
200+
SFE_UBLOX_GNSS myGNSS;
201+
if (myGNSS.begin(serialGNSS) == true) //begin() attempts 3 connections
202+
{
203+
zedUartPassed = true;
204+
bluetoothStatusText = (settings.bluetoothRadioType == BLUETOOTH_RADIO_OFF) ? "Off" : "Online";
205+
}
206+
else
207+
bluetoothStatusText = "Offline";
208+
209+
i2cGNSS.setSerialRate(settings.dataPortBaud, COM_PORT_UART1); //Defaults to 460800 to maximize message output support
210+
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
211+
212+
startUART2Tasks(); //Return to normal operation
213+
}
214+
else
215+
bluetoothStatusText = (settings.bluetoothRadioType == BLUETOOTH_RADIO_OFF) ? "Off" : "Online";
216+
}
217+
else
218+
bluetoothStatusText = "GNSS Offline";
219+
220+
//Display Bluetooth MAC address and test results
221+
char macAddress[5];
222+
sprintf(macAddress, "%02X%02X", btMACAddress[4], btMACAddress[5]);
223+
Serial.print("Bluetooth ");
224+
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
225+
Serial.print("Low Energy ");
226+
Serial.print("(");
227+
Serial.print(macAddress);
228+
Serial.print("): ");
229+
Serial.println(bluetoothStatusText);
230+
}
231+
186232
//Write data to the Bluetooth device
187233
int bluetoothWriteBytes(const uint8_t * buffer, int length)
188234
{

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,8 @@ void menuSystem()
6666
printNEOInfo();
6767
}
6868

69-
//Display Bluetooth MAC address
70-
char macAddress[5];
71-
sprintf(macAddress, "%02X%02X", btMACAddress[4], btMACAddress[5]);
72-
Serial.print("Bluetooth (");
73-
Serial.print(macAddress);
74-
Serial.print("): ");
75-
76-
//Verify the ESP UART2 can communicate TX/RX to ZED UART1
77-
if (online.gnss == true)
78-
{
79-
if (zedUartPassed == false)
80-
{
81-
stopUART2Tasks(); //Stop absoring ZED serial via task
82-
83-
i2cGNSS.setSerialRate(460800, COM_PORT_UART1); //Defaults to 460800 to maximize message output support
84-
serialGNSS.begin(460800); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
85-
86-
SFE_UBLOX_GNSS myGNSS;
87-
if (myGNSS.begin(serialGNSS) == true) //begin() attempts 3 connections
88-
{
89-
zedUartPassed = true;
90-
Serial.print("Online");
91-
}
92-
else
93-
Serial.print("Offline");
94-
95-
i2cGNSS.setSerialRate(settings.dataPortBaud, COM_PORT_UART1); //Defaults to 460800 to maximize message output support
96-
serialGNSS.begin(settings.dataPortBaud); //UART2 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at the same rate.
97-
98-
startUART2Tasks(); //Return to normal operation
99-
}
100-
else
101-
Serial.print("Online");
102-
}
103-
else
104-
{
105-
Serial.print("GNSS Offline");
106-
}
107-
Serial.println();
69+
//Display the Bluetooth status
70+
bluetoothTest(false);
10871

10972
#ifdef COMPILE_WIFI
11073
Serial.print("WiFi MAC Address: ");
@@ -391,6 +354,8 @@ void menuDebug()
391354
Serial.print("29) Run Logging Test: ");
392355
Serial.printf("%s\r\n", settings.runLogTest ? "Enabled" : "Disabled");
393356

357+
Serial.println("30) Run Bluetooth Test");
358+
394359
Serial.println("t) Enter Test Screen");
395360

396361
Serial.println("e) Erase LittleFS");
@@ -578,6 +543,8 @@ void menuDebug()
578543
//Mark current log file as complete to force test start
579544
startCurrentLogTime_minutes = systemTime_minutes - settings.maxLogLength_minutes;
580545
}
546+
else if (incoming == 30)
547+
bluetoothTest(true);
581548
else
582549
printUnknown(incoming);
583550
}

0 commit comments

Comments
 (0)