Wifi serial data example, connection lists, etc...

rayzrocket

Member
Licensed User
Longtime User
Is there a WiFi parallel to the B4A Bluetooth examples?

a. show a list of WiFi connections?
b. select which wifi (by MAC, i presume) connection to connect Serial & Asynchstreams?

I'm using a Gainspan GS1011 Wifi Serial module (<$30). I have B4A working for Bluetooth serial modules(<$8) quite well due to the great forum help & samples!!

Bluetooth example:
B4X:
Sub ButtonConnect_Click  'use BTLabel to express if connected or not; if connected, then show device name here
    If Serial1.IsEnabled = False Then 
        Msgbox("Please enable Bluetooth.", "")
    Else
        Serial1.Listen 'listen for incoming connections
    End If
   Dim PairedDevices As Map
    PairedDevices = Serial1.GetPairedDevices
    Dim l As List
    l.Initialize
    For i = 0 To PairedDevices.Size - 1
        l.Add(PairedDevices.GetKeyAt(i)) 'add the friendly name to the list
    Next
    Dim res As Int
    res = InputList(l, "Choose device", -1) 'show list a list(l) of  paired devices as selection dialog box
    If res <> DialogResponse.CANCEL Then
        Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address
    End If
End Sub
 

rayzrocket

Member
Licensed User
Longtime User
mac address? Bluetooth vs. Wifi

Connecting 'Serial' to a Bluetooth device uses:
B4X:
Serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address and connect

From the looks of this, the 'Serial' connection needs the 'MAC' address. For Bluetooth devices this is acquired by:
B4X:
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l As List
l.Initialize
For i = 0 To PairedDevices.Size - 1
    l.Add(PairedDevices.GetKeyAt(i))
Next

However, I'm not sure if this is the same process that needs to occur for WiFi?

Seems like somewhere in ABWifi, one can make a list of connected devices and connect one to 'Serial' via the 'MAC' address. I think by first using ABNumberOfAvailableWifiNetworks, then ABLoadWifi, and ABWifiInfo.
 
Upvote 0

rayzrocket

Member
Licensed User
Longtime User
serial.connect work with Wifi ?

May a WiFi macaddress acquired using AFWifi library used with:
serial.connect(macaddress) ?
serial.disconnect ?
serial.listen ?
:sign0104:
 
Upvote 0
Top