How can I disconnect ble from within a class

35 ビュー (過去 30 日間)
Geoffrey Lansberry
Geoffrey Lansberry 2019 年 11 月 13 日
回答済み: Joseph DeCerce 2020 年 5 月 14 日
I'm attempting to use BLE from within App Designer. I am able to connect to my device with the following code.
properties (Access = public)
BLEDev ble % Handle to ble device
uart_w matlabshared.blelib.Characteristic % Handle to uart write characteristic
end
methods (Access = public)
function results = connect_BLE(app)
%%start talking to the device - reuse connection if it already exists
try
clear app.uart_w;
clear app.BLEDev;
catch
end
app.BLEDev = ble("Driver");
app.uart_w = characteristic(app.BLEDev, "6E400001-B5A3-F393-E0A9-E50E24DCCA9E", "6E400002-B5A3-F393-E0A9-E50E24DCCA9E");
results = app.BLEDev.Connected;
end
end
However I have not been able to figure out how to disconnect my device - the only thing that works is to close the app.
I matlab scripts, the way to close the device would be as follows, but this does not work in the class. Can anyone offer suggestions?
clear BLEDev
  2 件のコメント
Moinul
Moinul 2020 年 1 月 24 日
Hi,
I'm having the same issue at my end. Did you find a solution yet?
Thanks,
Imon
Geoffrey Lansberry
Geoffrey Lansberry 2020 年 1 月 24 日
No, have not found any solution. I have not yet tried Matlab 2020, perhaps there are improvements included in that.

サインインしてコメントする。

採用された回答

Moinul
Moinul 2020 年 1 月 24 日
編集済み: Moinul 2020 年 1 月 24 日
Hi Again,
I've solved the problem in a different way. I've declare the "BLEDev" variable as a Global varaible inside the class. Then simply calling "clear global BLEDev" allowed me to disconnect from the BLE device. Hope this helps.
Regards,
Imon

その他の回答 (1 件)

Joseph DeCerce
Joseph DeCerce 2020 年 5 月 14 日
You can also set the objet to ""
app.bleOBJ = "";
clear app.bleOBJ

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by