WiFi Example

I’m unclear on the code sample provided for WiFi.

Is that code setting up an network interface with it’s own SSID? that will appear as an available network that others can connect to?

Or is it setting up a new connection to an existing network?

I ran this as-is and it runs OK but I cannot see any “Endpoint” network when I look with other devices.

Also as soon as it starts it writes “Connected” to the output window, but connected to what??

The sample is for connecting to an existing access point. I believed someone has already raised a question on how to create an access point on the endpoint device.

I cannot get the sample to run, the loop waiting for the connection flag runs forever. I use the TL-WN725N. Are there any restrictions like “don’t use the space character inside the SSID” or “don’t use WPA3” ?

I also just tried the USB host example, but the method Usbhost_OnConnectionChangedEvent is not triggered while plugging in the USB wifi dongle. It works for a USB memory stick, and also for a USB camera. Any hints?

Is that an RTL8188 chipset? Does not appear to be. GHI has only stated support for the RTL8188 at this time.

Speculating a bit here but again, if it’s not a supported chipset, then the USB id would not be recognized and no driver would be triggered, and thus no connection event raised.

The TL-WN725N is one of the two dongles mentioned to work in the forum entry WiFi Dongle

Yup, fair enough. @Designer had success with one of those models. I have only been able to get RTL8188’s to work so far. What does dmesg (from an ssh command prompt) have to say? It should tell you what happened when it found that USB device attached.

for example:

[    0.288954] usbcore: registered new interface driver rtl8187
[    0.289062] usbcore: registered new interface driver rtl8192cu
[    0.289135] usbcore: registered new interface driver rtl8xxxu

Any errors shown in dmesg?

Thank you for your help. Unfortunately I cannot connect via SSH - connection refused. Apple Silicon… or me :wink:

Finally I connected…

[    0.099622] usbcore: registered new interface driver usbfs
[    0.099703] usbcore: registered new interface driver hub
[    0.099781] usbcore: registered new device driver usb
[    0.279914] usbcore: registered new interface driver rtl8187
[    0.280022] usbcore: registered new interface driver rtl8192cu
[    0.280093] usbcore: registered new interface driver rtl8xxxu
[    0.293144] usbcore: registered new interface driver uas
[    0.293248] usbcore: registered new interface driver usb-storage
[    0.484798] usbcore: registered new interface driver usbhid

And yes, there are a lot of lines containing “failed”, “missing”, “invalid”…
But I am not familiar with this kind of output, so it’s hard for me to decide whether these messages are fatal or not.

And, no worries wrt Apple Silicon. That’s what I’m running here too, brother :wink:

So, those are all good messages (same as on my system).

