Merge pull request #2169 from openmv/cyw43_sec_mode

ports/all: Fix WiFi AP mode issues.
This commit is contained in:
Ibrahim Abdelkader 2024-03-04 15:24:04 +02:00 committed by GitHub
commit 68296674e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 4 deletions

View File

@ -15,8 +15,9 @@ PORT = 8080 # Arbitrary non-privileged port
# Init wlan module and connect to network
wlan = network.WLAN(network.AP_IF)
wlan.config(ssid=SSID, key=KEY, channel=2)
wlan.active(True)
wlan.config(essid=SSID, key=KEY, security=wlan.WEP, channel=2)
print("AP mode started. SSID: {} IP: {}".format(SSID, wlan.ifconfig()[0]))

View File

@ -25,9 +25,9 @@ sensor.set_pixformat(sensor.GRAYSCALE)
# Init wlan module in AP mode.
wlan = network.WLAN(network.AP_IF)
wlan.config(ssid=SSID, key=KEY, channel=2)
wlan.active(True)
# Note some WiFi modules only support WEP in AP mode.
wlan.config(ssid=SSID, key=KEY, channel=2) # security=wlan.WEP
print("AP mode started. SSID: {} IP: {}".format(SSID, wlan.ifconfig()[0]))
# You can block waiting for client to connect

@ -1 +1 @@
Subproject commit 99baee47ded6c52b2ff1881cb278def56fe8dd0d
Subproject commit 07e3a4c5ad8c29d72619439673e5de7c95c84ad1

View File

@ -135,6 +135,7 @@ soft_reset:
memcpy(&buf[0], "PYBD", 4);
mp_hal_get_mac_ascii(MP_HAL_MAC_WLAN0, 8, 4, (char *) &buf[4]);
cyw43_wifi_ap_set_ssid(&cyw43_state, 8, buf);
cyw43_wifi_ap_set_auth(&cyw43_state, CYW43_AUTH_WPA2_AES_PSK);
cyw43_wifi_ap_set_password(&cyw43_state, 8, (const uint8_t *) "pybd0123");
}
#endif

View File

@ -348,6 +348,7 @@ soft_reset:
memcpy(&buf[0], "PYBD", 4);
mp_hal_get_mac_ascii(MP_HAL_MAC_WLAN0, 8, 4, (char *) &buf[4]);
cyw43_wifi_ap_set_ssid(&cyw43_state, 8, buf);
cyw43_wifi_ap_set_auth(&cyw43_state, CYW43_AUTH_WPA2_AES_PSK);
cyw43_wifi_ap_set_password(&cyw43_state, 8, (const uint8_t *) "pybd0123");
}
#endif

View File

@ -160,6 +160,12 @@ static mp_obj_t py_winc_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Key can't be empty!"));
}
// Activate the interface if it's inactive.
if (!self->active) {
mp_obj_t args[2] = { pos_args[0], MP_OBJ_NEW_SMALL_INT(1) };
py_winc_active(2, args);
}
if (self->itf == WINC_MODE_STA) {
// Initialize WiFi in STA mode.
if (winc_connect(ssid, security, key, M2M_WIFI_CH_ALL) != 0) {