mirror of https://github.com/noisymime/Arduino.git
Fix ScanNetworks list
This commit is contained in:
parent
4ed671bdfb
commit
85c054756d
Binary file not shown.
|
@ -76,6 +76,7 @@
|
|||
|
||||
extern void tcp_debug_print_pcbs(void);
|
||||
extern bool ifStatus;
|
||||
extern bool scanNetCompleted;
|
||||
|
||||
static char buf[CMD_MAX_LEN];
|
||||
static char reply[REPLY_MAX_LEN];
|
||||
|
@ -1004,22 +1005,45 @@ static void copy_network_list(struct wl_network_list_t *dst,
|
|||
}
|
||||
}
|
||||
|
||||
int start_scan_net_cmd_cb(int numParam, char* buf, void* ctx) {
|
||||
wl_err_t err = WL_FAILURE;
|
||||
|
||||
INFO_SPI("Start Network Scan %d\n", numParam);
|
||||
if (scanNetCompleted){
|
||||
scanNetCompleted = false;
|
||||
err = wl_scan();
|
||||
if (err != WL_SUCCESS)
|
||||
{
|
||||
// May be busy scanning already, no fatal error
|
||||
WARN("err=%d\n", err);
|
||||
err = WL_SUCCESS;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
cmd_spi_state_t get_reply_scan_networks_cb(char* recv, char* reply, void* ctx, uint16_t* count) {
|
||||
|
||||
INFO_SPI("netif:0x%x\n", ard_netif);
|
||||
CHECK_ARD_NETIF(recv, reply, count);
|
||||
const int8_t SCAN_NOT_YET_COMPLETED = 0;
|
||||
|
||||
if (!scanNetCompleted)
|
||||
{
|
||||
//return empty list with an error to retry
|
||||
CREATE_HEADER_REPLY(reply, recv, SCAN_NOT_YET_COMPLETED);
|
||||
END_HEADER_REPLY(reply, 3, *count);
|
||||
INFO_SPI("Scan not completed!\n");
|
||||
return SPI_CMD_DONE;
|
||||
}
|
||||
|
||||
int network_cnt = 0;
|
||||
|
||||
struct wl_network_list_t* wl_network_list;
|
||||
|
||||
wl_scan();
|
||||
wl_get_network_list(&wl_network_list);
|
||||
if (wl_network_list->cnt == 0)
|
||||
{
|
||||
CREATE_HEADER_REPLY(reply, recv, 0);
|
||||
END_HEADER_REPLY(reply, 3, *count);
|
||||
INFO_SPI("Networks not found!\n");
|
||||
return SPI_CMD_DONE;
|
||||
}
|
||||
|
||||
|
@ -1354,6 +1378,7 @@ void init_spi_cmds() {
|
|||
spi_add_cmd(GET_CURR_BSSID_CMD, ack_cmd_cb, get_reply_curr_net_cb, (void*)GET_CURR_BSSID_CMD, CMD_GET_FLAG);
|
||||
spi_add_cmd(GET_CURR_RSSI_CMD, ack_cmd_cb, get_reply_curr_net_cb, (void*)GET_CURR_RSSI_CMD, CMD_GET_FLAG);
|
||||
spi_add_cmd(GET_CURR_ENCT_CMD, ack_cmd_cb, get_reply_curr_net_cb, (void*)GET_CURR_ENCT_CMD, CMD_GET_FLAG);
|
||||
spi_add_cmd(START_SCAN_NETWORKS, start_scan_net_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG);
|
||||
spi_add_cmd(SCAN_NETWORKS, ack_cmd_cb, get_reply_scan_networks_cb, NULL, CMD_GET_FLAG);
|
||||
spi_add_cmd(DISCONNECT_CMD, disconnect_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG);
|
||||
spi_add_cmd(GET_IDX_ENCT_CMD, ack_cmd_cb, get_reply_idx_net_cb, (void*)GET_IDX_ENCT_CMD, CMD_GET_FLAG);
|
||||
|
|
|
@ -84,6 +84,7 @@ struct ctx_server {
|
|||
};
|
||||
|
||||
bool ifStatus = false;
|
||||
bool scanNetCompleted = false;
|
||||
|
||||
// to maintain the word alignment
|
||||
//#define PAD_CTX_SIZE 0x18
|
||||
|
@ -105,6 +106,7 @@ wl_cm_scan_cb(void* ctx)
|
|||
{
|
||||
INFO_INIT("Scan Completed!\n");
|
||||
set_result(WL_SCAN_COMPLETED);
|
||||
scanNetCompleted=true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,7 +338,7 @@ wl_init_complete_cb(void* ctx)
|
|||
|
||||
INFO_INIT("Starting CM...\n");
|
||||
/* start connection manager */
|
||||
wl_status = wl_cm_init(NULL, wl_cm_conn_cb, wl_cm_disconn_cb, hs);
|
||||
wl_status = wl_cm_init(wl_cm_scan_cb, wl_cm_conn_cb, wl_cm_disconn_cb, hs);
|
||||
ASSERT(wl_status == WL_SUCCESS, "failed to init wl conn mgr");
|
||||
wl_cm_start();
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ enum {
|
|||
GET_IDX_ENCT_CMD = 0x33,
|
||||
REQ_HOST_BY_NAME_CMD= 0x34,
|
||||
GET_HOST_BY_NAME_CMD= 0x35,
|
||||
START_SCAN_NETWORKS = 0x36,
|
||||
|
||||
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||
|
||||
SEND_DATA_TCP_CMD = 0x44,
|
||||
|
|
Loading…
Reference in New Issue