我的sdk是simplelink_cc2640r2_sdk_1_40_00_45。请问,在CC2640R2F 的example 下central 如何变成主从一体机,实现发出adv 广播,
同时又能主动连接?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我的sdk是simplelink_cc2640r2_sdk_1_40_00_45。请问,在CC2640R2F 的example 下central 如何变成主从一体机,实现发出adv 广播,
同时又能主动连接?
我在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 没有响应。
看下
uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE;
我测试可以自动发起绑定
/*-----------------CLIENT------------------*/ // Initialize GATT Client VOID GATT_InitClient(); // Register for GATT local events and ATT Responses pending for transmission GATT_RegisterForMsgs(selfEntity); // Register to receive incoming ATT Indications/Notifications GATT_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 mode GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode); // Set authentication requirements GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm); // Set I/O capabilities GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap); // Set bonding requirements GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);
谢谢!
我的主从一体机中设置pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ,连接peripheral 后,原peripheral 的pairMode 是GAPBOND_PAIRING_MODE_INITIATE,正常情况下,peripheral 是会主动发起配对的,而我的主从一体机这端没有收到配对请求事件;
而我的主从一体机中设置pairMode = GAPBOND_PAIRING_MODE_INITIATE ,用手机ble app去连接主从一体机,主从一体机是会主动发起配对的,在手机上可以显示配对窗口。
现在就不清楚,为何主从一体机的central角色不能收到配对请求?