Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cyw43.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ typedef struct _cyw43_t {
#if CYW43_ENABLE_BLUETOOTH
bool bt_loaded;
#endif
#if CYW43_ASSOC_CALLBACK
void (*assoc_cb)(bool assoc);
#endif
} cyw43_t;

extern cyw43_t cyw43_state;
Expand Down
33 changes: 28 additions & 5 deletions src/cyw43_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ void cyw43_init(cyw43_t *self) {
#if CYW43_ENABLE_BLUETOOTH
self->bt_loaded = false;
#endif
#if CYW43_ASSOC_CALLBACK
self->assoc_cb = NULL;
#endif
}

void cyw43_deinit(cyw43_t *self) {
Expand Down Expand Up @@ -342,11 +345,23 @@ void cyw43_cb_process_async_event(void *cb_data, const cyw43_async_event_t *ev)
cyw43_cb_tcpip_set_link_down(self, CYW43_ITF_STA);
self->wifi_join_state = 0x0000;

#if 0
// WiFi ap events
#if CYW43_ASSOC_CALLBACK
} else if (ev->event_type == CYW43_EV_ASSOC_IND) {
if (ev->interface == CYW43_ITF_AP) {
if (self->assoc_cb) {
self->assoc_cb(true);
}
}
} else if (ev->event_type == CYW43_EV_DISASSOC_IND) {
if (ev->interface == CYW43_ITF_AP) {
#if 0
// Station disassociated with our AP, let DHCP server know so it can free the IP address
dhcp_server_disassoc(&self->dhcp_server, buf + 24);
#endif
if (self->assoc_cb) {
self->assoc_cb(false);
}
}
#endif

Expand Down Expand Up @@ -382,10 +397,18 @@ void cyw43_cb_process_async_event(void *cb_data, const cyw43_async_event_t *ev)
self->wifi_join_state = WIFI_JOIN_STATE_BADAUTH;
}
} else if (ev->event_type == CYW43_EV_DEAUTH_IND) {
if (ev->status == 0 && ev->reason == 2) {
// Deauth, probably because password was wrong; disassociate
self->pend_disassoc = true;
cyw43_schedule_internal_poll_dispatch(cyw43_poll_func);
if (ev->interface == CYW43_ITF_STA) {
if (ev->status == 0 && ev->reason == 2) {
// Deauth, probably because password was wrong; disassociate
self->pend_disassoc = true;
cyw43_schedule_internal_poll_dispatch(cyw43_poll_func);
}
#if CYW43_ASSOC_CALLBACK
} else {
if (self->assoc_cb) {
self->assoc_cb(false);
}
#endif
}
} else if (ev->event_type == CYW43_EV_LINK) {
if (ev->status == 0) {
Expand Down
1 change: 1 addition & 0 deletions src/cyw43_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#define CYW43_EV_DEAUTH (5)
#define CYW43_EV_DEAUTH_IND (6)
#define CYW43_EV_ASSOC (7)
#define CYW43_EV_ASSOC_IND (8)
#define CYW43_EV_DISASSOC (11)
#define CYW43_EV_DISASSOC_IND (12)
#define CYW43_EV_LINK (16)
Expand Down