Detect Bluetooth BLE device disconnection event - Add listener to 'Connected' property

조회 수: 13(최근 30일)
Hello,
I am working on an app designer based application where I would like to be able to detect a BLE device disconnection event, so the user interface reacts consequently (e.g. displaying a "Device disconnected" message on a text label).
My initial idea was to add a listener to the BLE object 'Connected' property, but I have tried this and does not work.
I have explored the 'Connected' property and it cannot be observed.
findprop(ble('HC-08'),'Connected') %you need to have some BLE device active to be able to execute successfully this line
I could poll periodically the state of this property, but the main state machine function on my application is designed to be executed only when an specific event happens. The only way I see to solve the problem is to add a timer that periodically checks this property value and reacts in consequence.
Is there any other way to listen to this property instead of polling it continuously?
Thank you,
Regards
David L.

답변(0개)

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by