AnW_BT_SRV
AnW Bluetooth Service API, offered two sorts of releases
1.APP Release (btsrv): executable BTDemo, laun
cher btsrv_client.sh, essentails libraries (.so), and App configures (.xml)
2.SDK Release (anwbtsrv_sdk): open source with AnWBTServiceDemo.cpp, imported essentials libraries (.so), header (anwbtservice.h), and App configures (.xml)
Pre-Requiremen
Modify combo module init script /etc/init.d/ubloxinit.sh
echo "[DDMISO] UBLOX Driver"
modprobe jody-w2-sdiouart
ifconfig uap0 192.168.1.10
hostapd /etc/ublox/hostapd.conf -B
udhcpd /etc/ublox/udhcpd.conf
ifconfig uap0 up
wpa_supplicant -B -D nl80211 -i mlan0 -c /etc/ublox/wpa_supplicant.conf
#modprobe jody-w2-sdiouart-bt
#hciattach /dev/ttyAMA1 any 3000000 flow
#hciconfig -a hci0 up
#hciconfig -a hci0
udhcpc -i mlan0
Run App on targets (*_btsrv_app-.zip)
1.1 unzip
1.2 Copy results folder /build/btsrv to target /home/btsrv , (suggest scp command)
1.3 go to target, in terminal entering /btsrv folder
1.4 run btsrv_client.sh to launch BTDemo demo app and following the menu commands
> ./btsrv_client.sh
, if permission warning
> chmod -R 755 btsrv
bluetooth menu
set device name
================bluetooth menu=================
...
4. SetLocalDevAddrOrName
...
===============================================
> input num: 4
0.set local name
1.set local address
> 0
> input name: IamSample(for example)
...
set device adress
================bluetooth menu=================
...
4. SetLocalDevAddrOrName
...
===============================================
> input num: 4
0.set local name
1.set local address
> 1
> input addr(xx:xx:xx:xx:xx:xx): 48:b8:a3:d5:8f:33 (for example)
...
get sdk version
================bluetooth menu=================
...
6. Version
...
===============================================
> input num:6
you can get the message of version
Version:1.0.1.20
customize settings path-folder
================bluetooth menu=================
...
5. SetFilePath
===============================================
> input num: 5
> input path:/usr/zzqdemo/
if set path success,you can get the log,for example
>>>AnWBTSRV_SetLocalConfigureFilePath
storage_filepath:/usr/zzqdemo/anwbt_storage.bin
...
<<<AnWBTSRV_SetLocalConfigureFilePath
Note: the Path of input must end with "/"
power on init
================bluetooth menu=================
...
2. BTPowerOn
...
===============================================
> input num: 2
BTPowerOn
...
power off
================bluetooth menu=================
...
3. BTPowerOff
...
===============================================
> input num: 3
BTPowerOff
...
Note: Looking for device name (e.g. AnWBT) from mobile, then pair the device with mobile When mobile shows connected succeed, turn off the BT button from mobile, then turn on the BT button from mobile again. At this time, mobile has paired storage with the device.
common Menu
start inquiry device
================ common Menu ==================
...
2.StartInquiry
...
===============================================
input num: 2
...
Note:then you can find the new device's message from respond log,for example
AnWBTService_MsgCallback(10)
AnWBTSERVICE_NEW_DEVICE_FOUND name[CSR - bc7] devclass[2098184]
stop inquiry device
================ common Menu ==================
...
3.StopInquiry
...
===============================================
input num: 3
...
connect device
================ common Menu ==================
...
8.ConnectDevice
...
===============================================
> input num: 8
...
> input connect addr(xx:xx:xx:xx:xx:xx): 11:e8:14:da:61:d4 (for example)
Note: You can find mobile BT mac from "Setting->General->About-> Bluetooth" (iphone)
> input profile_mask: 0x00000040 (Take spp as an example)
Note: Then, connected.Querying the mobile phone shows that the connection is successful
profile mask table:
HFP_HF = 0x00000001;
HFP_AG = 0x00000002;
A2DP_SINK = 0x00000004;
A2DP_SOURCE = 0x00000008;
PBAP_CLIENT = 0x00000010;
MAP_CLIENT = 0x00000020;
SPP = 0x00000040;
HID = 0x00000080;
IAP = 0x00000100;
OPPS = 0x00000200;
OPPC = 0x00000400;
ALL = 0xFFFF
spp write
================ common Menu ==================
...
10.SPP_Write
...
===============================================
> input num: 10
> input connect addr(xx:xx:xx:xx:xx:xx): 11:e8:14:da:61:d4 (for example)
Note: You can find mobile BT mac from "Setting->General->About-> Bluetooth" (iphone)
CarPlay spp settings
>input SPP_data:ff,55,2,0,ee,10 (for example)
Note: ff,55,2,0,ee,10 is specified for CarPlay, to check log printed to get successfully responded from iPhone Note: Then, check log printed to get successfully responded
AnWBTService_SPP_DATA_IND_S sppData:
[ff] [55] [2] [0] [ee] [10]
android auto spp settings
>input SPP_data:00, 15, 00, 04, 08, 01, 10, 00, 18, 00,20, 95, 01, 20, 99, 01, 20, 9D,01, 20, A1, 01, 20, A5, 01 (for example)
Note: 00, 15, 00, 04, 08, 01, 10, 00 ... is specified for Android Auto or inquiry device from Android phone, upon paired, if phone is "Android Auto" supported, the connect request will automatically send to host HU. Note: Then, check log printed to get successfully responded
AnWBTService_SPP_DATA_IND_S sppData:
[0][64][0][5][8][1][10][5][1a][e][39][41][32][37][31][46][46][41][5a][30][30][41][4b][34][20][0][32][4c][a][24][66][32][61][63][66]
disconnect device
Note: the device had been connected a.k.a. spp connected
================ common Menu ==================
...
9.DisconnectDevice
...
===============================================
> input num: 9
> input connect addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
> input profile_mask:0x00000040
After execution, you can receive the answer message of disconnection and find call back message in the log
AnWBTService_MsgCallback(7)
AnWBTSERVICE_DEV_PROFILE_STATE_CHANGED profile_mask[10] devclass[7995916] isConnected[0]
When StartInquiry is running, execute StopInquiry immediately and stop inquiry
pair response
================ common Menu ==================
...
4.PairResponse
...
===============================================
input num: 4
...
set pin code
================ common Menu ==================
...
5.SetPinCode
...
===============================================
input num: 5
input pincode:1111
set local DevCoD
================ common Menu ==================
...
6.SetLocalDevCoD
...
===============================================
input num:6
input devClass:7995916
get local OOB data
================ common Menu ==================
...
7.GetLocalOOBData
...
===============================================
input num:7
...
Note:then you can get the respond message from log,"status[0]" indicates success,for example
AnWBTService_MsgCallback(13)
AnWBTSERVICE_GET_LOCAL_OOB_DATA status[0] hash_c192...
set scan mode
================ common Menu ==================
...
11.SetScanMode
...
===============================================
> input num:11
> input setPairingState:3
After execution, the log print the pairing state "setPairingState:state[5]"
get scan mode
================ common Menu ==================
...
12.GetScanMode
...
===============================================
> input num:12
After execution, you can get the state form log ,for example: PairingState[5]
pair device
================ common Menu ==================
...
14.PairDevice
...
===============================================
> input num:14
> input pair addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
> input pincode:0000
After execution, you can receive the answer message and find call back message in the log
AnWBTService_MsgCallback(8)
AnWBTSERVICE_PAIRED_DEVICE_ELEMENT_CHANGED isFirstPaired[1] event_type[0] support_profile_mask[2ced]
Note:Querying the mobile phone shows paired record
unpair device
================ common Menu ==================
...
13.UnPairDevice
...
===============================================
> input num:13
> input unpair addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
After execution, you can receive the answer message and find call back message in the log
AnWBTService_MsgCallback(9)
AnWBTService_UnpairDevice_S type[1] status[0]
get all paired device Info
================ common Menu ==================
...
15.GetAllPairedDeviceInfo
...
===============================================
> input num:15
then the log print all paired device Info,for example
PairedDevInfo:btaddr[11:e8:14:da:61:d4] linkKey[w쳇[:µb7] devClass[7995916] nameLen[6] rdName[123asd] servicesSupported[11501] didVenderID[76] didProductID[28937] didVersion[2880] didVenderIDSource[1]
get local device Info
================ common Menu ==================
...
16.GetLocalDevInfo
...
===============================================
> input num:16
then the log print local device Info, for example
LocalDevInfo:btaddr[a5:a5:0:5b:2:0] devClass[2098184] nameLen[6] Name[ANWBT] servicesSupported[15] pinLen[4] pinCode[0000]
##get BT power status
================ common Menu ==================
...
17.get BT power status
...
===============================================
> input num:17
then the log print the power status of BT, like "power_status[0]"
send HCI command
================ common Menu ==================
...
18.SendHCICommand
...
===============================================
> input num:18
> input OpCode Group:
> input OpCode Command:
> input Command parameters:
check device is connected
================ common Menu ==================
...
19.DeviceIsConnected
===============================================
> input num:19
> input addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
then the log print the status that the device is connected or not connected,for example
connect_status[1](0-not connected 1-connected)
get connected SPP information (CarPlay /AndroidAuto)
================ common Menu ==================
...
20.AnWBTSRV_SPP_GetInformation
===============================================
> input num:20
>input addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
then you can get the SPP information , for example
CarPlay:
AnWBTService_SPP_Info_S:dev_type=0 actual_spp_index=100
spp_uuid128:[0x00][0x00][0x00][0x00][0xde][0xca][0xfa][0xde][0xde][0xca][0xde][0xaf][0xde][0xca][0xca][0xfe]
AndroidAuto:
AnWBTService_SPP_Info_S:dev_type=1 actual_spp_index=101
spp_uuid128:[0x4d][0xe1][0x7a][0x00][0x52][0xcb][0x11][0xe6][0xbd][0xf4][0x08][0x00][0x20][0x0c][0x9a][0x66]
view BT name & address
================ common Menu ==================
...
21.Local BT Name & Address
===============================================
> input num:21
then you can get the local device BT name & address, for example
---------------------------------------
Local Host Name:IamSample
Local Host Address:[48:b8:a3:d5:8f:33]
---------------------------------------
HFP Menu
outgoing call
================== HFP Menu ===================
...
2.OutgoingCall
...
===============================================
> input num:2
> input typeofcall:0 (0/1/2/3)
> input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
> input phonenum:10010
After execution, you can receive the answer message and find call back message in the log, for example
AnWBTService_MsgCallback(15)
AnWBTService_HFPCallChanged_S devclass[7995916] call1_number[10010] call1_state[5] call2_number[10010 ] call2_state[2] call3_number[] call3_state[1]
AnWBTService_MsgCallback(16)
AnWBTService_HFPClccInfoChanged_S number[10010] name[ 10010 ] dir[0] status[0]
accept all
================== HFP Menu ===================
...
3.AcceptCall
...
===============================================
> input num:3
> input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
hang up
================== HFP Menu ===================
...
4.Hangup
...
===============================================
> input num:4
> input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
After execution, you can receive the answer message and find call back message in the log, for example
AnWBTService_MsgCallback(15)
AnWBTService_HFPCallChanged_S devclass[7995916] call1_number[2] call1_state[4] call2_number[10010 ] call2_state[2] call3_number[] call3_state[2]
AnWBTService_MsgCallback(14)
AnWBTService_HFPFeatureValueChanged_S rdName[123asd] devclass[7995916] HFP_Feature_mask[2]
AnWBTService_MsgCallback(14)
AnWBTService_HFPFeatureValueChanged_S rdName[123asd] devclass[7995916] HFP_Feature_mask[4]
AnWBTService_MsgCallback(14)
AnWBTService_HFPFeatureValueChanged_S rdName[123asd] devclass[7995916] HFP_Feature_mask[32]
get audio state
================== HFP Menu ===================
...
5.GetAudioState
...
===============================================
> input num:5
> input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
then the log print the audio state ,for example "audio state[0]"
get call status list
================== HFP Menu ===================
...
6.GetCallStatusList
===============================================
> input num:6
> input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
then logs print the respond message,for exaple
AnWBTService_HFPClccInfoChanged_S number[10010] name[ 10010 ] dir[0] status[0]
pbap Menu
sync start
Note: To execute this API, pbap and HFP must be connected successfully. so we can input profile_mask:0x00000011
================ common Menu ==================
...
8.ConnectDevice
...
===============================================
> input num: 8
...
> input connect addr(xx:xx:xx:xx:xx:xx): 11:e8:14:da:61:d4 (for example)
>input profile_mask: 0x00000011
Note: You can find mobile BT mac from "Setting->General->About-> Bluetooth" (iphone)
start sync pabap
================== pbap Menu ==================
...
2.SYNCSTART
...
===============================================
>input num:2
>input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
After execution, you can receive the answer message and find call back message in the log, for example
AnWBTService_MsgCallback(30)
AnWBTService_PBAP_CONTACT_DATA_S contactID[1] contactTYPE[1] fnLen[12] fn[我的编号] honorific_suffixesLen[4] honorific_suffixes[wdbh]
AnWBTService_MsgCallback(32)
AnWBTService_PBAP_TELEPHONE_DATA_S contactID[1] telephoneNumID[1] telephoneNumLen[14] telephoneNum[+8617621702696]
AnWBTService_MsgCallback(31)
AnWBTService_PBAP_CALLLOG_DATA_S callID[123] callTYPE[2] fnLen[0] fn[] number[055112340] timeLen[19] time[2021-12-14T15:17:12]
sync cancal
================== pbap Menu ==================
...
3.SYNCCANCEL
...
===============================================
>input num:2
>input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
then the pbap SYNC will cancel and stop
get contact data
================== pbap Menu ==================
...
4.AnWBTSRV_PBAP_GetContactBaseOnContactID
...
===============================================
>input num:4
>input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
>input contactID:4
You can find the printed data in the log,for example
AnWBTService_PBAP_CONTACT_DATA_S contactID[4] contactTYPE[1] fnLen[12] fn[大头] honorific_suffixesLen[4] honorific_suffixes[aeyy]
get call log data
================== pbap Menu ==================
...
5.AnWBTSRV_PBAP_GetCalllogBaseOnCallID
...
===============================================
>input num:5
>input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
>input callID:1
You can find the printed data in the log,for example
AnWBTService_PBAP_CALLLOG_DATA_S callID[4] callTYPE[1] fnLen[9] fn[李] number[13455322147] timeLen[19] time[2022-01-30T10:05:00]
get telephone data
================== pbap Menu ==================
...
6.AnWBTSRV_PBAP_GetNumbersBaseOnContactID
===============================================
>input num:6
>input target addr(xx:xx:xx:xx:xx:xx):11:e8:14:da:61:d4
>input contactID:4
You can find the printed data in the log,for example
telephoneData:xuhao[1] rdName[SniperKaka] contactID[4] telephoneNumID[4] telephoneNumLen[11] telephoneNum[13625427382]
telephoneData:xuhao[2] rdName[SniperKaka] contactID[4] telephoneNumID[5] telephoneNumLen[12] telephoneNum[053284920528]
telephoneData:xuhao[3] rdName[SniperKaka] contactID[4] telephoneNumID[6] telephoneNumLen[11] telephoneNum[18053365017]
MAP Menu
connect map
we can input profile_mask:0x00000020
================ common Menu ==================
...
8.ConnectDevice
...
===============================================
> input num: 8
...
> input connect addr(xx:xx:xx:xx:xx:xx): 11:e8:14:da:61:d4 (for example)
>input profile_mask: 0x00000020
after connect success,we can execute map operation
set message status
================= map Menu =================
...
2. SetMessageStatus
...
============================================
input num: 2
send message
================= map Menu =================
...
3. SendMessage
...
============================================
input num: 3
download message
================= map Menu =================
...
4. Download
...
============================================
input num: 4
If the SMS is downloaded successfully, the log will print the returned information,for example
AnWBTService_MsgCallback(38)
AnWBTSERVICE_MAP_SMS_DATA: sender_name[] sender_telephone_num[10010] datetime[20210812T151753] message[I am Examples...] message_status_type[0] message_subject[-1261446707] store_type[83] utc_offset[-1261446605]
abort download
================= map Menu =================
...
5. AbortDownload
============================================
input num: 5
If the short message download is interrupted successfully, the map will disconnect and the log will print the callbck information,for example
AVRCP Menu
connect avrcp & a2dp
we can input profile_mask:0x00000004 to Connect AVRCP&A2DP
================ common Menu ==================
...
8.ConnectDevice
...
===============================================
> input num: 8
...
> input connect addr(xx:xx:xx:xx:xx:xx): 11:e8:14:da:61:d4 (for example)
>input profile_mask: 0x00000004
if connect success ,we can get the log of callback,for example
AnWBTService_MsgCallback(7)
AnWBTSERVICE_DEV_PROFILE_STATE_CHANGED profile_mask[4] devclass[7995916] isConnected[1]
after connect success,you need to turn on the music player.then we can execute AVRCP api
music control
for example,Host control play music,controlid input 0 to play music(0: CTRL_PLAY_PRESS).
================== avrcp Menu =================
...
2. AVRCP_Control
...
===============================================
input num:2
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
input controlid:0
The mobile music player will play music and the log will print the callback information.
AnWBTSERVICE_AVRCP_MEDIA_INFO_CHANGED: albumName[解药 (新版)] artistName[来一碗老于] mediaTitle[解药 (新版)] playingTimeMs[51836] SongLengthTimeMs[212000]
AnWBTSERVICE_AVRCP_MEDIA_INFO_CHANGED: sizeAlbumName[15] sizeArtistName[15] sizeMediaTitle[15] sizePlayingTimeMs[5] sizeSongLengthTimeMs[6]
set player application setting
================== avrcp Menu =================
...
3. AVRCP_SetPlayerApplicationSetting
...
===============================================
input num:3
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
input attributeId:0X02
input attributeValue:0X02
log will print callback of setting that you set
get player application setting
================== avrcp Menu =================
...
4. AVRCP_GetPlayerApplicationSetting
...
===============================================
input num:4
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
log will print callback of setting
AnWBTService_MsgCallback(44)
AnWBTSERVICE_AVRCP_CURRENT_REPEAT_SHUFFLE currentRepeatMode[0] currentShuffleMode[0]
set absolute volume
================== avrcp Menu =================
...
5. AVRCP_SetCtAbsoluteVolume
...
===============================================
input num:5
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
browsing data refresh
================== avrcp Menu =================
...
6. AnWBTSRV_AVRCP_BR_Refresh
...
===============================================
input num:6
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
you can get the callback message form log,for example
AnWBTService_MsgCallback(57)
AnWBTSERVICE_AVRCP_BR_GET_PLAYERLIST: status[12]
browsing enter
================== avrcp Menu =================
...
7. AnWBTSRV_AVRCP_BR_Enter
...
===============================================
input num:7
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
input index:0
you can get the callback message form log,for example
AnWBTService_MsgCallback(63)
AnWBTSERVICE_MAP_STATE_CHANGED: state[117]
browsing back to previous
================== avrcp Menu =================
...
8. AnWBTSRV_AVRCP_BR_Back
===============================================
input num:8
input target addr(xx:xx:xx:xx:xx:xx):d4:61:da:14:e8:11
you can get the callback message form log,for example
AnWBTService_MsgCallback(55)
AnWBTSERVICE_AVRCP_BR_PLAYER_ITEM_START: numberOfItems[1] uidCounter[0] addr[e6:ad:95:85:52:dc]
AnWBTService_MsgCallback(57)
AnWBTSERVICE_AVRCP_BR_GET_PLAYERLIST: status[0]
A2DP Menu
connect avrcp & a2dp
we can input profile_mask:0x00000004 to Connect AVRCP&A2DP
================ common Menu ==================
...
8.ConnectDevice
...
===============================================
> input num: 8
...
> input connect addr(xx:xx:xx:xx:xx:xx): 11:e8:14:da:61:d4 (for example)
>input profile_mask: 0x00000004
if connect success ,we can get the log of callback,for example
AnWBTService_MsgCallback(7)
AnWBTSERVICE_DEV_PROFILE_STATE_CHANGED profile_mask[4] devclass[7995916] isConnected[1]
after connect success,you need to turn on the music player.then we can execute A2DP api
(un)mute
================== a2dp Menu ==================
...
2. A2DP_WAVEOUT_Mute
...
===============================================
input num: 2
input mode(mute or unmute):1
If the setting is successful, you can receive a callback in log,for example
musicPlay[1] bt_status_manager.Bluetooth_Element_A2DP_Mute[-1261474894]
AnWBTService_MsgCallback(41)
AnWBTSERVICE_A2DP_MUTE: mute[1]
set volume
================== a2dp Menu ==================
...
3. A2DP_WAVEOUT_Volume
...
===============================================
input num: 3
input volume:2
you can receive a callback of music mode in log ,for example
select music mode
================== a2dp Menu ==================
...
4. AnWBTSRV_Music_Mode_Select
...
===============================================
input num: 4
input mode:3
you can receive a callback of music mode in log ,for example
AnWBTService_MsgCallback(52)
AnWBTSERVICE_MUSIC_MODE: musicMode[3]
volume up
================== a2dp Menu ==================
...
5. A2DP_WAVEOUT_VolumeUp
...
===============================================
input num: 5
volume down
================== a2dp Menu ==================
...
6. A2DP_WAVEOUT_VolumeDown
===============================================
input num: 6
Audio flow menu
enable audio flow
============== Audio flow menu ================
...
2.AnWBTSRV_Enable_Audio_Flow
...
===============================================
> input num: 2
>input mode: 1(1-enable 0-Invalidate)
we can get the log of callback,for example
AnWBTService_MsgCallback(4096)
AnWBTSERVICE_ENABLE_AUDIO_FLOW: status[0]
hfp enable audio flow
============== Audio flow menu ================
...
3.AnWBTSRV_HFP_Enable_Audio_Flow
...
===============================================
> input num: 3
>input mode: 1(1-enable 0-Invalidate)
we can get the log of callback,for example
AnWBTService_MsgCallback(4097)
AnWBTSERVICE_HFP_ENABLE_AUDIO_FLOW: status[0]
a2dp enable audio flow
============== Audio flow menu ================
...
4.AnWBTSRV_A2DP_Enable_Audio_Flow
...
===============================================
> input num: 4
>input mode: 1(1-enable 0-Invalidate)
we can get the log of callback,for example
AnWBTService_MsgCallback(4098)
AnWBTSERVICE_A2DP_ENABLE_AUDIO_FLOW: status[0]