Development Examples

[中文版]

Profile Initialization

Module Profile initialization, response event examples are as follows:

@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: +PWRSTAT=1
bt -> host: +VER=FSC-BT1038,V1.1.2,20250118
bt -> host: +PROFILE=24747
bt -> host: +SPPSTAT=1
bt -> host: +GATTSTAT=1
bt -> host: +A2DPSTAT=1
bt -> host: +AVRCPSTAT=1
bt -> host: +HFPSTAT=2
bt -> host: +BISSTAT=1
bt -> host: +CISSTAT=1
bt -> host: +DEVSTAT=7

@enduml

Parameter Modification

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: Change Bluetooth name
host -> bt: AT+NAME
bt -> host: AT+NAME=FSC-BT1038-1E49
host -> bt: AT+NAME=CARKIT,0
bt -> host: OK
host -> bt: AT+NAME
bt -> host: +NAME=CARKIT

@enduml

Before the MCU modifies any parameters, it is recommended to first query, then modify, and finally verify. For the MCU to modify the device name to CARKIT, the reference code example is as follows:

void change_name(void)
{

    uart_send("AT+NAME\r\n");
    if(uart_read("+NAME",name_buf))
    {
        if(memcmp(name_buf,"CARKIT",6))
        {
            uart_send("AT+NAME=CARKIT,0\r\n");  //defalut disable MAC address suffix
            uart_send("AT+NAME\r\n"); // read bt name
            if(uart_read("+NAME",name_buf))
            {
                if(memcmp(name_buf,"CARKIT",6))
                {
                    //change name fail
                }
                else
                {
                    //change name success
                }
            }
        }
    }
}

Classic Auido Sink Mode Application

Application Scenarios

../_images/db200-bt1038x-audio-rx-200dpi.png

Application Examples

@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=1195
bt -> host: ...
bt -> host: +DEVSTAT=7

rnote over host, bt: Mobile phone scan and connect to BT1038x
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: AT+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 Application

Application Scenarios

../_images/db200-bt1038x-audio-bisrx-200dpi.png

Application Examples

@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=1195
bt -> host: ...
bt -> host: +DEVSTAT=7

rnote over host, bt: Module initiates broadcast source scanning
host -> bt: AT+BISSCAN=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.
host -> bt: AT+BISADD=15,43356
bt -> host: +BISADD=15,43356
bt -> host: OK
bt -> host: +BISSTAT=4
bt -> host: +BISSTAT=5


@enduml

Phonebook Download

Note

For some firmware versions of SOC audio modules, automatic connection to PBAP (Phone Book Access Profile) is not supported when downloading contacts. You need to first send the AT command AT+PBCONN to establish a PBAP connection before proceeding with the download.

@startuml
hide footbox
skinparam sequenceMessageAlign center

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

rnote over host, bt: HFP connected

bt -> host: ...
bt -> host: +HFPSTAT=3

rnote over host, bt: Download all phone books
host -> bt: AT+PBDOWN=1
bt -> host: +PBSTAT=2
bt -> host: +PBSTAT=3 (PBAP is connected.)
bt -> host: +PBSTAT=4 (PBAP is being downloaded.)
bt -> host: +PBDATA=1,local number,+8618620277272
bt -> host: +PBDATA=1,Tom,0571-85592192
bt -> host: ...
bt -> host: +PBDATA=1,jerry,18909731215
bt -> host: +PBDATA=E (download completes)
bt -> host: +PBSTAT=3


rnote over host, bt: Download 50 call records
host -> bt: AT+PBWODN=5,50
bt -> host: +PBDATA=3,yidong,+10086,20200213T114247
bt -> host: ...
bt -> host: +PBDATA=2,andy,85592192,20200212T104202
bt -> host: +PBDATA=E
bt -> host: +PBSTAT=3

@enduml