I am connecting a headless RPi 2 with bluetooth dongle to a tablet running a B4A App. Everything was working fine some months ago but suddenly I have a problem.
The b4j app is a non UI and can be started from the menu to debug etc. It is also started in the rc.local on boot.
If I boot the Rpi, it seems that the BT is not ready for about 5 seconds after the GUI appears (the icon is grey and then goes blue). During this time, my app has tried to initialise BT, fails and closes. If I start the app manually via the menu, it works fine as the icon is blue - clear I hope.
This is the code I am using(b4j ver. 4.70):
I think it would be better to use a
instead of the If-End. Am I correct or not and would this be the correct code?
Many thanks.
The b4j app is a non UI and can be started from the menu to debug etc. It is also started in the rc.local on boot.
If I boot the Rpi, it seems that the BT is not ready for about 5 seconds after the GUI appears (the icon is grey and then goes blue). During this time, my app has tried to initialise BT, fails and closes. If I start the app manually via the menu, it works fine as the icon is blue - clear I hope.
This is the code I am using(b4j ver. 4.70):
B4X:
'Start bluetooth
bt.Initialize("bt")
If bt.IsEnabled = False Then
Log("Bluetooth not available1")
ExitApplication
End If
RPiStatus.State=True ' turn on green LED to show ready status of RPi
Log($"My address: ${GetBluetoothAddress}"$)
Log("***************************************************************************")
bt.Listen 'bt_Connected is called when connection is made
StartMessageLoop
I think it would be better to use a
B4X:
Wait For bt.IsEnabled = True
Many thanks.