ABWifi is returning null

salmander

Active Member
Licensed User
Longtime User
Hello All,

I want to determine the Mac Address of my device. I don't know if I need to connect to wifi first in order to find the mac address. But to what I understand, MAC address is a unique address assigned to every networking device. So it should be something similar to IMEI number. However, if anyone knows more on this subject please share.

The problem that I am facing is I want to determine the MAC address of my device, and by searching the forum, ABWifi library seems to do that. So here is my little code.

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim mac As ABWifiInfo
End Sub

Sub Activity_Resume
   getImei
End Sub

Sub getUniqueID
   Dim unique_number As String

   unique_number = mac.MacAddress ' getting mac address
   Log("mac.BSSID: " & mac.BSSID)
   Log("mac.IsConnected: " & mac.IsConnected)
   Log("mac.NetworkId: " & mac.NetworkId)
   Log("mac.State: " & mac.State)
   Log("mac.Rssi: " & mac.Rssi)
   Log("device ID: " & unique_number)
   Return unique_number
End Sub

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
mac.BSSID: 
mac.IsConnected: false
mac.NetworkId: 0
mac.State: 
mac.Rssi: 0
device ID:

Anyone knows what am I doing wrong? I need to get the mac address of my device. And also, my device is connected to the network.

:sign0163: please???
 

salmander

Active Member
Licensed User
Longtime User
This code runs fine for me and returns the MAC from all the devices I have:

B4X:
'This is using ABWiFi Version 1.10 library
Sub Globals
   Dim myWifi As ABWifi 
End Sub

Sub Get_Mac() As String
   myWifi.ABLoadWifi()
   mymac = "Mac Address: " & myWifi.ABGetCurrentWifiInfo().MacAddress 
   Return mymac
End Sub
Cheers mate. Its working.
I am kinda confused as I was declaring wifi object using "ABWifiInfo" then "ABWifi" as it appears in the autosuggest list. But thanks anyway.
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
This code runs fine for me and returns the MAC from all the devices I have:

B4X:
'This is using ABWiFi Version 1.10 library
Sub Globals
   Dim myWifi As ABWifi 
End Sub

Sub Get_Mac() As String
   myWifi.ABLoadWifi()
   mymac = "Mac Address: " & myWifi.ABGetCurrentWifiInfo().MacAddress 
   Return mymac
End Sub
Sorry one question mate, what are you using brackets "()"?
I tried using without brackets like below and it also seems to work.
B4X:
mymac = "Mac Address: " & myWifi.ABGetCurrentWifiInfo.MacAddress
 
Upvote 0
Top