I’m trying to connect with the RTL8720DN to an AP with hidden SSID but unfortunately I can’t get it to work. Connection to an AP with a public SSID seems to work just fine.
I’ve build the images with the standard sdk from github and included the ATCMD, command and the wifi interactive API in the build. I’ve even tried images built from release and master branches.
When I enter
wifi_connect <my_hidden_ssid>
it re-tries to connect and outputs:
RTL8721D[Driver]: set ssid [my_hidden_ssid]
After last last retry wifi_info outputs:
Last Link Error
==============================
Target AP Not Found
When querying during retries wifi_info shows:
WIFI wlan0 Setting:
==============================
MODE => STATION
SSID =>
CHANNEL => 1
SECURITY => AES
PASSWORD => <the wpa pw>
Last Link Error
==============================
Unknown Error(6)
Note that the above output prints out the wpa password but the SSID is not shown (empty).
When I try to connect with the AT command ATPN=ssid,pw
it outputs:
Can't get AP security mode and channel.
The preinstalled firmware from B&T worked just fine with hidden SSID.
What I’m missing / doing wrong?
Thanks for your help!
Marc
Edit: I just noted, that it works in 2.4Ghz Band but not in 5Ghz.
On the current SDK available on GitHub, using the ATW0, ATW1, ATWC commands, I have tested and verified that connecting to 5GHz WiFi networks with a hidden SSID seems to be failing. The same commands works normally with hidden and regular 2.4GHz networks, and regular 5GHz networks.
The development team has confirmed that 5GHz WiFi only uses passive scanning, thus hidden SSIDs are not supported.
If you absolutely need to use hidden SSID, I would suggest sticking to 2.4GHz WiFi.
That are bad news. I explicitly ordered these modules because of the 5GHz support and I didn’t expect to have issues regarding hidden SSID’s.
Can you ask the development team what the reason is that it isn’t supported? I can’t imagine that it is a technical limitation since it worked on the B&T firmware (which looks like it is based on the ameba-sdk).
Is there no way to get it working? Is it supported with the full-sdk?
Due to differences in national regulations on active scanning in the 5GHz band, the board is configured with passive scanning on all 5GHz channels as a default.
This setting is configured using the eFuse, and detailed information on active and passive channel configurations can be seen in AN0400 Application Note chapter 13.5.4 Wi-Fi Channel Plan.
From chapter 18.2.4.3, int wifi_set_channel_plan(uint8_t channel_plan) found in wifi_conf.c can be used to change the eFuse channel plan, with the available channel plans found in wifi_constants.h
Thanks for getting back to me and pointing me to the Application Note. That did the trick. After setting the correct channel plan I can now connect to 5GHz with hidden ssid. Very good.
Is it possible to access these functions from an Arduino application?
Looking at the WiFi.h file - which seems to be what exposes functions to the Arduino environment - it would seem that this is not possible.
I am guessing I will need to re-factor my project to be built under the ‘normal’ command-line SDK rather than the Arduino so-called IDE.
Or perhaps I just edit WiFi.h - or create a new pair of files e.g. WiFiConfig.h and WiFiConfig.c - and pull them into the Arduino ‘sketch’?
Technically it is possible in an Arduino application, just that the right header files need to be included.
But the recommended method is to use the standard SDK, since it will be easier there. From what I can see from the application note, this should be a one-time configuration instead of code you need to run every time. Using the standard SDK, run the code once, verify that it can connect to hidden SSIDs, and you can go back to using regular Arduino sketches and still connect to hidden SSIDs, since the setting is saved into efuse.
Thanks for that.
I found that I could simply add the following header files to my sketch: #include <wifi_conf.h> #include <wifi_constants.h>
Then I was able to use the functions defined in:
C:\Users<my username>\AppData\Local\Arduino15\packages\realtek\hardware\AmebaD\3.1.2\system\component\common\api\wifi\wifi_conf.h
And I can confirm that once wifi_set_channel_plan has been called successfully, re-flashing the application does not wipe the setting - so I’m now doing that in my user configuration menu rather than on start-up each time.
I must confess I don’t really understand how the header search paths are set in Arduino, but that’s for a different forum!
Hi @boatbodger
You are doing great, the header path that you included are source from the Realtek Standard SDK which is similar to ESP32’s IDF (if you have heard before), thus it contains more API and functions for controling WiFi.
Hi @wyy
Unfortunately, the trick did not work for me.
I tried to set different channel plans (listed in the Application note) but still can’t connect to HIDDEN 5GHz network.
I used the wifi_get_channel_plan() to check if channel plan was set correctly, as well as reboot was performed.
Additionally, I found another function wifi_set_country() and tried to use in with RTW_COUNTRY_EU - also without success. Still getting an error (RTW_ERROR) from the wifi_connect() function because the wifi_is_connected_to_ap() function does not return RTW_SUCCESS.
Any hints?
Yes, I tried to change my Access Point configuration.
I used automatic configuration (with channel 108) as well as manual (channel 48 and 44).
No difference. Still can’t connect.
I added 2 AT commands for that, named ATW8 and ATW9
the ATW8 gets the channel plan (using wifi_get_channel_plan)
and ATW9 sets the channel plan (using wifi_set_channel_plan)
I experimented with wifi_set_country() to.
NOTE: I’m aware of Hex and Dec format for the parameter values. My new AT commands gets and sets values in Decimals. I used “AN0400 Ameba-D Application Note.pdf” to obtain channel plan number for EU (0x26) and converted it to Dec (38).
One more thing. Above Application Note concludes that my hidden 5GHz SSID must be configured to one of the following channels: 36, 40, 44, 48. I tried all of them but none works with the WiFi module. I can confirm that I can connect to the hidden SSID from my mobile phone.
Below 2 functions I added to the atcmd_wifi.c file:
Still having trouble to connect to hidden 5GHz network so…
I started from scratch using clean copy of SDK source code (branch: Master)
I did minimum modifications to change pins, enable AT commands etc.
For normal SSID everything works well so I changed my router configuration to hide the SSID (and use channel 48).
By using AT command: ATWS (scan AP) I got the following:
AP : 1,48,WPA2 AES,-29,ac:84:c9:4c:45:e7
AP : 2,PREDICA,11,WPA2 AES,-52,ac:84:c9:4c:45:e2
AP : 3,CGA2121_2eYneNV,1,WPA2 AES,-55,f8:5e:42:52:3d:49
AP : 4,UPC5048326,44,WPA2 AES,-55,68:02:b8:4c:f4:03
Looks like my hidden network (without the name) is at the 1st position.
Then, using my custom AT commands I checked the channel plan is set to 0x76 (I tried also 0x26 - EU)
Using AT command ATPN=name,password…
I got the response with error #6: “get ap security type failed”. After some investigation I found it is because the _get_ap_security_mode() function compares the given SSID with the scanned SSID and it fails. My guess was: “here’s the bug!!” so I allowed to pass this function with success assigning channel and security type. Note: the wifi_scan_networks_with_ssid() function returned success so I was convinced.
After the above modification, I got another error: #4 “connect to AP failed”. So, it did not connect in the end anyway
Any hints please?
PS: the wifi_scan_networks_with_ssid function returns success but the rtw_wifi_setting_t wifi structure seems to be empty (zeroed)
Can you provide details on the hardware you are using? e.g. which chip & development board, and the model of the WiFi AP you are testing with.
Are the latest tests done with the code using wifi_change_channel_plan and wifi_set_country functions? I did not notice them having an effect when testing, and worry that they might be setting conflicting configurations. In my testing, after wifi_set_channel_plan I restarted the chip and ensured that the configuration remained with wifi_get_channel_plan before proceeding with connecting.
Connecting to a WiFi AP using ATPN will first perform a scan to determine the exact WiFi security type (WEP/WPA/WPA2) as this is required during the connection stage. Which security type did you use, and can you connect using the same code and security type when the SSID is not hidden?
the return value of wifi_scan_networks_with_ssid only indicates that WiFi scanning is started successfully.