蓝牙 - 调试BluetopiaPM中的SPP Demo程序

准备:
1,一个主机,一个客户端设备。
2, 两个设备在终端上都打开系统的log打印
# logread -f &
3,两个设备都在终端上运行server程序(SS1BTPM)和demo程序(LinuxSPPM):
# ./SS1BTPM & ./LinuxSPPM
注:上面是同时运行两个程序,第一个是在后台运行,第二个是前台运行。
4,运行成功后,LinuxSPPM输出命令菜单,并可以在终端上输入序号和参数来执行命令。
******************************************************************
* Command Options: 1) Initialize                                 *
*                  2) Cleanup                                    *
*                  3) QueryDebugZoneMask                         *
*                  4) SetDebugZoneMask                           *
*                  5) ShutdownService                            *
*                  6) RegisterEventCallback,                     *
*                  7) UnRegisterEventCallback,                   *
*                  8) QueryDevicePower                           *
*                  9) SetDevicePower                             *
*                  10)QueryLocalDeviceProperties                 *
*                  11)SetLocalDeviceName                         *
*                  12)SetLocalClassOfDevice                      *
*                  13)SetDiscoverable                            *
*                  14)SetConnectable                             *
*                  15)SetPairable                                *
*                  16)StartDeviceDiscovery                       *
*                  17)StopDeviceDiscovery                        *
*                  18)QueryRemoteDeviceList                      *
*                  19)QueryRemoteDeviceProperties                *
*                  20)AddRemoteDevice                            *
*                  21)DeleteRemoteDevice                         *
*                  22)PairWithRemoteDevice                       *
*                  23)CancelPairWithRemoteDevice                 *
*                  24)UnPairRemoteDevice                         *
*                  25)QueryRemoteDeviceServices                  *
*                  26)RegisterAuthentication                     *
*                  27)UnRegisterAuthentication                   *
*                  28)PINCodeResponse                            *
*                  29)PassKeyResponse                            *
*                  30)UserConfirmationResponse                   *
*                  31)ChangeSimplePairingParameters              *
*                  32)RegisterServerPort                         *
*                  33)OpenServerPortRequestResponse              *
*                  34)UnRegisterServerPort                       *
*                  35)OpenRemotePort                             *
*                  36)ClosePort                                  *
*                  37)ReadData                                   *
*                  38)WriteData                                  *
*                  39)SendLineStatus                             *
*                  40)SendPortStatus                             *
*                  41)QueryServerPresent                         *
*                  42)FindFreeServerPort                         *
*                  43)ChangeBufferSize                           *
*                  44)LoopbackMode                               *
*                  45)AutomaticReadMode                          *
*                  46)DisplayRawDataMode                         *
*                  47)EnableBluetoothDebug                       *
*                  Help, Quit.                                   *
******************************************************************
启动Demo程序
// 1) Initialize. 初始化.
// 用法:Initialize [0/1 - Register for Events].
// 说明:参数表示是否注册回调函数DEVM_Event_Callback;
SPPM> 1 1
BTPM_Initialize() Success: 0.
DEVM_RegisterEventCallback() Success: 5.
// 9) SetDevicePower. 上电.
// 用法:SetDevicePower [0/1 - Power Off/Power On].
SPPM>9 1
echo 45 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio45/direction
echo 0 > /sys/class/gpio/gpio45/value
echo 1 > /sys/class/gpio/gpio45/value
echo 0 > /sys/class/gpio/gpio45/value
echo 1 > /sys/class/gpio/gpio45/value
BT COMM PORT (/dev/ttyS1): 1
Status: Executing BTS Script /lib/firmware/TIInit_6.12.26.bts.
Status: BTS Script successfully executed.
DEVM_PowerOnDevice() Success: 0.
SPPM>
Device Powered On.
// 关闭电源
SPPM>9 0
DEVM_PowerOffDevice() Success: 0.
SPPM>
Device Powering Off Event, Timeout: 0x00000BB8.
SPPM>echo 0 > /sys/class/gpio/gpio45/value
echo 0 > /sys/class/gpio/gpio45/value
Device Powered Off.
// 8) QueryDevicePower 查询电源状态
SPPM>8
DEVM_QueryDevicePowerState() Success: On.
// 6) RegisterEventCallback
// 说明:注册DEVM_Event_Callback回调函数,未注册时才能注册,每注册一次返回值加1,表示注册ID。
SPPM>6
DEVM_RegisterEventCallback() Success: 6.
// 7) UnRegisterEventCallback
// 说明:取消注册DEVM_Event_Callback回调函数,注册时的ID在调用函数时作为参数使用。
SPPM>7
DEVM_UnRegisterEventCallback() Success.
// 反注册了的东西都要注销,就像进了澡堂你还要出来,但进去的时候给你个手牌,出来的时候手牌要归还。
// 2) Cleanup 
// 说明:和Initialize相反的操作,如果有DEVMCallback注册则注销,有其他的运行任务也关闭。
//       并且cleanup后,可以重新initialize,但这个不影响power on状态。
SPPM>2
// 5) ShutdownService
// 说明:关闭服务程序SS1BTPM
SPPM>5
BTPM_ShutdownService() Success: 0.
SPPM>echo 0 > /sys/class/gpio/gpio45/value
echo 0 > /sys/class/gpio/gpio45/value
Server has been Un-Registered.
SPPM>Nov 24 05:33:41 LinuxSPPM: [BTPM] PMCLT_EventHandler:UNSUPPORTED EVENT=1
Client:
// 35)OpenRemotePort 打开主机端口
// 用法:OpenRemotePort [BD_ADDR] [Server Port] [Flags (Optional - 1:Authentication, 2:Encryption)]
// 说明:直接打开会被拒绝。只会互相发现对方,通过DEVM_Event_Callback互相交换信息。
SPPM>35 84C69237FBD0 5
Remote Device Found.
BD_ADDR:      84C69237FBD0
COD:           0x000000
Device Name:
Device Flags:  0x80000000
RSSI:          0
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>SPPM_OpenRemotePort(5) Success. Port Handle: 1.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000048
Connect State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Name:   serer
Device Flags:  0x80000049
SPPM>
Remote Port Open Status.
    Port Handle: 1
    Status:      Remote Port Open Failure: Refused
