This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem!!! BLE pairing configration in NRF52810...

Hello All,

Right now i am working on nRF52810 custom board. I use segger studio in windows 7. i used nRF52 SDK 15.2.0 .Right now i am trying to pairing for security purpose.

I am use just working method of pairing. i initialization of pairing as shown below,

sec_param.bond = 1;
sec_param.mitm = 0;
sec_param.lesc = 0;
sec_param.keypress =0;
sec_param.io_caps = BLE_GAP_IO_CAPS_NONE;
sec_param.oob = 0;
sec_param.min_key_size = 7;
sec_param.max_key_size = 16;
sec_param.kdist_own.enc = 1;
sec_param.kdist_own.id = 1;
sec_param.kdist_peer.enc = 1;
sec_param.kdist_peer.id = 1;

I use just work because in custom board not use display or keyboard.So use this characteristic BLE_GAP_IO_CAPS_NONE. I am trying to do simple pairing with device(mobile) and done successfully pairing and bound is also create without any giving acknowledged from custom board.

My problem is that i wouldn't to do pairing successfully without giving any acknowledged from custom board and as a acknowledged i use switch. I am trying to do this type of pairing when i press switch and than got pairing successfully and than successfully connect device with BLE. And also by default pairing timeout interval is 30 second so in that time interval i press switched.And in this time interval i am not press switch. so after that time interval advertising is start and disconnect event is create.

How can i implement this pairing security.??? 

I trying to add while loop in PM_EVT_CONN_SEC_START  this event as shown below,

case PM_EVT_CONN_SEC_START:
               NRF_LOG_INFO("PM EVT CONN SEC START");
               while(nrf_gpio_pin_read(switch_pin) && pairing_sample <28)
              {
                      nrf_delay_ms(1000);
                       pairing_sample++;
                      if(pairing_sample >29)
                     {
                           pairing_sample = 0;
                           advertising_start(false);
                           break;
                     }
              }
break;

First case: in this use infinite while loop so when i press switch after that while loop is break and got successfully pairing and connection.

Second case: after 30 second i press switch then in the device popup menu open with option of pair or cancel.

Third case: i am not press switch within time interval(30 second) after 30 second advertising not start and also device not disconnect with BLE. 

So please give me suggestion how can i implement paring security as like i mention above..

Have A Nice Day!!!

Thanks & Regards,

Urvisha Andani

Parents
  • Hi,

    Can you explain again what you want to achieve? (it is not clear to me).

    Regarding your code, it does not make much sense to me regardless of what you want to do, for the following reasons:

    • You are busy waiting for 30-ish seconds in an even handler, which is in interrupt handler mode. This will effectively block any other same or lover priority tasks to occur at the same time, which is not acceptable for most real applications. There are also other issues such as current consumption etc...
    • The last iteration of the while loop is when pairing_sample is 27, where is incremented to 28. After that the wile loop will exit, so if(pairing_sample >29) will never be true.
    • Inside the if statement, you check an error code ("APP_ERROR_CHECK(err_code);") which have never been set. It is clearly not correct, but it does not have any effect though, as this code is never executed.
Reply
  • Hi,

    Can you explain again what you want to achieve? (it is not clear to me).

    Regarding your code, it does not make much sense to me regardless of what you want to do, for the following reasons:

    • You are busy waiting for 30-ish seconds in an even handler, which is in interrupt handler mode. This will effectively block any other same or lover priority tasks to occur at the same time, which is not acceptable for most real applications. There are also other issues such as current consumption etc...
    • The last iteration of the while loop is when pairing_sample is 27, where is incremented to 28. After that the wile loop will exit, so if(pairing_sample >29) will never be true.
    • Inside the if statement, you check an error code ("APP_ERROR_CHECK(err_code);") which have never been set. It is clearly not correct, but it does not have any effect though, as this code is never executed.
Children
No Data
Related