Hi Erel
I need to receive data from a ble by UART. Using old bleexended library it works, but using new ble2 library when calling ReadData, i receive the error :No matching characteristic found.
i post my code:
Sub Process_Globals
Dim manager As BleManager2
Dim mappa As Map
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim bc As ByteConverter
Private Button1 As Button
Private Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("ble2")
If FirstTime Then
manager.Initialize("ble")
End If
End Sub
Sub ble_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
Dim i As Int
Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData)
Dim data1() As Byte = AdvertisingData.Get(75)
Label1.Visible = True
Label1.Text = "Name: " & Name & CRLF & "Mac: " & Id & CRLF & "Data: " & bc.HexFromBytes(data1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ble_Connected(services As List)
Log("Connected")
'manager.SetNotify("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e",True)
'manager.ReadData2("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e")
For Each s As String In services
Log(s)
manager.ReadData(s)
Next
End Sub
Sub ble_DataAvailable(ServiceId As String, Characteristics As Map)
Log("receiving from " & ServiceId)
For Each id As String In Characteristics.Keys
Dim data3() As Byte = Characteristics.Get(id)
Log(id)
Log(bc.StringFromBytes(data3,"UTF8"))
Next
End Sub
Sub Button1_Click
Log("searching")
manager.Scan2(Null,True)
End Sub
Sub Label1_Click
manager.StopScan
manager.Connect("F8:61:A6:3D:39:AD")
End Sub
my Log is:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
searching
Found: Adafruit Bluefruit LE, F8:61:A6:3D:39:AD, RSSI = -77, (MyMap) {1=[B@423ed250, 75=[B@423ed2b8, 9=[B@423ed2f8}
Adafruit Bluefruit LE
Discovering services.
Connected
00001800-0000-1000-8000-00805f9b34fb
00001801-0000-1000-8000-00805f9b34fb
00001530-1212-efde-1523-785feabcd123
0000180a-0000-1000-8000-00805f9b34fb
6e400001-b5a3-f393-e0a9-e50e24dcca9e
ee0c2080-8786-40ba-ab96-99b91ac981d8
receiving from 00001800-0000-1000-8000-00805f9b34fb
00002a00-0000-1000-8000-00805f9b34fb
Adafruit Bluefruit LE
00002a01-0000-1000-8000-00805f9b34fb
����
00002a04-0000-1000-8000-00805f9b34fb
��P�������
receiving from 00001530-1212-efde-1523-785feabcd123
00001534-1212-efde-1523-785feabcd123
��
receiving from 0000180a-0000-1000-8000-00805f9b34fb
00002a29-0000-1000-8000-00805f9b34fb
Adafruit Industries
00002a24-0000-1000-8000-00805f9b34fb
BLEFRIEND32
00002a28-0000-1000-8000-00805f9b34fb
0.6.7 - Sep 17 2015
00002a26-0000-1000-8000-00805f9b34fb
S110 8.0.0, 0.2
00002a27-0000-1000-8000-00805f9b34fb
QFACA10
receiving from ee0c2080-8786-40ba-ab96-99b91ac981d8
ee0c2081-8786-40ba-ab96-99b91ac981d8
��
ee0c2084-8786-40ba-ab96-99b91ac981d8
��adafruit
ee0c2085-8786-40ba-ab96-99b91ac981d8
ee0c2087-8786-40ba-ab96-99b91ac981d8
ee0c2088-8786-40ba-ab96-99b91ac981d8
d��
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
as you can see, it works for all characteristic, but not for 6e400001-b5a3-f393-e0a9-e50e24dcca9e that is the UART characteristic i need.
using
manager.SetNotify("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e",True)
and
manager.ReadData2("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e")
i have: No matching characteristic found
P.s. i need to use ble2 because i have to read some data that i send in GAP
can you help me Pease? thanks
I need to receive data from a ble by UART. Using old bleexended library it works, but using new ble2 library when calling ReadData, i receive the error :No matching characteristic found.
i post my code:
Sub Process_Globals
Dim manager As BleManager2
Dim mappa As Map
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim bc As ByteConverter
Private Button1 As Button
Private Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("ble2")
If FirstTime Then
manager.Initialize("ble")
End If
End Sub
Sub ble_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
Dim i As Int
Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData)
Dim data1() As Byte = AdvertisingData.Get(75)
Label1.Visible = True
Label1.Text = "Name: " & Name & CRLF & "Mac: " & Id & CRLF & "Data: " & bc.HexFromBytes(data1)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ble_Connected(services As List)
Log("Connected")
'manager.SetNotify("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e",True)
'manager.ReadData2("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e")
For Each s As String In services
Log(s)
manager.ReadData(s)
Next
End Sub
Sub ble_DataAvailable(ServiceId As String, Characteristics As Map)
Log("receiving from " & ServiceId)
For Each id As String In Characteristics.Keys
Dim data3() As Byte = Characteristics.Get(id)
Log(id)
Log(bc.StringFromBytes(data3,"UTF8"))
Next
End Sub
Sub Button1_Click
Log("searching")
manager.Scan2(Null,True)
End Sub
Sub Label1_Click
manager.StopScan
manager.Connect("F8:61:A6:3D:39:AD")
End Sub
my Log is:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
searching
Found: Adafruit Bluefruit LE, F8:61:A6:3D:39:AD, RSSI = -77, (MyMap) {1=[B@423ed250, 75=[B@423ed2b8, 9=[B@423ed2f8}
Adafruit Bluefruit LE
Discovering services.
Connected
00001800-0000-1000-8000-00805f9b34fb
00001801-0000-1000-8000-00805f9b34fb
00001530-1212-efde-1523-785feabcd123
0000180a-0000-1000-8000-00805f9b34fb
6e400001-b5a3-f393-e0a9-e50e24dcca9e
ee0c2080-8786-40ba-ab96-99b91ac981d8
receiving from 00001800-0000-1000-8000-00805f9b34fb
00002a00-0000-1000-8000-00805f9b34fb
Adafruit Bluefruit LE
00002a01-0000-1000-8000-00805f9b34fb
����
00002a04-0000-1000-8000-00805f9b34fb
��P�������
receiving from 00001530-1212-efde-1523-785feabcd123
00001534-1212-efde-1523-785feabcd123
��
receiving from 0000180a-0000-1000-8000-00805f9b34fb
00002a29-0000-1000-8000-00805f9b34fb
Adafruit Industries
00002a24-0000-1000-8000-00805f9b34fb
BLEFRIEND32
00002a28-0000-1000-8000-00805f9b34fb
0.6.7 - Sep 17 2015
00002a26-0000-1000-8000-00805f9b34fb
S110 8.0.0, 0.2
00002a27-0000-1000-8000-00805f9b34fb
QFACA10
receiving from ee0c2080-8786-40ba-ab96-99b91ac981d8
ee0c2081-8786-40ba-ab96-99b91ac981d8
��
ee0c2084-8786-40ba-ab96-99b91ac981d8
��adafruit
ee0c2085-8786-40ba-ab96-99b91ac981d8
ee0c2087-8786-40ba-ab96-99b91ac981d8
ee0c2088-8786-40ba-ab96-99b91ac981d8
d��
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
as you can see, it works for all characteristic, but not for 6e400001-b5a3-f393-e0a9-e50e24dcca9e that is the UART characteristic i need.
using
manager.SetNotify("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e",True)
and
manager.ReadData2("6e400001-b5a3-f393-e0a9-e50e24dcca9e","6e400003-b5a3-f393-e0a9-e50e24dcca9e")
i have: No matching characteristic found
P.s. i need to use ble2 because i have to read some data that i send in GAP
can you help me Pease? thanks