// ==> 主机端显示的消息:
Remote Device Found.
BD_ADDR:      84C692382BF0
COD:           0x1C0424
Device Name:
Device Flags:  0x80000000
RSSI:          0
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000008
Connect State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Name:   WL18xx Device
Device Flags:  0x80000009
// 说明:在两边都执行过26)RegisterAuthentication以后,如果不设置IO Capacity,则两边分别输入UserConfirmationResponse命令后,端口打开成功。
SPPM>35 84C69237FBD0 5
Remote Device Found.
BD_ADDR:      84C69237FBD0
COD:           0x000000
Device Name:
Device Flags:  0x80000000
RSSI:          0
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>SPPM_OpenRemotePort(5) Success. Port Handle: 1.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000048
Connect State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Name:   WL18xx Device
Device Flags:  0x80000049
SPPM>
Authentication Request received for 84C69237FBD0.
I/O Capability Request.
DEVM_AuthenticationResponse() Success.
SPPM>
Authentication Request received for 84C69237FBD0.
I/O Capability Response.
Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE.
SPPM>
Authentication Request received for 84C69237FBD0.
User Confirmation Request.
User Confirmation: 979202
Respond with the command: UserConfirmationResponse
SPPM>UserConfirmationResponse 1
DEVM_AuthenticationResponse(), User Confirmation Response Success.
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x800000CD
Paired State : TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x800000DD
Encrypt State: TRUE
SPPM>
Remote Port Open Status.
    Port Handle: 1
    Status:      Remote 
Open Successful
SPPM>
Port Status Changed.
    Port Handle: 1
    Port Status:
       Mask:         0x00000003
       BreakSignal:  0
       BreakTimeout: 0
// ==> 主机端显示的消息:
Remote Device Found.
BD_ADDR:      84C692382BF0
COD:           0x1C0424
Device Name:
Device Flags:  0x80000000
RSSI:          0
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000008
Connect State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Name:   WL18xx Device
Device Flags:  0x80000009
SPPM>
Authentication Request received for 84C692382BF0.
I/O Capability Response.
Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE.
SPPM>
Authentication Request received for 84C692382BF0.
I/O Capability Request.
DEVM_AuthenticationResponse() Success.
SPPM>
Authentication Request received for 84C692382BF0.
User Confirmation Request.
User Confirmation: 979202
Respond with the command: UserConfirmationResponse
SPPM>UserConfirmationResponse 1
DEVM_AuthenticationResponse(), User Confirmation Response Success.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x8000008D
Paired State : TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x8000009D
Encrypt State: TRUE
SPPM>
Server Port Open.
    Port Handle:    1
    Remote Address: 84C692382BF0
SPPM>
Port Status Changed.
    Port Handle: 1
    Port Status:
       Mask:         0x00000003
       BreakSignal:  0
       BreakTimeout: 0
// 38)WriteData 写入数据
// 用法:WriteData [Port Handle] [String | NumberBytes] [Timeout (optional)].
SPPM>38 1 testing.123
SPPM_WriteData Success: 11 bytes written.
// ==> 主机端显示的消息:
SPPM>
Data Received.
    Port Handle: 1
    Data Length: 11
// 36)ClosePort 关闭端口
// 用法:ClosePort [Port Handle] [Timeout (optional)].
SPPM>36 1
SPPM_ClosePort Success: 0.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000085
Connect State: FALSE
Encrypt State: FALSE
// ==> 主机端显示的信息
SPPM>
Port Closed.
    Port Handle: 2
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000085
Connect State: FALSE
Encrypt State: FALSE
Server:
// 32)RegisterServerPort 
// 用法:RegisterServerPort [Port Number] [Flags (1: Authorization, 2: Authentication, 4: Encryption) (optional)].
// 说明:注册一个server port。Port Number的范围是1 - 30. 但Port 0~4在SS1BTPM初始化时已打开,所以要使用大于等于5的端口。
//      后面的Flags不了解怎么使用。
SPPM>32 5
SPPM_RegisterServerPort(5) Success. Port Handle: 1.
SPPM_RegisterServerPortServiceRecord Success. Record Handle: 65545 (0x00010009).
// 41)QueryServerPresent 查询某个port是否存在
// 用法:QueryServerPresent [Server Port].
SPPM>41 5
SPPM_QueryServerPresent(0x00000005) Success: 0, TRUE.
// 37)ReadData 读取数据
// 用法:ReadData [Port Handle] [DataLength] [Timeout (optional)].
SPPM>37 1 11
SPPM_ReadData(11) Success: 11 bytes read.
Data:0x74 0x65 0x73 0x74 0x69 0x6E 0x67 0x2E 0x31 0x32 0x33
// 34)UnRegisterServerPort
// 用法:UnRegisterServerPort [Port Handle].
SPPM>34 1
SPPM_UnRegisterServerPort(1) Success: 0.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000085
Connect State: FALSE
Encrypt State: FALSE
// ==> 客户端显示的信息
SPPM>
Port Closed.
    Port Handle: 1
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000085
Connect State: FALSE
Encrypt State: FALSE
// 33)OpenServerPortRequestResponse
// 用法:OpenServerPortRequestResponse [Port Handle] [Accept/Reject Flag].
// 说明:收到远程客户端的打开端口的请求时,回复此命令来接受或拒绝。即SPPM_Event_Callback里收到setServerPortOpenRequest事件。
// 42)FindFreeServerPort 发现一个未使用的可供打开的port
// 用法:FindFreeServerPort
// 说明:返回一个port number值,用来打开一个新的SPP port。如果打开了这个端口,再查询可用端口,就会找下一个最近的port number。
SPPM>42
SPPM_FindFreeServerPort() Success: 5.
SPPM>32 5
SPPM_RegisterServerPort(5) Success. Port Handle: 1.
SPPM_RegisterServerPortServiceRecord Success. Record Handle: 65545 (0x00010009).
SPPM>42
SPPM_FindFreeServerPort() Success: 6.
// 说明:
// Server端和Client端一样,能够调用ClosePort。
// Server和Client连接后,可以互相发送数据,也就是都能调用ReadData、WriteData命令。
关于信息查询命令的详细说明(在信息查询时,互相之间是对等的,两个设备没有特殊关系)
// 10)QueryLocalDeviceProperties 查询本地设备信息
// 用法:QueryLocalDeviceProperties
// 说明:返回DEVM_Local_Device_Properties_t结构体。
SPPM>10
DEVM_QueryLocalDeviceProperties() Success: 0.
BD_ADDR:      84C69237FBD0
HCI Ver:      0x0008
HCI Rev:      0x0000
LMP Ver:      0x0008
LMP Sub Ver:  0x9A18
Device Man:   0x000D (Texas Instruments Inc.)
Device Flags: 0x80000000
COD:          0x1C0424
Device Name:  WL18xx Device
Disc. Mode:   TRUE , 0x00000000
Conn. Mode:   TRUE , 0x00000000
Pair. Mode:   TRUE , 0x00000000
   /* The following structure is used to hold information pertaining to */
   /* the current State of the Local Device.                            */
