Check Bluetooth connect state

wantlin

Member
Licensed User
Longtime User
Hi All

How to check Bluetooth connect state at 1 sec ?
I need to confirm the Bluetooth state , if it disconnect ,I need to do some active

Please help me the problem .Thank you !
:sign0085:
 

wantlin

Member
Licensed User
Longtime User
Hi Erel

I need to check the Bluetooth is active or not . Do you give me the some idea or give me the sample program ?
thank you !
 
Upvote 0

wantlin

Member
Licensed User
Longtime User
Hi Erel
Thank you for reply my question !
But I turn on the Bluetooth device . I need to confirm Bluetooth device state .
I use the command (Serial.IsEnabled ) ,but I turn off the Bluetooth device ,the Serial.IsEnabled value is true always . Do you think the my program is error ?Please help me to check it .
Code :
Dim BtAdmin As BluetoothAdmin
Dim BtSerial As Serial
.....................
time5.Initialize("time5",1000)
time5.Enabled=True '

Sub time5_Tick
If BtSerial.IsEnabled=False Then
Log("BtSerial Not Enable" & BtSerial.IsEnabled)
reconnect_mark =True
time5.Enabled=False
Else
Log("BtSerial Enable" & BtSerial.IsEnabled)
reconnect_mark=False
End If
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But I turn on the Bluetooth device . I need to confirm Bluetooth device state .
Will be easier if you post the relevant code together with the question...

Do you mean that Serial.IsEnabled returns True after you turn off the Bluetooth device? Note that it might take a few seconds for the Bluetooth to actually turn off.

Seems like you are looking for BluetoothAdmin_StateChanged event.
 
Upvote 0

wantlin

Member
Licensed User
Longtime User
Hi Erel

Q: Do you mean that Serial.IsEnabled returns True after you turn off the Bluetooth device?
A: Yes ! I true off the Bluetooth device ,the Serial.IsEnabled value is true at repeat 100 times .
Do you have any idea ?

Thank you !
 
Upvote 0

wantlin

Member
Licensed User
Longtime User
Hi Erel

I use the HTC one . Android OS is 4.11. I have to try StateChanged, it is not change the state . When turn off the my phone Bluetooth device , the command have change the state . So I don't know what happen . So I use the AsyncStreams command . It can to check the Bluetooth device state ,but the wait time is too long , So I want to have other solution for the issue .
Thank you for your help .
 
Upvote 0
Top