FR8016HA加密配对相关问题
-
概述:初始化需要PIN码验证,连接蓝牙之后用gap_security_send_pairing_password(0,123456);发送绑定操作时所需的PIN码,看日志没触发任何绑定相关或者PIN码验证成功的事件触发。求助大家帮忙看看是不是初始化或者哪个环节有问题?
安全参数初始化:
gap_security_param_t param =
{
.mitm = true,
.ble_secure_conn = false,
.io_cap = GAP_IO_CAP_DISPLAY_ONLY,
.pair_init_mode = GAP_PAIRING_MODE_WAIT_FOR_REQ,
.bond_auth = true,
.password = 123456,
};
gap_security_param_init(¶m);
-
/从机端*********/
从机的配对机制
#if 0
// 配置为绑定时需要PIN码
gap_security_param_t param =
{
.mitm = true, // use PIN code during bonding
.ble_secure_conn = true, //not enable security encryption
.io_cap = GAP_IO_CAP_DISPLAY_ONLY, //ble device has output ability, will show pin code.
.pair_init_mode = GAP_PAIRING_MODE_WAIT_FOR_REQ,//need bond
.bond_auth = true, //need bond auth
.password = 12345, //set PIN code, it is a dec num between 100000 ~ 999999
};
#endif#if 1
//配置为不需要PIN码
gap_security_param_t param =
{
.mitm = false, // use PIN code during bonding
.ble_secure_conn = false, //not enable security encryption
.io_cap = GAP_IO_CAP_DISPLAY_ONLY, //ble device has output ability, will show pin code.
.pair_init_mode = GAP_PAIRING_MODE_WAIT_FOR_REQ, //need bond
.bond_auth = true, //need bond auth
.password = 0, //set PIN code, it is a dec num between 100000 ~ 999999
};
#endif
//initialize bonding configuration
gap_security_param_init(¶m);
//*****************************************************///主机端*********/
需要在 app_gap_evt_cb(gap_event_t *p_event)里面
加入
case GAP_SEC_EVT_BOND_FAIL: //!< Link bond is failed
co_printf("GAP_SEC_EVT_BOND_FAIL:0x%02x\r\n",GAP_SEC_EVT_BOND_FAIL);
break;
case GAP_SEC_EVT_BOND_SUCCESS: //!< Link bond is successful
co_printf("GAP_SEC_EVT_BOND_SUCCESS:0x%02x\r\n",GAP_SEC_EVT_BOND_SUCCESS);
break;
case GAP_SEC_EVT_PIN_CODE_REQ: //!< Link bond request pin code inpu
gap_security_send_pairing_password(0,12345);
co_printf("GAP_SEC_EVT_PIN_CODE_REQ:0x%02x\r\n",GAP_SEC_EVT_PIN_CODE_REQ);
break;
-
您好,非常感谢答疑gap_security_send_pairing_password接口的用法。但是如果我想通过APP下发PIN到从机端,从机端能否使用gap_security_send_pairing_password来进行PIN码校验,就是我不想使用系统弹框去输入PIN码,APP这边是自定义界面给用户输入PIN码,PIN码传输到蓝牙模组之后,我有什么办法接着进行PIN码配对流程?