Skip to content

Commit 3faaf98

Browse files
BluemarkInnovationstridge
authored andcommitted
make BLE device name and SSID the same
1 parent 2a7b080 commit 3faaf98

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

RemoteIDModule/parameters.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ void Parameters::load_defaults(void)
271271
}
272272
}
273273

274+
#define IMIN(a,b) ((a)<(b)?(a):(b))
275+
274276
void Parameters::init(void)
275277
{
276278
load_defaults();
@@ -303,13 +305,18 @@ void Parameters::init(void)
303305
}
304306
}
305307
}
306-
308+
//fall back options for ssid. If the uas_id is not set, use the 4 chars from the MAC address instead
307309
if (strlen(g.wifi_ssid) == 0) {
308-
uint8_t mac[6] {};
309-
esp_read_mac(mac, ESP_MAC_WIFI_STA);
310-
snprintf(wifi_ssid, 20, "RID_%02x%02x%02x%02x%02x%02x",
311-
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
312-
310+
if (strlen(g.uas_id) == 0) {
311+
uint8_t mac[6] {};
312+
esp_read_mac(mac, ESP_MAC_WIFI_STA);
313+
snprintf(wifi_ssid, 20, "RID_02x%02x",
314+
mac[4], mac[5]);
315+
} else {
316+
const uint8_t ID_len = strlen(g.uas_id);
317+
const uint8_t ID_tail = IMIN(4, ID_len);
318+
snprintf(wifi_ssid, 20, "RID_%s", &g.uas_id[ID_len-ID_tail]);
319+
}
313320
}
314321

315322
if (g.done_init == 0) {

0 commit comments

Comments
 (0)