How to use Bluetooth Low Energy in a compiled application ?

2 views (last 30 days)
I am trying to compile a Matlab Application using BLE communication into a standalone app. The application is compiled properly, without any errors, and can be launched, but each time I try to scan BLE devices using the function blelist, the application crashes.
I used the diary function to get the error message, and it says that " Bluetooth permission is not enabled for MATLAB. Allow MATLAB or Terminal to use Bluetooth from the Security & Privacy settings ". Of course, I allowed both Matlab and Terminal to use Bluetooth, but the errors still occurs and the application continues to crash.
I don't know if I missed an application to add into the Bluetooth permissions, like an executable of Matlab Runtime ?
I work on macOs, if it can help.
Thanks for your help !

Answers (1)

Ayush
Ayush on 21 May 2024
Edited: Ayush on 21 May 2024
Hello Hugo,
To resolve the issue of your MATLAB compiled application crashing whenever you are trying to scan the Bluetooth Low Energy (BLE) devices, you can consider the following workarounds:
1. Since the standalone application runs in MATLAB Runtime which requires additional Bluetooth permissions that MacOS would not have allowed automatically, and you must ensure that MATLAB Runtime is specifically allowed in the list.
2. You can try modifying the Info.plist file for Bluetooth permissions, by modifying the permission keys i.e. NSBluetoothPeripheralUsageDescription and NSBluetoothAlwaysUsageDescription providing reasons for access.
3. Ensure that the application’s deployment target is supported by MacOS to avoid any system specific permission constraints.
4. You can try testing on another machine to identify if the issue is machine-specific or a broader issue. Thereafter, you can try contacting MathWorks support for specific solutions for BLE communication in compiled MATLAB application on MacOS. Please refer to the link below to visit the support website:
For more information on BLE communication and its troubleshooting techniques you can refer to the following documentations:
Hope it helps!

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!