summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2024-04-24 19:58:06 +0200
committerDamien George <damien@micropython.org>2024-07-12 01:03:46 +1000
commit20b00ca501f5e7ff096ae3e31c3e7e7d99963d23 (patch)
treea4e43c1ea9c6af9d1ec4efa09ce5171bb7c3567f
parent2be45dd682f0ce01e4a1061375e96ce2c501a187 (diff)
extmod/network_nina: Fix the AP security mode constants.
The only AP security mode supported is actually WPA/WPA2 not WEP. The firmware command `0x19` starts the AP using `WIFI_AUTH_WPA_WPA2_PSK` mode. There are no functional changes in this commit, it just fixes the constant names and removes the useless sanity checks for WEP. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
-rw-r--r--drivers/ninaw10/nina_wifi_drv.c8
-rw-r--r--extmod/network_ninaw10.c14
2 files changed, 5 insertions, 17 deletions
diff --git a/drivers/ninaw10/nina_wifi_drv.c b/drivers/ninaw10/nina_wifi_drv.c
index 6e4df8429..1aaeec5a0 100644
--- a/drivers/ninaw10/nina_wifi_drv.c
+++ b/drivers/ninaw10/nina_wifi_drv.c
@@ -95,7 +95,7 @@ typedef enum {
// AP mode commands.
NINA_CMD_START_AP_OPEN = 0x18,
- NINA_CMD_START_AP_WEP = 0x19,
+ NINA_CMD_START_AP_WPA = 0x19,
// AP mode scan commands.
NINA_CMD_AP_START_SCAN = 0x36,
@@ -395,7 +395,7 @@ int nina_start_ap(const char *ssid, uint8_t security, const char *key, uint16_t
uint8_t status = NINA_STATUS_AP_FAILED;
if ((key == NULL && security != NINA_SEC_OPEN) ||
- (security != NINA_SEC_OPEN && security != NINA_SEC_WEP)) {
+ (security != NINA_SEC_OPEN && security != NINA_SEC_WPA_PSK)) {
return -1;
}
@@ -406,8 +406,8 @@ int nina_start_ap(const char *ssid, uint8_t security, const char *key, uint16_t
return -1;
}
break;
- case NINA_SEC_WEP:
- if (nina_send_command_read_ack(NINA_CMD_START_AP_WEP,
+ case NINA_SEC_WPA_PSK:
+ if (nina_send_command_read_ack(NINA_CMD_START_AP_WPA,
3, ARG_8BITS, NINA_ARGS(ARG_STR(ssid), ARG_STR(key), ARG_BYTE(channel))) != SPI_ACK) {
return -1;
}
diff --git a/extmod/network_ninaw10.c b/extmod/network_ninaw10.c
index 62961f871..a9abd5776 100644
--- a/extmod/network_ninaw10.c
+++ b/extmod/network_ninaw10.c
@@ -266,7 +266,7 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_key, MP_ARG_OBJ, {.u_obj = mp_const_none} },
- { MP_QSTR_security, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
+ { MP_QSTR_security, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = NINA_SEC_WPA_PSK} },
{ MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
};
@@ -277,7 +277,6 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
// get ssid
const char *ssid = mp_obj_str_get_str(args[ARG_ssid].u_obj);
-
if (strlen(ssid) == 0) {
mp_raise_ValueError(MP_ERROR_TEXT("SSID can't be empty"));
}
@@ -290,12 +289,6 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
// get security mode
mp_uint_t security = args[ARG_security].u_int;
- if (security == -1 && self->itf == MOD_NETWORK_STA_IF) {
- security = NINA_SEC_WPA_PSK;
- } else if (security == -1 && self->itf == MOD_NETWORK_AP_IF) {
- security = NINA_SEC_WEP;
- }
-
// Ensure that the key is not empty if a security mode is used.
if (security != NINA_SEC_OPEN && strlen(key) == 0) {
mp_raise_ValueError(MP_ERROR_TEXT("key can't be empty"));
@@ -326,11 +319,6 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
soft_timer_reinsert(&mp_wifi_poll_timer, NINAW10_POLL_INTERVAL);
} else {
mp_uint_t channel = args[ARG_channel].u_int;
-
- if (security != NINA_SEC_OPEN && security != NINA_SEC_WEP) {
- mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("AP mode only supports WEP or OPEN security modes"));
- }
-
// Initialize WiFi in AP mode.
if (nina_start_ap(ssid, security, key, channel) != 0) {
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("failed to start in AP mode"));