Couple things to try:

  1. What are the error messages?
  2. What happens if you ssh in and type: /usr/sbin/init_wifi.sh [ssid] [passphrase]? Be sure to use quotes around the arguments, such as: /usr/sbin/init_wifi.sh "my wifi" "mypassword". What errors are shown? You only need to provide the ssid and password once. After that they are saved and you can leave them off. Mine shows:
   Found WiFi config...
   Startig WiFi...
   ln: /dev/rfkill: File exists
   Successfully initialized wpa_supplicant
   dhcpcd-9.4.1 starting
   DUID 00:01:00:01:00:00:00:23:48:8f:4c:f1:6c:f9
   wlan0: waiting for carrier
   wlan0: carrier acquired
   wlan0: connected to Access Point: vodafoneBA1048
   wlan0: IAID 4c:f1:6c:f9
   wlan0: adding address fe80::bfc4:5a13:5320:8a14
   wlan0: soliciting an IPv6 router
   wlan0: rebinding lease of 192.168.0.19
   wlan0: NAK: from 192.168.0.1
   wlan0: soliciting a DHCP lease
   wlan0: offered 192.168.0.18 from 192.168.0.1
   wlan0: probing address 192.168.0.18/24
   wlan0: leased 192.168.0.18 for 86400 seconds
   wlan0: adding route to 192.168.0.0/24
   wlan0: adding default route via 192.168.0.1
   forked to background, child pid 443
  1. If the previous step shows no errors, then what does ifconfig (again, from the # prompt) tell you? In addition to lo and usb0, it should show something like:
   wlan0     Link encap:Ethernet  HWaddr 48:8F:4C:F1:6C:F9  
             inet addr:192.168.0.18  Bcast:192.168.0.255  Mask:255.255.255.0
             inet6 addr: fe80::bfc4:5a13:5320:8a14/64 Scope:Link
             UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
             RX packets:129 errors:0 dropped:5 overruns:0 frame:0
             TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:1000 
             RX bytes:18982 (18.5 KiB)  TX bytes:3622 (3.5 KiB)

Of course, this all should work from dotnet code. The above is just some necessary debugging to figure out why it isn’t working from you. A good day is any day where you don’t have to drop down into a shell prompt. :wink:

Thank you bro - I tried but got a timeout :frowning:

dhcpcd-9.4.1 starting
wlan0: waiting for carrier
timed out

And - as expected - the wlan does not show any ip address:

wlan0     Link encap:Ethernet  HWaddr 40:A5:EF:D2:BA:F7
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

No carrier means that wifi is working, but has not successfully associated with an AP. This can happen if your AP supports both 2.4 and 5GHz on the same SSID and auto-promotes connections to 5Ghz, or if you get the SSID or password wrong.

RTL8188 are 2.4Ghz-only radios, so if you have 2.4GHz and 5Ghz AP set up with the same ssid for both bands, then you either need to turn off 5Ghz promotion (how to do that varies by manufacturer), or disable 5Ghz (sad gamer face), or name the 2.4 and 5 Ghz with different SSIDs, or target a 2.4Ghz AP.

And, of course, make sure the SSID and password are correct.

After disabling 5 GHz and double-checking SSID & PW still timeout.

Hi, could you take picture of your WiFi box? We have one here that doesn’t work with one of our routers but connect to different router it works. We use Phone WiFi hotspot it still doesn’t work. We though this WiFi is bad and ignore it. We would like to know if they are same exactly.

Do you have another router to give it a try? If it works with different router then we will come back to investigate.
The one from @Mike work perfect as we tested so far. Amazon.com: Netis WF2120 Wireless N150 Nano USB Dongle, Ideal for Raspberry, Windows, Mac OS, Linux, RTL8188CUS, Plug in and Forget : Electronics

Also, could you try flash the image again with a diffierent SD card? The WiFi is controlled by multiple drivers and somehow one of them broken then WiFi drivers is not loaded fully, usually happened if the SD becomes bad. That is why the flashing image application usually has “check” feature after writing.

If this helps.

Host

Intel Mac 2018.
Ventura 13.3.1

Wifi

TL-WN725N

Router

Dlink DIR-X3260

Both 2.4 and 5 Ghz bands are on

dmesg output

[    7.961890] RTW: rtl8188eu v5.2.2.4_25483.20171222
[    7.999318] RTW: hal_com_config_channel_plan chplan:0x22
[    8.000375] RTW: rtw_regsty_chk_target_tx_power_valid return false for band:0, path:0, rs:0, t:-1
[    8.001464] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001496] RTW: unsupported channel: 114 at 5G
[    8.001511] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001527] RTW: unsupported channel: 114 at 5G
[    8.001541] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001556] RTW: unsupported channel: 114 at 5G
[    8.001671] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001687] RTW: unsupported channel: 114 at 5G
[    8.001701] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001717] RTW: unsupported channel: 114 at 5G
[    8.001730] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001746] RTW: unsupported channel: 114 at 5G
[    8.001861] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001877] RTW: unsupported channel: 114 at 5G
[    8.001891] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001906] RTW: unsupported channel: 114 at 5G
[    8.001920] RTW: Invalid Channel 114 of Band 1 in phy_GetChannelIndexOfTxPowerLimit
[    8.001936] RTW: unsupported channel: 114 at 5G
[    8.008036] usbcore: registered new interface driver rtl8188eu
[    9.457309] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.457663] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.457912] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.458162] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.458414] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.458662] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.458912] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.459162] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.459412] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.459662] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.459912] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.460162] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.460414] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.460662] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.460913] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.461162] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.461412] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.461662] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.461912] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[    9.462162] RTW: Invalid Channel 0 of Band 0 in phy_GetChannelIndexOfTxPowerLimit
[   12.225445] RTW: rtw_set_802_11_connect(wlan0)  fw_state=0x00000000
[   12.252109] RTW: start auth
[   12.254817] RTW: auth success, start assoc
[   12.362631] RTW: send eapol packet
[   12.495647] RTW: send eapol packet
[   12.496215] RTW: set pairwise key camid:4, addr:0c:0e:76:d4:b6:09, kid:0, type:AES
[   12.496873] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   12.499433] RTW: set group key camid:5, addr:0c:0e:76:d4:b6:09, kid:1, type:TKIP
[   12.558006] 8021q: 802.1Q VLAN Support v1.8

Running the GHI Example code

From VSCode

Address: 192.168.0.167
 gateway: 192.168.0.1
 DNS: 192.168.0.1

I ran a test using my ISP’s modem+router Xfinity and was successful.

For you @Dat_Tran

The router is a Fritz!Box 7530, the picture of the wifi dongle below:

I also tried with a second network - router is an Apple Airport Express - with no success.

Also no LED lights flashing within the dongle.

Next I will try with a plain new flashed sd card - stay tuned…

Does this WiFi still work? Try on PC and does it work ?