Ejemplo n.º 1
0
static int wps_find_out_triger_wps_AP(char *target_ssid, u16 config_method)
{
	internal_wps_scan_handler_arg_t wps_arg = {0};

	wps_password_id = 0xFF;

	wps_arg.isoverlap = -1;
	wps_arg.config_method = config_method;
	wps_arg.target_ssid = target_ssid;
	rtw_init_sema(&wps_arg.scan_sema, 0);
	if(wps_arg.scan_sema == NULL) return RTW_ERROR;

	if(wifi_scan_networks(wps_scan_result_handler, &wps_arg ) != RTW_SUCCESS){
		printf("\n\rERROR: wifi scan failed");
		goto exit;
	}
	if(rtw_down_timeout_sema(&wps_arg.scan_sema, SCAN_LONGEST_WAIT_TIME) == RTW_FALSE){
		printf("\r\nWPS scan done early!\r\n");
	}

exit:
	rtw_free_sema(&wps_arg.scan_sema);
	
	return wps_arg.isoverlap;
}
Ejemplo n.º 2
0
int rthw_wifi_scan(scan_callback_fn fun, void *data)
{
    struct scan_user_data *user_data;

    if (fun == RT_NULL)
    {
        rt_kprintf("scan callback fun is null\n");
        return -1;
    }
    user_data = rt_malloc(sizeof(struct scan_user_data));
    if (user_data == RT_NULL)
    {
        rt_kprintf("wifi scan malloc fail\n");
        return -1;
    }
    user_data->fun = fun;
    user_data->data = data;

    if (wifi_scan_networks(rthw_wifi_scan_result_handler, user_data) != RTW_SUCCESS)
    {
        rt_kprintf("ERROR: wifi scan failed\n\r");
        return -1;
    }

    return 0;
}
Ejemplo n.º 3
0
void fATWS(void *arg){
        char buf[32] = {0};
        u8 *channel_list = NULL;
        u8 *pscan_config = NULL;
        int num_channel = 0;
        int i, argc = 0;
        char *argv[MAX_ARGC] = {0};        
        printf("[ATWS]: _AT_WLAN_SCAN_\n\r");
        if(arg){
          strcpy(buf, arg);
          argc = parse_param(buf, argv);
          if(argc < 2)
            goto exit;
          num_channel = atoi(argv[1]);
          channel_list = (u8*)malloc(num_channel);
          if(!channel_list){
                  printf("[ATWS]ERROR: Can't malloc memory for channel list\n\r");
                  goto exit;
          }
          pscan_config = (u8*)malloc(num_channel);
	  	  if(!pscan_config){
				printf("[ATWS]ERROR: Can't malloc memory for pscan_config\n\r");
				goto exit;
		  }
          //parse command channel list
          for(i = 2; i <= argc -1 ; i++){
                  *(channel_list + i - 2) = (u8)atoi(argv[i]);
                  *(pscan_config + i - 2) = PSCAN_ENABLE;
          }
          
          if(wifi_set_pscan_chan(channel_list, pscan_config, num_channel) < 0){
              printf("[ATWS]ERROR: wifi set partial scan channel fail\n\r");
              goto exit;
          }
        }
        
	if(wifi_scan_networks(app_scan_result_handler, NULL ) != RTW_SUCCESS){
		printf("[ATWS]ERROR: wifi scan failed\n\r");
		goto exit;
	}
exit:
	if(arg && channel_list)
		free(channel_list);
}