typedef struct _tagDEVM_Local_Device_Properties_t
{
   BD_ADDR_t         BD_ADDR;
   Class_of_Device_t ClassOfDevice;
   unsigned int      DeviceNameLength;
   char              DeviceName[MAX_NAME_LENGTH + 1];
   unsigned int      HCIVersion;
   unsigned int      HCIRevision;
   unsigned int      LMPVersion;
   unsigned int      LMPSubVersion;
   unsigned int      DeviceManufacturer;
   unsigned long     LocalDeviceFlags;
   Boolean_t         DiscoverableMode;
   unsigned int      DiscoverableModeTimeout;
   Boolean_t         ConnectableMode;
   unsigned int      ConnectableModeTimeout;
   Boolean_t         PairableMode;
   unsigned int      PairableModeTimeout;
   Word_t            DeviceAppearance;
   BD_ADDR_t         BLEBD_ADDR;
   AddressType_t     BLEAddressType;
   unsigned int      ScanTimeout;
   unsigned int      AdvertisingTimeout;
} DEVM_Local_Device_Properties_t;
// 16)StartDeviceDiscovery 搜索蓝牙设备
// 用法:StartDeviceDiscovery [Duration]
// 说明:可以指定搜索时间参数,单位为秒,然后就在DEVM_Event_Callback中收到detRemoteDeviceFound,获得各个设备的属性信息。
SPPM>16 3
Attempting to Start Discovery (3 Seconds).
Local Device Properties Changed.
SPPM>
Device Discovery Started.
SPPM>DEVM_StartDeviceDiscovery() Success: 0.
SPPM>
Remote Device Found.
BD_ADDR:      84C69237FBD0
COD:           0x1C0424
Device Name:
Device Flags:  0x80000000
RSSI:          -31
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Found.
BD_ADDR:      D8CE3ACC81D6
COD:           0x0C025A
Device Name:   MI 8
Device Flags:  0x80000401
RSSI:          -76
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Found.
BD_ADDR:      841B77F6049F
COD:           0x0C012A
Device Name:   CH3ULTCB3NDB3
Device Flags:  0x80000601
RSSI:          -92
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Found.
BD_ADDR:      8CC681447D88
COD:           0x0C012A
Device Name:   CH3ULT40G1453
Device Flags:  0x80000601
RSSI:          -66
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Found.
BD_ADDR:      0C2369F7AACB
COD:           0x0C025A
Device Name:
Device Flags:  0x80000000
RSSI:          -102
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Found.
BD_ADDR:      9487E0A46623
COD:           0x0C025A
Device Name:   14 promax
Device Flags:  0x80000401
RSSI:          -80
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Found.
BD_ADDR:      001020F566CB
COD:           0x0C025A
Device Name:   CT40
Device Flags:  0x80000401
RSSI:          -90
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Name:   WL18xx Device
Device Flags:  0x80000001
// 17)StopDeviceDiscovery
// 用法:StopDeviceDiscovery
// 说明:执行此命令,停止搜索设备。
SPPM>17
DEVM_StopDeviceDiscovery() Success: 0.
Remote Device相关操作:
// 18)QueryRemoteDeviceList
// 用法:QueryRemoteDeviceList [Number of Devices] [Filter (Optional)] [COD Filter (Optional)].
// 说明:第二个参数的使用在头文件中有定义。第三个参数根据给定的COD值来过滤。在搜寻到的已经存在server中的设备信息中,筛选符合条件的设备。
#define DEVM_QUERY_REMOTE_DEVICE_LIST_ALL_DEVICES              0x00000000
#define DEVM_QUERY_REMOTE_DEVICE_LIST_CURRENTLY_CONNECTED      0x00000001
#define DEVM_QUERY_REMOTE_DEVICE_LIST_CURRENTLY_PAIRED         0x00000002
#define DEVM_QUERY_REMOTE_DEVICE_LIST_CURRENTLY_UNPAIRED       0x00000003
#define DEVM_QUERY_REMOTE_DEVICE_LIST_NO_LOW_ENERGY_DEVICES    0x40000000
#define DEVM_QUERY_REMOTE_DEVICE_LIST_NO_BR_EDR_DEVICES        0x80000000
SPPM>18 10 0x40000000 0x0c0000
Attempting Query 10 Devices.
DEVM_QueryRemoteDeviceList() Success: 5, Total Number Devices: 5.
Returned device list (5 Entries):
1. 502F9B7B67EE
2. 8CC681447D88
3. 001020D0CD14
4. B46BFCA8F5A1
5. 841B77F6049F
SPPM>18 10
Attempting Query 10 Devices.
DEVM_QueryRemoteDeviceList() Success: 5, Total Number Devices: 5.
Returned device list (5 Entries):
1. 502F9B7B67EE
2. 8CC681447D88
3. 001020D0CD14
4. B46BFCA8F5A1
5. 841B77F6049F
SPPM>18 0
Attempting Query 0 Devices.
DEVM_QueryRemoteDeviceList() Success: 0, Total Number Devices: 5.
// 19)QueryRemoteDeviceProperties
// 用法:QueryRemoteDeviceProperties [BD_ADDR] [Force Update].
// 说明:使用搜索发现的设备里的地址,就可以获得本地已保存属性信息。
1,调用DEVM_QueryRemoteDeviceProperties,取得远端主机设备的属性,直接返回DEVM_Remote_Device_Properties_t类型变量。
2,返回的属性信息包含了一系列的设备属性信息,包括:RSSI、ClassOfDevice等。
SPPM>19 84C69237FBD0 0
Attempting to Query Device Properties: 84C69237FBD0, ForceUpdate: FALSE.
DEVM_QueryRemoteDeviceProperties() Success: 0.
BD_ADDR:      84C69237FBD0
COD:           0x1C0424
Device Name:   WL18xx Device
Device Flags:  0x80000001
RSSI:          -31
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
   /* The following structure is used to hold information pertaining to */
   /* the current State of a specific Remote Device.                    */
