Hi All,
I want to add pairing and binding functions to the blinky project.
But nothing happens when I connect.
Please help me,thank you.
Here is my project => Lab10_PeerManager_pairing.zip
I'm using SDK v17.1.0
Best regards,
Kai
Hi All,
I want to add pairing and binding functions to the blinky project.
But nothing happens when I connect.
Please help me,thank you.
Here is my project => Lab10_PeerManager_pairing.zip
I'm using SDK v17.1.0
Best regards,
Kai
Hi Kai,
I had a biref look at your project and see one issue that is clearly incorrect. In your handling of the BLE_GAP_EVT_SEC_PARAMS_REQUEST you reply that pairing is not supported. You need to remove this. In fact, there is no need to handle this event at all, as it is handled by the peer manger library.
Einar
Hi Einar,
Finally I refer to the example of gls.
I observed that pairing needs to use these few lines of code =>
err_code = pm_conn_secure(p_ble_evt->evt.gap_evt.conn_handle, false);
if (err_code != NRF_ERROR_BUSY)
{
APP_ERROR_CHECK(err_code);
}
Now I have two questions : 1. why bps example does not use this API.
2. My program has a pairing function after adding that API, but the phone will jump 2 times to notify before it can be connected.
Best regards,
Kai
Hi Kai,
I tested your project briefly (just connecting and pairing) and that seems to work as expected. With the unmodified project, I connect, and then the nRF initiates pairing and that proceeds successfully when I test with an iPhone with the nRF Connect app.
After commenting out the call to pm_conn_secure() the nRF no longer initiates pairing, so that is now up to the central. iOS only pairs when needed (after not being allowed to access a characteristic due to too low security level). So in order to make the iPhone pair I did a small change to your LBS service so that reading or writing to the button or LED requires security, and thus makes the iPhone pair:
diff --git a/ble_lbs/ble_lbs.c b/ble_lbs/ble_lbs.c
index f2a72f9..c255ede 100644
--- a/ble_lbs/ble_lbs.c
+++ b/ble_lbs/ble_lbs.c
@@ -107,8 +107,8 @@ uint32_t ble_lbs_init(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init)
add_char_params.char_props.read = 1;
add_char_params.char_props.notify = 1;
- add_char_params.read_access = SEC_OPEN;
- add_char_params.cccd_write_access = SEC_OPEN;
+ add_char_params.read_access = SEC_JUST_WORKS;
+ add_char_params.cccd_write_access = SEC_JUST_WORKS;
err_code = characteristic_add(p_lbs->service_handle,
&add_char_params,
@@ -127,8 +127,8 @@ uint32_t ble_lbs_init(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init)
add_char_params.char_props.read = 1;
add_char_params.char_props.write = 1;
- add_char_params.read_access = SEC_OPEN;
- add_char_params.write_access = SEC_OPEN;
+ add_char_params.read_access = SEC_JUST_WORKS;
+ add_char_params.write_access = SEC_JUST_WORKS;
return characteristic_add(p_lbs->service_handle, &add_char_params, &p_lbs->led_char_handles);
}
(This change is not needed when using Android or nRF Connect for Desktop, where you can force pairing as you like).
Hi Einar,
I'm using Android.
(This change is not needed when using Android or nRF Connect for Desktop, where you can force pairing as you like).
It cannot match.
I am not able to see any issue in that case. Can you try to explain with words what the problem is, how you test and in what way it does not work?
Hi Einar,
So in order to make the iPhone pair I did a small change to your LBS service so that reading or writing to the button or LED requires security, and thus makes the iPhone pair:
I tested it not long ago, and Android also needs this setting to have the pairing function appear.
Now my doubts are resolved, but there is still one question I don't understand.
Why does pm_conn_secure() need to be paired twice?
Hi,
kai19960504 said:I tested it not long ago, and Android also needs this setting to have the pairing function appear.
It needs it for pairing to appear automatically, yes (because it needs to be initiated form one side, and if the phone does not do it one way or another, the nRF must). But pairing works regardless, just that it must be initiated in a different way. Also, there is not much point in pairing without also requiring security on some characteristics.
kai19960504 said:Why does pm_conn_secure() need to be paired twice?
What do you mean? The function just initiates pairing, it works the same every time (that said, if bonded already, it will just initiate encryption of the link using existing key. If not bonded, it will initiate pairing).
Hi,
kai19960504 said:I tested it not long ago, and Android also needs this setting to have the pairing function appear.
It needs it for pairing to appear automatically, yes (because it needs to be initiated form one side, and if the phone does not do it one way or another, the nRF must). But pairing works regardless, just that it must be initiated in a different way. Also, there is not much point in pairing without also requiring security on some characteristics.
kai19960504 said:Why does pm_conn_secure() need to be paired twice?
What do you mean? The function just initiates pairing, it works the same every time (that said, if bonded already, it will just initiate encryption of the link using existing key. If not bonded, it will initiate pairing).
Hi Einar,
What do you mean? The function just initiates pairing, it works the same every time (that said, if bonded already, it will just initiate encryption of the link using existing key. If not bonded, it will initiate pairing).
You can refer to this link.
The statement is a problem with Android itself. If it is actually applied to the product, will the same situation happen?
Sorry, I am still not able to understand your question. Please explain in detail, and preferably also provide logs or method to reproduce the issue you are describing to make things clearer.
Hi Einar,
Do you actually use an Android phone to run my program?
Hi,
No, I have not tested with an Android device yet (I do not have immediate access to one, and I am still not sure about what to test - all the tests I have been able to do both from iOS and nRF Connect for Desktop shows everything working as expected with regard to pairing). The thread you link to does not describe a common problem, and I do not see any reason in what you have written before that indicate it is related. However, I have yet to get a proper description about what the problem is, so I do not know what to look for.
If you want me to look into this, then please elaborate on the issue. Currently my understanding is that "pairing function appear", and if you by that mean does not appear by itself, that is expected. With your current code you need to initiate it from the Android side, and it will not happen automatically. Again, please describe in more detail both what is happening and what you want.
Hi Einar,
I had no idea how to tell you the problem, so I made a video.