Android Question BLE listener

Hirogens

Active Member
Licensed User
Longtime User
Hello, I work with BLE function and I would like to know how I can get in real time if I'm connected or not.
Thanks
 

Hirogens

Active Member
Licensed User
Longtime User
Are you connecting to the BLE peripheral from your app? You need to handle the Connected and Disconnected events.
Hello, well I use the BLE manager to connect to my device, I am connected with success but if I plug the device (cause a disconnect) I have'nt a message to say "You are disconnect".
B4X:
Sub Manager_StateChanged (State As Int)
    'Log("DANS STARTER StateChanged")
    Select State
        Case manager.STATE_POWERED_OFF
            currentStateText = "POWERED OFF"
        Case manager.STATE_POWERED_ON
            currentStateText = "POWERED ON"
        Case manager.STATE_UNSUPPORTED
            currentStateText = "UNSUPPORTED"
    End Select
    currentState = State
    CallSub(page_creation_compte, "StateModification")
End Sub
I use this to check but I would like to check my state everywhere in my app. It's clear or not ? Cause maybe I forget something.
Thanks =)
 
Upvote 0
Hello, well I use the BLE manager to connect to my device, I am connected with success but if I plug the device (cause a disconnect) I have'nt a message to say "You are disconnect".
B4X:
Sub Manager_StateChanged (State As Int)
    'Log("DANS STARTER StateChanged")
    Select State
        Case manager.STATE_POWERED_OFF
            currentStateText = "POWERED OFF"
        Case manager.STATE_POWERED_ON
            currentStateText = "POWERED ON"
        Case manager.STATE_UNSUPPORTED
            currentStateText = "UNSUPPORTED"
    End Select
    currentState = State
    CallSub(page_creation_compte, "StateModification")
End Sub
I use this to check but I would like to check my state everywhere in my app. It's clear or not ? Cause maybe I forget something.
Thanks =)
My understanding that if you are connected and then later on by some reason connection breaks, StateChanged event will be raised and your 'StateModification' sub will be called. I use primitive HomTom HT3 device and sometimes by some unknown reason it loses connection and then restores it, and I always see 'POWERED ON' popping up in my log in the middle of normal program execution.
 
Upvote 0
Top