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

PASSKEY

 I’ve downloaded     nRF5_SDK_11.0.0_89a8197 and starting with examples from \examples\ble_peripheral\???\pca10040\s132\arm5_no_packs\

 I would like the other device to request a passkey (constant) at pairing (the passkey on my side is constant - no display needed)

After   gap_params_init();I’ve added the following code:

 

{

 static ble_opt_t optS;

   static uint8_t passw[]="123456";           

 optS.gap_opt.passkey.p_passkey=passw;

   err_code =sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &optS);

}

 

err_code returned :  0  

 

Still the module will pair and communicate without requesting a passkey.

I've tried to find an answer in Q&A . in some answers there was a reference to fields : io_caps,mitm. cant make out what does it mean. 

(these fields belong to structs relevant to services, not pairing)

 

Thanks for any help

   Yona

Parents Reply
  • Hi,

    Notifications are enabled by writing to the 0x2 to the CCCD so it is the write operation that should require authentication. It's not possible  to require authentication for reading of the CCCD, and that is why the softdevice returns the invalid param error. Note that CCCD only contains the configuration value, not the characteristic value. Also worth noting that this configuration is persistent across connections when the devices are bonded.

    The characteristic value permissions are set on attr_md.read_perm  and  attr_md.write_perm if you use ble_hrs.c::heart_rate_measurement_char_add()as reference. 

Children
  • Hi again

    eventually I found   the variable    m_connection_table[0].state

    it contains the connection state- so if passkey not cleared - I can avoid notifys.

    now if I may- a new issue:     sd_flash_write,sd_flash_page_erase

    calling sd_flash_write returns (after 20uS)  0x00 (probably NRF_SUCCESS)

    than (after 2870uS) at   sys_evt_dispatch i receive  sys_evt=2    ( probably NRF_EVT_FLASH_OPERATION_SUCCESS)

    STILL nothing is written to flash.

    maybe you have a clue to what I'm doing wrong.

    using nRF5_SDK_11.0.0_89a8197  SW package.

    thanks again

    YONA

  • Hi,

    It sounds like you're doing it correctly.  sys_evt=2 means  NRF_EVT_FLASH_OPERATION_SUCCESS, so it should have worked. Did you make sure to read out the flash content after the NRF_EVT_FLASH_OPERATION_SUCCESS event?  

  • sorry sorry sorry.

    my mistake was somewhere else.

    thanks again for your patience.

    YONA

  • No worries, thanks for letting me know. 

    Vidar

  • Hi again.

    new issue:

    the guys writing the application on the cell phone are bringing this up.

    I might have 1-20 BLE devices in a given location. all of them would be seen by the cellphone application.

    each of my BLE devices has a different TYPE (say up to 10 types ).

    the TYPE of a given device might change (not very often)  .

    the application "would like" to search all devices ,sort only my devices, show a list of them, each with an icon. the icon is the TYPE of the device.

    my suggestion was to use appearance.

    so every time my TYPE changed- I'll use sd_ble_gap_appearance_set to change it.

    their complaint is that in order for them to know all TYPES, they need to READ the appearance characteristic for each of my devices, and that would take them too long.

    their suggestion is to have a service that its uuid will be a function of the device's TYPE.

    in that way- I'll will have one (an empty) service that its uuid will a function of the TYPE. 

    in that way- all that's needed from them is to scan services , sort those that belong to me , and understand (from the uuid ) there TYPES.AVOIDING the need to actually preform  a READ into these services (characteristics).

    the thing is- I don't see a function for service delete,characteristic delete, change of uuid.

    How can I solve this? what would you do?

    thanks

    yona

Related