8000 extmod/network_nina: Fix the AP security mode constants. · scy/micropython@20b00ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 20b00ca

Browse files
iabdalkaderdpgeorge
authored andcommitted
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>
1 parent 2be45dd commit 20b00ca

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

drivers/ninaw10/nina_wifi_drv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ typedef enum {
9595

9696
// AP mode commands.
9797
NINA_CMD_START_AP_OPEN = 0x18,
98-
NINA_CMD_START_AP_WEP = 0x19,
98+
NINA_CMD_START_AP_WPA = 0x19,
9999

100100
// AP mode scan commands.
101101
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
395395
uint8_t status = NINA_STATUS_AP_FAILED;
396396

397397
if ((key == NULL && security != NINA_SEC_OPEN) ||
398-
(security != NINA_SEC_OPEN && security != NINA_SEC_WEP)) {
398+
(security != NINA_SEC_OPEN && security != NINA_SEC_WPA_PSK)) {
399399
return -1;
400400
}
401401

@@ -406,8 +406,8 @@ int nina_start_ap(const char *ssid, uint8_t security, const char *key, uint16_t
406406
return -1;
407407
}
408408
break;
409-
case NINA_SEC_WEP:
410-
if (nina_send_command_read_ack(NINA_CMD_START_AP_WEP,
409+
case NINA_SEC_WPA_PSK:
410+
if (nina_send_command_read_ack(NINA_CMD_START_AP_WPA,
411411
3, ARG_8BITS, NINA_ARGS(ARG_STR(ssid), ARG_STR(key), ARG_BYTE(channel))) != SPI_ACK) {
412412
return -1;
413413
}

extmod/network_ninaw10.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
266266
static const mp_arg_t allowed_args[] = {
267267
{ MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
268268
{ MP_QSTR_key, MP_ARG_OBJ, {.u_obj = mp_const_none} },
269-
{ MP_QSTR_security, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
269+
{ MP_QSTR_security, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = NINA_SEC_WPA_PSK} },
270270
{ MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
271271
};
272272

@@ -277,7 +277,6 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
277277

278278
// get ssid
279279
const char *ssid = mp_obj_str_get_str(args[ARG_ssid].u_obj);
280-
281280
if (strlen(ssid) == 0) {
282281
mp_raise_ValueError(MP_ERROR_TEXT("SSID can't be empty"));
283282
}
@@ -290,12 +289,6 @@ static mp_obj_t network_ninaw10_connect(mp_uint_t n_args, const mp_obj_t *pos_ar
290289

291290
// get security mode
292291
mp_uint_t security = args[ARG_security].u_int;
293-
if (security == -1 && self->itf == MOD_NETWORK_STA_IF) {
294-
security = NINA_SEC_WPA_PSK;
295-
} else if (security == -1 && self->itf == MOD_NETWORK_AP_IF) {
296-
security = NINA_SEC_WEP;
297-
}
298-
299292
// Ensure that the key is not empty if a security mode is used.
300293
if (security != NINA_SEC_OPEN && strlen(key) == 0) {
301294
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
326319
soft_timer_reinsert(&mp_wifi_poll_timer, NINAW10_POLL_INTERVAL);
327320
} else {
328321
mp_uint_t channel = args[ARG_channel].u_int;
329-
330-
if (security != NINA_SEC_OPEN && security != NINA_SEC_WEP) {
331-
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("AP mode only supports WEP or OPEN security modes"));
332-
}
333-
334322
// Initialize WiFi in AP mode.
335323
if (nina_start_ap(ssid, security, key, channel) != 0) {
336324
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("failed to start in AP mode"));

0 commit comments

Comments
 (0)
0