Hi Erel,
I use your BLEexample and adding some log messages as you can see in the following code:
Sub DataAvailable (Service As String, Characteristics As Map)
pbReadData.Visible = False
Log("Log in DataAvailable")
Log("Service: "&Service)
clv.Add(CreateServiceItem(Service), 30dip, "")
For Each id As String In Characteristics.Keys
Log("Log in DataAvailable")
Log("Characteristic Key: "&id&" Characteristic Item: "& Characteristics.Get(id))
clv.Add(CreateCharacteristicItem(id, Characteristics.Get(id)), 40dip, "")
Next
End Sub
....
Sub CreateServiceItem (service As String) As Panel
Dim pnl As Panel
pnl.Initialize("")
pnl.Color = 0xFF808080
Dim lbl As Label
lbl.Initialize("")
lbl.Text = service
Log("Log in CreateServiceItem")
Log("service: "&service)
lbl.Gravity = Gravity.CENTER
lbl.Typeface = Typeface.DEFAULT_BOLD
pnl.AddView(lbl, 0, 0, clv.AsView.Width, 30dip)
Return pnl
End Sub
Sub CreateCharacteristicItem(Id As String, Data() As Byte) As Panel
Dim pnl As Panel
pnl.Initialize("")
pnl.Color = Colors.White
Dim lbl As Label
lbl.Initialize("")
lbl.Text = Id
pnl.AddView(lbl, 0, 0, clv.AsView.Width, 20dip)
Log("Log in CharacteristicItem")
Log("Id: "&Id)
Dim lbl2 As Label
lbl2.Initialize("")
Try
lbl2.Text = BytesToString(Data, 0, Data.Length, "UTF8")
Log("Log in CharacteristicItem")
Log("Data Length: "&Data.Length&" Data: "&lbl2.Text)
Catch
Log(LastException)
lbl2.Text = "Error reading data as string"
End Try
lbl2.TextColor = 0xFF909090
lbl2.TextSize = 14
pnl.AddView(lbl2, 0, 20dip, clv.AsView.Width, 20dip)
Return pnl
End Sub
I obtain this log:
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Found: Bluegiga CR Demo, 00:07:80:A7:44:6E, RSSI = -74, (MyMap) {1=[B@427b8848, 7=[B@427b88b0, 9=[B@427b8900}
Discovering services.
Connected
Log in DataAvailable
Service: 0bd51666-e7cb-469b-8e4d-2742f1ba77cc
Log in CreateServiceItem
service: 0bd51666-e7cb-469b-8e4d-2742f1ba77cc
Log in DataAvailable
Characteristic Key: e7add780-b042-4876-aae1-112855353cc1 Characteristic Item: [B@427c1f08
Log in CharacteristicItem
Id: e7add780-b042-4876-aae1-112855353cc1
Log in CharacteristicItem
Data Length: 0 Data:
Log in DataAvailable
Service: 00001800-0000-1000-8000-00805f9b34fb
Log in CreateServiceItem
service: 00001800-0000-1000-8000-00805f9b34fb
Log in DataAvailable
Characteristic Key: 00002a00-0000-1000-8000-00805f9b34fb Characteristic Item: [B@4266b140
Log in CharacteristicItem
Id: 00002a00-0000-1000-8000-00805f9b34fb
Log in CharacteristicItem
Data Length: 16 Data: Bluegiga CR Demo
Log in DataAvailable
Characteristic Key: 00002a01-0000-1000-8000-00805f9b34fb Characteristic Item: [B@427bf788
Log in CharacteristicItem
Id: 00002a01-0000-1000-8000-00805f9b34fb
Log in CharacteristicItem
Data Length: 2 Data: AB
** Activity (main) Pause, UserClosed = false **
I hope this can be usefull for you to solve my problem.
Best Regard.
Thank in advance.
Mosè