Logger connected to: samsung SM-T280
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
Let the games begin...
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Device = 7C:CE:77:17:DE:72 -31
Device = C8:69:CD:10:1E:C9 -32
Device = 07:42:08:E3:ED:4A -47
Device = 48:6C:B9:B9:B5:1B -28
Device = 60:03:08:B9:B3:AA -32
Device = D3:CC:CB:F7:AC:09 34507 -27
Discovering services.
Connected
Service = 00001800-0000-1000-8000-00805f9b34fb
Service = 00001801-0000-1000-8000-00805f9b34fb
Service = cc4a6a80-51e0-11e3-b451-0002a5d5c51b
Service = 0000180f-0000-1000-8000-00805f9b34fb
Service = 00001804-0000-1000-8000-00805f9b34fb
Service = 0000180a-0000-1000-8000-00805f9b34fb
Service = 000018ff-0000-1000-8000-00805f9b34fb
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = FF DF
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = FF DF
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = FF E0
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = 01 1F
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = 01 1D
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = FF E4
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = FF E0
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
DataAvailable
Characteristic 835ab4c0-51e4-11e3-a5bd-0002a5d5c51b = FF E0
Characteristic 8cd67da0-da9b-11e3-9087-0002a5d5c51b = 01
Characteristic 00002a1c-0000-1000-8000-00805f9b34fb = 00 41 AC 80 00
Characteristic 00002a21-0000-1000-8000-00805f9b34fb = 1E 00
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public BleMan As BleManager2
Public RunPer As RuntimePermissions
Public BytCon As ByteConverter
Public SaveDeviceName As String
Public SaveDeviceId As String
Public SaveServiceId As String
Public SaveCharacteristicId As String
Public BleReadTimer As Timer
Public DeviceIdStartsWith As String = "D3:CC:"
Public ServiceIdStartsWith As String = "cc4a"
Public CharacteristicIdStartsWith As String = "835a"
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
BleMan.Initialize("BleMan")
BleReadTimer.Initialize("BleReadTimer", 123) 'will set interval when enable timer (ie 123 = don't care)
If BleMan.State <> BleMan.STATE_POWERED_ON Then
Log("Not powered on.")
Else If RunPer.Check(RunPer.PERMISSION_ACCESS_COARSE_LOCATION) = False Then
Log("No location permission.")
Else
Log("Let the games begin...")
BleMan.Scan2(Null, False) 'set second parameter to True to see multiple/all scans per device
End If
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
'*** THE THREE HANDLERS FOR BLE EVENTS ***
Sub BleMan_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
Log("Device = " & Id.Trim & " " & Name.Trim & " " & RSSI)
If SaveDeviceId = "" Then 'if we haven't yet found the device we're looking for
If Id.StartsWith(DeviceIdStartsWith) Then 'and this one is it
SaveDeviceId = Id 'then save it
BleMan.Connect2(SaveDeviceId, False) 'and connect to it
BleMan.StopScan 'this can be done anytime after the device-of-interest has been found and its id saved
End If
End If
End Sub
Sub BleMan_Connected (Services As List)
Log("Connected")
For Each S As String In Services
Log("Service = " & S)
If SaveServiceId = "" Then 'if we haven't yet found the service we're looking for
If S.StartsWIth(ServiceIdStartsWith) Then 'and this one is it
SaveServiceId = S 'then save it
BleMan.ReadData(SaveServiceId) 'and read it
End If
End If
Next
End Sub
Sub BleMan_DataAvailable (ServiceId As String, Characteristics As Map)
Log("DataAvailable")
For Each C As String In Characteristics.Keys
Dim V() As Byte = Characteristics.Get(C)
Log("Characteristic " & C & " = " & ByteArrayToSpaceSeparatedHexString(V))
If SaveCharacteristicId = "" Then 'if haven't yet found the characteristic we're looking for
If ServiceId = SaveServiceId Then
If C.StartsWith(CharacteristicIdStartsWith) Then 'and this one is it
SaveCharacteristicId = C 'then save it (ServiceId already saved)
BleReadTimer.Interval = 10000 'and read it every 10 seconds
BleReadTimer.Enabled = True
End If
End If
End If
Next
End Sub
'*** TIMER DEMONSTRATING READDATA2 (RETURNS SPECIFIC CHARACTERISTIC, CF READDATA RETURNS ALL) ***
Sub BleReadTimer_Tick
'SaveServiceId should have already been set in BleMan_Connected, before BleMan.ReadData was done
'SaveCharacteristicId should have already been set in BleMan_DataAvailable, before this timer was enabled
BleMan.ReadData2(SaveServiceId, SaveCharacteristicId)
End Sub
'*** AND LAST, BUT BY NO MEANS LEAST, A FUNCTION TO STOP ME GOING CROSS-EYED ***
Sub ByteArrayToSpaceSeparatedHexString(BA() As Byte) As String
Dim HexString As String = ""
For I = 0 To BA.Length -1
HexString = HexString & " " & BytCon.HexFromBytes(Array As Byte(BA(I)))
Next
Return HexString.Trim 'trims leading space
End Sub
Public DeviceIdStartsWith As String = "D3:CC:"
Public ServiceIdStartsWith As String = "cc4a"
Public CharacteristicIdStartsWith As String = "835a"
Public DeviceIdStartsWith As String = "20:C3:8F:FD:68:52"
Public ServiceIdStartsWith As String = "0000fff0"
Public CharacteristicIdStartsWith As String = "0000fff1"
Public ServiceIdStartsWith As String = "0000ffe0"
Public CharacteristicIdStartsWith As String = "0000ffe1"
Why it happens?
Public DeviceIdStartsWith As String = "D3:CC:"
Public ServiceIdStartsWith As String = "00001800" '"cc4a"
Public CharacteristicIdStartsWith As String = "don't match any" '"835a"
*** Service (starter) Create ***
Let the games begin...
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Device = 7C:CE:77:17:DE:72 -32
Device = 07:42:08:E3:ED:4A -31
Device = 5C:2C:04:02:5C:E2 -25
Device = 60:03:08:B9:B3:AA -32
Device = A0:E6:F8:4D:1D:71 63472 -32
Device = D3:CC:CB:F7:AC:09 34507 -28
Discovering services.
Connected
Service = 00001800-0000-1000-8000-00805f9b34fb
Service = 00001801-0000-1000-8000-00805f9b34fb
Service = cc4a6a80-51e0-11e3-b451-0002a5d5c51b
Service = 0000180f-0000-1000-8000-00805f9b34fb
Service = 00001804-0000-1000-8000-00805f9b34fb
Service = 0000180a-0000-1000-8000-00805f9b34fb
Service = 000018ff-0000-1000-8000-00805f9b34fb
DataAvailable
Characteristic 00002a00-0000-1000-8000-00805f9b34fb = 33 34 35 30 37 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Characteristic 00002a01-0000-1000-8000-00805f9b34fb = 00 00
Characteristic 00002a04-0000-1000-8000-00805f9b34fb = 20 03 20 03 00 00 58 02
In characteristics 0000fff1-... thru 0000fff5-
Characteristic 0000fff1-0000-1000-8000-00805f9b34fb = 01
Characteristic 0000fff2-0000-1000-8000-00805f9b34fb = 02
Characteristic 0000fff5-0000-1000-8000-00805f9b34fb = 01 02 03 04 05
Characteristic 0000fff3-0000-1000-8000-00805f9b34fb =
Characteristic 0000fff4-0000-1000-8000-00805f9b34fb =
Yes, in nRF Connect (0000ffe1-0000-1000-8000-00805f9b34fb) data changes.Next thought is: Can you make your device send data that changes, as in treat those 5 bytes like a counter and increment it every two seconds? Then check with nRF Connect to make sure the different readings come through, changing about every 5 seconds. Then do same with app.
That's a coincidence.in nRF app, characteristic 0000ffe1 returns 31 32 33 34 35 = ASCII "12345"
in B4A app, characteristic 0000fff5 returns 01 02 03 04 05
Public DeviceIdStartsWith As String = "20:C3:8F:FD:68:52"
Public ServiceIdStartsWith As String = "00001800"
Public CharacteristicIdStartsWith As String = "00002a00"'"0000ffe1"
I do not understand why nRF Connect correctly reads the value of 0000ffe1-0000-1000-8000-00805f9b34fb characteristics, and b4a does not ...
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?