typedef struct _tagDEVM_Remote_Device_Properties_t
{
   BD_ADDR_t                             BD_ADDR;
   Class_of_Device_t                     ClassOfDevice;
   unsigned int                          DeviceNameLength;
   char                                  DeviceName[MAX_NAME_LENGTH + 1];
   unsigned long                         RemoteDeviceFlags;
   int                                   RSSI;
   int                                   TransmitPower;
   unsigned int                          SniffInterval;
   DEVM_Remote_Device_Application_Data_t ApplicationData;
   AddressType_t                         BLEAddressType;
   int                                   LE_RSSI;
   int                                   LETransmitPower;
   Word_t                                DeviceAppearance;
   BD_ADDR_t                             PriorResolvableBD_ADDR;
} DEVM_Remote_Device_Properties_t;
// 也可以强制更新,在DEVM_Event_Callback中收到detRemoteDevicePropertiesStatus,信息重新更新一遍。
SPPM>19 84C69237FBD0 1
Attempting to Query Device Properties: 84C69237FBD0, ForceUpdate: TRUE.
DEVM_QueryRemoteDeviceProperties() Success: 0.
BD_ADDR:      84C69237FBD0
COD:           0x1C0424
Device Name:   WL18xx Device
Device Flags:  0x80000001
RSSI:          -31
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Properties Status: 84C69237FBD0, SUCCESS.
BD_ADDR:      84C69237FBD0
COD:           0x1C0424
Device Name:   WL18xx Device
Device Flags:  0x80000001
RSSI:          -31
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
// 25)QueryRemoteDeviceServices 查询主机端提供的服务信息
// 用法:QueryRemoteDeviceServices [BD_ADDR] [Force Update] [Bytes to Query (specified if Force is 0)].
// 说明:查询service信息,直接显示本地信息是没有的。
SPPM>25 84C69237FBD0 0 2048
Attempting Query Remote Device 84C69237FBD0 For Services.
DEVM_QueryRemoteDeviceServices() Failure: -10055, Device Services not Known.
Function Error.
// 需要Force update一下。在DEVM_Event_Callback中收到detRemoteDevicePropertiesChanged。
// 如果这个设备还没被搜索到过,还会触发detRemoteDeviceFound事件。
// detRemoteDeviceFound和detRemoteDevicePropertiesChanged事件,对方设备也会收到,因为是互相发现对方。
SPPM>25 84C69237FBD0 1
Attempting Query Remote Device 84C69237FBD0 For Services.
DEVM_QueryRemoteDeviceServices() Success: 0, Total Number Service Bytes: 0.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000049
Connect State: TRUE
SPPM>
Remote Device 84C69237FBD0 Services Status: BR/EDR, SUCCESS.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000149
Serv. Known  : TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000101
Connect State: FALSE
// 再查询service信息。
直接显示的蓝牙设备的服务信息:
    a,调用DEVM_QueryRemoteDeviceServices,直接获得一个字节流。
    b,调用DEVM_ConvertRawSDPStreamToParsedSDPData,从字节流转换为一个结构体DEVM_Parsed_SDP_Data_t。
  c, 结构体成员包括:service记录的数目;service记录内容的指针;保留字段void*。
  d,service记录内容也是一个结构体SDPServiceAttributeResponseData,成员包括:属性记录的数目;属性记录内容的指针;
  e, 属性记录是一个结构体SDP_Service_Attribute_Value_Data,成员包括:属性记录ID;属性记录内容的指针。
  f,属性记录内容也是一个结构体SDP_Data_Element_t,成员包括:属性内容类型;长度;一个共用体包含各种内容类型。
SPPM>25 84C69237FBD0 0 10240
Attempting Query Remote Device 84C69237FBD0 For Services.
DEVM_QueryRemoteDeviceServices() Success: 813, Total Number Service Bytes: 813.
Returned Service Data (813 Bytes):
36032A35580900000A0001000109000135061911121912030900020A00000004090004350C350319010035051900030804090006350909656E09006A09010009000935083506191108090102090100250C48656164736574202D20414735580900000A0001000209000135061911081912030900020A00000005090004350C350319010035051900030802090006350909656E09006A090100090009350835061911080901020901002507486561647365740903022801356F0900000A00010003090001350619111F1912030900020A00000006090004350C350319010035051900030803090006350909656E09006A0901000900093508350619111E090106090100251848616E6473204672656520417564696F20476174657761790903010801090311090027355C0900000A00010004090001350619111E1912030900020A00000005090004350C350319010035051900030801090006350909656E09006A0901000900093508350619111E090106090100250A48616E6473204672656509031109003F35560900000A00010005090001350319110B0900020A00000004090004351035061901000900193506190019090103090006350909656E09006A0901000900093508350619110D0901030901002509413244502053696E6B357C0900000A00010006090001350619110E19110F0900020A00000006090004351035061901000900173506190017090104090006350909656E09006A0901000900093508350619110E0901040901002510415652435020436F6E74726F6C6C65720901022511546578617320496E737472756D656E747309031109000335580900000A00010007090001350319110A0900020A00000004090004351035061901000900193506190019090103090006350909656E09006A0901000900093508350619110D090103090100250B4132445020536F7572636535750900000A00010008090001350319110C0900020A00000006090004351035061901000900173506190017090104090006350909656E09006A0901000900093508350619110E090104090100250C4156524350205461726765740901022511546578617320496E737472756D656E7473090311090003
Service Record: 1:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010001
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x1112
          Type: UUID_16 = 0x1203
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000004
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
          Type: Data Element Sequence
             Type: UUID_16 = 0x0003
             Type: Unsigned Int = 0x04
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x1108
             Type: Unsigned Int = 0x0102
    Attribute ID 0x0100
       Type: Text String = Headset - AG
