RAK411/RAK421扫描获取网络函数示例



  • rak_scan_t ScanFrame;
    do {
    	ScanFrame.channel=0;
    	ScanFrame.ssid[0]=0;
    	retval=  rak_uscan(&ScanFrame);
    	if(retval!=RUN_OK)
    	{
    		return retval;
    	}
    	else
    	{                    
    		RAK_RESPONSE_TIMEOUT(RAK_SCAN_IMEOUT);
    		rak_read_packet(&uCmdRspFrame);
    		printf("scan retval =%d\r\n",uCmdRspFrame.scanResponse.status);
    		rak_clearPktIrq();
    		if (uCmdRspFrame.scanResponse.status==0)
    		{ 
    			printf("Scan num =%d\r\n",uCmdRspFrame.scanResponse.ap_num);
    			break;
    		}else {
    			delay_ms(100);
    		}
      } 
     }while(1);
    	
     rak_getscan_t GetScanFrame;
     GetScanFrame.scan_num=uCmdRspFrame.scanResponse.ap_num;
     retval=  rak_getscan(&GetScanFrame);
     if(retval!=RUN_OK)
    	{
    		return retval;
    	}else{                    
    		RAK_RESPONSE_TIMEOUT(RAK_GETSCAN_IMEOUT);
    		rak_read_packet(&uCmdRspFrame);
    		for (int i=0;i<GetScanFrame.scan_num;i++)
    		{
    		printf("%s  ch=%d   rssi=-%d   security=0x%x\r\n",uCmdRspFrame.getscanResponse.strScanInfo[i].ssid,
    		                                           uCmdRspFrame.getscanResponse.strScanInfo[i].rfChannel,
    		                                           255-uCmdRspFrame.getscanResponse.strScanInfo[i].rssiVal,
    		                                           uCmdRspFrame.getscanResponse.strScanInfo[i].securityMode);
    		}
    		rak_clearPktIrq();	
    }


  • 发现是在读应答数据之前获得长度为零,需要再读一次才能将数据长度读到。这个手册没有写。



  • rak_uscan 和 编程手册上的命令名不是一一对应的? 需要参考编程手册上的命令 去 代码库中寻找类似功能大库函数哈?


登录后回复
 

与 RAK支持中心 的连接断开,我们正在尝试重连,请耐心等待