Reconnecting to a Bluetooth device within a class
Afficher commentaires plus anciens
I have built a class to communicate with a Bluetooth device, setting one of the class properties as the Bluetooth object 's'. Within a class function that updates the device, I need to reset the device, which breaks the link with MATLAB. I've created a basic disconnect command that has worked thus far from outside the class.
function disconnect(obj)
obj.s.delete;
obj.s=[];
end
When I do this from inside the class function and then reconnect...
BTaddr=obj.s.Address;
BTchan=obj.s.Channel;
obj.s.delete;
obj.s=[];
obj.s=bluetooth(BTaddr,BTchan);
...the function continues to run as expected, but then the 'myDev.s' object is a "handle to deleted bluetooth" variable. I am then able to disconnect and reconnect outside of the class, but it seems unnecessarily messy. Is there something that I could do better to make this work as expected?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Bluetooth Communication dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!