BT Music Sink Relay Example

Source code path: example/bt/music_sink_with_relay

Supported Platforms

  • eh-lb52J

Overview

This example demonstrates a music_sink-based implementation that requires two boards to download this project, enabling simultaneous music playback from a mobile phone on both devices.

Example Usage

The example consists of two parts:

  1. One part involves operations between the device and mobile phone, same as music_sink. The project enables Bluetooth Inquiry scan and page scan on startup, allowing A2DP source devices like mobile phones to discover this device and initiate connections. After connection, mobile phone music can be played.

  2. The other part involves operations between two boards. The two boards need to complete pairing to achieve music forwarding. Only one board can connect to the mobile phone at a time. The board not connected to the mobile phone will receive forwarded music information.

2.1 The board connected to the mobile phone will be configured as relay src role, otherwise you can set the role through the finsh command music set_role x (1 is relay sink; 2 is relay src). But ensure that relay src is the board connected to the mobile phone. If pairing is in progress or already completed, setting the role will fail; you can check the current role through music get_role. Only src and sink can perform pairing.

2.2 After the roles of both boards are determined, use music pair to perform pairing. Successful pairing will show the log “A2DP relay paired! Role is x”

2.3 Use music unpair to cancel pairing between the two boards.

2.4 Before the two boards are paired, you can set the audio channels of the two boards through music set_chnl x (0 represents src left channel/sink right channel, 1 represents src right channel/sink left channel, 2 represents both sides play left channel).

  1. The default Bluetooth name of this device is sifli_music_sink.

Hardware Requirements

Before running this example, you need to prepare:

Compilation and Flashing

Switch to the example project directory and run the scons command to compile:

> scons --board=eh-lb525 -j32

Switch to the example project/build_xx directory and run uart_download.bat, select the port as prompted to download:

$ ./uart_download.bat

     Uart Download

please input the serial port num:5

For detailed compilation and download steps, please refer to the relevant introduction in Quick Start.

Expected Results

After the example starts: Mobile phone music forwarding can be achieved with synchronized sound between forwarding devices without stuttering.

Exception Diagnosis

Reference Documentation

Update History

Version

Date

Release Notes

0.0.1

01/2025

Initial version