ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Ritesh
Posts: 1128
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby Ritesh » Wed Jul 03, 2019 6:50 pm

kjames wrote:
Wed Jul 03, 2019 10:27 am
Many thanks again for helping. I am still having an issue here. The access point is starting but the ESP does not connect as a station to my Android (for example) as it normally would in station mode. So it is not functioning as an access point + station, just as an access point and for some reason the access point is starting as "ESP_188539", even though I have named it "Test_Transmitter" in the attached code. If you have time to take a look, perhaps I am missing something. I've attached the code here. If you have any suggestions at all, I will give it another try. thank you very muchAPSTA_attempt.c
Hello,

Would you please first check how to use strncpy function into C? You have provided length as NULL while copying configuration using strncpy API.

So, Please correct it with proper length otherwise use strcpy without length. Also print configuration once it will be copied to make sure copy operation has been done successfully or not.

I believe if you do it properly then you will get success for that.
Regards,
Ritesh Prajapati

Ritesh
Posts: 1128
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby Ritesh » Thu Jul 04, 2019 5:29 am

Hello,

Please let me know if you still find any difficulties for same.
Regards,
Ritesh Prajapati

kjames
Posts: 16
Joined: Mon Jul 01, 2019 3:27 pm

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby kjames » Wed Jul 10, 2019 10:54 am

My apologies for the delay in replying as I was away for several days - my mistake regarding strncpy and entering NULL; I had fixed this and the access point was working, but station mode doesn't seem to be working. I'm not sure what the problem is here but the access point is up and I can connect stations to it, but I cannot connect the ESP to another access point as a station.

Many thanks again for your help, but I am a bit stuck here. If any other suggestions, I can give it a try next week when I return.

Ritesh
Posts: 1128
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby Ritesh » Wed Jul 10, 2019 4:54 pm

kjames wrote:
Wed Jul 10, 2019 10:54 am
My apologies for the delay in replying as I was away for several days - my mistake regarding strncpy and entering NULL; I had fixed this and the access point was working, but station mode doesn't seem to be working. I'm not sure what the problem is here but the access point is up and I can connect stations to it, but I cannot connect the ESP to another access point as a station.

Many thanks again for your help, but I am a bit stuck here. If any other suggestions, I can give it a try next week when I return.
Ok.
If possible then please provide your updated application example with IDF details.
Regards,
Ritesh Prajapati

JL1946
Posts: 4
Joined: Mon Feb 25, 2019 3:46 pm

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby JL1946 » Wed Mar 04, 2020 6:13 pm

I think that what is missing here is the fact that the ESP32 has only 1 radio and 1 antenna. Therefore, the channels selected for STA Mode and AP Mode have to be the same. Different Channels will not work. The same goes for ESP NOW/MESH implementations.

My suggestion would be that, on start-up, define a scan function that will return the channel of an AP Router/Modem to which you intend to connect and then synchronize your wifi function with that channel for both STA and AP mode as well as any other protocol in use (ESP Now, Mesh, etc).

Further, it would be prudent to isolate AP related functions from STA related functions. For example, implement a web server for the AP function that is separate from a web server for the STA function.

Anyway, that's my 2 cents...

Ritesh
Posts: 1128
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby Ritesh » Fri Mar 13, 2020 11:30 am

JL1946 wrote:
Wed Mar 04, 2020 6:13 pm
I think that what is missing here is the fact that the ESP32 has only 1 radio and 1 antenna. Therefore, the channels selected for STA Mode and AP Mode have to be the same. Different Channels will not work. The same goes for ESP NOW/MESH implementations.

My suggestion would be that, on start-up, define a scan function that will return the channel of an AP Router/Modem to which you intend to connect and then synchronize your wifi function with that channel for both STA and AP mode as well as any other protocol in use (ESP Now, Mesh, etc).

Further, it would be prudent to isolate AP related functions from STA related functions. For example, implement a web server for the AP function that is separate from a web server for the STA function.

Anyway, that's my 2 cents...
Yes. Obviously.

Let me know if need anything else from my side.
Regards,
Ritesh Prajapati

ryanf55
Posts: 5
Joined: Sun Mar 22, 2020 7:15 am

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby ryanf55 » Sun Mar 22, 2020 7:38 am

How should this be handled if the station ssid and password is unknown?

I have set up my ESP32 to run in AP mode and allow entering config from a http server it generates (this is done).
I do not require both STA and AP modes at the same time, so some explanation on how to bring the wifi down then back up could be helpful.

Alternatively, sharing how to change wifi_config.sta.ssid and wifi_config.sta.password while keeping AP mode on would also work.

Thanks!

Ritesh
Posts: 1128
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby Ritesh » Sun Apr 19, 2020 10:41 am

ryanf55 wrote:
Sun Mar 22, 2020 7:38 am
How should this be handled if the station ssid and password is unknown?

I have set up my ESP32 to run in AP mode and allow entering config from a http server it generates (this is done).
I do not require both STA and AP modes at the same time, so some explanation on how to bring the wifi down then back up could be helpful.

Alternatively, sharing how to change wifi_config.sta.ssid and wifi_config.sta.password while keeping AP mode on would also work.

Thanks!
Hello,