Service Record: 2:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010002
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x1108
          Type: UUID_16 = 0x1203
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000005
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
          Type: Data Element Sequence
             Type: UUID_16 = 0x0003
             Type: Unsigned Int = 0x02
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x1108
             Type: Unsigned Int = 0x0102
    Attribute ID 0x0100
       Type: Text String = Headset
    Attribute ID 0x0302
       Type: Boolean = TRUE
Service Record: 3:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010003
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x111F
          Type: UUID_16 = 0x1203
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000006
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
          Type: Data Element Sequence
             Type: UUID_16 = 0x0003
             Type: Unsigned Int = 0x03
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x111E
             Type: Unsigned Int = 0x0106
    Attribute ID 0x0100
       Type: Text String = Hands Free Audio Gateway
    Attribute ID 0x0301
       Type: Unsigned Int = 0x01
    Attribute ID 0x0311
       Type: Unsigned Int = 0x0027
Service Record: 4:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010004
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x111E
          Type: UUID_16 = 0x1203
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000005
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
          Type: Data Element Sequence
             Type: UUID_16 = 0x0003
             Type: Unsigned Int = 0x01
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x111E
             Type: Unsigned Int = 0x0106
    Attribute ID 0x0100
       Type: Text String = Hands Free
    Attribute ID 0x0311
       Type: Unsigned Int = 0x003F
Service Record: 5:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010005
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x110B
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000004
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
             Type: Unsigned Int = 0x0019
          Type: Data Element Sequence
             Type: UUID_16 = 0x0019
             Type: Unsigned Int = 0x0103
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x110D
             Type: Unsigned Int = 0x0103
    Attribute ID 0x0100
       Type: Text String = A2DP Sink
Service Record: 6:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010006
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x110E
          Type: UUID_16 = 0x110F
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000006
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
             Type: Unsigned Int = 0x0017
          Type: Data Element Sequence
             Type: UUID_16 = 0x0017
             Type: Unsigned Int = 0x0104
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x110E
             Type: Unsigned Int = 0x0104
    Attribute ID 0x0100
       Type: Text String = AVRCP Controller
    Attribute ID 0x0102
       Type: Text String = Texas Instruments
    Attribute ID 0x0311
       Type: Unsigned Int = 0x0003
Service Record: 7:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010007
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x110A
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000004
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
             Type: Unsigned Int = 0x0019
          Type: Data Element Sequence
             Type: UUID_16 = 0x0019
             Type: Unsigned Int = 0x0103
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x110D
             Type: Unsigned Int = 0x0103
    Attribute ID 0x0100
       Type: Text String = A2DP Source
Service Record: 8:
    Attribute ID 0x0000
       Type: Unsigned Int = 0x00010008
    Attribute ID 0x0001
       Type: Data Element Sequence
          Type: UUID_16 = 0x110C
    Attribute ID 0x0002
       Type: Unsigned Int = 0x00000006
    Attribute ID 0x0004
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x0100
             Type: Unsigned Int = 0x0017
          Type: Data Element Sequence
             Type: UUID_16 = 0x0017
             Type: Unsigned Int = 0x0104
    Attribute ID 0x0006
       Type: Data Element Sequence
          Type: Unsigned Int = 0x656E
          Type: Unsigned Int = 0x006A
          Type: Unsigned Int = 0x0100
    Attribute ID 0x0009
       Type: Data Element Sequence
          Type: Data Element Sequence
             Type: UUID_16 = 0x110E
             Type: Unsigned Int = 0x0104
    Attribute ID 0x0100
       Type: Text String = AVRCP Target
    Attribute ID 0x0102
       Type: Text String = Texas Instruments
    Attribute ID 0x0311
       Type: Unsigned Int = 0x0003
