Skip to content

Commit

Permalink
make BLE device name and SSID the same
Browse files Browse the repository at this point in the history
  • Loading branch information
BluemarkInnovations authored and tridge committed Jan 10, 2023
1 parent 2a7b080 commit 3faaf98
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions RemoteIDModule/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ void Parameters::load_defaults(void)
}
}

#define IMIN(a,b) ((a)<(b)?(a):(b))

void Parameters::init(void)
{
load_defaults();
Expand Down Expand Up @@ -303,13 +305,18 @@ void Parameters::init(void)
}
}
}

//fall back options for ssid. If the uas_id is not set, use the 4 chars from the MAC address instead
if (strlen(g.wifi_ssid) == 0) {
uint8_t mac[6] {};
esp_read_mac(mac, ESP_MAC_WIFI_STA);
snprintf(wifi_ssid, 20, "RID_%02x%02x%02x%02x%02x%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

if (strlen(g.uas_id) == 0) {
uint8_t mac[6] {};
esp_read_mac(mac, ESP_MAC_WIFI_STA);
snprintf(wifi_ssid, 20, "RID_02x%02x",
mac[4], mac[5]);
} else {
const uint8_t ID_len = strlen(g.uas_id);
const uint8_t ID_tail = IMIN(4, ID_len);
snprintf(wifi_ssid, 20, "RID_%s", &g.uas_id[ID_len-ID_tail]);
}
}

if (g.done_init == 0) {
Expand Down

0 comments on commit 3faaf98

Please sign in to comment.