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

Secure_manager library adding problem in segger embedded studio

Hello everyone,

I developed my code secure connection with static passkey i'm using ble_app_gls example code to implement my custom code i have added all library files i got some error as below

1> Linking cbeacon-52810.elf
1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 4.30c/gcc/arm-none-eabi/bin/ld: Output/cbeacon-52810 Release/Obj/security_manager.o: in function `smd_params_reply_perform':
1> E:\BLE\projects\STG\nRF5_SDK_15.2_Beacon_test\components\ble\peer_manager/security_manager.c:331: undefined reference to `nrf_ble_lesc_public_key_get'
1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 4.30c/gcc/arm-none-eabi/bin/ld: Output/cbeacon-52810 Release/Obj/security_manager.o: in function `sm_init':
1> E:\BLE\projects\STG\nRF5_SDK_15.2_Beacon_test\components\ble\peer_manager/security_manager.c:484: undefined reference to `nrf_ble_lesc_init'
1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 4.30c/gcc/arm-none-eabi/bin/ld: Output/cbeacon-52810 Release/Obj/security_manager.o: in function `sm_ble_evt_handler':
1> E:\BLE\projects\STG\nRF5_SDK_15.2_Beacon_test\components\ble\peer_manager/security_manager.c:515: undefined reference to `nrf_ble_lesc_on_ble_evt'
Build failed

I added all library file but i don't know where i made a mistake please help to solve this problem.

hardware: NRF52810 SDK15.2

Compiler : Seeger embedded Studio v4.30

Parents
  • Hi,

    after some try I've implemented the PEER Manager module into an existent demo applications based on NUS UART notification.

    My step used to configure this module are detailed at this link:

    https://devzone.nordicsemi.com/f/nordic-q-a/81673/trouble-in-configuring-nrf_ble_lesc-c-for-peer-manager

    All the things seems work properly, but after simulating some real situation I've found a particular condition where I have some trouble after a disconnection and then again to perform a new connection with the peripheral device, here below some detailed explanation of this strange behavior.

    The explanation start when the peripheral application is loaded and the run into execution, here below the SES Log taken from the Debug Terminal at the starting of the application:

    <info> nrf_sdh_ble: RAM starts at 0x20002AE8
    <debug> nrf_ble_lesc: Initialized nrf_crypto.
    <debug> nrf_ble_lesc: Initialized nrf_ble_lesc.
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> app: Company ID : 0x59
    <info> app: Version#   : 0xA
    <info> app: Subversion#: 0x100
    <info> app: Debug logging for UART over RTT started.
    <info> app: Erase bonds
    <info> peer_manager_handler: All peers deleted.

    now from the nRF Connect app on my smartphone I can scan and Connect with the peripheral device but I can see into the log the error 4102.

    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    <info> app: Connected
    <info> app: PHY update set.
    <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
    <info> app: Data len is set to 0xF4(244)
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 251
    <debug> nrf_ble_gatt: max_rx_time: 328
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Encryption, error: 4102

    When I try to activate the notification service the passkey windows is shown, then I can enter the code and presso the Bond button,I see:

    <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Bonding
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Bonding data, action: Update
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Local database, action: Update
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Central address resolution, action: Update
    <info> app: Disconnected

    and a disconnection event occour.

    Then I've to get in connection again:

    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
    <info> app: Connected
    <info> app: PHY update set.
    <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
    <info> app: Data len is set to 0xF4(244)
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 251
    <debug> nrf_ble_gatt: max_rx_time: 328
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Encryption
    <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change

    now I can enable the notification (no passkey request at this time) and the notification start to be sent regularity.

    Now I did a disconnection without disable the notification and then I press again the connect button on the nRF Connect app, now the peripheral application crash with this error:

    <info> app: Connected
    <info> app: PHY update set.
    <info> app: (main) currsize: 6 (items)
    <info> app: (main) ble_nus_data_send: 33 bytes
    <info> app: (main) ble_nus_data_send: #39529-3803#39530-3828#39531-3789
    <error> app: ERROR 15 [NRF_ERROR_FORBIDDEN] at C:\Users\STE\Downloads\nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart__saadc_timer_driven__scan_mode\main.c:1214
    PC at: 0x00035CD9
    <error> app: End of error report

    the error was triggered by the function ble_nus_data_send() that I'm using to send the notification from the main() function.

    May be this function can not be used before the passkey was entered or some other things related the authentication stage has passed succesfully? There ia s way to intercept an event to be sure that I can start to send data through notification after the security procedure is finished?

    How I can check and overcome the error 4102?

    Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Encryption, error: 4102

    After that I've did a bonding delete from nRF Connect, so it should delete any previosly bod devices and I've reprogrammed the peripheral device, connection give this SES log:

    <info> nrf_sdh_ble: RAM starts at 0x20002AE8
    <debug> nrf_ble_lesc: Initialized nrf_crypto.
    <debug> nrf_ble_lesc: Initialized nrf_ble_lesc.
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> app: Company ID : 0x59
    <info> app: Version#   : 0xA
    <info> app: Subversion#: 0x100
    <info> app: Debug logging for UART over RTT started.
    <info> app: Erase bonds
    <error> peer_manager_handler: Peer deleted successfully: peer_id: 0
    <info> peer_manager_handler: All peers deleted.
    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    <info> app: Connected
    <info> app: PHY update set.
    <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
    <info> app: Data len is set to 0xF4(244)
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 251
    <debug> nrf_ble_gatt: max_rx_time: 328
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7

    Now the notification request after the passkey works well without any error, why this strange behavior?

    Enabling the PEER Manager log level to 4 I see this Log:

    <info> nrf_sdh_ble: RAM starts at 0x20002AE8
    <debug> nrf_ble_lesc: Initialized nrf_crypto.
    <debug> nrf_ble_lesc: Initialized nrf_ble_lesc.
    <debug> nrf_ble_lesc: Generating ECC key pair
    <info> app: Company ID : 0x59
    <info> app: Version#   : 0xA
    <info> app: Subversion#: 0x100
    <info> app: Debug logging for UART over RTT started.
    <info> app: Erase bonds
    <debug> peer_manager_handler: Event PM_EVT_PEER_DELETE_SUCCEEDED
    <error> peer_manager_handler: Peer deleted successfully: peer_id: 0
    <debug> peer_manager_handler: Event PM_EVT_PEERS_DELETE_SUCCEEDED
    <info> peer_manager_handler: All peers deleted.
    <debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
    <debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
    <info> app: Connected
    <info> app: PHY update set.
    <debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
    <info> app: Data len is set to 0xF4(244)
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
    <debug> nrf_ble_gatt: max_rx_octets: 27
    <debug> nrf_ble_gatt: max_tx_octets: 251
    <debug> nrf_ble_gatt: max_rx_time: 328
    <debug> nrf_ble_gatt: max_tx_time: 2120
    <debug> app: ATT MTU exchange completed. central 0xF7 peripheral 0xF7
    <debug> peer_manager_handler: Event PM_EVT_CONN_SEC_START
    <debug> peer_manager_handler: Connection security procedure started: role: Peripheral, conn_handle: 0, procedure: Encryption
    <debug> peer_manager_handler: Event PM_EVT_CONN_SEC_FAILED
    <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Encryption, error: 4102
    <debug> peer_manager_handler: Error (decoded): PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING

    Thanks and best regards.

    F.

  • Hi Fabio, 
    I'm sorry for late response. I was on a vacation. If you still have issue with this please create a new case and update the link here.

Reply Children
Related