Skip to content

Commit d135d44

Browse files
committed
Limit device name length during BLE.
1 parent 623e933 commit d135d44

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Firmware/RTK_Surveyor/Bluetooth.ino

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,28 @@ void bluetoothStart()
158158
else
159159
log_d("State out of range for Bluetooth Broadcast: %d", systemState);
160160

161-
snprintf(deviceName, sizeof(deviceName), "%s %s%02X%02X", platformPrefix, stateName, btMACAddress[4],
161+
char productName[50] = {0};
162+
strncpy(productName, platformPrefix, sizeof(productName));
163+
164+
// BLE is limited to ~28 characters in the device name. Shorten platformPrefix if needed.
165+
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
166+
{
167+
if (strcmp(productName, "Facet L-Band Direct") == 0)
168+
{
169+
strncpy(productName, "Facet L-Band", sizeof(productName));
170+
}
171+
}
172+
173+
snprintf(deviceName, sizeof(deviceName), "%s %s%02X%02X", productName, stateName, btMACAddress[4],
162174
btMACAddress[5]);
163175

176+
if (strlen(deviceName) > 28)
177+
{
178+
if (ENABLE_DEVELOPER)
179+
systemPrintf("Warning! The Bluetooth device name '%s' is %d characters long. It may not work in BLE mode.\r\n", deviceName,
180+
strlen(deviceName));
181+
}
182+
164183
// Select Bluetooth setup
165184
if (settings.bluetoothRadioType == BLUETOOTH_RADIO_OFF)
166185
return;

0 commit comments

Comments
 (0)