Either you have to use ESP32 STA+AP mode or you can down reconfigure WIFi STA mode configuration by bringing device back into AP mode.
Regards,
Ritesh Prajapati

ryanf55
Posts: 5
Joined: Sun Mar 22, 2020 7:15 am

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby ryanf55 » Tue May 05, 2020 2:16 am

Ritesh wrote:
Sun Apr 19, 2020 10:41 am
ryanf55 wrote:
Sun Mar 22, 2020 7:38 am
How should this be handled if the station ssid and password is unknown?

I have set up my ESP32 to run in AP mode and allow entering config from a http server it generates (this is done).
I do not require both STA and AP modes at the same time, so some explanation on how to bring the wifi down then back up could be helpful.

Alternatively, sharing how to change wifi_config.sta.ssid and wifi_config.sta.password while keeping AP mode on would also work.

Thanks!
Hello,

Either you have to use ESP32 STA+AP mode or you can down reconfigure WIFi STA mode configuration by bringing device back into AP mode.
Thanks! I went the route of WiFi STA mode for configuration, then bring back up in STA+AP.

When in STA mode, I used the following function to stop the WiFi.

void kill_wifi(void){
wifi_mode_t mode;
ESP_ERROR_CHECK(esp_wifi_get_mode(&mode));

if (mode == WIFI_MODE_STA){ ///TODO this condition needs testing on all three modes
//Answer the question: When do you need to run esp_wifi_disconnect.
//Confirmed: Don't run in WIFI_MODE_AP because there is nothing to disconnect from and it breaks.
ESP_ERROR_CHECK(esp_wifi_disconnect());
}
ESP_ERROR_CHECK(esp_wifi_stop());
ESP_ERROR_CHECK(esp_wifi_deinit());
ESP_ERROR_CHECK(esp_event_loop_delete_default());
}

ryanf55
Posts: 5
Joined: Sun Mar 22, 2020 7:15 am

Re: ESP IDF: Station + soft-AP (WIFI_MODE_APSTA) There is no working example - why? Where is?

Postby ryanf55 » Thu May 07, 2020 7:08 am

Has anyone seen inconsistencies in the WiFi behavior between ESP-WROOM-32 and ESP-WROOM-32D?

When running this on ESP32-WROOM-32D, I get an exception error and it restarts during the transition from AP to STA modes.

It's the same code on either module.

Code: Select all

Switching from softAP to station
Onward! esp_wifi_stop has been run. Time to start station.... (TODO) 
 I (16848) wifi: station: 3c:37:86:0b:64:f0 leave, AID = 1, bss_flags is 134259, bss:0x3ffc6bc8
I (16848) wifi: new:<1,0>, old:<1,1>, ap:<1,1>, sta:<255,255>, prof:1
I (16858) cv-esp32: station 3c:37:86:0b:64:f0 leave, AID=1
I (16878) wifi: flush txq
I (16878) wifi: stop sw txq
Guru Meditation Error: Core  0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013cf60: ffbf0000 ffffffff ffffffff
0x4013cf60: set_rx_gain_table at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7.c:2486

Core 0 register dump:
PC      : 0x4013cf64  PS      : 0x00060930  A0      : 0x8013ddc7  A1      : 0x3ffc1270  
0x4013cf64: set_rx_gain_table at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7.c:2486

A2      : 0x600050dc  A3      : 0xffffffff  A4      : 0xd93c1800  A5      : 0x00000200  
A6      : 0x43422c18  A7      : 0x3ffb8304  A8      : 0x001f0000  A9      : 0x00005100  
A10     : 0x6001c02c  A11     : 0x80121bfd  A12     : 0x00000100  A13     : 0x00000007  
A14     : 0x00000005  A15     : 0x00000060  SAR     : 0x00000037  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0x00000000  

ELF file SHA256: c90b6f82024916081b0e27802c0a8ecdce1805f9a18bd3979e87f20f61e3edda

Backtrace: 0x4013cf61:0x3ffc1270 0x4013ddc4:0x3ffc1290 0x4013e35e:0x3ffc12b0 0x4014a91c:0x3ffc1370 0x4014aac5:0x3ffc13a0 0x40129313:0x3ffc13d0 0x401294b4:0x3ffc1400 0x4012955a:0x3ffc1430 0x4012626e:0x3ffc1450 0x4008a016:0x3ffc1470 0x40092e59:0x3ffc14b0
0x4013cf61: set_rx_gain_table at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7.c:2486

0x4013ddc4: bb_init at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7.c:2633

0x4013e35e: register_chipv7_phy at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7.c:3371

0x4014a91c: esp_phy_rf_init at /home/ryan/esp/esp-idf/components/esp_wifi/src/phy_init.c:222

0x4014aac5: esp_modem_sleep_deregister at /home/ryan/esp/esp-idf/components/esp_wifi/src/phy_init.c:434

0x40129313: wifi_rf_phy_disable at ??:?

0x401294b4: wifi_hw_stop at ??:?

0x4012955a: wifi_stop_process at ??:?

0x4012626e: ieee80211_ioctl_process at ??:?

0x4008a016: ppTask at ??:?

0x40092e59: vPortTaskWrapper at /home/ryan/esp/esp-idf/components/freertos/port.c:143


Rebooting...


Who is online

Users browsing this forum: Google [Bot] and 21 guests