1Bluetooth: L2CAP Shell
2######################
3
4The :code:`l2cap` command exposes parts of the L2CAP API. The following example shows how to
5register a LE PSM, connect to it from another device and send 3 packets of 14 octets each.
6
7The example assumes that the two devices are already connected.
8
9On device A, register the LE PSM:
10
11.. code-block:: console
12
13        uart:~$ l2cap register 29
14        L2CAP psm 41 sec_level 1 registered
15
16On device B, connect to the registered LE PSM and send data:
17
18.. code-block:: console
19
20        uart:~$ l2cap connect 29
21        Chan sec: 1
22        L2CAP connection pending
23        Channel 0x20000210 connected
24        Channel 0x20000210 status 1
25        uart:~$ l2cap send 3 14
26        Rem 2
27        Rem 1
28        Rem 0
29        Outgoing data channel 0x20000210 transmitted
30        Outgoing data channel 0x20000210 transmitted
31        Outgoing data channel 0x20000210 transmitted
32
33On device A, you should have received the data:
34
35.. code-block:: console
36
37        Incoming conn 0x20002398
38        Channel 0x20000210 status 1
39        Channel 0x20000210 connected
40        Channel 0x20000210 requires buffer
41        Incoming data channel 0x20000210 len 14
42        00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff       |........ ......  |
43        Channel 0x20000210 requires buffer
44        Incoming data channel 0x20000210 len 14
45        00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff       |........ ......  |
46        Channel 0x20000210 requires buffer
47        Incoming data channel 0x20000210 len 14
48        00000000: ff ff ff ff ff ff ff ff  ff ff ff ff ff ff       |........ ......  |
49