Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Dim bc As ByteConverter
Dim b() As Byte
Dim vals As String
Dim s As String
Dim v As Byte
End Sub
Sub DataAvailable (Service As String, Characteristics As Map)
If Service = Starter.nus_sid Then
For Each key As String In Characteristics.Keys
If key = Starter.nus_txc Then
b = Characteristics.Get(key) 'get 5 bytes from BLE peripheral
vals = bc.HexFromBytes(b) 'convert the 5 bytes to a string called vals
If vals.Length > 0 Then 'check for valid data from the BLE peripheral
s = vals.SubString2(0,2) 'extract 2 string characters - representing one byte
v = Bit.ParseInt(s,16) 'convert 2 hex string characters to decimal representation
pmSensitivity.SelectedValue = v 'load the B4XPlusMinus decimal string value shown to user
s = vals.SubString2(2,4)
v = Bit.ParseInt(s,16)
pmBarks.SelectedValue = v
s = vals.SubString2(4,6)
v = Bit.ParseInt(s,16)
pmBarkTime.SelectedValue = v
s = vals.SubString2(6,8)
v = Bit.ParseInt(s,16)
pmSprayDuration.SelectedValue = v
s = vals.SubString2(8,10)
v = Bit.ParseInt(s,16)
pmToneDuration.SelectedValue = v
End If
End If
Next
End If
End Sub