在掌握角色实现绑定

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
7 posts / 0 new
Last post
dhirajp15
Offline
Last seen:2 years 1 month ago
Joined:2016-06-08 15:26
在掌握角色实现绑定

Hi Dialog ,
I have two devices BLE central and peripheral made of da14583 exchanging data on connection .I want to implement bonding , so I made the changes on peripheral side as suggested in tutorial_5 ble_security_example.pdf. But on Central side I cannot find procedure to implement bonding .I also went through sps_host example but no implementation. Going through RW-BLE-GAP-IS.pdf I got to know that bonding procedure needs to be initiated from master side using the command :GAPC_BOND_CMD. I have requested security on peripheral through GAPC_SECURITY_CMD and successfully receive an indication GAPC_SECURITY_IND on master .I need help to write a procedure to initiate bonding from master on security request.
谢谢,

问候,
Dhiraj

Device:
MT_dialog
Offline
Last seen:2 months 6 days ago
Staff
Joined:2015-06-08 11:34
Hi dhirajp15,

Hi dhirajp15,

不幸的是,没有一个示例,它将通过中央的安全过程来指导您,但由于文档指示您需要发出GAPC_BOND_CMD以启动该过程,因此您可以立即发送GAPC_BOND_CMDrapc_security_ind被触发。因此,您可以创建一个回调,该回调将发送GAPC_BOND_CMD,就像下面一样:

struct gapc_bond_cmd *msg;
msg = (struct gapc_bond_cmd *) KE_MSG_ALLOC(GAPC_BOND_CMD, TASK_GAPC,TASK_APP, gapc_bond_cmd);

and then attach your callback in the .app_on_security_req_ind hook.

Thansk MT_dialog

dhirajp15
Offline
Last seen:2 years 1 month ago
Joined:2016-06-08 15:26
Hi MT_Dialog,

Hi MT_Dialog,
I am using Justworks security level for bonding with folowing configuration:
static const struct security_configuration user_security_configuration = {
.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT,
.key_size = KEY_LEN,
.iocap = GAP_IO_CAP_NO_INPUT_NO_OUTPUT,
.auth = gap_auth_req_no_mitm_bond,
.sec_req = GAP_SEC1_NOAUTH_PAIR_ENC,
.ikey_dist = GAP_KDIST_SIGNKEY,
.rkey_dist = GAP_KDIST_ENCKEY,
.tk={
.key={0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
},
.csrk={
.key = {0xab,0xab,0x45,0x55,0x23,0x01,0x0,0x0.0,0x0.0x0,0x0,0x0,0x0.0x0,0x0,0x0},
},
};
我如图所示在umast_catch_rest处理程序cb上实现了uper_catch_rest handler cb中的gapc_bond_cmd。因此,外围设备获取配对请求,它提供了一个配对响应。在中央设备上获取App_On_Pairing_Succeded回调.I在这里接收MSG_PON-> INFO == GAPC_LTK_EXCH上的GAPC_BOND_CMD发送先前收到的长期密钥.Further我收到app_on_encryption_ind回调后跟msg_param->操作== gapc_encrypt和msg_param-> status = 00,指示加密完成,没有错误.is在中央设备上实现绑定的正确方法是有没有更多的命令我缺少?

thanks ,
问候,
dhiraj

MT_dialog
Offline
Last seen:2 months 6 days ago
Staff
Joined:2015-06-08 11:34
Hi dhirajp15,

Hi dhirajp15,

If i properly understand what the sequence that you describe is, when the GAPC_BOND_IND comes with the GAPC_LTK_EXCH, it means that the device obtained the LTK key, when you receive that key you should store it, not initiate a GAPC_ENCRYPT_CMD (what kind keys are distributed over the air depends on the application). The GAPC_ENCRYPT command is in order to encrypt the link after the bonding procedure is over, and the pairing has succeded, and if you would like to encrypt the link with the LTK instead of the TK (which is the current encryption of the link), then you can send a encryption command. For example you can send an encryption command in the app_on_pairing_succeded.

Thanks MT_dialog

dhirajp15
Offline
Last seen:2 years 1 month ago
Joined:2016-06-08 15:26
Hi MT_dialog,

Hi MT_dialog,
Thanks for the help. I did the suggested changes and was able to complete the bonding process successfully. Now on re-connection If i don't want to repeat the paring procedure (assuming I have bonding data present- LTK,Ediv,randnb),the RW_BLE_GAP_IS.pdf suggests:
"When receiving the security request indication, master of the link can decide to initiate pairing or encryption
according to its bond data". --page 95.
So on master side if I receive GAPC_SECURITY_IND , should i keep a check whether to issue a GAPC_BOND_CMD or GAPC_ENCRYPT_CMD (previous bonded)??
Thanks ,
问候,
Dhiraj

MT_dialog
Offline
Last seen:2 months 6 days ago
Staff
Joined:2015-06-08 11:34
Hi dhirajp15,

Hi dhirajp15,

Since the bonding is complete and then the device is disconnected that means that both of the devices are bonded and retain their bonding data, so there is no need to execute the bonding procedure again in order to reconnect with security. So when the devices are bonded the central should issue a ecryption command in order to encrypt the link, so yes the master should check if its bonded or not in order to issue either a bonding command or an encryption command.

Thanks MT_dialog

dhirajp15
Offline
Last seen:2 years 1 month ago
Joined:2016-06-08 15:26
Hi MT_Dialog,

Hi MT_Dialog,
谢谢您的帮助!
问候,
Dhiraj