Why can't I reconnect to my BLE device using its name after its MAC address changes?
2 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2020 年 9 月 4 日
回答済み: MathWorks Support Team
2020 年 9 月 4 日
My BLE device uses random private addresses as a security feature which changes its MAC address periodically. I can connect to it the first time using its friendly name, but after the MAC address changes and I try to reconnect to the device using its name, MATLAB reports the following error:
Multiple devices found with device name <deviceName>. Specify one of the following addresses to connect:
followed by multiple addresses.
Reproduction steps:
>> blelist('Timeout',5)
ans =
6×5 table
Index Name Address RSSI Advertisement
_____ ____________ ____________ ____ _____________
1 "LE-testBLE" "<address 1>" -45 [1×1 struct]
>> b = ble('LE-testBLE')
b =
ble with properties:
Name: "LE-testBLE"
Address: "<address 1>"
Connected: 1
Services: [6×2 table]
Characteristics: [26×5 table]
Show services and characteristics
>> clear b
>> blelist('Timeout',5)
ans =
8×5 table
Index Name Address RSSI Advertisement
______ ________ ______________ ______ _____________
1 "LE-JB DW Color" "<address 1>" -36 [1×1 struct]
2 "LE-testBLE" "<address 2>" -50 [1×1 struct]
3 "" "<address 3>" -52 [1×1 struct]
4 "" "<address 4>" -65 [1×1 struct]
5 "" "<address 5>" -66 [1×1 struct]
6 "" "<address 6>" -76 [1×1 struct]
7 "" "<address 7>" -77 [1×1 struct]
8 "" "<address 8>" -85 [1×1 struct]
>> b = ble('LE-testBLE')
Multiple devices found with device name LE-testBLE. Specify one of the following addresses to connect: <address 1>,<address 2>.
How can I reconnect to my device?
採用された回答
MathWorks Support Team
2020 年 9 月 4 日
The reason that multiple devices with the same name were found is that MATLAB caches all previously found devices in the system to avoid forcing users to scan for the device for each MATLAB session. To work around this issue, use the blelist command to scan for the desired device and identify the new address of the device. With this address, connect to it using the following command:
>> b = ble(address);
For more information regarding connecting to a BLE device, refer to the following documentation page:
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!