Skip to content

Commit 4f9f035

Browse files
committed
wip
1 parent f2e720f commit 4f9f035

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

ports/zephyr-cp/common-hal/socketpool/Socket.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ static bool _socketpool_socket(socketpool_socketpool_obj_t *self,
184184
socketpool_socketpool_addressfamily_t family, socketpool_socketpool_sock_t type,
185185
int proto,
186186
socketpool_socket_obj_t *sock) {
187+
printk("socketpool_socket\n");
188+
187189
int addr_family;
188190
int ipproto;
189191

@@ -245,6 +247,9 @@ bool socketpool_socket(socketpool_socketpool_obj_t *self,
245247

246248
socketpool_socket_obj_t *common_hal_socketpool_socket(socketpool_socketpool_obj_t *self,
247249
socketpool_socketpool_addressfamily_t family, socketpool_socketpool_sock_t type, int proto) {
250+
printk("common_hal_socketpool_socket\n");
251+
252+
248253
switch (family) {
249254
#if CIRCUITPY_SOCKETPOOL_IPV6
250255
case SOCKETPOOL_AF_INET6:
@@ -343,6 +348,8 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o
343348

344349
size_t common_hal_socketpool_socket_bind(socketpool_socket_obj_t *self,
345350
const char *host, size_t hostlen, uint32_t port) {
351+
printk("common_hal_socketpool_socket_bind\n");
352+
346353
// struct sockaddr_storage bind_addr;
347354
const char *broadcast = "<broadcast>";
348355

ports/zephyr-cp/common-hal/socketpool/SocketPool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void common_hal_socketpool_socketpool_construct(socketpool_socketpool_obj_t *sel
1515
if (radio != MP_OBJ_FROM_PTR(&common_hal_wifi_radio_obj)) {
1616
mp_raise_ValueError(MP_ERROR_TEXT("SocketPool can only be used with wifi.radio"));
1717
}
18+
printk("common_hal_socketpool_socketpool_construct\n");
1819
}
1920

2021
// common_hal_socketpool_socket is in socketpool/Socket.c to centralize open socket tracking.

ports/zephyr-cp/common-hal/wifi/Radio.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,26 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t
335335
params.psk = password;
336336
params.psk_length = password_len;
337337
params.timeout = (int)timeout;
338+
params.channel = WIFI_CHANNEL_ANY;
339+
params.security = WIFI_SECURITY_TYPE_NONE;
340+
if (password_len > 0) {
341+
params.security = WIFI_SECURITY_TYPE_WPA_PSK;
342+
}
343+
params.mfp = WIFI_MFP_OPTIONAL;
344+
params.eap_ver = 1;
345+
params.ignore_broadcast_ssid = 0;
346+
params.bandwidth = WIFI_FREQ_BANDWIDTH_20MHZ;
338347
if (channel > 0) {
339348
params.band = WIFI_FREQ_BAND_2_4_GHZ;
340349
params.channel = channel;
341350
}
351+
printk("bssid_len: %d\n", bssid_len);
342352
if (bssid_len > 0) {
343353
memcpy(params.bssid, bssid, bssid_len);
344354
}
355+
printk("net_mgmt\n");
345356
int res = net_mgmt(NET_REQUEST_WIFI_CONNECT, self->sta_netif, &params, sizeof(params));
357+
printk("net_mgmt returned\n");
346358
if (res != 0) {
347359
printk("Failed to start connect to wifi %d\n", res);
348360
return WIFI_RADIO_ERROR_AUTH_FAIL;

ports/zephyr-cp/common-hal/wifi/__init__.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ wifi_radio_obj_t common_hal_wifi_radio_obj;
2929
#include <zephyr/kernel.h>
3030
#include <zephyr/net/wifi_mgmt.h>
3131

32+
#include <supp_events.h>
33+
3234
#define MAC_ADDRESS_LENGTH 6
3335

3436
static void schedule_background_on_cp_core(void *arg) {
@@ -43,6 +45,9 @@ static void schedule_background_on_cp_core(void *arg) {
4345

4446
static struct net_mgmt_event_callback wifi_cb;
4547
static struct net_mgmt_event_callback ipv4_cb;
48+
static struct net_mgmt_event_callback supp_cb;
49+
static struct net_mgmt_event_callback iface_cb;
50+
static struct net_mgmt_event_callback l4_cb;
4651

4752
static void _event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, struct net_if *iface) {
4853
wifi_radio_obj_t *self = &common_hal_wifi_radio_obj;
@@ -276,10 +281,25 @@ void common_hal_wifi_init(bool user_initiated) {
276281
NET_EVENT_WIFI_AP_DISABLE_RESULT |
277282
NET_EVENT_WIFI_AP_STA_CONNECTED |
278283
NET_EVENT_WIFI_AP_STA_DISCONNECTED);
284+
net_mgmt_init_event_callback(&iface_cb, _event_handler,
285+
NET_EVENT_IF_UP |
286+
NET_EVENT_IF_DOWN);
287+
net_mgmt_init_event_callback(&l4_cb, _event_handler,
288+
NET_EVENT_L4_CONNECTED |
289+
NET_EVENT_L4_DISCONNECTED);
290+
net_mgmt_init_event_callback(&supp_cb, _event_handler,
291+
NET_EVENT_SUPPLICANT_READY |
292+
NET_EVENT_SUPPLICANT_NOT_READY |
293+
NET_EVENT_SUPPLICANT_IFACE_ADDED |
294+
NET_EVENT_SUPPLICANT_IFACE_REMOVED |
295+
NET_EVENT_SUPPLICANT_IFACE_REMOVING |
296+
NET_EVENT_SUPPLICANT_INT_EVENT);
279297

280298
net_mgmt_init_event_callback(&ipv4_cb, _event_handler, NET_EVENT_IPV4_ADDR_ADD);
281299

282300
net_mgmt_add_event_callback(&wifi_cb);
301+
net_mgmt_add_event_callback(&iface_cb);
302+
net_mgmt_add_event_callback(&supp_cb);
283303
net_mgmt_add_event_callback(&ipv4_cb);
284304

285305
// Set the default hostname capped at NET_HOSTNAME_MAX_LEN characters. We trim off

ports/zephyr-cp/cptools/build_circuitpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"zephyr_serial",
5555
"errno",
5656
"warnings",
57-
"io"
57+
"io",
5858
]
5959
MPCONFIG_FLAGS = ["ulab", "warnings", "alarm", "array", "json", "errno", "io"]
6060

ports/zephyr-cp/prj.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CONFIG_DYNAMIC_INTERRUPTS=y
77
CONFIG_UART_INTERRUPT_DRIVEN=y
88

99
CONFIG_FLASH_MAP_LABELS=y
10-
CONFIG_MAIN_STACK_SIZE=24288
10+
CONFIG_MAIN_STACK_SIZE=32768
1111
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
1212
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
1313

@@ -26,3 +26,7 @@ CONFIG_ASSERT=y
2626
CONFIG_LOG_BLOCK_IN_THREAD=y
2727

2828
CONFIG_EVENTS=y
29+
CONFIG_DEBUG=y
30+
CONFIG_WIFI_NRF70_LOG_LEVEL_INF=y
31+
32+
CONFIG_WIFI_NM_WPA_SUPPLICANT_THREAD_STACK_SIZE=12288

0 commit comments

Comments
 (0)