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: +DEVSTAT=0
bt -> host: +HFPSTAT=1
bt -> host: +A2DPSTAT=1
bt -> host: +AVRCPSTAT=1
bt -> host: +PBSTAT=1
bt -> host: +SPPSTAT=1
bt -> host: +GATTSTAT=1
bt -> host: +VER=FSC-BT1026C,V4.9.4,20230428
bt -> host: +DEVSTAT=7
bt -> host: +PROFILE=1195

@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: +NAME=FSC-BT1026C
host -> bt: AT+NAME=My_Bluetooth,1
bt -> host: OK
host -> bt: AT+NAME
bt -> host: +NAME=My_Bluetooth0012

@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
                }
            }
        }
    }
}

Auido Sink Mode Application

Profile Connection

@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 search and connect to BT1026x
bt -> host: +PAIRED=44DA30391295
bt -> host: +A2DPSTAT=2
bt -> host: +HFPSTAT=2
bt -> host: +AVRCPSTAT=2
bt -> host: +A2DPSTAT=3(A2DP connection established)
bt -> host: +DEVSTAT=5
bt -> host: +A2DPDEV=44DA30391295,Rickphone
bt -> host: +HFPIBR=1
bt -> host: +AVRCPSTAT=3(AVRCP connection established)
bt -> host: +AVRCPDEV=44DA30391295
bt -> host: +HFPSIG=5
bt -> host: +HFPROAM=0
bt -> host: +HFPBATT=4
bt -> host: +HFPDEV=44DA30391295,Rickphone
bt -> host: +HFPSTAT=3((HFP connection established))
bt -> host: +A2DPDEC=3
bt -> host: +HFPMANU=AppleInc.
@enduml

Play and Pause Music

@startuml
hide footbox
skinparam sequenceMessageAlign center

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

rnote over host, bt: Play and Pause

host -> bt: AT+PLAY
bt -> host: OK
bt -> host: +A2DPSTAT=4
bt -> host: +PLAYSTAT=1
bt -> host: +TRACKINFO=beautiful
bt -> host: +TRACKSTAT=1,73174,392874
bt -> host: +TRACKSTAT=1,74202,392874
bt -> host: +TRACKSTAT=1,75272,392874
host -> bt: AT+PAUSE
bt -> host: OK
bt -> host: +PLAYSTAT=2
bt -> host: +A2DPSTAT=3
@enduml

Take and Hang up Call

@startuml
hide footbox
skinparam sequenceMessageAlign center

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

rnote over host, bt: Make and hang up calls

host -> bt: AT+HFPDIAL=10086
bt -> host: OK
bt -> host: +HFPAUDIO=1
bt -> host: +HFPSTAT=4
bt -> host: +HFPCID=10086
bt -> host: +HFPCIE=10086
bt -> host: +HFPSTAT=6

host -> bt: AT+HFPCHUP
bt -> host: OK
bt -> host: +HFPAUDIO=0
bt -> host: +HFPSTAT=3
bt -> host: +HFPSIG=5

@enduml

Phonebook Download

Application Process Operation Examples:

HFP connection has been established

Response: <<+PWRSTAT=1
Response: <<+VER=FSC-BT1026C,V4.9.4,20230428     // Example, please refer to the actual version
Response: <<+PROFILE=1195            // General default, enable SPP, GATT Server, HFP-HF, A2DP Sink, AVRCP Controller, PBAP Server profiles
Response: <<+SPPSTAT=1
Response: <<+GATTSTAT=1
Response: <<+A2DPSTAT=1
Response: <<+AVRCPSTAT=1
Response: <<+HFPSTAT=1
Response: <<+AVRCPSTAT=1
Response: <<+PBSTAT=1
Response: <<+DEVSTAT=1
Response: <<+DEVSTAT=7            // Enables device discoverability; mobile phones can find this Bluetooth device and establish a connection

Download all phonebooks

Send :>>AT+PBDOWN=1
Response: <<OK
Response: <<+PBSTAT=2
Response: <<+PBSTAT=3         // PBAP connected
Response: <<+PBSTAT=4         // PBAP downloading
Response: <<+PBDATA=1<FF>Local Number<FF>+8618620277272
Response: <<+PBDATA=1<FF>Zhang San<FF>0571-85592192
  ...
Response: <<+PBDATA=1<FF>Jerry<FF>18909731215
Response: <<+PBDATA=E         // Download completed
Response: <<+PBSTAT=3

Download 50 call records

Send: >>AT+PBWODN=5,50
Response: <<ok
Response: <<+PBDATA=3<FF>yidong<FF>+10086<FF>20200213T114247
  ...
Response: <<+PBDATA=2<FF>andy<FF>85592192<FF>20200212T104202
Response: <<+PBDATA=E                    // Download completed
Response: <<+PBSTAT=3