bluetooth_monitor#
Description#
This node monitors a Bluetooth connection to a wireless device by using L2ping.
L2ping generates PING echo command on Bluetooth L2CAP layer, and it is able to receive and check echo response from a wireless device.
Block diagram#
L2ping is only allowed for root by default, so this package provides the following approach to minimize security risks as much as possible:
- Provide a small program named
l2ping_servicewhich performs L2ping and provides wireless device information tobluetooth_monitorby using socket programming. bluetooth_monitoris able to know wireless device information and L2ping status as an unprivileged user since those information are sent by socket communication.
Output#
bluetooth_monitor: bluetooth_connection#
[summary]
| level | message |
|---|---|
| OK | OK |
| WARN | RTT warning |
| ERROR | Lost |
| Function error |
[values]
| key | value (example) |
|---|---|
| Device [0-9]: Status | OK / RTT warning / Verify error / Lost / Ping rejected / Function error |
| Device [0-9]: Name | Wireless Controller |
| Device [0-9]: Manufacturer | MediaTek, Inc. |
| Device [0-9]: Address | AA:BB:CC:DD:EE:FF |
| Device [0-9]: RTT | 0.00ms |
- The following key will be added when
bluetooth_monitorreportsFunction error.
ex.) Theconnectsystem call failed.
| key (example) | value (example) |
|---|---|
| Device [0-9]: connect | No such file or directory |
Parameters#
| Name | Type | Description | Default | Range |
|---|---|---|---|---|
| addresses | array | Bluetooth addresses of the device to monitor | ['4C:B9:9B:6E:7F:9A'] | N/A |
| port | integer | Port number to connect to L2ping service on the host | 7640 | N/A |
| timeout | integer | Time in seconds to wait for a response from the device | 5 | N/A |
| rtt_warn | float | Time in seconds to warn if the round trip time is greater than this value | 0.1 | N/A |
rtt_warn- 0.00(zero): Disable checking RTT
- otherwise: Check RTT with specified seconds
addresses- *: All connected devices
- AA:BB:CC:DD:EE:FF: You can specify a device to monitor by setting a Bluetooth address
Instructions before starting#
- You can skip this instructions if you run
l2ping_serviceas root user.
-
Assign capability to
l2ping_servicesince L2ping requirescap_net_raw+eipcapability.sudo setcap 'cap_net_raw+eip' ./build/bluetooth_monitor/l2ping_service -
Run
l2ping_serviceandbluetooth_monitor../build/bluetooth_monitor/l2ping_service ros2 launch autoware_bluetooth_monitor bluetooth_monitor.launch.xml
Known limitations and issues#
None.