Skip to content

Commit e238807

Browse files
committed
Allow disable of BT radio
Used primarily for debugging.
1 parent 2e80170 commit e238807

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

Firmware/RTK_Surveyor/Bluetooth.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ void bluetoothStart()
116116

117117
sprintf(deviceName, "%s %s%02X%02X", platformPrefix, stateName, unitMACAddress[4], unitMACAddress[5]);
118118

119-
// BLE vs Bluetooth Classic
120-
if (settings.enableBLE)
121-
bluetoothSerial = new BTLESerial();
122-
else
119+
// Select Bluetooth setup
120+
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_OFF)
121+
return;
122+
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
123123
bluetoothSerial = new BTClassicSerial();
124+
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
125+
bluetoothSerial = new BTLESerial();
124126

125127
if (bluetoothSerial->begin(deviceName) == false)
126128
{

Firmware/RTK_Surveyor/Display.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ uint32_t setRadioIcons()
659659
//Because of lack of space we will indicate the Base/Rover if only two radios or less are active
660660

661661
//Count the number of radios in use
662-
uint8_t numberOfRadios = 1; //Bluetooth always indicated
662+
uint8_t numberOfRadios = 1; //Bluetooth always indicated. TODO don't count if BT radio type is OFF.
663663
if (wifiState > WIFI_OFF) numberOfRadios++;
664664
if (espnowState > ESPNOW_OFF) numberOfRadios++;
665665

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void recordSystemSettingsToFile(File * settingsFile)
267267
}
268268
settingsFile->printf("%s=%d\n\r", "espnowPeerCount", settings.espnowPeerCount);
269269
settingsFile->printf("%s=%d\n\r", "enableNtripServerMessageParsing", settings.enableNtripServerMessageParsing);
270-
settingsFile->printf("%s=%d\n\r", "enableBLE", settings.enableBLE);
270+
settingsFile->printf("%s=%d\n\r", "radioType", settings.bluetoothRadioType);
271271

272272
//Record constellation settings
273273
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
@@ -871,13 +871,13 @@ bool parseLine(char* str, Settings *settings)
871871
else if (strcmp(settingName, "enablePrintDuplicateStates") == 0)
872872
settings->enablePrintDuplicateStates = d;
873873
else if (strcmp(settingName, "radioType") == 0)
874-
settings->radioType = (radioType_e)d;
874+
settings->radioType = (RadioType_e)d;
875875
else if (strcmp(settingName, "espnowPeerCount") == 0)
876876
settings->espnowPeerCount = d;
877877
else if (strcmp(settingName, "enableNtripServerMessageParsing") == 0)
878878
settings->enableNtripServerMessageParsing = d;
879-
else if (strcmp(settingName, "enableBLE") == 0)
880-
settings->enableBLE = d;
879+
else if (strcmp(settingName, "bluetoothRadioType") == 0)
880+
settings->bluetoothRadioType = (BluetoothRadioType_e)d;
881881

882882
//Check for bulk settings (constellations, message rates, ESPNOW Peers)
883883
//Must be last on else list

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ void menuSystem()
152152
Serial.printf("z) Set time zone offset: %02d:%02d:%02d\r\n", settings.timeZoneHours, settings.timeZoneMinutes, settings.timeZoneSeconds);
153153

154154
Serial.print(F("b) Set Bluetooth Mode: "));
155-
if (settings.enableBLE == true)
155+
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
156+
Serial.println(F("Classic"));
157+
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
156158
Serial.println(F("BLE"));
157159
else
158-
Serial.println(F("Classic"));
160+
Serial.println(F("Off"));
159161

160162
Serial.println("r) Reset all settings to default");
161163

@@ -206,12 +208,13 @@ void menuSystem()
206208
{
207209
// Restart Bluetooth
208210
bluetoothStop();
209-
if (settings.enableBLE == false)
210-
settings.enableBLE = true;
211-
else
212-
settings.enableBLE = false;
211+
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_SPP)
212+
settings.bluetoothRadioType = BLUETOOTH_RADIO_BLE;
213+
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
214+
settings.bluetoothRadioType = BLUETOOTH_RADIO_OFF;
215+
else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_OFF)
216+
settings.bluetoothRadioType = BLUETOOTH_RADIO_SPP;
213217
bluetoothStart();
214-
215218
}
216219
else if (incoming == 'r')
217220
{

Firmware/RTK_Surveyor/settings.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,18 @@ enum RtcmTransportState
164164
RTCM_TRANSPORT_STATE_CHECK_CRC
165165
};
166166

167-
typedef enum radioType_e
167+
typedef enum RadioType_e
168168
{
169169
RADIO_EXTERNAL = 0,
170170
RADIO_ESPNOW,
171-
} radioType_e;
171+
} RadioType_e;
172+
173+
typedef enum BluetoothRadioType_e
174+
{
175+
BLUETOOTH_RADIO_SPP = 0,
176+
BLUETOOTH_RADIO_BLE,
177+
BLUETOOTH_RADIO_OFF,
178+
} BluetoothRadioType_e;
172179

173180
//Radio status LED goes from off (LED off), no connection (blinking), to connected (solid)
174181
enum BTState
@@ -462,11 +469,11 @@ typedef struct {
462469
bool enablePrintNtripClientRtcm = false;
463470
bool enablePrintStates = true;
464471
bool enablePrintDuplicateStates = false;
465-
radioType_e radioType = RADIO_EXTERNAL;
472+
RadioType_e radioType = RADIO_EXTERNAL;
466473
uint8_t espnowPeers[5][6]; //Max of 5 peers. Contains the MAC addresses (6 bytes) of paired units
467474
uint8_t espnowPeerCount;
468475
bool enableNtripServerMessageParsing = false;
469-
bool enableBLE = false;
476+
BluetoothRadioType_e bluetoothRadioType = BLUETOOTH_RADIO_SPP;
470477
} Settings;
471478
Settings settings;
472479

0 commit comments

Comments
 (0)