TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2 Central 变成主从一体机

我的sdk是simplelink_cc2640r2_sdk_1_40_00_45。请问,在CC2640R2F 的example 下central 如何变成主从一体机,实现发出adv 广播,

同时又能主动连接?

Kevin Qiu1:

建议你升级SDK,有主从一体的例程:C:\ti\simplelink_cc2640r2_sdk_4_30_00_08\examples\rtos\CC2640R2_LAUNCHXL\blestack\multi_role

user6224880:

回复 Kevin Qiu1:

目前simplelink_cc2640r2_sdk_1_40_00_45 也有主从一体机的例程,但是发现它的paring 事件不能触发,之前的central角色例程是可以触发pairing 事件的。所以想在central角色的例程上增加从机广播模块,只要能发出adv就行,不知要增加哪些内容?

Kevin Qiu1:

回复 user6224880:

自己加比较复杂,也没有教程,建议你还是在multi_role中修改,paring 事件不能触发具体指的是什么

user6224880:

回复 Kevin Qiu1:

我在multi-role中加了pairing&&bond 的代码部分;

//dev_init { // The default passkey if no passcode callback function is registered with // GAPBondMgr (in GAPBondMgr_Register()). The default in this application // is to post an SBC_PASSCODE_NEEDED_EVT to the application where it will // generate a random passcode. uint32_t passkey = DEFAULT_PASSCODE; // send a pairing request after connecting; the device waits for the // application to start pairing uint8_t pairMode = DEFAULT_PAIRING_MODE; // use authenticated pairing uint8_t mitm = DEFAULT_MITM_MODE; // This is a display only device uint8_t ioCap = DEFAULT_IO_CAPABILITIES; // Create a bond during the pairing process uint8_t bonding = DEFAULT_BONDING_MODE; 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); } 注册回调也有加上 static gapBondCBs_t SimpleBLECentral_bondCB = { (pfnPasscodeCB_t)SimpleBLECentral_passcodeCB, // Passcode callback SimpleBLECentral_pairStateCB // Pairing / Bonding state Callback };现测试连接某个peripheral,发现在multi-role端并没有pairing 事件触发,在 events = Event_pend(syncEvent, Event_Id_NONE, MR_ALL_EVENTS, ICALL_TIMEOUT_FOREVER);没有收到触发事件,而peripheral 是有pairing流程的,只要被连接后,若central端没有绑定,就会发起配对请求;我通过wireshark ,看到peripheral端已经发出配对请求,而multi-role 没有响应。

Kevin Qiu1:

回复 user6224880:

 /*-----------------CLIENT------------------*/// Initialize GATT ClientVOID GATT_InitClient();// Register for GATT local events and ATT Responses pending for transmissionGATT_RegisterForMsgs(selfEntity);// Register to receive incoming ATT Indications/NotificationsGATT_RegisterForInd(selfEntity);}// Setup the GAP Bond Manager{uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE;uint8_t mitm = TRUE;uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;uint8_t bonding = TRUE;uint8_t replaceBonds = FALSE;// Set pairing modeGAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);// Set authentication requirementsGAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);// Set I/O capabilitiesGAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);// Set bonding requirementsGAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);

看下上面的

uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE;我试了下可以自动发起绑定

user6224880:

回复 Kevin Qiu1:

我的配对是被动发起模式,确实没有收到触发pairing事件:
#define DEFAULT_PAIRING_MODEGAPBOND_PAIRING_MODE_WAIT_FOR_REQ
#define DEFAULT_MITM_MODETRUE
#define DEFAULT_BONDING_MODETRUE
#define DEFAULT_IO_CAPABILITIESGAPBOND_IO_CAP_DISPLAY_ONLY//GAPBOND_IO_CAP_KEYBOARD_ONLY/*—————–CLIENT——————*/// Initialize GATT ClientVOID GATT_InitClient();
// Register for GATT local events and ATT Responses pending for transmissionGATT_RegisterForMsgs(selfEntity);
// Register to receive incoming ATT Indications/NotificationsGATT_RegisterForInd(selfEntity);}// Setup the GAP Bond Manager. For more information see the section in the// User's Guide:// software-dl.ti.com/…/gapbondmngr.html{// The default passkey if no passcode callback function is registered with// GAPBondMgr (in GAPBondMgr_Register()). The default in this application// is to post an SBC_PASSCODE_NEEDED_EVT to the application where it will// generate a random passcode.uint32_t passkey = DEFAULT_PASSCODE;//send a pairing request after connecting; the device waits for the// application to start pairinguint8_t pairMode = DEFAULT_PAIRING_MODE;//use authenticated pairinguint8_t mitm = DEFAULT_MITM_MODE;// This is a display only deviceuint8_t ioCap = DEFAULT_IO_CAPABILITIES;// Create a bond during the pairing processuint8_t bonding = DEFAULT_BONDING_MODE;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);}
注册回调也是有的。
// Bond Manager Callbacks
static gapBondCBs_t SimpleBLECentral_bondCB =
{(pfnPasscodeCB_t)SimpleBLECentral_passcodeCB,// Passcode callbackSimpleBLECentral_pairStateCB// Pairing / Bonding state Callback
};GAPBondMgr_Register(&SimpleBLECentral_bondCB);

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2 Central 变成主从一体机
分享到: 更多 (0)