Android Question Beacon - nRF

f0raster0

Well-Known Member
Licensed User
Longtime User
Hi

testing a Beacon,
what changes do I have to do in this Beacon example to read a nRF-Beacon
https://www.b4x.com/android/forum/t...iscover-ibeacons-and-eddystone-beacons.61127/

I download the demo and ran it. Just after un-comented:
B4X:
    For Each key As Int In AdvertisingData.Keys
        Log($"${key}= ${bc.HexFromBytes(AdvertisingData.Get(key))}"$)
    Next
I see the logs:
B4X:
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
1= 04
-1= 590002150112233445566778899AABBCCDDEEFF001020304C3
0= 0201041AFF590002150112233445566778899AABBCCDDEEFF001020304C30000000000000000000000000000000000000000000000000000000000000000
1= 04
-1= 590002150112233445566778899AABBCCDDEEFF001020304C3
0= 0201041AFF590002150112233445566778899AABBCCDDEEFF001020304C30000000000000000000000000000000000000000000000000000000000000000
1= 04
-1= 590002150112233445566778899AABBCCDDEEFF001020304C3
0= 0201041AFF590002150112233445566778899AABBCCDDEEFF001020304C30000000000000000000000000000000000000000000000000000000000000000
1= 04
-1= 590002150112233445566778899AABBCCDDEEFF001020304C3
0= 0201041AFF590002150112233445566778899AABBCCDDEEFF001020304C30000000000000000000000000000000000000000000000000000000000000000
1= 04
-1= 590002150112233445566778899AABBCCDDEEFF001020304C3
0= 0201041AFF590002150112233445566778899AABBCCDDEEFF001020304C30000000000000000000000000000000000000000000000000000000000000000
1= 1A
10= 0C

Using nRF Connect i got this information:
Screenshot_20191018-200512_nRF Connect.jpg

Screenshot_20191018-200535_nRF Connect.jpg
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Something like:
B4X:
'590002150112233445566778899AABBCCDDEEFF001020304C3
Dim key As Int = -1
Dim data() As Byte = AdvertisingData.Get(key)
Dim uuid(16) As Byte
Bit.ArrayCopy(data, 4, uuid, 0, 16)
Log(bc.HexFromBytes(uuid))
Dim major As Int = Bit.And(0xff, data(20)) * 256 + Bit.And(0xff, data(21))
Dim minor As Int = Bit.And(0xff, data(22)) * 256 + Bit.And(0xff, data(23))
Log(major)
Log(minor)
 
Upvote 0
Top