|
76 | 76 |
|
77 | 77 | extern void tcp_debug_print_pcbs(void); |
78 | 78 | extern bool ifStatus; |
| 79 | +extern bool scanNetCompleted; |
79 | 80 |
|
80 | 81 | static char buf[CMD_MAX_LEN]; |
81 | 82 | static char reply[REPLY_MAX_LEN]; |
@@ -1004,22 +1005,45 @@ static void copy_network_list(struct wl_network_list_t *dst, |
1004 | 1005 | } |
1005 | 1006 | } |
1006 | 1007 |
|
| 1008 | +int start_scan_net_cmd_cb(int numParam, char* buf, void* ctx) { |
| 1009 | + wl_err_t err = WL_FAILURE; |
| 1010 | + |
| 1011 | + INFO_SPI("Start Network Scan %d\n", numParam); |
| 1012 | + if (scanNetCompleted){ |
| 1013 | + scanNetCompleted = false; |
| 1014 | + err = wl_scan(); |
| 1015 | + if (err != WL_SUCCESS) |
| 1016 | + { |
| 1017 | + // May be busy scanning already, no fatal error |
| 1018 | + WARN("err=%d\n", err); |
| 1019 | + err = WL_SUCCESS; |
| 1020 | + } |
| 1021 | + } |
| 1022 | + return err; |
| 1023 | +} |
1007 | 1024 |
|
1008 | 1025 | cmd_spi_state_t get_reply_scan_networks_cb(char* recv, char* reply, void* ctx, uint16_t* count) { |
1009 | 1026 |
|
1010 | | - INFO_SPI("netif:0x%x\n", ard_netif); |
1011 | | - CHECK_ARD_NETIF(recv, reply, count); |
| 1027 | + const int8_t SCAN_NOT_YET_COMPLETED = 0; |
1012 | 1028 |
|
1013 | | - int network_cnt = 0; |
| 1029 | + if (!scanNetCompleted) |
| 1030 | + { |
| 1031 | + //return empty list with an error to retry |
| 1032 | + CREATE_HEADER_REPLY(reply, recv, SCAN_NOT_YET_COMPLETED); |
| 1033 | + END_HEADER_REPLY(reply, 3, *count); |
| 1034 | + INFO_SPI("Scan not completed!\n"); |
| 1035 | + return SPI_CMD_DONE; |
| 1036 | + } |
1014 | 1037 |
|
| 1038 | + int network_cnt = 0; |
1015 | 1039 | struct wl_network_list_t* wl_network_list; |
1016 | 1040 |
|
1017 | | - wl_scan(); |
1018 | 1041 | wl_get_network_list(&wl_network_list); |
1019 | 1042 | if (wl_network_list->cnt == 0) |
1020 | 1043 | { |
1021 | 1044 | CREATE_HEADER_REPLY(reply, recv, 0); |
1022 | 1045 | END_HEADER_REPLY(reply, 3, *count); |
| 1046 | + INFO_SPI("Networks not found!\n"); |
1023 | 1047 | return SPI_CMD_DONE; |
1024 | 1048 | } |
1025 | 1049 |
|
@@ -1354,6 +1378,7 @@ void init_spi_cmds() { |
1354 | 1378 | spi_add_cmd(GET_CURR_BSSID_CMD, ack_cmd_cb, get_reply_curr_net_cb, (void*)GET_CURR_BSSID_CMD, CMD_GET_FLAG); |
1355 | 1379 | spi_add_cmd(GET_CURR_RSSI_CMD, ack_cmd_cb, get_reply_curr_net_cb, (void*)GET_CURR_RSSI_CMD, CMD_GET_FLAG); |
1356 | 1380 | spi_add_cmd(GET_CURR_ENCT_CMD, ack_cmd_cb, get_reply_curr_net_cb, (void*)GET_CURR_ENCT_CMD, CMD_GET_FLAG); |
| 1381 | + spi_add_cmd(START_SCAN_NETWORKS, start_scan_net_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG); |
1357 | 1382 | spi_add_cmd(SCAN_NETWORKS, ack_cmd_cb, get_reply_scan_networks_cb, NULL, CMD_GET_FLAG); |
1358 | 1383 | spi_add_cmd(DISCONNECT_CMD, disconnect_cmd_cb, ack_reply_cb, NULL, CMD_SET_FLAG); |
1359 | 1384 | spi_add_cmd(GET_IDX_ENCT_CMD, ack_cmd_cb, get_reply_idx_net_cb, (void*)GET_IDX_ENCT_CMD, CMD_GET_FLAG); |
|
0 commit comments