cc2640取消配對
您好
我有個應用在cc2640上的glucose與iphone連接,phone app是Store下載的兩款,
希望手機在get data時不要進行配對&passcode(希望按get data 按鈕即取得data)
應用如下:
smart phone(app:BLE Tool, EzGluco) --> <Connect> --> cc2640(Glucose sensor)
smart phone(app:BLE Tool, EzGluco) <-- <Reply connected> <-- cc2640(Glucose sensor)
smart phone(app:BLE Tool, EzGluco) --> <Get glucose data> --> cc2640(Glucose sensor)
smart phone(app:BLE Tool, EzGluco) <-- <Reply data> <-- cc2640(Glucose sensor)
參考各位前輩define pairing param:
uint32_t passkey = 000000;
uint8_t pairMode = GAPBOND_PAIRING_MODE_NO_PAIRING;
uint8_t mitm = FALSE;
uint8_t ioCap = GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT;
uint8_t bonding = FALSE;
GAPBondMgr_SetParameter(GAPBOND_DEFAULT_PASSCODE, sizeof(uint32_t),&passkey);
GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);
GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);
GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);
GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);
現況:
[phone]:iphone可以連線,但無法get data(一直處於等待data中)。
[2640]:
GlucoseSensor_taskFxn()
{
………
for (;;)
{
ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER);
// 無法往下跑,因而無法get data
}
while (!Queue_empty(appMsgQueue))
{
//get data
GlucoseSensor_processAppMsg(pMsg);
}
}
測試:
懷疑是否在GAPBOND_PAIRING_MODE_NO_PAIRING 下無法get data,做以下測試…
1、ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY
2、在gapbondmgr.c的GAPBondMgr_ProcessGAPMsg(),case GAP_PAIRING_REQ_EVENT中的
else if ( gapBond_PairingMode == GAPBOND_PAIRING_MODE_NO_PAIRING )裡加上:
// No Pairing - Send error
#if 1
linkDBItem_t *pLinkItem = linkDB_Find( pPkt->connectionHandle );
// Send pairing response
gapBondMgrAuthenticate( pPkt->connectionHandle, pLinkItem->addrType, &(pPkt->pairReq) );
#else
VOID GAP_TerminateAuth( pPkt->connectionHandle, SMP_PAIRING_FAILED_NOT_SUPPORTED );
#endif
測試結果:
在GAPBOND_PAIRING_MODE_NO_PAIRING 下是能get data的(但因上面測試修改,故需輸入passcode,但沒bond)
問題:
回歸到測試修改之前,當else if (gapBond_PairingMode == GAPBOND_PAIRING_MODE_NO_PAIRING)成立,
就應該 GAP_TerminateAuth()終止認證,並且繼續往下跑get data,為何看起來像是等認證般的卡住呢??
是否有哪裡我沒設定到的嗎??
你下载的两款APP是确定能用的APP吗?有没有使用lightblue试过?CC2640 SDK是什么版本的?
Hi WBJ
lightblue有試過,但沒有glucose的功能,而下載的兩款app在允許pairing & keyin passcode時都能正常取得glucose data,
就我理解pairing request應該是2640發出請求吧,如果上述程序進入不配對(GAPBOND_PAIRING_MODE_NO_PAIRING)成立後,
應該會執行GAP_TerminateAuth();結束認證程序,因此也不會對phone發出配對請求,因此兩款app應該不會有誤。
SDK: BLE-STACK V21(ble_cc26xx_setupwin32_2_01_00_44423)
我判斷SDK沒錯,錯在我的code,但似乎很難debug這個issue,是否有個建議,通常取消配對取得不到data的問題可能在哪?
看了一下代码似乎glucose里面的参数有些是需要配对才能打开的
在glucservice.c 里面static gattAttribute_t glucoseAttrTbl[] 下面定义的。
衷心衷心的感謝你…爬過N篇文沒有一個有寫到這個權限,整個一直在define GAPBOND_PAIRING_MODE_NO_PAIRING
和gapbondmgr裡的打轉…感謝
Hi WBJ
Sorry,我可能在反覆測試時不小心綁定過,誤以為解了,現在仍然停在ICall_wait(),
以下是gattAttribute_t glucoseAttrTbl[]的定義,紅色字是針對gatt.h的define修改的,是否還有其它地方呢??
static gattAttribute_t glucoseAttrTbl[] =
{
// Glucose Service
{
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
GATT_PERMIT_READ, /* permissions */
0, /* handle */
(uint8 *)&glucoseService /* pValue */
},
// 1. Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseProps
},
// 2. Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseMeasUUID },
0, //return READ_NOT_PERMITTED
0,
&glucoseMeas
},
// 3.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_ENCRYPT_WRITE,
0,
(uint8 *)&glucoseMeasConfig
},
//////////////////////////////////////////////
// MEASUREMENT CONTEXT
//////////////////////////////////////////////
// 4.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseContextProps
},
// 5.Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseContextUUID },
0, //return READ_NOT_PERMITTED
0,
&glucoseContext
},
// 6.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_ENCRYPT_WRITE,
0,
(uint8 *)&glucoseContextConfig
},
//////////////////////////////////////////////
// GLUCOSE FEATURE
//////////////////////////////////////////////
// 7.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseFeatureProps
},
// 8.Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseFeatureUUID },
//GATT_PERMIT_ENCRYPT_READ, // TI ori
GATT_PERMIT_READ, //[TI jerry k], for PTS test GLF GL BV-06-I
0,
(uint8 *) &glucoseFeature
},
//////////////////////////////////////////////
// GLUCOSE CONTROL POINT
//////////////////////////////////////////////
// 9.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseControlProps
},
// 10.Characteristic Value
{
{ ATT_BT_UUID_SIZE, recordControlPointUUID },
#ifdef KUO_DEBUG
GATT_PERMIT_WRITE,
#else
GATT_PERMIT_AUTHEN_WRITE,
#endif
0,
&glucoseControl
},
// 11.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_ENCRYPT_WRITE,
0,
(uint8 *)&glucoseControlConfig
}
};
您修改错地方了,我在我这边用原始的SDK里面的glucoseSensor代码和lightblue试过了,
取消配对,这部分你修改对了
在这个数组里面,我大致修改了如下地方,然后在lightblue里面打开notification的开关,就可以获取glucosesensor发过来的notification数据了
static gattAttribute_t glucoseAttrTbl[] =
{
// Glucose Service
{
{ ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
GATT_PERMIT_READ, /* permissions */
0, /* handle */
(uint8 *)&glucoseService /* pValue */
},
// 1. Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseProps
},
// 2. Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseMeasUUID },
0, //return READ_NOT_PERMITTED
0,
&glucoseMeas
},
// 3.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,//del by WBJ//GATT_PERMIT_ENCRYPT_WRITE,
0,
(uint8 *)&glucoseMeasConfig
},
//////////////////////////////////////////////
// MEASUREMENT CONTEXT
//////////////////////////////////////////////
// 4.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseContextProps
},
// 5.Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseContextUUID },
0, //return READ_NOT_PERMITTED
0,
&glucoseContext
},
// 6.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,//del by WBJ//GATT_PERMIT_ENCRYPT_WRITE,
0,
(uint8 *)&glucoseContextConfig
},
//////////////////////////////////////////////
// GLUCOSE FEATURE
//////////////////////////////////////////////
// 7.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseFeatureProps
},
// 8.Characteristic Value
{
{ ATT_BT_UUID_SIZE, glucoseFeatureUUID },
GATT_PERMIT_READ,//del by WBJ//GATT_PERMIT_ENCRYPT_READ,
0,
(uint8 *) &glucoseFeature
},
//////////////////////////////////////////////
// GLUCOSE CONTROL POINT
//////////////////////////////////////////////
// 9.Characteristic Declaration
{
{ ATT_BT_UUID_SIZE, characterUUID },
GATT_PERMIT_READ,
0,
&glucoseControlProps
},
// 10.Characteristic Value
{
{ ATT_BT_UUID_SIZE, recordControlPointUUID },
GATT_PERMIT_AUTHEN_WRITE,
0,
&glucoseControl
},
// 11.Characteristic Configuration
{
{ ATT_BT_UUID_SIZE, clientCharCfgUUID },
GATT_PERMIT_READ | GATT_PERMIT_WRITE,//del by WBJ//GATT_PERMIT_ENCRYPT_WRITE,
0,
(uint8 *)&glucoseControlConfig
}
};
我修改过了所有的地方,其实你可以按照你的需求来修改一部分。关键是notification的开关的写属性要修改
Hi WBJ
再次謝謝,的確是您說的這裡要改,
有個差異點是在我的porject除了您上述修改的地方外,"// 10.Characteristic Value"也必須修改才行,
應該是有用到才對,謝謝您的幫忙!!