当我用ping 时,esp32打印如下信息:
W (30761) wifi:unknown csi bug!
我的开发环境是idf-v4-0-1,在项目中,我开启了wifi csi功能,并将wifi初始化为station模式,程序上电连接到路由器后,ping线程开始给路由器发送ping报文,在wifi csi回调函数中,打印相位和振幅数据。
这是我的csi初始化函数:
Code: Select all
void csi_init()
{
ESP_ERROR_CHECK(esp_wifi_set_csi(true));
wifi_csi_config_t configuration_csi;
configuration_csi.lltf_en = 1;
configuration_csi.htltf_en = 1;
configuration_csi.stbc_htltf2_en = 1;
configuration_csi.ltf_merge_en = 1;
configuration_csi.channel_filter_en = 0;
configuration_csi.manu_scale = 0;
ESP_ERROR_CHECK(esp_wifi_set_csi_config(&configuration_csi));
ESP_ERROR_CHECK(esp_wifi_set_csi_rx_cb(&_wifi_csi_cb, NULL));
}
Code: Select all
void _wifi_csi_cb(void *ctx, wifi_csi_info_t *data)
{
int8_t *my_ptr = data->buf;
int i;
for(i=0;i<64;i++){
outprintf("%.4f,", sqrt(pow(my_ptr[i * 2], 2) + pow(my_ptr[(i * 2) + 1], 2)));
}
vTaskDelay(0);
}
这是我的ping线程:
Code: Select all
static void ping_task(void *arg)
{
uint32_t timeout = 1000;
uint32_t total_count = 100;
uint32_t current_count = 0;
in_addr_t gw_ip = inet_addr("192.168.3.4"); //ping gw
int s, ret;
LWIP_UNUSED_ARG(arg);
if ((s = socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
{
printf("create socket fail\n");
}
ret = setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
if (ret == 0)
{
printf("set socket timeout success\n");
}
int tos = 1;
tos <<= 5;
ret = setsockopt(s, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
if (ret == 0)
{
printf("set socket tos success\n");
}
while (1)
{
if (current_count++ >= total_count)
{
ping_flag = false;
}
if(ping_flag)
{
if (ping_send(s, gw_ip) == ERR_OK)
{
//printf("ping send ok \n");
//gettimeofday(&ping_time, NULL);
//ping_recv(s);
}
else
{
printf("ping send fail \n");
}
}
vTaskDelay(1000 / portTICK_RATE_MS);
}
}
W (30761) wifi:unknown csi bug!