I iCAB Well-Known Member Licensed User Longtime User Mar 2, 2021 #1 Hi There Can someone tell me why the information outputted to the log screen is different between the 2 implementations? https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/ https://www.b4x.com/android/forum/threads/ble-bluetooth-low-energy-library.46099/#content A typical B4A output looks like: B4X: Found: , 6E:A6:00:FE:D2:8D, RSSI = -39, (MyMap) {1=[B@5c30ea4, 10=[B@95b640d, -1=[B@373bfc2, 0=[B@ec1f1d3} A typical B4I output looks like: B4X: Found: , 0ED03A0B-1294-C733-AE1B-3A16B2B9DE3D, RSSI = -89, (read only map) { kCBAdvDataIsConnectable = 1; kCBAdvDataTxPowerLevel = 12; } Using B4I, I am able to detect a device using its name, while with B4A I don't see the device (maybe it's there by there is no easy way for me to identify it) Also with B4I you can see the device UUID, while I don't see the same info with B4A Please advise. Thanks, iCAB
Hi There Can someone tell me why the information outputted to the log screen is different between the 2 implementations? https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/ https://www.b4x.com/android/forum/threads/ble-bluetooth-low-energy-library.46099/#content A typical B4A output looks like: B4X: Found: , 6E:A6:00:FE:D2:8D, RSSI = -39, (MyMap) {1=[B@5c30ea4, 10=[B@95b640d, -1=[B@373bfc2, 0=[B@ec1f1d3} A typical B4I output looks like: B4X: Found: , 0ED03A0B-1294-C733-AE1B-3A16B2B9DE3D, RSSI = -89, (read only map) { kCBAdvDataIsConnectable = 1; kCBAdvDataTxPowerLevel = 12; } Using B4I, I am able to detect a device using its name, while with B4A I don't see the device (maybe it's there by there is no easy way for me to identify it) Also with B4I you can see the device UUID, while I don't see the same info with B4A Please advise. Thanks, iCAB
f0raster0 Well-Known Member Licensed User Longtime User Mar 2, 2021 #2 in my last project I used this: Connecting to Arduino with BLE (Bluetooth Low Energy) In the previous example we broadcasted a single byte as part of the advertising data: https://www.b4x.com/android/forum/threads/ble-hm-10-module-broadcasting-a-single-byte.65785/ In this example the Android or iOS device (only one at a time) will connect to the BLE peripheral and read and write... www.b4x.com Upvote 0
in my last project I used this: Connecting to Arduino with BLE (Bluetooth Low Energy) In the previous example we broadcasted a single byte as part of the advertising data: https://www.b4x.com/android/forum/threads/ble-hm-10-module-broadcasting-a-single-byte.65785/ In this example the Android or iOS device (only one at a time) will connect to the BLE peripheral and read and write... www.b4x.com
Erel B4X founder Staff member Licensed User Longtime User Mar 2, 2021 #3 iCAB said: Can someone tell me why the information outputted to the log screen is different between the 2 implementations? Click to expand... The underlying APIs are completely different so the output is different. Don't try to extract anything from this string. Code: For Each Key As Int In AdvertisingData.Keys Dim b() As Byte = AdvertisingData.Get(Key) Log(Key & ": " & BytesToString(b, 0, b.Length, "utf8")) 'not safe. can throw an exception Log(Key & ": " & bc.HexFromBytes(b)) 'safe Next Upvote 0
iCAB said: Can someone tell me why the information outputted to the log screen is different between the 2 implementations? Click to expand... The underlying APIs are completely different so the output is different. Don't try to extract anything from this string. Code: For Each Key As Int In AdvertisingData.Keys Dim b() As Byte = AdvertisingData.Get(Key) Log(Key & ": " & BytesToString(b, 0, b.Length, "utf8")) 'not safe. can throw an exception Log(Key & ": " & bc.HexFromBytes(b)) 'safe Next
I iCAB Well-Known Member Licensed User Longtime User Mar 2, 2021 #4 Thanks guys for your reply, @Erel Is there anything common in the returned data to identify the same device in B4A and B4I? Thank you! Upvote 0
Thanks guys for your reply, @Erel Is there anything common in the returned data to identify the same device in B4A and B4I? Thank you!
Erel B4X founder Staff member Licensed User Longtime User Mar 2, 2021 #5 1. What is the output of the code I posted? 2. Why aren't you using the Name and DeviceId parameters? Upvote 0
1. What is the output of the code I posted? 2. Why aren't you using the Name and DeviceId parameters?
I iCAB Well-Known Member Licensed User Longtime User Mar 2, 2021 #6 Hi Erel, Please see the output that I am getting. That's why I am unable to use the name properly. The first section of the file outputted using B4A, the second section is using B4I. The device I am looking for is "WWA1 BLE" Thanks for your help, greatly appreciated! Attachments B4A_B4I output.txt B4A_B4I output.txt 9.4 KB · Views: 618 Upvote 0
Hi Erel, Please see the output that I am getting. That's why I am unable to use the name properly. The first section of the file outputted using B4A, the second section is using B4I. The device I am looking for is "WWA1 BLE" Thanks for your help, greatly appreciated!
f0raster0 Well-Known Member Licensed User Longtime User Mar 2, 2021 #7 try the code in post #2 change the uuid with your uuid from your device Upvote 0
I iCAB Well-Known Member Licensed User Longtime User Mar 2, 2021 #8 f0raster0 said: try the code in post #2 change the uuid with your uuid from your device Click to expand... Thanks, let me give it a try Upvote 0
f0raster0 said: try the code in post #2 change the uuid with your uuid from your device Click to expand... Thanks, let me give it a try