2525#include <zephyr/shell/shell.h>
2626
2727#include "host/shell/bt.h"
28+ #include "common/bt_shell_private.h"
2829
2930struct bt_a2dp * default_a2dp ;
3031static uint8_t a2dp_sink_sdp_registered ;
@@ -207,99 +208,99 @@ static void shell_a2dp_print_capabilities(struct bt_a2dp_ep_info *ep_info)
207208 codec_type = ep_info -> codec_type ;
208209 codec_ie = ep_info -> codec_cap .codec_ie ;
209210 codec_ie_len = ep_info -> codec_cap .len ;
210- shell_print ( ctx_shell , "endpoint id: %d, %s, %s:" , ep_info -> sep_info .id ,
211- (ep_info -> sep_info .tsep == BT_AVDTP_SINK ) ? "(sink)" : "(source)" ,
212- (ep_info -> sep_info .inuse ) ? "(in use)" : "(idle)" );
211+ bt_shell_print ( "endpoint id: %d, %s, %s:" , ep_info -> sep_info .id ,
212+ (ep_info -> sep_info .tsep == BT_AVDTP_SINK ) ? "(sink)" : "(source)" ,
213+ (ep_info -> sep_info .inuse ) ? "(in use)" : "(idle)" );
213214 if (BT_A2DP_SBC == codec_type ) {
214- shell_print ( ctx_shell , " codec type: SBC" );
215+ bt_shell_print ( " codec type: SBC" );
215216
216217 if (BT_A2DP_SBC_IE_LENGTH != codec_ie_len ) {
217- shell_error ( ctx_shell , " wrong sbc codec ie" );
218+ bt_shell_error ( " wrong sbc codec ie" );
218219 return ;
219220 }
220221
221- shell_print ( ctx_shell , " sample frequency:" );
222+ bt_shell_print ( " sample frequency:" );
222223 if (0U != (codec_ie [0U ] & A2DP_SBC_SAMP_FREQ_16000 )) {
223- shell_print ( ctx_shell , " 16000 " );
224+ bt_shell_print ( " 16000 " );
224225 }
225226 if (0U != (codec_ie [0U ] & A2DP_SBC_SAMP_FREQ_32000 )) {
226- shell_print ( ctx_shell , " 32000 " );
227+ bt_shell_print ( " 32000 " );
227228 }
228229 if (0U != (codec_ie [0U ] & A2DP_SBC_SAMP_FREQ_44100 )) {
229- shell_print ( ctx_shell , " 44100 " );
230+ bt_shell_print ( " 44100 " );
230231 }
231232 if (0U != (codec_ie [0U ] & A2DP_SBC_SAMP_FREQ_48000 )) {
232- shell_print ( ctx_shell , " 48000" );
233+ bt_shell_print ( " 48000" );
233234 }
234235
235- shell_print ( ctx_shell , " channel mode:" );
236+ bt_shell_print ( " channel mode:" );
236237 if (0U != (codec_ie [0U ] & A2DP_SBC_CH_MODE_MONO )) {
237- shell_print ( ctx_shell , " Mono " );
238+ bt_shell_print ( " Mono " );
238239 }
239240 if (0U != (codec_ie [0U ] & A2DP_SBC_CH_MODE_DUAL )) {
240- shell_print ( ctx_shell , " Dual " );
241+ bt_shell_print ( " Dual " );
241242 }
242243 if (0U != (codec_ie [0U ] & A2DP_SBC_CH_MODE_STREO )) {
243- shell_print ( ctx_shell , " Stereo " );
244+ bt_shell_print ( " Stereo " );
244245 }
245246 if (0U != (codec_ie [0U ] & A2DP_SBC_CH_MODE_JOINT )) {
246- shell_print ( ctx_shell , " Joint-Stereo" );
247+ bt_shell_print ( " Joint-Stereo" );
247248 }
248249
249- /* Decode Support for Block Length */
250- shell_print ( ctx_shell , " Block Length:" );
250+ /* Decode Support for Block Length */
251+ bt_shell_print ( " Block Length:" );
251252 if (0U != (codec_ie [1U ] & A2DP_SBC_BLK_LEN_4 )) {
252- shell_print ( ctx_shell , " 4 " );
253+ bt_shell_print ( " 4 " );
253254 }
254255 if (0U != (codec_ie [1U ] & A2DP_SBC_BLK_LEN_8 )) {
255- shell_print ( ctx_shell , " 8 " );
256+ bt_shell_print ( " 8 " );
256257 }
257258 if (0U != (codec_ie [1U ] & A2DP_SBC_BLK_LEN_12 )) {
258- shell_print ( ctx_shell , " 12 " );
259+ bt_shell_print ( " 12 " );
259260 }
260261 if (0U != (codec_ie [1U ] & A2DP_SBC_BLK_LEN_16 )) {
261- shell_print ( ctx_shell , " 16" );
262+ bt_shell_print ( " 16" );
262263 }
263264
264265 /* Decode Support for Subbands */
265- shell_print ( ctx_shell , " Subbands:" );
266+ bt_shell_print ( " Subbands:" );
266267 if (0U != (codec_ie [1U ] & A2DP_SBC_SUBBAND_4 )) {
267- shell_print ( ctx_shell , " 4 " );
268+ bt_shell_print ( " 4 " );
268269 }
269270 if (0U != (codec_ie [1U ] & A2DP_SBC_SUBBAND_8 )) {
270- shell_print ( ctx_shell , " 8" );
271+ bt_shell_print ( " 8" );
271272 }
272273
273274 /* Decode Support for Allocation Method */
274- shell_print ( ctx_shell , " Allocation Method:" );
275+ bt_shell_print ( " Allocation Method:" );
275276 if (0U != (codec_ie [1U ] & A2DP_SBC_ALLOC_MTHD_SNR )) {
276- shell_print ( ctx_shell , " SNR " );
277+ bt_shell_print ( " SNR " );
277278 }
278279 if (0U != (codec_ie [1U ] & A2DP_SBC_ALLOC_MTHD_LOUDNESS )) {
279- shell_print ( ctx_shell , " Loudness" );
280+ bt_shell_print ( " Loudness" );
280281 }
281282
282- shell_print ( ctx_shell , " Bitpool Range: %d - %d" ,
283- codec_ie [2U ], codec_ie [3U ]);
283+ bt_shell_print ( " Bitpool Range: %d - %d" ,
284+ codec_ie [2U ], codec_ie [3U ]);
284285 } else {
285- shell_print ( ctx_shell , " not SBC codecs" );
286+ bt_shell_print ( " not SBC codecs" );
286287 }
287288}
288289
289290void app_connected (struct bt_a2dp * a2dp , int err )
290291{
291292 if (!err ) {
292293 default_a2dp = a2dp ;
293- shell_print ( ctx_shell , "a2dp connected" );
294+ bt_shell_print ( "a2dp connected" );
294295 } else {
295- shell_print ( ctx_shell , "a2dp connecting fail" );
296+ bt_shell_print ( "a2dp connecting fail" );
296297 }
297298}
298299
299300void app_disconnected (struct bt_a2dp * a2dp )
300301{
301302 found_peer_sbc_endpoint = NULL ;
302- shell_print ( ctx_shell , "a2dp disconnected" );
303+ bt_shell_print ( "a2dp disconnected" );
303304}
304305
305306int app_config_req (struct bt_a2dp * a2dp , struct bt_a2dp_ep * ep ,
@@ -312,10 +313,10 @@ int app_config_req(struct bt_a2dp *a2dp, struct bt_a2dp_ep *ep,
312313 * stream = & sbc_stream ;
313314 * rsp_err_code = 0 ;
314315
315- shell_print ( ctx_shell , "receive requesting config and accept" );
316+ bt_shell_print ( "receive requesting config and accept" );
316317 sample_rate = bt_a2dp_sbc_get_sampling_frequency (
317318 (struct bt_a2dp_codec_sbc_params * )& codec_cfg -> codec_config -> codec_ie [0 ]);
318- shell_print ( ctx_shell , "sample rate %dHz" , sample_rate );
319+ bt_shell_print ( "sample rate %dHz" , sample_rate );
319320
320321 return 0 ;
321322}
@@ -326,115 +327,115 @@ int app_reconfig_req(struct bt_a2dp_stream *stream,
326327 uint32_t sample_rate ;
327328
328329 * rsp_err_code = 0 ;
329- shell_print ( ctx_shell , "receive requesting reconfig and accept" );
330+ bt_shell_print ( "receive requesting reconfig and accept" );
330331 sample_rate = bt_a2dp_sbc_get_sampling_frequency (
331332 (struct bt_a2dp_codec_sbc_params * )& codec_cfg -> codec_config -> codec_ie [0 ]);
332- shell_print ( ctx_shell , "sample rate %dHz" , sample_rate );
333+ bt_shell_print ( "sample rate %dHz" , sample_rate );
333334
334335 return 0 ;
335336}
336337
337338void app_config_rsp (struct bt_a2dp_stream * stream , uint8_t rsp_err_code )
338339{
339340 if (rsp_err_code == 0 ) {
340- shell_print ( ctx_shell , "success to configure" );
341+ bt_shell_print ( "success to configure" );
341342 } else {
342- shell_print ( ctx_shell , "fail to configure" );
343+ bt_shell_print ( "fail to configure" );
343344 }
344345}
345346
346347int app_establish_req (struct bt_a2dp_stream * stream , uint8_t * rsp_err_code )
347348{
348349 * rsp_err_code = 0 ;
349- shell_print ( ctx_shell , "receive requesting establishment and accept" );
350+ bt_shell_print ( "receive requesting establishment and accept" );
350351 return 0 ;
351352}
352353
353354void app_establish_rsp (struct bt_a2dp_stream * stream , uint8_t rsp_err_code )
354355{
355356 if (rsp_err_code == 0 ) {
356- shell_print ( ctx_shell , "success to establish" );
357+ bt_shell_print ( "success to establish" );
357358 } else {
358- shell_print ( ctx_shell , "fail to establish" );
359+ bt_shell_print ( "fail to establish" );
359360 }
360361}
361362
362363int app_release_req (struct bt_a2dp_stream * stream , uint8_t * rsp_err_code )
363364{
364365 * rsp_err_code = 0 ;
365- shell_print ( ctx_shell , "receive requesting release and accept" );
366+ bt_shell_print ( "receive requesting release and accept" );
366367 return 0 ;
367368}
368369
369370void app_release_rsp (struct bt_a2dp_stream * stream , uint8_t rsp_err_code )
370371{
371372 if (rsp_err_code == 0 ) {
372- shell_print ( ctx_shell , "success to release" );
373+ bt_shell_print ( "success to release" );
373374 } else {
374- shell_print ( ctx_shell , "fail to release" );
375+ bt_shell_print ( "fail to release" );
375376 }
376377}
377378
378379int app_start_req (struct bt_a2dp_stream * stream , uint8_t * rsp_err_code )
379380{
380381 * rsp_err_code = 0 ;
381- shell_print ( ctx_shell , "receive requesting start and accept" );
382+ bt_shell_print ( "receive requesting start and accept" );
382383 return 0 ;
383384}
384385
385386void app_start_rsp (struct bt_a2dp_stream * stream , uint8_t rsp_err_code )
386387{
387388 if (rsp_err_code == 0 ) {
388- shell_print ( ctx_shell , "success to start" );
389+ bt_shell_print ( "success to start" );
389390 } else {
390- shell_print ( ctx_shell , "fail to start" );
391+ bt_shell_print ( "fail to start" );
391392 }
392393}
393394
394395int app_suspend_req (struct bt_a2dp_stream * stream , uint8_t * rsp_err_code )
395396{
396397 * rsp_err_code = 0 ;
397- shell_print ( ctx_shell , "receive requesting suspend and accept" );
398+ bt_shell_print ( "receive requesting suspend and accept" );
398399 return 0 ;
399400}
400401
401402void app_suspend_rsp (struct bt_a2dp_stream * stream , uint8_t rsp_err_code )
402403{
403404 if (rsp_err_code == 0 ) {
404- shell_print ( ctx_shell , "success to suspend" );
405+ bt_shell_print ( "success to suspend" );
405406 } else {
406- shell_print ( ctx_shell , "fail to suspend" );
407+ bt_shell_print ( "fail to suspend" );
407408 }
408409}
409410
410411void stream_configured (struct bt_a2dp_stream * stream )
411412{
412- shell_print ( ctx_shell , "stream configured" );
413+ bt_shell_print ( "stream configured" );
413414}
414415
415416void stream_established (struct bt_a2dp_stream * stream )
416417{
417- shell_print ( ctx_shell , "stream established" );
418+ bt_shell_print ( "stream established" );
418419}
419420
420421void stream_released (struct bt_a2dp_stream * stream )
421422{
422- shell_print ( ctx_shell , "stream released" );
423+ bt_shell_print ( "stream released" );
423424}
424425
425426void stream_started (struct bt_a2dp_stream * stream )
426427{
427- shell_print ( ctx_shell , "stream started" );
428+ bt_shell_print ( "stream started" );
428429}
429430
430431void stream_suspended (struct bt_a2dp_stream * stream )
431432{
432- shell_print ( ctx_shell , "stream suspended" );
433+ bt_shell_print ( "stream suspended" );
433434}
434435
435436void stream_aborted (struct bt_a2dp_stream * stream )
436437{
437- shell_print ( ctx_shell , "stream aborted" );
438+ bt_shell_print ( "stream aborted" );
438439}
439440
440441void sink_sbc_streamer_data (struct bt_a2dp_stream * stream , struct net_buf * buf ,
@@ -446,9 +447,9 @@ void sink_sbc_streamer_data(struct bt_a2dp_stream *stream, struct net_buf *buf,
446447 return ;
447448 }
448449 sbc_hdr = net_buf_pull_u8 (buf );
449- shell_print ( ctx_shell , "received, num of frames: %d, data length:%d" ,
450- (uint8_t )BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_GET (sbc_hdr ), buf -> len );
451- shell_print ( ctx_shell , "data: %d, %d, %d, %d, %d, %d ......" , buf -> data [0 ],
450+ bt_shell_print ( "received, num of frames: %d, data length:%d" ,
451+ (uint8_t )BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_GET (sbc_hdr ), buf -> len );
452+ bt_shell_print ( "data: %d, %d, %d, %d, %d, %d ......" , buf -> data [0 ],
452453 buf -> data [1 ], buf -> data [2 ], buf -> data [3 ], buf -> data [4 ], buf -> data [5 ]);
453454}
454455
@@ -584,7 +585,7 @@ static int cmd_disconnect(const struct shell *sh, int32_t argc, char *argv[])
584585void app_configured (int err )
585586{
586587 if (err ) {
587- shell_print ( ctx_shell , "configure fail" );
588+ bt_shell_print ( "configure fail" );
588589 }
589590}
590591
@@ -655,7 +656,7 @@ static uint8_t bt_a2dp_discover_peer_endpoint_cb(struct bt_a2dp *a2dp,
655656 struct bt_a2dp_ep_info * info , struct bt_a2dp_ep * * ep )
656657{
657658 if (info != NULL ) {
658- shell_print ( ctx_shell , "find one endpoint" );
659+ bt_shell_print ( "find one endpoint" );
659660 shell_a2dp_print_capabilities (info );
660661 if ((info -> codec_type == BT_A2DP_SBC ) &&
661662 (ep != NULL )) {
0 commit comments