SPPM>
// 20)AddRemoteDevice
// 用法:AddRemoteDevice [BD_ADDR] [[COD (Optional)] [Friendly Name (Optional)] [Application Info (Optional)]].
// 说明:根据用户自己构造的信息,加入到server的设备列表中。然后就可以使用命令19来检索到这个设备。
// 注意:地址已经存在的设备无法添加或更新信息。这里有个application data,8个字节,怀疑是用DEVM_UpdateRemoteDeviceApplicationData这个来本地设定的附加remote device信息。
SPPM>20 001020D0CD13 0x0c012a hello
Attempting to Add Device: 001020D0CD13.
Remote Device Found.
BD_ADDR:      001020D0CD13
COD:           0x0C012A
Device Name:
Device Flags:  0x00000002
RSSI:          0
Friendly Name: hello
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>DEVM_AddRemoteDevice() Success: 0.
// 21)DeleteRemoteDevice
// 用法:DeleteRemoteDevice [BD_ADDR].
// 说明:从本地存储的设备列表中删除指定地址的设备。
SPPM>21 841B77F6049F
Attempting to Delete Device: 841B77F6049F.
Remote Device Deleted: 841B77F6049F.
SPPM>DEVM_DeleteRemoteDevice() Success: 0.
设置本地设备属性
// 11)SetLocalDeviceName 设置设备名称
// 用法:SetLocalDeviceName [Name]
// 说明:DEVM_Event_Callback里收到detLocalDevicePropertiesChanged消息。
SPPM>11 client
Attempting to set Device Name to: "client".
Local Device Properties Changed.
Device Name:  client
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
// 12)SetLocalClassOfDevice
// 用法:SetLocalClassOfDevice [Class of Device].
// 说明:给的参数可以是十进制数,或者是16进制:0xAA或0XAA。
// 特别注意:参数表示的class of device,是大端的,而结构体存储信息时是小端的。
// 具体的class of device定义请参照蓝牙spec。
typedef __PACKED_STRUCT_BEGIN__ struct _tagClass_of_Device_t
{
   Byte_t Class_of_Device0;
   Byte_t Class_of_Device1;
   Byte_t Class_of_Device2;
} __PACKED_STRUCT_END__ Class_of_Device_t;
SPPM>12 0x123456
Attempting to set Class Of Device to: 0x123456.
Local Device Properties Changed.
COD:          0x123456
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
// 13)SetDiscoverable
// 用法:SetDiscoverable [Enable/Disable] [Timeout (Enable only)].
// 说明:时间单位为秒。DEVM_Event_Callback里收到detLocalDevicePropertiesChanged消息,当属性变化会收到此事件。
//       如果设置了超时,则也会更新属性,并在超时后关闭可发现属性。
SPPM>13 0
Attempting to set Discoverability Mode: None.
Local Device Properties Changed.
Disc. Mode:   FALSE, 0x00000000
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>
SPPM>13 0
Attempting to set Discoverability Mode: None.
DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>
SPPM>
SPPM>13 1
Attempting to set Discoverability Mode: Limited (0 Seconds).
DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>
Local Device Properties Changed.
Disc. Mode:   TRUE , 0x00000000
SPPM>
SPPM>
SPPM>13 1 3
Attempting to set Discoverability Mode: General.
DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>
Local Device Properties Changed.
Disc. Mode:   TRUE , 0x00000003
SPPM>
Local Device Properties Changed.
Disc. Mode:   FALSE, 0x00000000
// 14)SetConnectable
// 用法:SetConnectable [Enable/Disable] [Timeout (Enable only)].
// 说明:时间单位为秒。DEVM_Event_Callback里收到detLocalDevicePropertiesChanged消息。
SPPM>14 0
Attempting to set Connectability Mode: Non-Connectable.
Local Device Properties Changed.
Conn. Mode:   FALSE, 0x00000000
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>14 1 3
Attempting to set Connectability Mode: Connectable (3 Seconds).
Local Device Properties Changed.
Conn. Mode:   TRUE , 0x00000003
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
// 过3秒。如果Timeout不设置或为0,则一直保持connectable状态。
SPPM>
Local Device Properties Changed.
Conn. Mode:   FALSE, 0x00000000
// 15)SetPairable
// 用法:SetPairable [Enable/Disable] [Timeout (Enable only)].
// 说明:时间单位为秒,默认为0,不超时。DEVM_Event_Callback里收到detLocalDevicePropertiesChanged消息。
//      如果设置了时间,则超时后就会改变配对状态,变成False。
SPPM>15 0
Attempting to set Pairability Mode: Non-Pairable.
Local Device Properties Changed.
Pair. Mode:   FALSE, 0x00000000
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>15 1 3
Attempting to set Pairability Mode: Pairable (3 Seconds).
Local Device Properties Changed.
Pair. Mode:   TRUE , 0x00000003
SPPM>DEVM_UpdateLocalDeviceProperties() Success: 0.
// 过3秒
SPPM>
Local Device Properties Changed.
Pair. Mode:   FALSE, 0x00000000
关于配对操作
// 26)RegisterAuthentication 注册认证回调函数
SPPM>26
DEVM_RegisterAuthentication() Success: 5.
// 22)PairWithRemoteDevice
// 用法:PairWithRemoteDevice [BD_ADDR] [Force Pair (Optional)].
// 说明:要配对前,两边的设备都需要注册认证处理函数,即执行26命令。如果没发现过此设备,会先发现。
// 这个强制配对参数,不知有什么用。
SPPM>22 84C69237FBD0
Attempting to Pair With Remote Device: 84C69237FBD0 (Force = 0).
DEVM_PairWithRemoteDevice() Failure: -10053, Authentication Handler not Registered.
Function Error.
// 执行完26命令以后,两边就可以成功配对了。
SPPM>22 84C69237FBD0
Attempting to Pair With Remote Device: 84C69237FBD0 (Force = 0).
Remote Device Found.
BD_ADDR:      84C69237FBD0
COD:           0x000000
Device Name:
Device Flags:  0x80000000
RSSI:          0
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>DEVM_PairWithRemoteDevice() Success: 0.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000048
Connect State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Name:   WL18xx Device
Device Flags:  0x80000049
SPPM>
Authentication Request received for 84C69237FBD0.
I/O Capability Request.
DEVM_AuthenticationResponse() Success.
SPPM>
Authentication Request received for 84C69237FBD0.
I/O Capability Response.
Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE.
SPPM>
Authentication Request received for 84C69237FBD0.
User Confirmation Request.
User Confirmation: 861032
Respond with the command: UserConfirmationResponse
SPPM>UserConfirmationResponse 1
DEVM_AuthenticationResponse(), User Confirmation Response Success.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x800000CD
Paired State : TRUE
SPPM>
Remote Device Pairing Status: 84C69237FBD0, SUCCESS (0x00)
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x800000DD
Encrypt State: TRUE
SPPM>
Remote Device 84C69237FBD0 Services Status: BR/EDR, SUCCESS.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x800001DD
Serv. Known  : TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C69237FBD0
Device Flags:  0x80000185
Connect State: FALSE
Encrypt State: FALSE
// 对方设备log信息:
Remote Device Found.
BD_ADDR:      84C692382BF0
COD:           0x1C0424
Device Name:
Device Flags:  0x80000000
RSSI:          0
Friendly Name:
App. Info:   : 00000000
Paired State : FALSE
Connect State: FALSE
Encrypt State: FALSE
Sniff State  : FALSE
Serv. Known  : FALSE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000008
Connect State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Name:   WL18xx Device
Device Flags:  0x80000009
SPPM>
Authentication Request received for 84C692382BF0.
I/O Capability Response.
Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE.
SPPM>
Authentication Request received for 84C692382BF0.
I/O Capability Request.
DEVM_AuthenticationResponse() Success.
SPPM>
Authentication Request received for 84C692382BF0.
User Confirmation Request.
User Confirmation: 861032
Respond with the command: UserConfirmationResponse
SPPM>UserConfirmationResponse 1
DEVM_AuthenticationResponse(), User Confirmation Response Success.
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x8000008D
Paired State : TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x8000009D
Encrypt State: TRUE
SPPM>
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000085
Connect State: FALSE
Encrypt State: FALSE
// Demo程序默认的I/O Capabilities是Display Yes/No,MITM Protection True。所以在认证回调函数中,先互相传递IO Capabilities消息,然后因为是yes/no,据需要查看两边收到一样的passkey后,回复UserConfirmationResponse 1.
// 如果把IO Capabilities改成:
// 30)UserConfirmationResponse
// 用法:UserConfirmationResponse [Confirmation (0 = No, 1 = Yes)
// 23)CancelPairWithRemoteDevice
// 用法:CancelPairWithRemoteDevice [BD_ADDR].
// 说明:可以取消正在进行的配对操作。需要注册认证回调函数,即26命令,还需要正处于认证过程进行中,还需要已经发现过这个设备。
SPPM>23 84C69237FBD0
Attempting to Cancel Pair With Remote Device: 84C69237FBD0.
DEVM_CancelPairWithRemoteDevice() Failure: -10041, Unknown Bluetooth device.
Function Error.
SPPM>23 84C69237FBD0
Attempting to Cancel Pair With Remote Device: 84C69237FBD0.
DEVM_CancelPairWithRemoteDevice() Failure: -10049, Device is not currently in Pairing Process.
Function Error.
SPPM>23 84C69237FBD0
Attempting to Cancel Pair With Remote Device: 84C69237FBD0.
Remote Device Pairing Status: 84C69237FBD0, FAILURE (0x16)
SPPM>DEVM_CancelPairWithRemoteDevice() Success: 0.
// 24)UnPairRemoteDevice
// 用法:UnPairRemoteDevice [BD_ADDR].
// 说明:已经配对过的设备可以解除配对。然后就能可以再次配对,和第一次配对一样。
// 取消配对时,和对方设备无关,只是本地操作。
SPPM>24 84C692382BF0
Attempting to Un-Pair Remote Device: 84C692382BF0.
Remote Device Properties Changed.
BD_ADDR:      84C692382BF0
Device Flags:  0x80000001
Paired State : FALSE
SPPM>DEVM_UnPairRemoteDevice() Success: 0.
修改IO Capablities参数的认证过程
// 31)ChangeSimplePairingParameters
// 用法:ChangeSimplePairingParameters [I/O Capability (0 = Display Only, 1 = Display Yes/No, 2 = Keyboard Only, 3 = No Input/Output)] [MITM Requirement (0 = No, 1 = Yes)].
// 说明:本地设备收到对方发过来的认证请求时,带了passkey,不是display yes/no,都是自动回复OK的。MITM为True对此不影响。
// 当两边设备都是keyboard only,并且MITM为true时,需要输入相同的passkey,6个数字,才能完成配对。MITM为0的话,就是自动配对。
// 当两边设备都是Display Yes/No时,MITM Protection为true时,在配对时,就需要执行以下用户确认操作,User Confirmation命令。
// 只有配对成功,才能进行SPP的端口操作。
Debug Log输出
// 47)EnableBluetoothDebug 使能log输出
// 用法:EnableBluetoothDebug [Enable (0/1)] [Type (1 - ASCII File, 2 - Terminal, 3 - FTS File)] [Debug Flags] [Debug Parameter String (no spaces)].
// 说明:Debug Flags值为0或1,1表示DEVM_BLUETOOTH_DEBUG_FLAGS_APPEND_FILE,默认值为0.
// 13)SetDiscoverable 使用设置属性为可发现来测试debug的log输出,会显示HCI的通信信息。
// 用法:SetDiscoverable [Enable/Disable] [Timeout (Enable only)].
// 说明:在DEVM_Event_Callback中收到detLocalDevicePropertiesChanged。
SPPM>47 1 2
DEVM_EnableBluetoothDebug(TRUE) Success.
SPPM>13 1
Attempting to set Discoverability Mode: Limited (0 Seconds).
DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>
Local Device Properties Changed.
Disc. Mode:   TRUE , 0x00000000
SPPM>Nov 24 02:22:33 SS1BTPM: [02:22:33.846 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Sending 3 Bytes (HCI Command Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  19 0C 00                                           ...
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.858 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Received 7 Bytes (HCI Event Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  0E 05 01 19 0C 00 02                               .......
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.859 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Sending 7 Bytes (HCI Command Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  3A 0C 04 01 33 8B 9E                               :...3..
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.861 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Received 6 Bytes (HCI Event Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  0E 04 01 3A 0C 00                                  ...:..
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.862 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Sending 4 Bytes (HCI Command Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  1A 0C 01 03                                        ....
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.864 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Received 6 Bytes (HCI Event Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  0E 04 01 1A 0C 00                                  ......
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.865 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Sending 3 Bytes (HCI Command Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  23 0C 00                                           #..
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.868 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Received 9 Bytes (HCI Event Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  0E 07 01 23 0C 00 1C 04 24                         ...#....$
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.868 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Sending 6 Bytes (HCI Command Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  24 0C 03 1C 04 24                                  $....$
Nov 24 02:22:33 SS1BTPM:
Nov 24 02:22:33 SS1BTPM: [02:22:33.871 11/24/1984]
Nov 24 02:22:33 SS1BTPM: Received 6 Bytes (HCI Event Packet):
Nov 24 02:22:33 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:22:33 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:22:33 SS1BTPM:     00000  0E 04 01 24 0C 00                                  ...$..
Nov 24 02:22:33 SS1BTPM:
SPPM>13 0
Attempting to set Discoverability Mode: None.
DEVM_UpdateLocalDeviceProperties() Success: 0.
SPPM>
Local Device Properties Changed.
Disc. Mode:   FALSE, 0x00000000
SPPM>Nov 24 02:23:05 SS1BTPM: [02:23:05.506 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Sending 3 Bytes (HCI Command Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  19 0C 00                                           ...
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.519 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Received 7 Bytes (HCI Event Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  0E 05 01 19 0C 00 03                               .......
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.519 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Sending 4 Bytes (HCI Command Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  1A 0C 01 02                                        ....
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.522 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Received 6 Bytes (HCI Event Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  0E 04 01 1A 0C 00                                  ......
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.523 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Sending 3 Bytes (HCI Command Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  23 0C 00                                           #..
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.525 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Received 9 Bytes (HCI Event Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  0E 07 01 23 0C 00 1C 04 24                         ...#....$
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.526 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Sending 6 Bytes (HCI Command Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  24 0C 03 1C 04 24                                  $....$
Nov 24 02:23:05 SS1BTPM:
Nov 24 02:23:05 SS1BTPM: [02:23:05.529 11/24/1984]
Nov 24 02:23:05 SS1BTPM: Received 6 Bytes (HCI Event Packet):
Nov 24 02:23:05 SS1BTPM:            00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F    0123456789ABCDEF
Nov 24 02:23:05 SS1BTPM:   --------------------------------------------------------------------------------
Nov 24 02:23:05 SS1BTPM:     00000  0E 04 01 24 0C 00                                  ...$..
Nov 24 02:23:05 SS1BTPM:
// 设置文件参数,则log会保存在文件中,里面内容是HCI通信数据。
SPPM>47 1 1 1 /tmp/bt.log
DEVM_EnableBluetoothDebug(TRUE) Success.
其他命令
// 设置Debug log输出的内容种类,debug zone的每个bit表示一类信息,可以控制debug log是否输出。
// 3) QueryDebugZoneMask
// 用法:QueryDebugZoneMask [0/1 - Local/Service] [Page Number - optional, default 0].
SPPM>3 0
BTPM_QueryDebugZoneMask(Local) Success: 0x00000000.
SPPM>3 1
BTPM_QueryDebugZoneMask(Remote) Success: 0x00000000.
// 4) SetDebugZoneMask
// 用法:SetDebugZoneMask [0/1 - Local/Service] [Debug Zone Mask].
SPPM>4 0 2
BTPM_SetDebugZoneMask(Local) Success: 0x00000002.
// 28)PINCodeResponse
// 用法:PINCodeResponse [PIN Code].
// 说明:在配对过程中,如果需要输入Pin码,则执行此命令。
// 29)PassKeyResponse
// 用法:PassKeyResponse [Numeric Passkey (0 - 999999)].
// 说明:在配对过程中,如果需要输入Passkey,则执行此命令。
// 43)ChangeBufferSize
// 用法:ChangeBufferSize [Port Handle] [Receive Buffer Size] [Transmit Buffer Size].
// 说明:调用SPPM_ChangeBufferSize接口来改变接收和发送的buffer size。
// 44)LoopbackMode
// 45)AutomaticReadMode
// 46)DisplayRawDataMode
// 说明:这三个是Demo程序内部的控制模式。
// 39)SendLineStatus
// 用法:SendLineStatus [Port Handle] [Status Mask].
// 说明:在SPPM_Event_Callback中会收到setLineStatusChanged事件。
   /* The following constants are used with the LineStatusMask members  */
   /* of the SPPM_Send_Line_Status_Request_t and                        */
   /* SPPM_Line_Status_Changed_Message_t messages to specify the Line   */
   /* Status Mask.                                                      */
#define SPPM_LINE_STATUS_MASK_NO_ERROR_VALUE                   (SPP_LINE_STATUS_NO_ERROR_VALUE)
#define SPPM_LINE_STATUS_MASK_OVERRUN_ERROR_MASK               (SPP_LINE_STATUS_OVERRUN_ERROR_BIT_MASK)
#define SPPM_LINE_STATUS_MASK_PARITY_ERROR_MASK                (SPP_LINE_STATUS_PARITY_ERROR_BIT_MASK)
#define SPPM_LINE_STATUS_MASK_FRAMING_ERROR_MASK               (SPP_LINE_STATUS_FRAMING_ERROR_BIT_MASK)
// 40)SendPortStatus
// 用法:SendPortstatus [Port Handle] [Status Mask] [Break Flag - 0/1 (optional)] [Break Length (optional)].
// 说明:在SPPM_Event_Callback中会收到setPortStatusChanged事件。
   /* The following structure is a container structure that holds the   */
   /* information pertaining to a Port Status Event.                    */
typedef struct _tagSPPM_Port_Status_t
{
   unsigned long PortStatusMask;
   Boolean_t     BreakSignal;
   unsigned int  BreakTimeout;
} SPPM_Port_Status_t;
   /*! The following enumerated type represents the Status of the Break
    * Signal for a specified Serial Port.
    */
typedef enum
{
   bsBreakCleared,
   bsBreakReceived
} SPP_Break_Status_t;
   /*! The following Constants represent the Bit Mask that specifies
    * the value of an individual Modem/Port Control Signal.  If the
    * specified Bit has a binary value of '1', then the Signal is
    * considered to be set, else it is considered NOT set (clear).
    * This Bit Mask is used with the SPP_Port_Status() function.
    */
#define SPP_PORT_STATUS_CLEAR_VALUE                             0x00000000
#define SPP_PORT_STATUS_RTS_CTS_BIT                             0x00000001
#define SPP_PORT_STATUS_DTR_DSR_BIT                             0x00000002
#define SPP_PORT_STATUS_RING_INDICATOR_BIT                      0x00000004
#define SPP_PORT_STATUS_CARRIER_DETECT_BIT                      0x00000008
   /*! The following constants represent the valid SPP Break Interval
    * values that can be used with the SPP_Send_Break() function.
    */
#define SPP_BREAK_SIGNAL_DETECTED           (RFCOMM_BREAK_SIGNAL_DETECTED)
#define SPP_BREAK_SIGNAL_MINIMUM            (RFCOMM_BREAK_TIMEOUT_INTERVAL*RFCOMM_BREAK_SIGNAL_MINIMUM)
#define SPP_BREAK_SIGNAL_MAXIMUM            (RFCOMM_BREAK_TIMEOUT_INTERVAL*RFCOMM_BREAK_SIGNAL_MAXIMUM)

你可能感兴趣的:(蓝牙,其他)