#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
#include "user_interface.h"
#include "driver/uart.h"
#define user_procTaskPrio 0
#define user_procTaskQueueLen 1
#define CHANNEL_HOP_INTERVAL 200
os_event_t user_procTaskQueue[user_procTaskQueueLen];
static volatile os_timer_t channelHop_timer;
static void loop(os_event_t *events);
static void promisc_cb(uint8 *buf, uint16 len);
void printmac(char* buf, unsigned int o)
{
if(buf[o+4] == 0x00 && buf[o+5] == 0x00)
return;
if(buf[o+4] == 0xff && buf[o+5] == 0xff)
return;
int i;
for(i=0;i<6;i++)
if(buf[o+i] != 0x00 && buf[o+i] != 0xff)
goto good;
return;
good: ;
char mac[strlen("00:00:00:00:00:00\n")];
os_sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x\n", buf[o+0], buf[o+1], buf[o+2], buf[o+3], buf[o+4], buf[o+5]);
uart0_sendStr(mac);
}
void channelHop(void *arg)
{
// 1 - 13 channel hopping
uint8 new_channel = wifi_get_channel() % 12 + 1;
os_printf("** hop to %d **\n", new_channel);
wifi_set_channel(new_channel);
}
static void ICACHE_FLASH_ATTR
promisc_cb(uint8 *buf, uint16 len)
{
os_printf("-> %3d: %d", wifi_get_channel(), len);
printmac(buf, 4);
printmac(buf, 10);
printmac(buf, 16);
os_printf("\n");
}
//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
os_delay_us(10);
}
//Init function
void ICACHE_FLASH_ATTR
user_init()
{
uart_init(115200, 115200);
os_delay_us(100);
uart0_sendStr("*** Monitor mode test ***\r\n");
os_printf(" -> Promisc mode setup ... ");
wifi_set_promiscuous_rx_cb(promisc_cb);
wifi_promiscuous_enable(1);
os_printf("done.\n");
os_printf(" -> Timer setup ... ");
os_timer_disarm(&channelHop_timer);
os_timer_setfn(&channelHop_timer, (os_timer_func_t *) channelHop, NULL);
os_timer_arm(&channelHop_timer, CHANNEL_HOP_INTERVAL, 1);
os_printf("done.\n");
os_printf(" -> Set opmode ... ");
wifi_set_opmode( 0x1 );
os_printf("done.\n");
//Start os task
system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
os_printf(" -> Init finished!\n\n");
}
Not really. Get the package completely impossible, since the buffer is limited to 128 bytes.
Increase the buffer developers are not going to be wondering where the reception packet buffer and its length ...
I'm working on an application where I don't want to deal with a lot of wifi issues like AP disassociation, ACKs, etc..
The data must be streamed continuously and whatever packets make it will be used. This is realtime data, so there is no need to re-transmit bad packets since fresh data will likely be available.
It seems to restrict which frame types you can send.
Any data (type 2) frame is allowed.
Only beacon management frames are allowed (type 0, subtype 8).
No control frames (type 1).