I am trying some modifications using the BLE example, and I need this:
A sub inside Starter Module needs to read "edittext1.text" from Main module.
This edittext has a value of 3C:71:BF:0B:0F:3A (example)
I want connect only if "Id" found is equal the "edittext1.text" from Main.
This is the code I want to modify:
' THIS WORKS
B4X:
Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
If Id == "3C:71:BF:AB:0E:3A" Then
Log("Found: " & Name)
Log("TAK_device: " & Id)
ConnectedName = Name
manager.StopScan
manager.Connect2(Id, False) 'disabling auto connect can make the connection quicker
End If
End Sub
'THIS DONT WORK
B4X:
Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
If Id == EditText1.Text Then
Log("Found: " & Name)
Log("TAK_device: " & Id)
ConnectedName = Name
manager.StopScan
manager.Connect2(Id, False) 'disabling auto connect can make the connection quicker
End If
End Sub
If the code you posted is in the Starter service, then you won't be able to access the EditText in your Main activity. The easiest way to do it would be to put a String var in either your Process_Globals in Main or Starter, then whenever the value in EditText1 changes, copy it to the var - which you can access from Starter by either Main.var or just var if it's in your Starter.