serialport / bluetooth issues

14 visualizzazioni (ultimi 30 giorni)
John Whalen
John Whalen il 3 Giu 2023
Commentato: John Whalen il 18 Giu 2023
There seems to be a lot of bluetooth issues with Matlab and MacOS. I connect to various ESP32's with bluetooth and I have to use "serialport" in order to communicate with them. blelist, bluetoothlist, etc. will crash matlab but I have this in a different post ( https://www.mathworks.com/matlabcentral/answers/1870442-macos-bluetoothlist-command-hangs-up-busy ). There was a suggestion that this would be fixed for 2023a but doesn't appear that it was.
At any rate, the problem I'm having with serialport() is that I have to quit Matlab completely and forget all my bluetooth pairing's every time before I open my .mlapp . On Mac this is requires a lot of mouse clicks and is tedious when you have to "forget" and reconnect a lot of bluetooth pairs. I tried to delete the ports before I close out my .mlapp but this doesn't seem to help. Looking at this post ( https://www.mathworks.com/matlabcentral/answers/886269-how-do-i-close-serialport-objects ) it suggests the ability to drop the handles was intentionally removed. Does anyone know if there is a way to drop the handles?
Does anyone out there have a reliable way to connect a Mac to a bluetooth device via matlab to send and receive serial data?

Risposte (1)

Walter Roberson
Walter Roberson il 4 Giu 2023
What that second post is telling you is that serialport() has an internal onCleanup that is invoked when serialport() detects the device is no longer reachable (because it is unplugged), so when the device gets unplugged, all of the internal MATLAB records of the port are removed -- there are no more handle objects left to drop when this situation occurs.
At the moment, I do not have any ideas why you need to re-pair the devices, so I cannot address that -- but it is not because of left-over handles.
  3 Commenti
Walter Roberson
Walter Roberson il 4 Giu 2023
I am running Catalina on the system I am using at the moment. I have three paired bluetooth devices. The only cu.* and tty.* in my /dev are /dev/cu.Bluetooth-Incoming-Port and /dev/tty.Bluetooth-Incoming-Port and there is nothing in /dev that looks like a device file for the paired bluetooth entities.
John Whalen
John Whalen il 18 Giu 2023
You'll want to use a bluetooth device that has Serial Port Profile (SPP). If you have an ESP32 or something similar you can setup SPP on that device. Basically it allows a bluetooth device to act like a serial device.

Accedi per commentare.

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by