您好,使用esp-now协议时,无法使用乐鑫专有的远程模式。
串口得到的日志如下所示:
IDF版本 v5.01 芯片 esp32-C3
I (522) wifi:enable tsf
E (522) wifi:failed to post WiFi event=2 ret=259
E (522) wifi:failed to post WiFi event=3 ret=259
I (522) wifi:enable tsf
E (532) wifi:failed to post WiFi event=2 ret=259
W (532) wifi:invalid rate, need change phy mode to LR
代码如下:
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); // WIFI_STORAGE_FLASH WIFI_STORAGE_RAM
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
ESP_ERROR_CHECK(esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCOL_LR));
// esp_wifi_config_80211_tx_rate(ESP_IF_WIFI_STA, WIFI_PHY_RATE_LORA_250K);
或者
// esp_wifi_config_espnow_rate(ESP_IF_WIFI_STA, WIFI_PHY_RATE_LORA_250K);
都测试过,日志是一样的。
【已解决】使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
Moderator: ESP_Bob
Re: 使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
将调用上述接口时的返回值贴一下
-
- Posts: 5
- Joined: Mon Mar 06, 2023 6:57 am
Re: 使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
返回值日志如下:
--------------------------------------------------------------
[0;32mI (390) pp: pp rom version: 9387209[0m
[0;32mI (400) net80211: net80211 rom version: 9387209[0m
I (410) wifi:wifi driver task: 3fc9e920, prio:23, stack:6656, core=0
[0;32mI (410) system_api: Base MAC address is not set[0m
[0;32mI (410) system_api: read default base MAC address from EFUSE[0m
I (420) wifi:wifi firmware version: 17afb16
I (420) wifi:wifi certification version: v7.0
I (430) wifi:config NVS flash: enabled
I (430) wifi:config nano formating: disabled
I (430) wifi:Init data frame dynamic rx buffer num: 32
I (440) wifi:Init management frame dynamic rx buffer num: 32
I (440) wifi:Init management short buffer num: 32
I (450) wifi:Init dynamic tx buffer num: 32
I (450) wifi:Init static tx FG buffer num: 2
I (460) wifi:Init static rx buffer size: 1600
I (460) wifi:Init static rx buffer num: 10
I (460) wifi:Init dynamic rx buffer num: 32
[0;32mI (470) wifi_init: rx ba win: 6[0m
[0;32mI (470) wifi_init: tcpip mbox: 32[0m
[0;32mI (480) wifi_init: udp mbox: 6[0m
[0;32mI (480) wifi_init: tcp mbox: 6[0m
[0;32mI (480) wifi_init: tcp tx win: 5744[0m
[0;32mI (490) wifi_init: tcp rx win: 5744[0m
[0;32mI (490) wifi_init: tcp mss: 1440[0m
[0;32mI (500) wifi_init: WiFi IRAM OP enabled[0m
[0;32mI (500) wifi_init: WiFi RX IRAM OP enabled[0m
function esp_wifi_init() return is 0
function esp_wifi_set_mode() return is 0
function esp_wifi_set_storage() return is 0
I (520) wifi:Set ps type: 0
function esp_wifi_set_ps() return is 0
[0;32mI (520) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12[0m
I (570) wifi:mode : sta (60:55:f9:72:e3:38)
I (570) wifi:enable tsf
E (570) wifi:failed to post WiFi event=2 ret=259
function esp_wifi_start() return is 0
E (570) wifi:failed to post WiFi event=3 ret=259
I (580) wifi:enable tsf
E (580) wifi:failed to post WiFi event=2 ret=259
function esp_wifi_set_protocol() return is 0
W (590) wifi:invalid rate, need change phy mode to LR
function esp_wifi_config_espnow_rate() return is -1
---------------------------------------------------------------
相关代码:
printf("---------------------------------------------------------------\r\n");
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
int i;
i = esp_wifi_init(&cfg);
printf(" function esp_wifi_init() return is %d \r\n", i);
i = esp_wifi_set_mode(WIFI_MODE_STA);
printf(" function esp_wifi_set_mode() return is %d \r\n", i);
// WIFI_STORAGE_FLASH WIFI_STORAGE_RAM
i = esp_wifi_set_storage(WIFI_STORAGE_RAM);
printf(" function esp_wifi_set_storage() return is %d \r\n", i);
i = esp_wifi_set_ps(WIFI_PS_NONE);
printf(" function esp_wifi_set_ps() return is %d \r\n", i);
i = esp_wifi_start();
printf(" function esp_wifi_start() return is %d \r\n", i);
#if CONFIG_ESPNOW_ENABLE_LONG_RANGE
i = (esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCOL_LR));
printf(" function esp_wifi_set_protocol() return is %d \r\n", i);
// esp_wifi_config_80211_tx_rate(ESP_IF_WIFI_STA, WIFI_PHY_RATE_LORA_250K);
i = esp_wifi_config_espnow_rate(ESP_IF_WIFI_STA, WIFI_PHY_RATE_LORA_250K);
printf(" function esp_wifi_config_espnow_rate() return is %d \r\n", i);
printf("---------------------------------------------------------------\r\n");[/Codebox]
--------------------------------------------------------------
[0;32mI (390) pp: pp rom version: 9387209[0m
[0;32mI (400) net80211: net80211 rom version: 9387209[0m
I (410) wifi:wifi driver task: 3fc9e920, prio:23, stack:6656, core=0
[0;32mI (410) system_api: Base MAC address is not set[0m
[0;32mI (410) system_api: read default base MAC address from EFUSE[0m
I (420) wifi:wifi firmware version: 17afb16
I (420) wifi:wifi certification version: v7.0
I (430) wifi:config NVS flash: enabled
I (430) wifi:config nano formating: disabled
I (430) wifi:Init data frame dynamic rx buffer num: 32
I (440) wifi:Init management frame dynamic rx buffer num: 32
I (440) wifi:Init management short buffer num: 32
I (450) wifi:Init dynamic tx buffer num: 32
I (450) wifi:Init static tx FG buffer num: 2
I (460) wifi:Init static rx buffer size: 1600
I (460) wifi:Init static rx buffer num: 10
I (460) wifi:Init dynamic rx buffer num: 32
[0;32mI (470) wifi_init: rx ba win: 6[0m
[0;32mI (470) wifi_init: tcpip mbox: 32[0m
[0;32mI (480) wifi_init: udp mbox: 6[0m
[0;32mI (480) wifi_init: tcp mbox: 6[0m
[0;32mI (480) wifi_init: tcp tx win: 5744[0m
[0;32mI (490) wifi_init: tcp rx win: 5744[0m
[0;32mI (490) wifi_init: tcp mss: 1440[0m
[0;32mI (500) wifi_init: WiFi IRAM OP enabled[0m
[0;32mI (500) wifi_init: WiFi RX IRAM OP enabled[0m
function esp_wifi_init() return is 0
function esp_wifi_set_mode() return is 0
function esp_wifi_set_storage() return is 0
I (520) wifi:Set ps type: 0
function esp_wifi_set_ps() return is 0
[0;32mI (520) phy_init: phy_version 950,11a46e9,Oct 21 2022,08:56:12[0m
I (570) wifi:mode : sta (60:55:f9:72:e3:38)
I (570) wifi:enable tsf
E (570) wifi:failed to post WiFi event=2 ret=259
function esp_wifi_start() return is 0
E (570) wifi:failed to post WiFi event=3 ret=259
I (580) wifi:enable tsf
E (580) wifi:failed to post WiFi event=2 ret=259
function esp_wifi_set_protocol() return is 0
W (590) wifi:invalid rate, need change phy mode to LR
function esp_wifi_config_espnow_rate() return is -1
---------------------------------------------------------------
相关代码:
printf("---------------------------------------------------------------\r\n");
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
int i;
i = esp_wifi_init(&cfg);
printf(" function esp_wifi_init() return is %d \r\n", i);
i = esp_wifi_set_mode(WIFI_MODE_STA);
printf(" function esp_wifi_set_mode() return is %d \r\n", i);
// WIFI_STORAGE_FLASH WIFI_STORAGE_RAM
i = esp_wifi_set_storage(WIFI_STORAGE_RAM);
printf(" function esp_wifi_set_storage() return is %d \r\n", i);
i = esp_wifi_set_ps(WIFI_PS_NONE);
printf(" function esp_wifi_set_ps() return is %d \r\n", i);
i = esp_wifi_start();
printf(" function esp_wifi_start() return is %d \r\n", i);
#if CONFIG_ESPNOW_ENABLE_LONG_RANGE
i = (esp_wifi_set_protocol(ESP_IF_WIFI_STA, WIFI_PROTOCOL_LR));
printf(" function esp_wifi_set_protocol() return is %d \r\n", i);
// esp_wifi_config_80211_tx_rate(ESP_IF_WIFI_STA, WIFI_PHY_RATE_LORA_250K);
i = esp_wifi_config_espnow_rate(ESP_IF_WIFI_STA, WIFI_PHY_RATE_LORA_250K);
printf(" function esp_wifi_config_espnow_rate() return is %d \r\n", i);
printf("---------------------------------------------------------------\r\n");
- [Codebox=c file=Untitled.c]
-
- Posts: 5
- Joined: Mon Mar 06, 2023 6:57 am
Re: 使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
有哪位大侠知道是哪里出问题了吗,是esp-now协议本身的问题,还是esp32-c3不支持esp-now速率改变,还是说用法或者函数顺序问题?
Re: 使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
Did you run esp_netif_init() before any Wifi initialisation?
-
- Posts: 5
- Joined: Mon Mar 06, 2023 6:57 am
Re: 使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
After testing, it is true that this function did not initialize. Thank you very much.
Re: 【已解决】使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
我这里一旦调用 esp_wifi_config_espnow_rate(ESPNOW_WIFI_IF, WIFI_PHY_RATE_LORA_500K)就会返回
wifi:invalid rate, need change phy mode to LR,设置成其他速率没有问题,请问你是解决了这个问题吗?
我是在espnow的demo基础上增加了这个速率切换,在esp_wifi_start后调用,但是一直报错不知道什么原因
wifi:invalid rate, need change phy mode to LR,设置成其他速率没有问题,请问你是解决了这个问题吗?
我是在espnow的demo基础上增加了这个速率切换,在esp_wifi_start后调用,但是一直报错不知道什么原因
Re: 【已解决】使用esp-now协议时,PHY模式无法设置成WIFI_LR模式
我在esp32-C3的esp now demo里切换了速率,在
esp_wifi_start后添加了
esp_wifi_config_espnow_rate(ESPNOW_WIFI_IF, WIFI_PHY_RATE_LORA_500K),如下
WIFI_PHY_RATE_LORA_500K和WIFI_PHY_RATE_LORA_250K速率不行,其他速率可以
发现会返回错误
W (506) wifi:invalid rate, need change phy mode to LR
不知道是哪里出问题了,按说espnow应该支持LR啊
esp_wifi_start后添加了
esp_wifi_config_espnow_rate(ESPNOW_WIFI_IF, WIFI_PHY_RATE_LORA_500K),如下
Code: Select all
static void example_wifi_init(void)
{
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
// esp_wifi_config_80211_tx_rate(ESPNOW_WIFI_MODE,WIFI_PHY_RATE_5M_L);
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(ESPNOW_WIFI_MODE) );
ESP_ERROR_CHECK( esp_wifi_start());
// esp_wifi_config_80211_tx_rate(ESP_IF_WIFI_STA,PreRate);
esp_wifi_set_bandwidth(ESP_IF_WIFI_STA,WIFI_BW_HT20);
#if 1//CONFIG_ESPNOW_ENABLE_LONG_RANGE
ESP_ERROR_CHECK( esp_wifi_set_protocol(ESPNOW_WIFI_IF, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_LR) );
//ESP_ERROR_CHECK( esp_wifi_set_protocol(ESPNOW_WIFI_IF, WIFI_PROTOCOL_LR) );
#endif
//ESP_ERROR_CHECK( esp_wifi_internal_set_fix_rate(ESPNOW_WIFI_IF,true, WIFI_PHY_RATE_LORA_500K));
ESP_ERROR_CHECK( esp_wifi_config_espnow_rate(ESPNOW_WIFI_IF, WIFI_PHY_RATE_LORA_500K));
}
发现会返回错误
W (506) wifi:invalid rate, need change phy mode to LR
不知道是哪里出问题了,按说espnow应该支持LR啊
Who is online
Users browsing this forum: No registered users and 21 guests