in timeapp sample
in ANCS section , how can i subscribe both Notification Source and Data Source and obtain their callback ?
(https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html)
Brief description:
9FBF [notify characteristic ] – Notification Source
22EA[notify characteristic ] – Data Source69D1 [write] - control point
msg receive -> 9FBF notify with message ID, write command with message ID to 69D1, 22EA will callback the info of that msg
do it means i can get CCCD from both 9FBF , 22EA ?
and i can start notify both by writing a value of 0x0001 to the client characteristic configuration descriptor (CCCD). ?
( http://www.deyisupport.com/question_answer/wireless_connectivity/f/45/p/18256/61800.aspx )
i tried to search for CCCD , only can find CCCD in 0x9FBF,
so 0x22EA never receive callback even i write value to 0x69D1
with reference to "timeapp_discover.c"
is the callback of both notify arrive at TimeAppDiscAlertNtf ?
Yan:
jeff,
i can barely follow your description, if you can speak chinese, could you write it down in Chinese?
But some concepts i can tell you, ANS works differently with most other BLE services.
for ANS, master side works as GATT server, slave works as GATT client, which is opposite from most other BLE services. That means, all the notifications have be to defined in the master side, in your case should be the iOS device. That also means, all the CCCDs are also defined on the master side.
jeff jeff:
回复 Yan:
正在做一個ancs 在iphone 的測試 ,目標是知道有新訊息,和其內容,但我現在我只能取得新訊息的notifcation看了http://mbientlab.com/blog/ancs-on-ti2541-in-an-afternoon/iphone 的ancs characteristic 為9FBF [notify characteristic ] – Notification Source22EA[notify characteristic ] – Data Source69D1 [write] – control point https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html1. 當有訊息時,0x9FBF 會返回一個 notification callback ,callback 包合了 notification ID2. 用notification ID write 到0x69D13. 成功的話,0x22EA 會收到 notification callback,會有全部關於這個message 的內容( sender,title,app id,content… )
我卡在3,因為不能起始0x22EA notify 或收到任何3的notification callback,
不知怎樣找0x22EA 的characteristic configuration (CCCD),也不知0x22EA 的notification callback 會到那兒,所以不知2 是否寫入正確資料我只能成功找到0x9FBF 的cccd,用它的handler 成功取得 0x9FBF 的notification timeapp 只顯示怎樣取得一個notify characteristic , 如果我要同時起始 及 listen 兩個notify characteristic 就沒頭緒
Yan:
回复 jeff jeff:
jeff,
我了解了。
根据示例代码 https://github.com/lkasso/ANCS/blob/master/timeapp_discovery.c
理论上这个代码根据状态机应该能找到ANCS 下的所有characteristic,包括data source,然后再查找他们的CCCD,并且enable。
你能用C2540 dongle sniffer 抓下Log 分享给大家一下分析一下吗?
jeff jeff:
回复 Yan:
再重新測試了lkasso , timeapp_discovery.chttps://github.com/lkasso/ANCS/blob/master/timeapp_discovery.c
做了些改動, pMsg->msg.findInfoRsp.numInfo ( see remark #1 ) 可以找到2 個 notification characteristic
但只能找到1 個 characteristics 有CCCD ( remark #2 )
要用sniffer 試一下
// Characteristic descriptors found
if ( pMsg->method == ATT_FIND_INFO_RSP &&
pMsg->msg.findInfoRsp.numInfo > 0 &&
pMsg->msg.findInfoRsp.format == ATT_HANDLE_BT_UUID_TYPE )
{
// For each handle/uuid pair
for ( i = 0; i < pMsg->msg.findInfoRsp.numInfo; i++ ) //// remark #1
{
// Look for CCCD
if ( (pMsg->msg.findInfoRsp.info.btPair[i].uuid[0] ==
LO_UINT16(GATT_CLIENT_CHAR_CFG_UUID)) &&
(pMsg->msg.findInfoRsp.info.btPair[i].uuid[1] ==
HI_UINT16(GATT_CLIENT_CHAR_CFG_UUID)) )
{
// CCCD found //// remark #2
timeAppHdlCache[HDL_ANCS_NTF_CCCD] =
pMsg->msg.findInfoRsp.info.btPair[i].handle;
break;
}
}
}
Yan:
回复 jeff jeff:
jeff,
至少找到一个CCCD了,好消息啊:)
pMsg->msg.findInfoRsp.numInfo 的值是多少呢?
这种情况最好还是sniffer 抓包看一下,是否所有的attribute 都查询到了。
jeff jeff:
回复 Yan:
numInfo = 2
只要write 0x0001到 data notification characteristics ( 0x7BFB ) , 就可以啟動
callback 也是在 timeAppProcessGattMsg 取得
Yan:
回复 jeff jeff:
jeff,
你的意思是目前两个notification 都可以用了?
0x7BFB 是你找到的iOS的data source CCCD 的UUID?
jeff jeff:
回复 Yan:
是,
找出有characteristic descriptor (CCCD) 的characteristics,因為notify characteristics 才用會用到CCCD,共有兩個,取CCCD 的handler ,handler 數值比較小的是"Notification Source" , 用來通知有訊息到來, 大一點的是Data Source ,是用來收取message detail 的 callback要起動這兩個 notification ,要用characteristic write ,寫0x0001 到這兩個CCCD handler,就能
在 timeAppProcessGattMsg ( timeapp.c ) 收到通知了* 記得要先在iphone 移除之前的pairup
attWriteReq_t writeReq;
writeReq.handle = cccd1; // or cccd2
writeReq.len = 2;
writeReq.value[0] = 0x01;
writeReq.value[1] = 0x00;GATT_WriteCharValue(connHandle, &writeReq, taskId );
Yan:
回复 jeff jeff:
jeff,
非常感谢你的分享 🙂
wei lu1:
回复 jeff jeff:
jeff你好
我已经使能了 Notification Source,Data Source。Notification Source会自动通知来电、短信。但是Data Source不会通知来电、短信的具体消息。
我是还需要NotificationUID吗?(因为需要它来作为handle去获取关于此notification的更多信息,例如来显通知,就需要这个通知中的NotificationUID作为handle,去查询是哪个号码打来,是哪个联系人等。)
// Characteristic descriptors found if ( pMsg->method == ATT_FIND_INFO_RSP && pMsg->msg.findInfoRsp.numInfo > 0 && pMsg->msg.findInfoRsp.format == ATT_HANDLE_BT_UUID_TYPE ) { // For each handle/uuid pair for ( i = 0; i < pMsg->msg.findInfoRsp.numInfo; i++ ) { // Look for CCCD if ( (pMsg->msg.findInfoRsp.info.btPair[i].uuid[0] == LO_UINT16(GATT_CLIENT_CHAR_CFG_UUID)) && (pMsg->msg.findInfoRsp.info.btPair[i].uuid[1] == HI_UINT16(GATT_CLIENT_CHAR_CFG_UUID)) ) { // CCCD found timeAppHdlCache[HDL_ANCS_DATA_SOURCE_CCCD] = pMsg->msg.findInfoRsp.info.btPair[i].handle; break; } } }
writeReq.len = 2;
writeReq.value[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY); writeReq.value[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY); writeReq.sig = 0; writeReq.cmd = 0; writeReq.handle = timeAppHdlCache[HDL_ANCS_DATA_SOURCE_CCCD]; GATT_WriteCharValue( timeAppConnHandle, &writeReq, timeAppTaskId );
TI中文支持网


