|
|
@@ -102,9 +102,33 @@ int luat_airlink_drv_wlan_disconnect(void) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int luat_airlink_drv_wlan_scan(void);
|
|
|
+int luat_airlink_drv_wlan_scan(void) {
|
|
|
+ uint64_t luat_airlink_next_cmd_id = luat_airlink_get_next_cmd_id();
|
|
|
+ airlink_queue_item_t item = {
|
|
|
+ .len = sizeof(luat_airlink_cmd_t) + 8
|
|
|
+ };
|
|
|
+ luat_airlink_cmd_t* cmd = luat_airlink_cmd_new(0x205, item.len) ;
|
|
|
+ if (cmd == NULL) {
|
|
|
+ return -101;
|
|
|
+ }
|
|
|
+ memcpy(cmd->data, &luat_airlink_next_cmd_id, 8);
|
|
|
+ item.cmd = cmd;
|
|
|
+ luat_airlink_queue_send(LUAT_AIRLINK_QUEUE_CMD, &item);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
-int luat_airlink_drv_wlan_scan_get_result(luat_wlan_scan_result_t *results, size_t ap_limit);
|
|
|
+uint8_t drv_scan_result_size = 0;
|
|
|
+uint8_t *drv_scan_result;
|
|
|
+int luat_airlink_drv_wlan_scan_get_result(luat_wlan_scan_result_t *results, size_t ap_limit) {
|
|
|
+ if (drv_scan_result == NULL || drv_scan_result_size == 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (ap_limit > drv_scan_result_size) {
|
|
|
+ ap_limit = drv_scan_result_size;
|
|
|
+ }
|
|
|
+ memcpy(results, drv_scan_result, ap_limit * sizeof(luat_wlan_scan_result_t));
|
|
|
+ return ap_limit;
|
|
|
+}
|
|
|
|
|
|
int luat_airlink_drv_wlan_set_station_ip(luat_wlan_station_info_t *info);
|
|
|
|
|
|
@@ -134,3 +158,26 @@ int luat_airlink_drv_wlan_get_ap_rssi(void);
|
|
|
int luat_airlink_drv_wlan_get_ap_gateway(char* buff);
|
|
|
|
|
|
|
|
|
+int luat_airlink_drv_wlan_scan_result_cb(void) {
|
|
|
+ #define MAX_SCAN_RESULT_SIZE 33
|
|
|
+ #define MAX_SCAN_RESULT_BUFF_SIZE (sizeof(luat_wlan_scan_result_t) * MAX_SCAN_RESULT_SIZE)
|
|
|
+ size_t fulllen = sizeof(luat_airlink_cmd_t) + 1 + MAX_SCAN_RESULT_BUFF_SIZE;
|
|
|
+ uint8_t* ptr = luat_heap_opt_zalloc(AIRLINK_MEM_TYPE, fulllen);
|
|
|
+ if (ptr == NULL) {
|
|
|
+ LLOGD("内存不足, 无法发送扫描结果");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ luat_wlan_scan_result_t *scan_result = ptr + sizeof(luat_airlink_cmd_t) + 1;
|
|
|
+
|
|
|
+ uint64_t luat_airlink_next_cmd_id = luat_airlink_get_next_cmd_id();
|
|
|
+ airlink_queue_item_t item = {
|
|
|
+ .len = fulllen,
|
|
|
+ .cmd = ptr
|
|
|
+ };
|
|
|
+ item.cmd->cmd = 0x206;
|
|
|
+ item.cmd->len = 1 + MAX_SCAN_RESULT_BUFF_SIZE;
|
|
|
+ item.cmd->data[0] = (uint8_t)luat_wlan_scan_get_result(scan_result, MAX_SCAN_RESULT_SIZE);;
|
|
|
+ luat_airlink_queue_send(LUAT_AIRLINK_QUEUE_CMD, &item);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|