你好,
我目前正在通过您的培训05安全性,并遵循步骤,并能够连接到设备。
但是,在测试一点点后,我不再能够与LightBlue连接。我收到错误:在被询问时断开连接。
然后我联系进行测试a different phone and was able to connect and use the device properly.
Investigating further I've tried connecting to the device with my own iPhone app developed on xcode and am able to connect to the device but am then immediately disconnected with an unknown error. I've tried uploading different projects and am still unable to connect with the phone I am testing on.
有谁可以指出我的方向来解决这个问题或更多地了解有关使用安全性的更多信息?
Device:
嗨敖,
断开连接的原因可能是安全性,在与设备配对之后,如果您再次尝试对设备进行断开连接,则自组配对以来将拒绝连接。尝试从手机中取消绑住设备并尝试再次连接,也可以捕捉断开回调并检查断开连接的原因。关于您对ManciDelly进行断开连接的事实,您是否正在测试您的手机实施安全性的应用程序?外围设备将进行安全请求,但是如果外设使此类请求和中央不回复外围设备将自动断开连接,则启动配对过程是担任主权。您可以查看智能标记项目,实现安全性并处理由配对过程中继的键。
谢谢mt_dialog.
嗨MT,
I have similar issue as Ao, after tried to turn on security with instructions in training 05, and it will be re-connected if I turn the security off.
断开原因是0x16(co_error_co_term_by_local_host),这完全是含义吗?
Exactly, I remembered, at the 1st time, it was successfully bonded and worked, somehow, it was disconnected after resetting the DA14580 Dev Kit.
在我从手机忘记绑定设备之后(使用iOS 9.3.2运行),它仍然无法与安全性连接。
任何线索?
霍勒斯,
当我从手机忘记设备时,我能够使用DA14580绑定。为了与芯片一起使用,我每次重新编程时都不必忘记设备。
嗨敖,
Yes, I have same situation with you, and now want to resolve it thoroughly.
豪拉,
The message that you get CO_ERROR_CO_TERM_BY_LOCAL_HOST is because the device is explictly rejecting the connection. If you have enabled the security in the device and the device has no bonding data it will accept a pairing request and bond with that device. If disconnected the reconnecting procedure is different. To reconnect with a bonded device, the central should sent a encryption request. The handler of the encryption request will check the security data from the central, if the data dont match the device will reject the connection. Your phone remembers the bonding data of your connection, but if you power cycle or reprogram the 580 all the bonding data will be lost and the when an encryption request comes for a reconnection the 580 will reject it.
您可以在User_callback_config.h文件中捕获配对和加密事件,在user_callback_config.h文件中(default_app_on_pairing_request()函数应在配对请求消息上调用,并且在verafault_app_on_ecryption_req_ind()函数中应在加密请求消息中调用断开和顺序重新核化)。您可以使用模板示例测试此功能,如user_config.h文件中的小修改,使用def_sec_req_on_connect更改.security_request_scenario才能请求连接的安全性,这将使您能够使用After Works安全连接。
谢谢mt_dialog.
亲爱的,
Thank you very much for reply.
Here is my adaptation at user_config.h
@@ -47,9 +47,15 @@ const static sleep_state_t app_default_sleep_mode=ARCH_SLEEP_OFF;
static const struct security_configuration user_security_configuration = {
.oob = GAP_OOB_AUTH_DATA_NOT_PRESENT,
.key_size = key_len,
+#IF 1
.iocap = gap_cap_no_input_no_output,
.auth = GAP_AUTH_REQ_NO_MITM_BOND,
- .sec_req = GAP_NO_SEC,
+ .sec_req = GAP_SEC1_NOAUTH_PAIR_ENC,
+#else
+ .iocap = gap_cap_kb_only,
+ .auth = gap_auth_req_mitm_bond,
+ .sec_req = gap_sec1_auth_pair_enc,
+#endif
.ikey_dist = gap_kdist_signkey,
.rkey_dist = gap_kdist_enckey,
.tk = {
@@ -215,7 +221,7 @@ static const struct default_handlers_configuration user_default_hnd_conf = {
//Configure the security start operation of the default handlers
//如果启用了安全性(cfg_app_security)
- .security_request_scenario = def_sec_req_never
+ .security_request_scenario = def_sec_req_on_connect
};
#endif // _user_config_h_
当您引导时,我抓住了default_app_on_pairing_request()和default_app_on_ecryption_req_ind()函数,
but it only invoked default_app_on_encryption_req_ind().
我认为这是因为外围设备已经与手机配对,不是吗?
void default_app_on_encrypt_req_ind(uint8_t connection_idx, struct gapc_encrypt_req_ind const *param)
==>
if (app_easy_security_validate_encrypt_req_against_env( connection_idx, param))
==>
bool app_easy_security_validate_encrypt_req_against_env (uint8_t connection_idx, struct gapc_encrypt_req_ind const *param)
{
if(((app_sec_env [connection_idx] .auth&gap_auth_bond)!= 0)
......
返回(真实);
别的
返回(false);- >走假。
}
connection_idx等于0,APP_SEC_ENV [0]填充零
这是否意味着我必须在永久商店中保存绑定信息
正如多个设备键合的Transtract_05材料的第18页中的描述?
那么,稍后,它可以在加密_req_ind中检查,正确?
Hi Dialog Support,
你能帮忙回答#7吗?谢谢!
Hi Horace,
正如我已经知道的那样,如果外设绑定,它将仅触发加密请求函数,以检查中央对连接的键是否有效。配对完成后,指定连接(Connection_idx)的app_sec_env不应为零,但应具有在配对过程中定义的键。如果设备失去电源,则不保留键(app_sec_env将设置为零),因为它们存储在RAM空间中,因此您应该将它们存储在闪存中并自定义应用程序以检查键的闪存。
谢谢mt_dialog.
嗨MT,
好的,得到它,谢谢!