完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我最近一直在玩 SDK,我可以连接到 AP 并闪烁 LED 等等,但是当我尝试扫描附近的 AP 时,状态代码总是显示 FAIL。
这是我的代码,我已经 3 天改变了一些东西,但没有任何效果。希望任何人都可以提示 谢谢! 代码:全选#include "ets_sys.h" #include "osapi.h" #include "gpio.h" #include "os_type.h" #include "ip_addr.h" #include "espconn.h" #include "user_interface.h" #include "user_config.h" #define user_procTaskPrio 0 #define user_procTaskQueueLen 1 os_event_t user_procTaskQueue[user_procTaskQueueLen]; static void loop(os_event_t *events); /** WIFI Functions **/ void ICACHE_FLASH_ATTR wifiInit() { os_printf(">>>%s\n", __FUNCTION__); //wifi_station_set_hostname("autolocator"); wifi_set_opmode(STATION_MODE); os_printf("<<<%s\n", __FUNCTION__); } static void ICACHE_FLASH_ATTR wifiScan_cb(void *arg, STATUS status) { os_printf(">>>%s\n", __FUNCTION__); uint8 ssid[33]; switch (status ) { case OK: os_printf("Status OK\n"); struct bss_info *bss_link = (struct bss_info *)arg; bss_link = bss_link->next.stqe_next;//ignore first while (bss_link != NULL) { os_memset(ssid, 0, 33); if (os_strlen(bss_link->ssid) <= 32) { os_memcpy(ssid, bss_link->ssid, os_strlen(bss_link->ssid)); } else { os_memcpy(ssid, bss_link->ssid, 32); } os_sprintf("+CWLAP:(%d,\"%s\",%d,\""MACSTR"\",%d)\r\n", bss_link->authmode, ssid, bss_link->rssi, MAC2STR(bss_link->bssid), bss_link->channel); bss_link = bss_link->next.stqe_next; } break; case FAIL: os_printf("Status FAIL\n"); break; case PENDING: os_printf("Status PENDING\n"); break; case BUSY: os_printf("Status BUSY\n"); break; case CANCEL: os_printf("Status CANCEL\n"); break; default: os_printf("Status UNKNOWN\n"); break; } os_printf("<<<%s\n", __FUNCTION__); } /** UART Functions **/ void ICACHE_FLASH_ATTR uartInit() { os_printf(">>>%s\n", __FUNCTION__ ); uart_div_modify( 0, UART_CLK_FREQ / ( 115200 ) ); os_printf("<<<%s\n", __FUNCTION__); } /** GPIO Functions **/ void ICACHE_FLASH_ATTR gpioInit() { os_printf(">>>%s\n", __FUNCTION__ ); gpio_init(); os_printf("<<<%s\n", __FUNCTION__); } /** Entry point **/ //Main code function void ICACHE_FLASH_ATTR loop(os_event_t *events) { os_printf(">>>%s\n", __FUNCTION__ ); os_delay_us(1*1000000); wifi_promiscuous_enable(0); os_printf("mode=%u\n",wifi_get_opmode()); os_printf("set mode=%u\n", wifi_set_opmode(STATION_MODE)); os_printf("mode_afterset=%u\n",wifi_get_opmode()); os_printf("scan_result=%u\n",wifi_station_scan(NULL,wifiScan_cb)); system_os_post(user_procTaskPrio, 0, 0); os_printf("<<<%s\n", __FUNCTION__); } void ICACHE_FLASH_ATTR user_rf_pre_init(void) {} //Init function void ICACHE_FLASH_ATTR user_init( void ) { os_printf(">>>%s\n", __FUNCTION__ ); uartInit(); os_delay_us(0.1*1000000); gpioInit(); wifiInit(); //Start os task //os_delay_us(5*1000000); system_os_task(loop, user_procTaskPrio, user_procTaskQueue, user_procTaskQueueLen); system_os_post(user_procTaskPrio, 0, 0); os_printf("<<<%s\n", __FUNCTION__); } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
545浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
437浏览 5评论
441浏览 4评论
411浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 05:29 , Processed in 0.819049 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号