diff options
author | Mark <markxr@gmail.com> | 2016-06-04 16:43:32 +0100 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-06-04 22:02:01 +0300 |
commit | 822e9ca8f3d2f63c7477bb7fb859b5d9ad948a3b (patch) | |
tree | d5fd7ed10448222019ed0d02f961c5b6d76ce08e /esp8266 | |
parent | a1a261d8e892007dd01a51255978ac601c0b427f (diff) | |
download | micropython-822e9ca8f3d2f63c7477bb7fb859b5d9ad948a3b.tar.gz micropython-822e9ca8f3d2f63c7477bb7fb859b5d9ad948a3b.zip |
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.
Diffstat (limited to 'esp8266')
-rw-r--r-- | esp8266/modnetwork.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/esp8266/modnetwork.c b/esp8266/modnetwork.c index c0763ce0eb..7cfa3ff77a 100644 --- a/esp8266/modnetwork.c +++ b/esp8266/modnetwork.c @@ -142,7 +142,13 @@ STATIC void esp_scan_cb(scaninfo *si, STATUS status) { struct bss_info *bs; STAILQ_FOREACH(bs, si->pbss, next) { mp_obj_tuple_t *t = mp_obj_new_tuple(6, NULL); + #if 1 + // struct bss_info::ssid_len is not documented in SDK API Guide, + // but is present in SDK headers since 1.4.0 + t->items[0] = mp_obj_new_bytes(bs->ssid, bs->ssid_len); + #else t->items[0] = mp_obj_new_bytes(bs->ssid, strlen((char*)bs->ssid)); + #endif t->items[1] = mp_obj_new_bytes(bs->bssid, sizeof(bs->bssid)); t->items[2] = MP_OBJ_NEW_SMALL_INT(bs->channel); t->items[3] = MP_OBJ_NEW_SMALL_INT(bs->rssi); |