0

I'm currently testing the bluez tools like l2ping & l2test, So my intention was to interface between two devices through l2cap layer.

I have cloned the bluez repository on two raspberry pi devices, and made necessary configuration to execute those tools, but I didn't get the expected output instead the program stuck at socket level during connect stage on sender due to which the receiver waits on accept stage, this result in either Host is down or Connection Refused Error, also I tried this sample tools on two different systems(PC) got the similar results, can someone guide me on what I'm missing here.

$ sudo ./tools/l2test -p C5:86:1A:53:D7:3B Can't connect socket: Host is down Server Advertisment start success *** Booting Zephyr OS build v4.1.0-1545-gfa45bebccfb1 *** [00:00:00.255,462] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002) [00:00:00.255,493] <inf> bt_hci_core: HW Variant: nRF52x (0x0002) [00:00:00.255,523] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 4.1 Build 99 [00:00:00.256,561] <inf> bt_hci_core: Identity: C5:86:1A:53:D7:3B (random) [00:00:00.256,591] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x0000, manufacturer 0x05f1 [00:00:00.256,622] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0xffff 

Here, I made a NRF device as peripheral which is discoverable & connectable, it advertises its info, using which it can be connected, this device can be connected using bluetoothctl but couldn't be connected using l2test

Two Raspberry Pis running BlueZ. My goal is to establish an L2CAP channel using tools like l2test and l2ping. The peripheral device (nRF52) successfully advertises and can be connected via bluetoothctl, but any attempt to connect using l2test fails with errors like Host is down or Connection refused. I've also replicated the test between two Raspberry Pi devices with the same result: the server waits on a PSM, but the client fails to connect. I'm trying to understand if this is a configuration issue, a limitation of the tools, or if additional setup (e.g., registering a PSM for LE CoC) is needed. I'd appreciate guidance on what's missing or how to properly use L2CAP over BLE with BlueZ and Zephyr.

2nd Approach using two PI devices

pi@raspberrypi:~/bluez $ sudo ./tools/l2test -V le_public -r l2test[2278]: Waiting for connection on psm 128 ... pi@raspberrypiclient:~/bluez $ sudo ./tools/l2test -V le_public -s DC:A6:32:76:10:DA l2test[977]: Can't connect: Connection refused (111) 

1 Answer 1

0

For your first approach, I'm assuming you set it up so that your nRF device has a listening L2CAP channel and is receiving data there. You might want to check some things:

  • Pass one of the following flags to l2test to test the L2CAP connection (output from running l2test -h):
 -r listen and receive -w listen and send -d listen and dump incoming data -x listen, then send, then dump incoming data -t listen, then send and receive at the same time -q connect, then send and receive at the same time -s connect and send -u connect and receive -n connect and be silent -y connect, then send, then dump incoming data -c connect, disconnect, connect, ... -m multiple connects -p trigger dedicated bonding -z information request 
  • Since I'm assuming your device is listening and receiving, you should pass the -s flag (connect and send);
  • Make sure the device has a L2CAP channel listening on PSM 0x80 (128) for l2test (or on the PSM of your choice by passing the -P $YOUR_PSM flag);
  • Get the used Bluetooth protocol (BR/EDR or LE) on your device (most likely LE from the logs);
  • If you're using Bluetooth LE, check whether the device's Bluetooth LE address is public or random (from Zephyr's logs, it is the latter);
  • Pass the correct flag to l2test to indicate the device's address type:
    • -V bredr for BR/EDR;
    • -V le_random for LE random;
    • -V le_public for LE public;

Putting it all together, you should be able to connect to your listening BLE device and send data with l2test -s -V le_random $YOUR_DEVICE_ADDRESS.

If you want to debug the connection on Zephyr's side, you can set the L2CAP module's log level to debug by setting CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y in your project's configuration file (e.g. prj.conf).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.