Development Examples

[中文版]

Modify Bluetooth Name

@startuml

hide footbox
skinparam sequenceMessageAlign center

box #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization
bt -> host: +SPPSTAT=1
bt -> host: +GATTSTAT=1
bt -> host: +A2DPSTAT=1
bt -> host: +AVRCPSTAT=1
bt -> host: +HFPSTAT=1
bt -> host: +VER=FSC-BT1058,V2.0.4,20260109
bt -> host: +DEVSTAT=1

rnote over host, bt: Enter BR/EDR/BLE discoverable mode
host -> bt: AT+PAIR=1
bt -> host: +DEVSTAT=7

rnote over host, bt: Change Bluetooth name
host -> bt: AT+NAME
bt -> host: AT+NAME=FSC-BT1058
host -> bt: AT+NAME=CARKIT,0
bt -> host: OK
host -> bt: AT+NAME
bt -> host: +NAME=CARKIT

@enduml

For the MCU to modify the device name to CARKIT, the reference code example is as follows:

 1void change_name(void)
 2{
 3    uart_send("AT+NAME\r\n");
 4    if(uart_read("+NAME",name_buf))
 5    {
 6        if(memcmp(name_buf,"CARKIT",6))
 7        {
 8            uart_send("AT+NAME=CARKIT,0\r\n");  // disable MAC address suffix
 9            uart_send("AT+NAME\r\n");   // read bt name
10            if(uart_read("+NAME",name_buf))
11            {
12                if(memcmp(name_buf,"CARKIT",6))
13                {
14                    //change name fail
15                }
16                else
17                {
18                    //change name success
19                }
20            }
21        }
22    }
23}

Note

Before the MCU modifies any parameters, it is recommended to first query, then modify, and finally verify.

SPP Data Transmission

@startuml

hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

rnote over host, bt: Enter BR/EDR/BLE discoverable mode
host -> bt: AT+PAIR=1
bt -> host: OK
bt -> host: +DEVSTAT=7

rnote over host, bt: Mobile phone connect to BT1058
bt -> host: +PAIRED=594171484D07
bt -> host: +SPPDEV=594171484D07
bt -> host: +SPPSTAT=3
bt -> host: +DEVSTAT=5

rnote over host, bt: Send data to the mobile phone
host -> bt: AT+SPPSEND=10,0123456789
bt -> host: OK

rnote over host, bt: Received the data sent by the mobile phone.
bt -> host: +SPPDATA=10,0123456789

rnote over host, bt: disconnected
host -> bt: AT+SPPDISC
bt -> host: OK
bt -> host: +SPPSTAT=1
bt -> host: +DEVSTAT=7

@enduml

Note

Apple devices do not support SPP connection.

GATT Data Transmission

@startuml

hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

rnote over host, bt: Enter BR/EDR/BLE discoverable mode
host -> bt: AT+PAIR=1
bt -> host: OK
bt -> host: +DEVSTAT=7

rnote over host, bt: Mobile phone connect to BT1058
bt -> host: +GATTSTAT=3
bt -> host: +GATTDEV=594171484D07

rnote over host, bt: Send data to the mobile phone
host -> bt: AT+GATTSEND=10,0123456789
bt -> host: OK

rnote over host, bt: Received the data sent by the mobile phone.
bt -> host: +GATTDATA=10,0123456789

rnote over host, bt: disconnected
host -> bt: AT+GATTDISC
bt -> host: OK
bt -> host: +GATTSTAT=1

@enduml

Audio Source Application

A2DP/HFP Application

@startuml

hide footbox
skinparam sequenceMessageAlign center

box #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

rnote over host, bt: Scan nearby BR/EDR devices
host -> bt: AT+SCAN=1
bt -> host: +SCAN=1,2,DC0D30000057,-42,11,FSC-BT1026C,240408
bt -> host: +SCAN=2,2,DC0D30000012,-70,16,FSC-BT1006A-0012,240404
bt -> host: +SCAN=E

host -> bt: AT+A2DPCONN=DC0D30000057 (A2DP connect to FSC-BT1026C)
bt -> host: OK
bt -> host: +A2DPSTAT=2
bt -> host: +A2DPSTAT=3 (A2DP connected)
bt -> host: +A2DPDEV=DC0D30000057,FSC-BT1026C
bt -> host: +HFPSTAT=3 (HFP connected)
bt -> host: +AVRCPSTAT=3 (AVRCP connected)
bt -> host: +A2DPENC=1 (SBC codec)
bt -> host: +A2DPSTAT=4 (Automatically start playing audio)

rnote over host, bt: Disconnect the audio connection
host -> bt: AT+A2DPAUDIO=0
bt -> host: +A2DPSTAT=5 (Audio paused)

