Skip to content

Commit 822e9ca

Browse files
MarkR42pfalcon
authored andcommitted
esp8266/modnetwork: Use struct bss_info::ssid_len for ESSID length.
Instead of calling strlen(), which won't work if there're 32 chars in returned ESSID. struct bss_info::ssid_len is not documented in SDK API Guide, but is present in SDK headers since 1.4.0. Just in case, previous code is left commented.
1 parent a1a261d commit 822e9ca

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

esp8266/modnetwork.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ STATIC void esp_scan_cb(scaninfo *si, STATUS status) {
142142
struct bss_info *bs;
143143
STAILQ_FOREACH(bs, si->pbss, next) {
144144
mp_obj_tuple_t *t = mp_obj_new_tuple(6, NULL);
145+
#if 1
146+
// struct bss_info::ssid_len is not documented in SDK API Guide,
147+
// but is present in SDK headers since 1.4.0
148+
t->items[0] = mp_obj_new_bytes(bs->ssid, bs->ssid_len);
149+
#else
145150
t->items[0] = mp_obj_new_bytes(bs->ssid, strlen((char*)bs->ssid));
151+
#endif
146152
t->items[1] = mp_obj_new_bytes(bs->bssid, sizeof(bs->bssid));
147153
t->items[2] = MP_OBJ_NEW_SMALL_INT(bs->channel);
148154
t->items[3] = MP_OBJ_NEW_SMALL_INT(bs->rssi);

0 commit comments

Comments
 (0)