Appendix A: Examples¶
These are some typical use case example.
In every one of them we assume that the pairing list is empty and the configuration is the default one.
UNPAIR
>OK
RESTORE
>IoT747 Copyright 2016
>Audio Agent V1.0.15
>Build: 1470411720
>Ready
Pairing and connection with Audio Agent¶
Discovering Audio Agent from a phone and initiating paring:
Use the STATUS command to make sure that Audio Agent is discoverable, if it is not the case you can use the DISCOVERABLE command:
DISCOVERABLE ON
>OK
STATUS
>STATE CONNECTABLE DISCOVERABLE IDLE
Now look for devices from your mobile phone. Your device should appear with the configured name (see NAME parameter). Select and initiate pairing with Audio Agent. This should automatically connect the phone to Audio Agent with all available profiles.
Audio Agent will respond with a notification OPEN_OK or OPEN_ERROR for each profiles.
Discovering a phone from Audio Agent and connect to it:
Make sure Bluetooth is ON and that your phone is discoverable if you want to it to be visible to Audio Agent.
Use the INQUIRY command to look for discoverable devices. Audio Agent will return a list of discoverable device:
When you find the correct device, take note of its Bluetooth address and use the OPEN command to connect. Audio Agent will respond with a notification OPEN_OK or OPEN_ERROR for each profiles.
INQUIRY 10
>PENDING
>INQUIRY {BT ADDRESS}{NAME}{DEVICE CLASS}{RSSI}
…
>INQU_OK
OPEN {BT ADDRESS} {PROFILE}
>PAIR_PENDING
>PAIR_OK {BT ADDRESS}
>OPEN_OK 10 A2DP {BT ADDRESS}
Please note that if you want to connect Audio Agent to a new device, Audio Agent will go automatically in discoverable mode to be able to pair with the new device. Once paired, the device will be added to paired device list (use LIST command to see it) and Audio Agent will be able to connect directly to it.
Link Policy¶
In this example we assume that Audio Agent is connected to a device (index 1). Here is how to set a power table with 2 entries:
LINK_POLICY 1 2
>PENDING
// Passive mode 30 seconds */
FF 0 0 0 0 1E
>PENDING
// Enter sniff mode (500mS)*/
1 320 320 2 1 0
>OK
Digital Audio configuration¶
Audio Agent board 1 | Audio Agent board 2 |
|
---|---|
//initial state
SET AUDIO=1
>OK
|
//initial state
SET AUDIO=1
>OK
|
// I2S master (default configuration)
// Bit clock: 2.822Mhz (64*44100Hz)
// Word clock: 44100Hz
// 16 bits per sample
// Left Justified with 1 Bit delay
SET AUDIO_DIGITAL=0 44100 64 100A00
>OK
|
// I2S slave
SET AUDIO_DIGITAL=0 44100 64 100200
>OK
|
// PCM master
// Bit clock: 1.536Mhz
// Word clock: 48000Hz
SET AUDIO_DIGITAL=1 48000 1536 2100420
>OK
|
// PCM slave
SET AUDIO_DIGITAL=1 48000 1536 100420
>OK
|
// SPDIF
// Output rate: 48000Hz
SET AUDIO_DIGITAL=2 48000 0 9
>OK
|
// SPDIF
SET AUDIO_DIGITAL=2 48000 0 9
>OK
|
A2DP¶
Multi-connection and audio routing¶
To be able to connect to multiple devices to Audio Agent you have to set the maximum number of connection per profile.
This can be done by setting up the PROFILES parameter as in the following example:
// Enable 3 A2DP Sink and 3 AVRCP connections
SET PROFILES=0 0 3 0 3 0 0 0 0 0 0 0
>OK
WRITE
>OK
RESET
In the following, three devices are connected with the A2DP and AVRCP profiles.
The MUSIC command is used to start streaming music and the ROUTE command allows you to select which stream to listen to:
>STATE CONNECTED[3] CONNECTABLE[ON] DISCOVERABLE[OFF] BLE[IDLE]
>LINK 10 CONNECTED A2DP {BT ADDRESS} SBC SRC 44100
>LINK 11 CONNECTED AVRCP {BTADDRESS} STOPPED
>LINK 20 CONNECTED A2DP {BTADDRESS} SBC SRC 44100
>LINK 21 CONNECTED AVRCP {BTADDRESS} STOPPED
>LINK 30 CONNECTED A2DP {BT ADDRESS} SBC SRC 44100
>LINK 31 CONNECTED AVRCP {BT ADDRESS} STOPPED
MUSIC 11 PLAY
>OK
>A2DP_STREAM_START 10
>AVRCP_PLAY 11
MUSIC 21 PLAY
>OK
>A2DP_STREAM_START 20
>AVRCP_PLAY 21
MUSIC 31 PLAY
>OK
>A2DP_STREAM_START 30
>AVRCP_PLAY 31
// Force audio routing to select device 3
ROUTE 30
>OK
// Revert to automatic routing (if more than one device is streaming, select to
the one that starts playing first, device 1 in this case)
ROUTE 0
>OK
Music source¶
To be able to stream music from Audio Agent to a speaker or headset you have to enable A2DP Source. This can be done by setting up the PROFILES parameter as in the following example:
// Enable A2DP Source and AVRCP (A2DP Sink is disabled)
SET PROFILES=0 0 0 1 1 0 0 0 0 0 0 0
>OK
WRITE
>OK
RESET
Audio Agent is now ready to stream some music. Once connected to a device you can use the MUSIC and VOLUME commands:
>STATE CONNECTED[1] CONNECTABLE[ON] DISCOVERABLE[OFF] BLE[IDLE]
>LINK 10 CONNECTED A2DP {BD ADDRESS} SBC SRC 44100
>LINK 11 CONNECTED AVRCP {BD ADDRESS} STOPPED
MUSIC 11 PLAY
>OK
>A2DP_STREAM_START 10
>AVRCP_PLAY 11
VOLUME 11 UP
>OK
>ABS_VOL 11 87
It is possible send meta data using the AVRCP_META_DATA command:
//notify a track changed and store the meta data
AVRCP_META_DATA 11 2 IoT747 //ARTIST: IoT747
>PENDING
//wait for the remote device to send a request to get the new meta data
...
//Audio Agent respond to the remote device with the data previously stored in memory
>OK [#f2]_
True Wireless Stereo (TWS)¶
Here is an example that shows how to stream music from a phone to two Audio Agent devices connected together with TWS.
Audio Agent board 1 | Audio Agent board 2 |
|
---|---|
//initial state
STATUS
>STATE CONNECTED[0] CONNECTABLE[ON] DISCOVERABLE[ON] BLE[IDLE]
>OK
//search and connect to the TWS device
(audio agent board 2)
INQUIRY 10 4 ON
>PENDING
>INQUIRY {BT ADDRESS}" audio agent board 2"
240418 -75db
...
>INQU_OK
OPEN {BT ADDRESS}TWS
>PENDING
>PAIR_PENDING
>PAIR_OK {BT ADDRESS}
>OPEN_OK 1A TWS {BT ADDRESS}
>OPEN_OK 11 AVRCP {BT ADDRESS}
//device discoverable, phone pairs and
connects
DISCOVERABLE ON
>OK
>PAIR_PENDING
>PAIR_OK {BT ADDRESS 2}
>OPEN_OK 23 HFP {BT ADDRESS}
>OPEN_OK 20 A2DP {BT ADDRESS}
>OPEN_OK 21 AVRCP {BT ADDRESS}
//Phone start streaming music
>AVRCP_PLAY 11
>A2DP_STREAM_START 10
>AVRCP_PLAY 21
|
//initial state
STATUS
>STATE CONNECTED[0] CONNECTABLE[ON] DISCOVERABLE[ON] BLE[IDLE]
>OK
//TWS connection
>PAIR_PENDING
>PAIR_OK {BT ADDRESS}
>OPEN_OK 1A TWS {BT ADDRESS}
>OPEN_OK 11 AVRCP {BT ADDRESS}
//Phone start streaming music
>AVRCP_PLAY 11
|
TalkBack¶
//Enable aptX Low Latency and TalkBack feature
SET CODEC=6 ON
>OK
WRITE
>OK
RESET
HFP¶
In these examples, we assume that we have two boards running Audio Agent. One configured is configured as the AG (AGHFP enabled in PROFILES) and one as the HF (HFP enabled in PROFILES). The connection is established using the OPEN command from the AG or HF.
Incoming call¶
AG |
HF |
---|---|
CALL 12 INCOMING {NUMBER}
>OK
>CALL_INCOMING AGHFP 12
>INBAND_RING AGHFP [#f1]_
|
>CALL_INCOMING HFP 13
|
Outgoing call¶
An outgoing call can be requested from the HF with CALL OUTGOING, REDIAL or MEMORY. On the AG, CALL OUTGOING is used to inform the HF of the outgoing state.
AG |
HF |
---|---|
>CALL_DIAL AGHFP 12 {NUMBER}
|
CALL 13 OUTGOING {NUMBER}
>OK
|
>CALL_REDIAL AGHFP 12
|
CALL 13 REDIAL
>OK
|
>CALL_MEMORY AGHFP 12 {MEMORY STRING}
|
CALL 13 MEMORY {MEMORY STRING}
>OK
|
CALL 12 OUTGOING {NUMBER}
>OK
>CALL_OUTGOING AGHFP 12
|
>CALL_OUTGOING HFP 13
|
Call answer/reject¶
When there is an incoming or outgoing call, CALL ANSWER or REJECT shall be used from the HF or the AG.
AG |
HF |
---|---|
>CALL_ACTIVE AGHFP 12
|
CALL 13 ANSWER
>OK
>CALL_ACTIVE HFP 13
|
>CALL_END AGHFP 12
|
CALL 13 REJECT
>OK
>CALL_IDLE HFP 13
|
CALL 12 ANSWER
>OK
>CALL_ACTIVE AGHFP 12
|
>CALL_ACTIVE HFP 13
|
CALL 12 REJECT
>OK
>CALL_END AGHFP 12
|
>CALL_IDLE HFP 13
|
Call transfer¶
When a call is active, the audio is transferred through the eSCO/SCO connection. The CALL TRANSFER command allows switching the audio between the AG and HF.
AG |
HF |
---|---|
CALL 12 TRANSFER
>OK
CALL 12 TRANSFER
>OK
|
// transfer from HF to AG
>SCO_CLOSE 13
// transfer from AG to HF
>SCO_OPEN 13
|
End call¶
An incoming/outgoing or active call can be terminated from the AG with the CALL END command. It is also possible to end an outgoing or active call from the HF.
AG |
HF |
---|---|
CALL 12 END
>OK
>CALL_END AGHFP 12
|
>CALL_IDLE HFP 13
|
>CALL_END AGHFP 12
|
CALL 13 END
>OK
>CALL_IDLE HFP 13
|
Three way calling¶
When there is an active call and another call incoming, the CALL TWC command shall be used instead of CALL ANSWER Tor reject. It can be used for instance to accept the incoming call and put the other call on hold or to merge the calls.
AG |
HF |
---|---|
>CALL_INCOMING AGHFP 12
|
>CALL_INCOMING HFP 13
// accept incoming call and put other
call on hold
CALL 12 TWC 1
>OK
>SCO_CLOSE 13
// transfer from AG to HF
>SCO_OPEN 13
// swap calls
CALL 12 TWC 1
>OK
// merge calls
CALL 12 TWC 3
>OK
|
AT commands¶
// Enable AT commands
SET HFP_CONFIG=OFF ON OFF OFF ON
>OK
// open HFP link 13, active call
...
LINK 13 CONNECTED HFP {BT ADDRESS} ACTIVE NB
// send DTMF tones
AT 13 AT+VTS=1
>OK
AT 13 AT+VTS=#
>OK
PBAP¶
// Enable PBAP in the profiles
SET PROFILES=1 0 0 0 0 0 0 1 0 0 0 0
// Open PBAP connection (make sure PBAP is enabled in the PROFILES parameter)
OPEN {BT ADDRESS} PBAP
>PENDING
>OPEN_OK 16 PBAP {BT ADDRESS}
// Download phonebook
PB_PULL 16
>PENDING
>PB_PULL_START 16
>BEGIN:VCARD
>VERSION:2.1
>FN;CHARSET=UTF-8:My Number
>N;CHARSET=UTF-8:My Number
>TEL;TYPE=CELL:+447446110144
>END:VCARD
>BEGIN:VCARD
>VERSION:2.1
>FN;CHARSET=UTF-8:Acavbsxns
>N;CHAPB_PULL_END 16
>PB_PULL_START 16
>RSET=UTF-8:;Acavbsxns
>TEL;TYPE=CELL:1234 567890
>END:VCARD
>PB_PULL_OK 16
// Download last 16 numbers dialled
PB_PULL 16 1 3 10 0 85
>PENDING
>PB_PULL_START 16
>BEGIN:VCARD
>VERSION:2.1
>FN;CHARSET=UTF-8:My Number
>N;CHARSET=UTF-8:My Number
>TEL;TYPE=CELL:+447446110144
>X-IRMC-CALL-DATETIME;DIALED:20151110T133324
>END:VCARD
>...
>PB_PULL_OK 16
MAP¶
// Enable MAP in the profiles
SET PROFILES=1 0 0 0 0 0 0 0 0 0 1 0
// Open MAP connection (make sure MAP is enabled in the PROFILES parameter)
OPEN {BT ADDRESS} MAP
>PENDING
>OPEN_OK 18 MAP {BT ADDRESS}
// Receive a notification and message
>MAP_NEW_SMS 18
>MAP_MSG_BEGIN 18
>BEGIN:BMSG
>VERSION:1.0
>STATUS:UNREAD
>TYPE:SMS_GSM
>FOLDER:telecom/msg/inbox
>NOTIFICATION:1
>BEGIN:VCARD
>VERSION:2.1
>FN;CHARSET=UTF-8:IoT747 Test
>N;CHARSET=UTF-8:IoT747 Test
>TEL:
>END:VCARD
>BEGIN:BENV
>BEGIN:BBODY
>CHARSET:UTF-8
>LANGUAGE:UNKNOWN
>LENGTH:45
>BEGIN:MSG
>Hello from iot747
>END:MSG
>END:BBODY
>END:BENV
>END:BMSG
>MAP_MSG_END 18
BLE¶
BC Smart service¶
Audio Agent (Central mode) |
Audio Agent(Peripheral mode) |
---|---|
// configure device in Central mode
SET BLE_CONFIG=1
>OK
// scan for peripheral devices
SCAN 5
>SCAN {BT ADDRESS}1 <BC00187> 12 -84db
......
>SCAN_OK
// central connects to peripheral
OPEN {BT ADDRESS} BLE 1 [#f3]_
>PENDING
>OPEN_OK 14 BLE {BT ADDRESS}
|
// configure device in Peripheral mode
SET BLE_CONFIG=0
>OK
// start advertising
ADVERTISING ON
>OK
// connection established
>OPEN_OK 14 BLE {BT ADDRESS}
|
// write message
SEND 14 Hello [#f4]_
>OK
|
// receive message
>RECV 14 Hello
|
// enable notification (BC_SMART Data
characteristic)
BC_SMART_NOTIF 14 ON OFF
>OK
// receive notification
>RECV 14 Hi!!
|
// send notification
SEND 14 Hi!!
>OK
|
// send command
BC_SMART_COMMAND 14 GET AUDIO
>OK
>RECV 14 AUDIO=0
>RECV 14 OK
|
// handle command
// response over BLE (if notif enabled)
|
Generic commands¶
In this example, Audio Agent is connected to another board with Audio Agent configured in Peripheral mode.
// Get list of services
BLE_GET_SERV 14
>PENDING
>BLE_SERV 14 U16 1801 0001 0004
>BLE_SERV 14 U16 1800 0005 0009
>BLE_SERV 14 U16 180A 000A 001C
>BLE_SERV 14 U16 1804 001D 001F
>BLE_SERV 14 U16 1802 0020 0022
>BLE_SERV 14 U16 1803 0023 0025
>BLE_SERV 14 U128 BC2F4CC6-AAEF-4351-9034-D66268E328F0 0026 002C
>BLE_SERV 14 U128 67D13B00-89B8-11E3-9DE5-0002A5D5C51B 002D FFFF
>OK
// Get list of characteristics (Device Information service)
BLE_GET_CHAR 14 000A 001C
>PENDING
>BLE_CHAR 14 U16 2A29 000C
>BLE_CHAR 14 U16 2A24 000E
>...
>OK
// Get list of characteristics (BC Smart service)
BLE_GET_CHAR 14 0026 002C
>PENDING
>BLE_CHAR 14 U128 06D1E5E7-79AD-4A71-8FAA-373789F7D93C 0028 //BC Smart Data
>BLE_CHAR 14 U128 818AE306-9C5B-448D-B51A-7ADD6A5D314D 002B //BC Smart Command
>OK
// Read characteristic - Manufacturer Name (Device Information service)
BLE_READ 14 000C
>PENDING
>BLE_READ_RES 14 000C 12426C75654372656174696F6E //IoT747
>OK
// Write characteristic - BC Smart Data (BC Smart service)
BLE_WRITE 14 0028 5
>PENDING
{48}{45}{4C}{4C}{4F} // values sent in hex format, 5 bytes
>OK
Beacons¶
This example shows you how to set your beacons parameters. Make sure that BLE is enabled in PROFILES. To advertise, you can use the ADVERTISING command or enable the auto-advertising feature in BLE_CONFIG.
SET BLE_CONFIG=2
>OK
// iBeacon
UUID: 0x00112233-4455-6677-8899-AABBCCDDEEFF
Major: 0x04D2 (1234)
Minor: 0x162E (5678)
Tx Power: -18dBm (0xEE)
>SET BEACON_DATA=0 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF 04 D2 16 2E EE
>OK
// Eddystone UID
Namespace: 0x00112233445566778899
Instance: 0xAABBCCDDEEFF
Tx Power: 0xEE
(the last 4 bytes are not used)
>SET BEACON_DATA=1 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF EE 00 00 00 00
>OK
// Eddystone URL
Tx Power: 0xEE
Prefix: 0x02 (http://)
Encoded URL: 0x676F6F2E676C2F495A304F5141 (goo.gl/IZ0OQA) [#f6]_
(the last 6 bytes are not used)
SET BEACON_DATA=2 EE 02 67 6F 6F 2E 67 6C 2F 49 5A 30 4F 51 41 00 00 00 00 00 00
>OK
WRITE
>OK
RESET
Set advertising data¶
// Set custom advertising data (flags: 0x06 - UUID128: bc2f4cc6-aaef-4351-9034-d66268e328f0 - Short name: BC00181)
ADVERTISING 30
>PENDING
{02}{01}{06}
{11}{06}{f0}{28}{e3}{68}{62}{d6}{34}{90}{51}{43}{ef}{aa}{c6}{4c}{2f}{bc}
{08}{08}{42}{43}{30}{30}{31}{38}{31}OK
// Start advertising
ADVERTISING ON
>OK
Set scan response data¶
// Set custom scan response data (set the Complete Local Name(0x09) to "MyName")
SSRD 8
>PENDING
{07}{09}{4d}{79}{4e}{61}{6d}{65}OK
HID¶
HID Host: note that all HID data is in HEX.
// Enable HID host profile
SET PROFILES=0 0 0 0 0 0 0 0 0 1 0 0
>OK
WRITE
>OK
RESET
// Read remote device descriptor
HID_READ {BD ADDRESS}
>PENDING
>HID_READ 335 {09}{02}{06}{36}{01}{49}{36}{01}{46}{08}{22}{26}{01}{41}{05}{01}{09}{06}{A1}{01}
{85}{01}{75}{01}{95}{08}{05}{07}{19}{E0}{29}{E7}{15}{00}{25}{01}{81}{02}{95}{01}{
75}{08}{81}{03}{95}{05}{75}{01}{05}{08}{19}{01}{29}{05}{91}{02}{95}{01}{75}{03}{9
1}{03}{95}{06}{75}{08}{15}{00}{26}{FF}{00}{05}{07}{19}{00}{29}{FF}{81}{00}{C0}{05
}{0C}{09}{01}{A1}{01}{85}{02}{15}{00}{25}{01}{75}{01}{95}{12}{0A}{23}{02}{0A}{AE}
{01}{0A}{B1}{01}{0A}{94}{01}{0A}{8A}{01}{0A}{82}{01}{0A}{21}{02}{09}{B6}{09}{CD}{
09}{B5}{09}{E2}{09}{EA}{09}{E9}{09}{30}{09}{40}{0A}{96}{01}{0A}{9D}{01}{0A}{C1}{0
1}{81}{02}{95}{01}{75}{06}{81}{03}{C0}{05}{0C}{09}{01}{A1}{01}{85}{03}{05}{01}{09
}{06}{A1}{02}{05}{06}{09}{20}{15}{00}{26}{FF}{00}{75}{08}{95}{01}{81}{02}{C0}{C0}
{05}{01}{09}{80}{A1}{01}{85}{04}{15}{00}{25}{01}{75}{01}{95}{01}{09}{82}{81}{02}{
95}{01}{75}{07}{81}{03}{C0}{05}{0C}{09}{01}{A1}{01}{85}{05}{05}{01}{09}{06}{A1}{0
2}{06}{00}{FF}{25}{01}{75}{01}{95}{02}{0A}{03}{FE}{0A}{04}{FE}{81}{02}{95}{06}{81
}{03}{C0}{C0}{05}{01}{09}{02}{A1}{01}{85}{08}{09}{01}{A1}{00}{05}{09}{19}{01}{29}
{05}{15}{00}{25}{01}{75}{01}{95}{05}{81}{02}{75}{03}{95}{01}{81}{01}{05}{01}{09}{
30}{09}{31}{15}{81}{25}{7F}{75}{08}{95}{02}{81}{06}{09}{38}{15}{81}{25}{7F}{75}{0
8}{95}{01}{81}{06}{C0}{C0}{05}{0C}{09}{01}{A1}{01}{85}{FF}{05}{06}{95}{01}{75}{02
}{19}{24}{29}{26}{81}{02}{75}{06}{81}{01}{C0}{4F}{4B}{0A}
>OK
// Initiate a connect to a HID device
OPEN {BD ADDRESS} HID
>PENDING
>OPEN_OK 17 HID {BT ADDRESS}
// Keyboard
>RECV 17 9 {01}{00}{00}{04}{00}{00}{00}{00}{00}{0A}
>RECV 17 9 {01}{00}{00}{00}{00}{00}{00}{00}{00}{0A}
>RECV 17 9 {01}{02}{00}{00}{00}{00}{00}{00}{00}{0A}
>RECV 17 9 {01}{02}{00}{04}{00}{00}{00}{00}{00}{0A}
>RECV 17 9 {01}{02}{00}{00}{00}{00}{00}{00}{00}{0A}
>RECV 17 9 {01}{00}{00}{00}{00}{00}{00}{00}{00}{0A}
// Mouse
>RECV 17 5 {08}{00}{02}{FF}{00}{0A}
>RECV 17 5 {08}{00}{00}{00}{00}{0A}
>RECV 17 5 {08}{00}{00}{00}{00}{0A}
>RECV 17 5 {08}{00}{00}{00}{00}{0A}
>RECV 17 5 {08}{00}{00}{00}{00}{0A}
>RECV 17 5 {08}{00}{00}{00}{00}{0A}
>RECV 17 5 {08}{00}{00}{00}{00}{0A}
HID device.
// Enable HID device profile and use default keyboard descriptor
SET PROFILES=0 0 0 0 0 0 0 0 1 0 0 0
>OK
SET COD=000540
>OK
WRITE
>OK
RESET
// Initiate a connect to a HID host
OPEN {BD ADDRESS} HID
>PENDING
>OPEN_OK 17 HID {BT ADDRESS}
// Press ‘a’
SEND_RAW 17 8
>PENDING
{00}{00}{04}{00}{00}{00}{00}{00}
// Release ‘a’
SEND_RAW 17 8
>PENDING
{00}{00}{00}{00}{00}{00}{00}{00}
// Enable HID device profile
SET PROFILES=0 0 0 0 0 0 0 0 1 0 0 0
>OK
SET COD=000580
>OK
WRITE
>OK
RESET
// Update HID descriptor to be a mouse
// example descriptor:
05010902A1010901A10005091901290815002501950875018102950081030501093009311601F826F
F07750C9502810609381581257F750895018106050C0A380295018106C0C0
HID_DESC 71
>PENDING
{05}{01}{09}{02}{A1}{01}{09}{01}{A1}{00}{05}{09}{19}{01}{29}{08}{15}{00}{25}{01}
{95}{08}{75}{01}{81}{02}{95}{00}{81}{03}{05}{01}{09}{30}{09}{31}{16}{01}{F8}{26}{
FF}{07}{75}{0C}{95}{02}{81}{06}{09}{38}{15}{81}{25}{7F}{75}{08}{95}{01}{81}{06}{0
5}{0C}{0A}{38}{02}{95}{01}{81}{06}{C0}{C0}
/ Initiate a connect to a HID host
OPEN {BD ADDRESS} HID
>PENDING
>OPEN_OK 17 HID
// Move the mouse vertically
SEND_RAW 17 6
>PENDING
{00}{00}{30}{00}{00}{00}
// Press left button
SEND_RAW 17 6
>PENDING
{01}{00}{00}{00}{00}{00}
// Release left button
SEND_RAW 17 6
>PENDING
{00}{00}{00}{00}{00}{00}
SPP¶
The following section describes a typical use case for an SPP connection. In this example, we create a SPP connection between two Audio Agent devices to show some of the capabilities of the SPP profile from the transmitter and receiver side.
First you must assure that the SPP profile is enabled on both devices:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Enable SPP
>SET PROFILES=0 0 0 0 0 0 1 0 0 0 0 0
>OK
>WRITE
>OK
>RESET
>IoT747 Copyright 2015
>Audio Agent V1.0.15
>Build: 1443202002
>Ready
|
// Enable SPP
>SET PROFILES=0 0 0 0 0 0 1 0 0 0 0 0
>OK
>WRITE
>OK
>RESET
>IoT747 Copyright 2015
>Audio Agent V1.0.15
>Build: 1443202002
>Ready
|
The next step is to create an SPP connection, in this example, the OPEN command is used:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
//Start connection
OPEN {BT ADDRESS} SPP
>OPEN_OK 15 SPP {BT ADDRESS}
|
//Accepts connection
>OPEN_OK 15 SPP {BT ADDRESS}
|
We can type status on both devices to see the details of the SPP connection:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
//Get connection details
STATUS
>LINK 15 CONNECTED SPP {BT ADDRESS}
COMMAND
|
//Get connection details
STATUS
>LINK 15 CONNECTED SPP {BT ADDRESS}
COMMAND
|
So, in both devices, we are in command mode. In this mode, we can use the SEND command as follows to send a string from device one to device two:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
//Sends a string to device two.
SEND 15 Hi, I’m device one.
>OK
|
//Device two prints a notification with
the SPP link, the length of the
received data and the data.
>RECV 15 19 Hi, I’m device one.
|
or we can use the SEND_RAW command to transfer a specified number of bytes:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Use the SEND command to send 20
bytes of data through the SPP
connection.
SEND_RAW 15 20
>PENDING
// The next 20 bytes we send through
the UART interface, will be sent
through the SPP connection to device
two.
012345678901234567890
>OK
// Device one has already received 20
characters, so send to the data to
device two.
|
// Do nothing in device two.
// Do nothing in device two.
// Device two receives the 20 bytes.
>RECV 15 20 01234567890123456789
|
If device two is in command mode, we can also execute commands in device two from device one, by sending the command we want to execute through the SPP connection. This is currently not supported for all commands.
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Execute the status command in device
two and obtain the results.
SEND_RAW 15 7
>PENDING
// Send the status command, <CR> is the
carriage return character.
STATUS<CR>
>OK
// Device one prints the results from
executing the status command in device
two.
>RECV 15 15 STATE CONNECTED
>RECV 15 4 OFF
>RECV 15 54 LINK 15 CONNECTED
{BT_ADDRESS} COMMAND STRING
|
// Do nothing in device two.
//Device two, which is in command mode,
receives the status command and
executes it, then it sends the results
through the SPP connection.
// Do nothing in device two.
|
Now we will use data mode in device one, but first the user must assure that hardware flow control in the UART interface is enabled.
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Get the UART configuration, which
shows that HW flow control is enabled.
GET UART_CONFIG
>UART_CONFIG=9600 ON 0
|
// Do nothing in device two.
|
When data mode is enabled, data received from the UART interface is sent through the SPP interface with no additional parsing, and, similarly, data received from the SPP connection is sent through the UART interface.
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Enable data mode.
ENTER_DATA_MODE 15
>OK
//Data received from the UART interface
is immediately sent through the SPP
connection.
>Hi I’m device one.
// Data received from the SPP
connection is immediately sent through
the UART.
>Hi, I’m device two.
|
// Do nothing in device two.
// Device two receives the data sent
from device one.
>RECV 15 1 H
>RECV 15 18 I, I’m device one.
// Send something from device two to
device one.
SEND 15 Hi, I’m device two.
>OK
|
To exit from data mode, you can use the escape sequence:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Follow the procedure to exit from
data mode using the escape sequence.
$$$$
>OK
// Device two is no longer in data
mode.
|
// Do nothing in device two.
// Do nothing in device two.
|
Finally, you can use the CLOSE command to terminate an SPP connection, in this example, we will use the close command in device one:
Audio Agent SPP Device One | Audio Agent SPP Device Two |
|
---|---|
// Follow the procedure to exit from
data mode using the escape sequence.
CLOSE 15
>CLOSE_OK 15 SPP
|
//Device two confirms that the SPP has
closed successfully.
>CLOSE_OK 15 SPP
|
Tones¶
The TONE command is used to play back tones on the Audio Agent audio output. Tones are mixed with any ongoing audio playback. See appendix A for more details about the tone parameters.
Here are some examples that demonstrate the TONE command capabilities:
A sample tone:
TONE TE 400 V 64 TI 0 N C5 L 8 N R0 L 32 N E5 L 8 N R0 L 32 N G5 L 8 N R0 L 32 N
B5 L 4 N R0 L 1 N C6 L 2 TN C6 L 8
>OK
Variable volume single note:
TONE V 64 N C6 L 4 V 128 N C6 L 4 V 255 N C6 L 4 V 128 N C6 L 4 V 64 N C6 L 4
>OK
Musical scale starting from C4 and omitting any flat and sharp tones:
TONE V 128 TI 0 N C4 L 8 N D4 L 8 N E4 L 8 N F4 L 8 N G4 L 8 N A4 L 8 N B4 L 8 N
C5 L 8
>OK
Footnotes
- 1
If in-band ringing is enabled in HFP_CONFIG
- 2
If the remote device is Audio Agent, don’t forget to enable meta data to receive the track information (MUSIC_META_DATA).
- 3
By default Audio Agent uses random address as we can see in the scan result (type = 1)
- 4
To send data over BLE, it is also possible to enter in Data mode.
- 5
Note that with BC Smart Service, it is simpler to use the SEND or the BC_SMART commands
- 6
IoT747 URL encoded with Google URL shortener at https://goo.gl