rnote over host, bt: Establish HFP call
host -> bt: AT+HFPAUDIO=1
bt -> host: +HFPSTAT=4
bt -> host: +HFPAUDIO=1
bt -> host: +HFPSTAT=6
bt -> host: +HFPSR=16000 (Sample: 16000)

rnote over host, bt: Disconnect HFP call
host -> bt: AT+HFPAUDIO=0
bt -> host: +HFPSTAT=3
bt -> host: +HFPAUDIO=0

@enduml

LE Audio Broadcast Application

@startuml

hide footbox
skinparam sequenceMessageAlign center

box #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

rnote over host, bt: Change the audio mode to the Le Audio Broadcasting mode
host -> bt: AT+AUDMODE=1
bt -> host: OK
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1
bt -> host: +BISSTAT=5 ((Automatically start playing audio)
bt -> host: +BISSR=48000 (Sample: 48000)

@enduml

Note

After setting it up, you can use devices that support the Le Audio function for scanning, such as FSC-BT1038A.

LE Audio Unicast Mode

@startuml

hide footbox
skinparam sequenceMessageAlign center

box #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

bt -> host: OK
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

rnote over host, bt: Change the audio mode to the Le Audio Unicast mode
host -> bt: AT+AUDMODE=2
bt -> host: OK
bt -> host: +SPPSTAT=1
bt -> host: ...
bt -> host: +DEVSTAT=1

rnote over host, bt: Scan nearby devices
host -> bt: AT+SCAN=2,10,2 (Only scan devices that support Le Audio.)
bt -> host: +SCAN=1,0,00025B00FF02,-52,23,FSC-BT1038A-LE-FF02
bt -> host: +SCAN=E
bt -> host: +DEVSTAT=1
rnote over host, bt: connect to BT1038A
host -> bt: AT+CSICONN=0,00025B00FF02 (connect to FSC-BT1038A-LE-FF02)
bt -> host: OK
bt -> host: +CISSTAT=3
bt -> host: +CISSTAT=4 (Automatically start playing audio)
bt -> host: +CISSR=48000 (Sample: 48000)

@enduml

Audio Sink Application

Classic Auido Sink Mode Application

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization

bt -> host: ...
bt -> host: +DEVSTAT=7

rnote over host, bt: Mobile phone scan and connect to BT1058
bt -> host: +A2DPSTAT=2
bt -> host: +A2DPSTAT=3 (A2DP connected)
bt -> host: +A2DPDEV=8C861E94A09E,Navy
bt -> host: +AVRCPSTAT=3 (AVRCP connected)
bt -> host: +HFPSTAT=3 (HFP connected)
bt -> host: +HFPDEV=8C861E94A09E,Navy
bt -> host: +HFPSIG=3
bt -> host: +HFPBATT=4
bt -> host: +HFPROAM=0
bt -> host: +HFPNUM=8618620277271
bt -> host: +HFPMANU=AppleInc.

host -> bt: +HFPDIAL=10086 (Take call "10086")
bt -> host: OK
bt -> host: +HFPSTAT=4,10086
bt -> host: +HFPAUDIO=1 (HFP audio link has been established)
bt -> host: +HFPSTAT=6,10086 (call active)
host -> bt: AT+HFPCHUP(Hang up)
bt -> host: +HFPSTAT=3
bt -> host: +HFPAUDIO=0 (HFP audio link has been disconnected)

host -> bt: AT+PLAY(play music)
bt -> host: +A2DPSTAT=5
bt -> host: +PLAYSTAT=1
bt -> host: +TRACKINFO=song,artist,album
bt -> host: +TRACKSTAT=1,1000,240000
bt -> host: +TRACKSTAT=1,2000,240000
host -> bt: AT+PAUSE(pause music)
bt -> host: +PLAYSTAT=2
bt -> host: +A2DPSTAT=3

@enduml

LE Audio Broadcast Slave Application

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
participant Host as host
participant Blueware as bt
end box

rnote over host, bt: Profile initialization

bt -> host: +PROFILE=20651
bt -> host: ...
bt -> host: +DEVSTAT=7

rnote over host, bt: Module initiates broadcast source scanning
bt -> host: AT+SCAN=3,5
bt -> host: +BIS=1,-61,15,98,DC0D30000062,FSC-BP410-0062
bt -> host: +BIS=2,-48,15,43356,00025B00FF0E,FSC-BP415-ff0e
bt -> host: +SCAN=E
rnote over host, bt: The module connect to the broadcast source.
bt -> host: AT+BISADD=15,43356
bt -> host: +BISADD=15,43356
bt -> host: OK
bt -> host: +BISSTAT=4
bt -> host: +BISSTAT=5


@enduml