1Bluetooth: A2DP Shell 2##################### 3 4The :code:`a2dp` command exposes parts of the A2DP API. 5 6The following examples assume that you have two devices already connected. 7 8Here is a example connecting two devices: 9 * Source and Sink sides register a2dp callbacks. using :code:`a2dp register_cb`. 10 * Source and Sink sides register stream endpoints. using :code:`a2dp register_ep source sbc` and :code:`a2dp register_ep sink sbc`. 11 * Source establish A2dp connection. It will create the AVDTP Signaling and Media L2CAP channels. using :code:`a2dp connect`. 12 * Source and Sink side can discover remote device's stream endpoints. using :code:`a2dp discover_peer_eps` 13 * Source or Sink configure the stream to create the stream after discover remote's endpoints. using :code:`a2dp configure`. 14 * Source or Sink establish the stream. using :code:`a2dp establish`. 15 * Source or Sink start the media. using :code:`a2dp start`. 16 * Source test the media sending. using :code:`a2dp send_media` to send one test packet data. 17 * Source or Sink suspend the media. using :code:`a2dp suspend`. 18 * Source or Sink release the media. using :code:`a2dp release`. 19 20.. tabs:: 21 22 .. group-tab:: Device A (Audio Source Side) 23 24 .. code-block:: console 25 26 uart:~$ a2dp register_cb 27 success 28 uart:~$ a2dp register_ep source sbc 29 SBC source endpoint is registered 30 uart:~$ a2dp connect 31 Bonded with XX:XX:XX:XX:XX:XX 32 Security changed: XX:XX:XX:XX:XX:XX level 2 33 a2dp connected 34 uart:~$ a2dp discover_peer_eps 35 endpoint id: 1, (sink), (idle): 36 codec type: SBC 37 sample frequency: 38 44100 39 48000 40 channel mode: 41 Mono 42 Stereo 43 Joint-Stereo 44 Block Length: 45 16 46 Subbands: 47 8 48 Allocation Method: 49 Loudness 50 Bitpool Range: 18 - 35 51 uart:~$ a2dp configure 52 success to configure 53 stream configured 54 uart:~$ a2dp establish 55 success to establish 56 stream established 57 uart:~$ a2dp start 58 success to start 59 stream started 60 uart:~$ a2dp send_media 61 frames num: 1, data length: 160 62 data: 1, 2, 3, 4, 5, 6 ...... 63 uart:~$ a2dp suspend 64 success to suspend 65 stream suspended 66 uart:~$ a2dp release 67 success to release 68 stream released 69 70 .. group-tab:: Device B (Audio Sink Side) 71 72 .. code-block:: console 73 74 uart:~$ a2dp register_cb 75 success 76 uart:~$ a2dp register_ep sink sbc 77 SBC sink endpoint is registered 78 <after a2dp connect> 79 Connected: XX:XX:XX:XX:XX:XX 80 Bonded with XX:XX:XX:XX:XX:XX 81 Security changed: XX:XX:XX:XX:XX:XX level 2 82 a2dp connected 83 <after a2dp configure of source side> 84 receive requesting config and accept 85 sample rate 44100Hz 86 stream configured 87 <after a2dp establish of source side> 88 receive requesting establishment and accept 89 stream established 90 <after a2dp start of source side> 91 receive requesting start and accept 92 stream started 93 <after a2dp send_media of source side> 94 received, num of frames: 1, data length: 160 95 data: 1, 2, 3, 4, 5, 6 ...... 96 <after a2dp suspend of source side> 97 receive requesting suspend and accept 98 stream suspended 99 <after a2dp release of source side> 100 receive requesting release and accept 101 stream released 102 ... 103