完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
测试平台RTOS V1.4.2
测试现象:wifi_set_promiscuous_rx_cb注册的回调并没有调用,PC一直向6信道发送数据 使用:主要是使用Sniffer模式简单评估信道的利用率 代码如下: /* * ESPRSSIF MIT License * * Copyright (c) 2015 * * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case, * it is free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the Software is furnished * to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include "esp_common.h" #include "user_config.h" #include "uart.h" static void promisc_cb(uint8 *buf, uint16 len); #define printmac(buf, i) printf("t%02X:%02X:%02X:%02X:%02X:%02X", buf[i+0], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5]) /****************************************************************************** * FunctionName : user_rf_cal_sector_set * Description : SDK just reversed 4 sectors, used for rf init data and paramters. * We add this function to force users to set rf cal sector, since * we don't know which sector is free in user's application. * sector map for last several sectors : ABCCC * A : rf cal * B : rf init data * C : sdk parameters * Parameters : none * Returns : rf cal sector *******************************************************************************/ uint32 user_rf_cal_sector_set(void) { flash_size_map size_map = system_get_flash_size_map(); uint32 rf_cal_sec = 0; switch (size_map) { case FLASH_SIZE_4M_MAP_256_256: rf_cal_sec = 128 - 5; break; case FLASH_SIZE_8M_MAP_512_512: rf_cal_sec = 256 - 5; break; case FLASH_SIZE_16M_MAP_512_512: case FLASH_SIZE_16M_MAP_1024_1024: rf_cal_sec = 512 - 5; break; case FLASH_SIZE_32M_MAP_512_512: case FLASH_SIZE_32M_MAP_1024_1024: rf_cal_sec = 1024 - 5; break; default: rf_cal_sec = 0; break; } return rf_cal_sec; } void test_task(void *pvParameters) { while(1) { //printf("SDK version:%sn", system_get_sdk_version()); vTaskDelay(500); /*uint8 new_channel = wifi_get_channel() % 12 + 1; printf("** hop to %d **n", new_channel); wifi_set_channel(new_channel);*/ printf("** channel : %d **n", wifi_get_channel()); } } static void promisc_cb(uint8 *buf, uint16 len) { printf("-> %3d: %d", wifi_get_channel(), len); //printmac(buf, 4); //printmac(buf, 10); //printmac(buf, 16); printf("n"); } /****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { wifi_station_set_auto_connect(0); //uart_init_new(); printf("SDK version:%sn", system_get_sdk_version()); //os_delay_us(100); // Promiscuous works only with station mode printf(" -> Set opmode ... "); wifi_set_opmode( 0x1 );//1---STATION_MODE printf("done.n"); // Set up promiscuous callback wifi_set_channel(6); //wifi_promiscuous_enable(0); printf(" -> Promisc mode setup ... "); wifi_set_promiscuous_rx_cb(promisc_cb); wifi_promiscuous_enable(1); printf("done.n"); xTaskCreate(test_task, "test_task", 512, NULL, 3, NULL); printf(" -> Init finished!nn"); } |
|
相关推荐
1个回答
|
|
在RTOS V1.4.2的Sniffer模式下无法接收到数据,可能是由以下几个原因导致的:
1. 确保您的ESP8266模块支持Sniffer模式。并非所有ESP8266模块都支持此功能。 2. 检查您的代码是否正确配置了Sniffer模式。以下是配置Sniffer模式的示例代码: ```c #include "esp_common.h" #include "esp_wifi.h" void ICACHE_FLASH_ATTR wifi_set_promiscuous_rx_cb(void *cb) { system_os_task(wifi_promiscuous_packet_handler, cb, 1); } void ICACHE_FLASH_ATTR wifi_promiscuous_packet_handler(void *arg) { struct rx_info *info = (struct rx_info *)arg; // 处理接收到的数据包 } ``` 3. 确保您已正确注册了回调函数。使用`wifi_set_promiscuous_rx_cb`函数注册回调函数,如下所示: ```c void user_init(void) { // 初始化WiFi wifi_set_opmode(STATION_MODE); wifi_set_promiscuous_rx_cb(&wifi_promiscuous_packet_handler); } ``` 4. 检查您的PC是否在正确的信道上发送数据。确保您的PC和ESP8266模块都设置为相同的信道(在您的例子中是信道6)。 5. 确保您的ESP8266模块的固件版本与您的代码兼容。如果您使用的是RTOS V1.4.2,请确保您的固件版本也是1.4.2或兼容的版本。 |
|
|
|
只有小组成员才能发言,加入小组>>
988 浏览 1 评论
553浏览 6评论
463浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
447浏览 5评论
448浏览 4评论
421浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 14:53 , Processed in 0.845219 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号