标题: ESP8266扫描周围WiFi源程序 [打印本页]

作者: LJLAAA    时间: 2020-4-1 21:39
标题: ESP8266扫描周围WiFi源程序
ESP8266扫描周围WiFi的APP


源程序如下:
  1. #include "scanwifi.h"
  2. #include "ets_sys.h"
  3. #include "os_type.h"
  4. #include "osapi.h"
  5. #include "mem.h"
  6. #include "user_interface.h"
  7. #include "gpio.h"
  8. #include "uart.h"
  9. /******************************************************************************
  10. *此区域为编辑区,请需要添加设计的请到此区域编辑!
  11. *******************************************************************************/
  12. at_recvTask(){}//此函数在所有工程中只能创建一次,可插入任意地方
  13. /******************************************************************************/
  14. struct scan_config *scanwifi;
  15. static void ICACHE_FLASH_ATTR
  16. scan_done(void *arg, STATUS status) {
  17. uint8 ssid[33];char temp[128];   
  18. if (status == OK) {
  19.      struct bss_info *bss_link = (struct bss_info *)arg;
  20.     while (bss_link != NULL)
  21.     {os_memset(ssid, 0, 33);
  22.       if (os_strlen(bss_link->ssid) <= 32)
  23.       {os_memcpy(ssid, bss_link->ssid, os_strlen(bss_link->ssid));}
  24.       else
  25.       {os_memcpy(ssid, bss_link->ssid, 32);}
  26.       os_sprintf(temp,"ssid:\"%s\",authmode:%d,通道:%d,mac:\""MACSTR"\",信号:%d\r\n",ssid,bss_link->authmode,bss_link->channel,MAC2STR(bss_link->bssid),bss_link->rssi);
  27.       uart0_sendStr(temp);
  28.       bss_link = bss_link->next.stqe_next; }}
  29. }
  30. void ICACHE_FLASH_ATTR
  31. scanssid(){  //扫描SSID调用函数
  32. wifi_station_scan(scanwifi,scan_done);
  33. }
  34. /******************************************************************************/


  35. /******************************************************************************/
  36. os_timer_t  cyctimer;
  37. void ICACHE_FLASH_ATTR
  38. //时钟周期处理函数
  39. cyctimer_exe(void)
  40. {



  41. scanssid();


  42. }
  43. //时钟周期处理函数结尾
  44. void ICACHE_FLASH_ATTR
  45. cyctimer_stop(void) //停止时钟
  46. {
  47. os_timer_disarm (&cyctimer) ;
  48. }

  49. void ICACHE_FLASH_ATTR
  50. cyctimer_star(void) //启用时钟
  51. {
  52. os_timer_setfn(&cyctimer, (os_timer_func_t *)cyctimer_exe, NULL);
  53. os_timer_arm(&cyctimer,10000,1);
  54. }
  55. /******************************************************************************/

  56. /******************************************************************************
  57. *编辑区结尾,下面是唯一个子程序,也叫接口程序,请不要动其位置!
  58. *******************************************************************************/
  59. void ICACHE_FLASH_ATTR
  60. scanwifi_init(void)
  61. {

  62. cyctimer_star();



  63. }
复制代码

所有资料51hei提供下载:
扫描周围wifi.rar (870.39 KB, 下载次数: 19)


作者: liu5678    时间: 2020-4-1 22:36
感谢分享





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1