http://blog.csdn.net/skdev/article/details/50974343
http://blog.csdn.net/sadshen/article/details/47761801
http://blog.csdn.net/feilusia/article/details/48917625
*****************BLE: TwoWinter******************
***** onTestBroadcastRecord *****
result = true, Has 0xfee7 or standard service in broadcast record
广播包:02 01 06 03 02 E7 FE 09 FF 0D 00 90 59 AF 0E 62 88(这几个是mac) 0A 09 54 77 6F 57 69 6E 74 65 72 05 12 50 00 20 03 02 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
***** onTestManufatureData *****
resut= true, 广播包中 manufacture specific data 字段中MAC地址校验成功.
如果这里显示警告,就是的mac地址不对,这里说一下mac的数据是可以自己写的,但是前提要前后保持一致
***** onDiscoverService *****
result = true, DiscoverService success
Discovered Services
ServiceUUID: 00001800-0000-1000-8000-00805f9b34fb
ServiceUUID: 00001801-0000-1000-8000-00805f9b34fb
ServiceUUID: 0000180a-0000-1000-8000-00805f9b34fb
ServiceUUID: 0000fee7-0000-1000-8000-00805f9b34fb
***** onTestHasWeChatService *****
result = true, has WeChatService or standard service
***** onTestHasIndicateCharacteristic *****
result = true, has WeChat Indicate Characteristic
***** onTestHasWriteCharacteristic *****
result = true, has Wechat Write Characteristic
***** onTestHasReadCharacteristic *****
result = true, Has WeChat read characteristic
***** onTestWriteCharacteristicPermisson *****
result = true, has Write permission
***** onTestIndicateCharacteristicPermisson *****
result = true, has Indication permission
***** onTestReadCharacteristicPermisson *****
result = true, Read Characteristic is read able
***** onTestStartIndicating *****
result = true, can Start Indicate
***** onConnected *****
result = true, connected
------onDataReceived------
data length = 20
data dump = FE 01 00 24 27 11 00 01 0A 00 18 84 80 04 20 01 28 02 3A 06
data receive seq = 0
------onDataReceived------
data length = 16
data dump = 90 59 AF 0E 62 88(MAC) 62 08 6D 79 64 65 76 69 63 65
data receive seq = 1
***** onTestRecvAuthReqtWhenStartedIndicating *****
result = true, received auth request pack
***** onTestIsValidAuthReqPack *****
result = true, is a valid auth request pack
AuthRequestPack: FE 01 00 24 27 11 00 01 0A 00 18 84 80 04 20 01 28 02 3A 06 90 59 AF 0E 62 88 62 08 6D 79 64 65 76 69 63 65
has BaseRequest
no Md5DeviceTypeAndDeviceId field!
has MacAddress field, Mac Address = 90 59 AF 0E 62 88
MacAddress BitLength = 48bit
Mac Address from broadcast record = 90:59:AF:0E:62:88
Mac address checkout success
has ProtoVersion field, ProtoVersion = 65540
has AuthProto field, AuthProto = 1
has AuthMethod field, AuthMethod = EAM_macNoEncrypt
no AesSign field!
has DeviceName field, DeviceName = mydevice
**** send auth response ****
data len = 14
data dump = FE 01 00 0E 4E 21 00 01 0A 02 08 00 12 00
**------onDataReceived------
data length = 16
data dump = FE 01 00 10 27 13 00 02 0A 00 1A 04 11 22 33 44
data receive seq = 2
***** onTestRecvInitReqPack *****
result = true, received init request pack
***** onTestIsValidInitReqPack *****
result = true, valid init request pack: has BaseRequest
has Challenge field, Challenge = 11 22 33 44
*****Disconnected Device*****
![>L@KVR4${L1(8>~O0@X{YRAC
Write Characteristic 是微信向BLE设备发数据的通道。
Indicate Characteristic 是BLE设备向微信发数据的通道。
Read Characteristic 返回MAC地址
通信主要由Writet和Indicate 两个特征来完成。
___________________
有几点强调一下
BlE indicate > http://blog.csdn.net/feilusia/article/details/48917625 我当初看这个文档收获很多,感谢原作者,后来者也仔细看看该文件. 当检测到微信发过来的初始化指令的时候,做一个标志位,在定时器里面处理发送,而且要发两次,中间要加点时间间隔,不加的话可能只能发前面一帧数据,不可过大不然会被看成不同的两帧,因为蓝牙协议栈最多支持20个字节的传输,关于AUTH的指令的协议的字节数大于20,所以要发两帧
------onDataReceived------
data length = 20
data dump = FE 01 00 24 27 11 00 01 0A 00 18 84 80 04 20 01 28 02 3A 06
data receive seq = 0
------onDataReceived------
data length = 16
data dump = 90 59 AF 0E 62 88(MAC) 62 08 6D 79 64 65 76 69 63 65
data receive seq = 1
各个标志位的属性配置要做好,这里需要多时间注意一下。
`
static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
{
// Simple Profile Service
{
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type /
GATT_PERMIT_READ, / permissions /
0, / handle /
(uint8 )&simpleProfileService /* pValue */
},
// Characteristic 1 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar1Props
},
// Characteristic Value 1
{
{ ATT_BT_UUID_SIZE, simpleProfilechar1UUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
&simpleProfileChar1
},
// Characteristic 1 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar1UserDesp
},
// Characteristic 2 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar2Props
},
// Characteristic Value 2
{
{ ATT_BT_UUID_SIZE, simpleProfilechar2UUID },
GATT_PERMIT_READ,
0,
simpleProfileChar2
},
// Characteristic 2 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar2UserDesp
},
// Characteristic 3 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar3Props
},
// Characteristic Value 3
{
{ ATT_BT_UUID_SIZE, simpleProfilechar3UUID },
GATT_PERMIT_WRITE,
0,
simpleProfileChar3
},
// Characteristic 3 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar3UserDesp
},
// Characteristic 4 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar4Props
},
// Characteristic Value 4
{
{ ATT_BT_UUID_SIZE, simpleProfilechar4UUID },
0,
0,
simpleProfileChar4
},
// Characteristic 4 configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)simpleProfileChar4Config
},
// Characteristic 4 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
simpleProfileChar4UserDesp
},
// Characteristic 5 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar5Props
},
// Characteristic Value 5
{
{ ATT_BT_UUID_SIZE, simpleProfilechar5UUID },
GATT_PERMIT_READ,
0,
simpleProfileChar5
},
// Characteristic 5 User Description
{
{ ATT_BT_UUID_SIZE, charUserDescUUID },
GATT_PERMIT_READ,
0,
simpleProfileChar5UserDesp
},
// Characteristic 6 Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&simpleProfileChar6Props
},
// Characteristic Value 6
{
{ ATT_BT_UUID_SIZE, simpleProfilechar6UUID },
GATT_PERMIT_READ|GATT_PERMIT_WRITE,
0,
simpleProfileChar6
},
// Characteristic 6 configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
0,
(uint8 *)simpleProfileChar6Config
},
自由通讯
作者: Bruce-Woo, 来源:面包板社区
链接: https://mbb.eet-china.com/blog/uid-me-1850657.html
版权声明:本文为博主原创,未经本人允许,禁止转载!
moniqiuwen 2021-1-25 14:09
Rain社区管理 2017-4-19 02:23
欢迎归来重新开始博客之旅