Only allow pairing requests with PIN code

⚠️
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.
16个帖子/ 0新
Last post
apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
Only allow pairing requests with PIN code

Hello,

我对SDK配对有一个问题。
The software on our board is waiting for pairing requests.
智能手机应用程序连接到电路板并开始配对请求。
The IO capabilities of the Dialog board are configured as "display only".

因此,目前手机可以使用电路板显示的PIN码进行配对请求,并且它可以正常工作。
But the problem is that the phone can also do a pairing request without PIN code and it works too.
是否有可能仅接受与PIN码的配对请求,并拒绝其他人?

谢谢,
安迪

设备:
MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

What do you mean that the phone is able to connect without the pin ? If for example the device asks you for a pin and you just ignore it from the phone side the device still remains connected until you issue a disconnection ? Or the device will just disconnect after a few seconds ? The device will accept the connection and if the implemenation requires security then the security request will happen while connected, if the security requirements of the link doesn't match the device's requirements it will just disconnect, you can take as an example the bms project of the SDK, as is it will require a pass key, if the device doesn't receive a pairing response within 30 seconds it will just disconnect.

谢谢MT_dialog

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
Hello,

Hello,

The characteristic in my BLE service was created using permission ATT_PERM_WRITE_ENCRYPT instead of ATT_PERM_WRITE_AUTH. Because of this some devices could pair without entering a PIN code ("just works" pairing).

However I have an other issue. Sometimes I want the user to be able to write this characteristic without being paired, and sometimes I want him to be able to do this only if he is paired.
我尝试使用函数ble_gatts_set_characteristic_prop来更改特性的权限(在att_perm_write和att_perm_write_auth之间切换)。但是,当我这样做时,我的特征变得无效。例如,如果我检查nrf connect,我可以看到特征uuid更改。因为这个智能手机无法找到特征(因为它抬头使用它的UUID)。
Is there something I should know when using ble_gatts_set_characteristic_prop? The initial UUID is a 128 bit UUID and after this function call it becomes a 16 bit UUID.

I was looking for a workaround to this issue: is it possible to destroy my service and create it again?

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

似乎函数ble_gatts_set_characteristic_prop()和ble_gatts_get_characteristic_prop()(在1.0.12 SDK)上有问题,我正在与SDK团队一起检查,我会尽快让您知道更多信息。据我所知,没有有效的API,这将允许您在运行时期间使用所需的权限轻松地破坏和重新创建数据库,我也与团队一起检查。

谢谢MT_dialog

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
谢谢你的答案

谢谢你的答案would be very nice if you could get back to me when you have more information on this issue (or a workaround).

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

I 've issued an internal ticket on that, i will reply as soon as i have an answer from the SDK team.

谢谢MT_dialog

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
Hello,

Hello,

您是否对此问题有任何更新?

谢谢

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

No, still no news from the SDK team, this might take a while.

谢谢MT_dialog

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

刚有一些反馈意见,请在以下职能下进行以下更改:

  1. ble_mgr_gatts_service_characteristic_set_prop_cmd_handler()
  2. ble_mgr_gatts_service_characteristic_get_prop_cmd_handler()

In the above functions you will find the following line of code:

gcmd-> handle = cmd->手柄+ 1;请用这个替换这条线gcmd->handle = cmd->handle;apparently the function was requesting and setting the wrong handle, this should fix the issue.

谢谢MT_dialog

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
你好mt_dialog,

你好mt_dialog,

在这种情况下,当我调用ble_gatts_set_characteristic_prop()函数时,我应该给出特征句柄或属性值句柄吗?

我在SDK上做了改变,但我的问题仍然存在。
- If I give the characteristic handle, nothing happens the permissions are not changed
- If I give the attribute value handle, the permissions are changed but the characteristic UUID is also changed (it becomes a 16bit UUID)

谢谢

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

I have not tested this on the central side only through the debugger on the DK just to check that the permissions are changed, tested on a central device i can reproduce your issue and see what you are mentioning, that the change affects the UUID of the characteristic, still checking on a solution for that. The handle that you should pass to the function is the attribute of the value.

谢谢mt_dialog.

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
你好mt_dialog,

你好mt_dialog,

感谢您的回答。
I'd be glad if you could get back to me when you have a solution regarding the UUID issue.

谢谢

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

仍然没有来自SDK团队的新闻,这是一个适当的修复,但我相信我们已经找到了一个工作,以便能够在不搞乱UUID的情况下更改特征的权限和属性,而不是使用BLE_GATTS_SET_CHAROURY_PROP()函数请检查下面的3行代码以更改特征的权限和属性。

att_perm_type test_perm;
struct attm_elmt elmt;

test_perm = prop_to_rwperm (GATT_PROP_READ| GATT_PROP_WRITE | GATT_PROP_NOTIFY) | perm_to_rwperm(ATT_PERM_READ_AUTH|ATT_PERM_WRITE)|
(PERM_UUID_128 << PERM_POS_UUID_LEN) ; //This will set the proper properties and permssions that will later be assigned to the attribute.
status = attmdb_get_attribute(mcs_glob-> mc_var_value_h,&elmt);//获取属性
elmt.info.att->perm = test_perm; //Set a new set of permissions to the targeted attribute.

我希望这将有所帮助。

谢谢MT_dialog

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
谢谢mt_dialog,你的

谢谢mt_dialog,你的解决方法就像魅力一样。
Do you know if the same thing can be done on descriptors?

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi apoudret,

Hi apoudret,

Almost, i have this working on my side for the descriptors:

test_perm = perm_to_rwperm(ATT_PERM_READ_AUTH);
status = attmdb_get_attribute(mcs_glob-> mc_descriptor,&elmt);
elmt.info.att->perm = test_perm;

谢谢MT_dialog

apoudret
Offline
Last seen:6个月前1年
加入:2017-09-22 08:33
谢谢mt_dialog这是

谢谢mt_dialog这是working perfectly.