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

Ble Bonding - error of unknown cause

Hi, Dev Zone.

thanks for help : )

I'm try to porting DK Board's Ble Bonding function to Target Board.

1st_question <- this is my first question links

main problem is freezing and reason is mutex error, that use cc310 mutex lock function,

so i was chenged to cc310 mutex function to freeRTOS mutex lock function to so solve it and looks like work it well

and now get another problem that can know error case

when processing Ble bonding between my device and nRF Connect App, it means when bonding request message send from App to my board

my board stop somewhere and reboot
i don't know why and hard to find stop point. that's why re make issue

this is my App's log

Connecting to MAC:ADD

gatt = device.coonnectGatt(autoConnect = false, TRANSPORT_LE)
[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
Connected to MAC:ADD

[Broadcast]Action received: androide.bluetooth.device.action.ACL_CONNECTED
Discovering service
gatt.discoverService()
[Callback]Service discovered with status: 0
Service discovered

Generic Access (0x1800)
...

gatt.setCharacteristicNotification(...., true)
device.createBond()
[Broadcast]Action received: androide.bluetooth.device.action.BOND_STATE_CHEANGED, bond state change to: BOND_BONDING(11)
[Broadcast]Action received: androide.bluetooth.device.action.BOND_STATE_CHEANGED, bond state change to: BOND_BONDING(12)

Device bonded

this is my device log

Connected
Data len is set to 0xF4(244)

BLE_GAP_EVT_LESC_DHKEY_REQUEST
Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 0
Generating ECC key pair

...

Event PM_EVT_CONN_SEC_START
Connection security produre started: Peripheral, conn_handle: 0, procedure: Bonding
Event PM_EVT_SEC_PARAMS_REQ
Security parameter request

after reboot, all function, auto connect, bonding working well

It would be a great help to correct the error if you tell us the possible cause or point of the error.

#Ble #Ble_Bonding #Bonding

thank you.

Best Regardes

Parents
  • Hello,

    Have you tried to see if bonding works ok if you disable LESC support (i.e. set SEC_PARAM_LESC = 0)? Also, are you calling the nrf_ble_lesc_request_handler() function periodically like in the ble_app_hrs example?

    Thanks,

    Vidar

    Edit: Forgot that we do have an example with Freertos+LESC in our nRF5 Thread & Zigbee SDK. Maybe that example could serve as a reference: https://devzone.nordicsemi.com/f/nordic-q-a/74337/use-the-le-secure-connections-in-the-ble_thread_dyn_mtd_coap_cli-example

  • Hello, Vidar

    thanks for answer

    if you disable LESC support (i.e. set SEC_PARAM_LESC = 0)?

    yes, i try Enable and disable both result are same

    here is full log (i was turn on Error, Warning, Info, Debug Message ) - using LESC 0

    Generating ECC key pair
    Erase bonds!
    Event PM_EVT_PEERS_DELETE_SUCCEEDED
    All peers deleted.
    
    BLE event: 0x10.
    Requesting to update ATT MTU to 247 bytes on connection 0x0.
    Updating data length to 251 on connection 0x0.
    Connected
    
    BLE event: 0x1c.
    BLE event: 0x3a.
    ATT MTU updated to 247 bytes on connection 0x0 (response).
    Data len is set to 0xF4(244)
    ATT MTU exchange completed. central 0xf7 peripheral 0xf7
    BLE event: 0x24.
    Data length updated to 123 on connection 0x0.
    max_rx_octets: 123
    max_tx_octets: 123
    max_rx_time: 1096
    max_tx_time: 1096
    ATT MTU exchange completed. central 0xf7 peripheral 0xf7
    BLE event: 0x12.
    BLE event: 0x23.
    Peer on connection 0x0 requested a data length of 123 bytes.
    Updating data length to 123 on connection 0x0.
    BLE event: 0x24.
    Data length updated to 123 on connection 0x0.
    max_rx_octets: 123
    max_tx_octets: 123
    max_rx_time: 1096
    max_tx_time: 1096
    ATT MTU exchange completed. central 0xf7 peripheral 0xf7
    BLE event: 0x12.
    BLE event: 0x13.
    Event PM_EVT_CONN_SEC_START
    Connection security procedure started: role: Peripheral, conn_handle: 0, procedure: Bonding
    Event PM_EVT_CONN_SEC_PARAMS_REQ
    Security parameter request
    BLE event: 0x12.
    BLE event: 0x1a.
    BLE event: 0x19.
    Event PM_EVT_CONN_SEC_SUCCEEDED

    here is full log ( also turn on Error, Warning, Info, Debug Message ) - using LESC 1

    Generating ECC key pair
    Erase bonds!
    Event PM_EVT_PEERS_DELETE_SUCCEEDED
    All peers deleted.
    BLE event: 0x10.
    Requesting to update ATT MTU to 247 bytes on connection 0x0.
    Updating data length to 251 on connection 0x0.
    Connected
    
    BLE event: 0x1c.
    BLE event: 0x3a.
    ATT MTU updated to 247 bytes on connection 0x0 (response).
    Data len is set to 0xF4(244)
    ATT MTU exchange completed. central 0xf7 peripheral 0xf7
    BLE event: 0x24.
    Data length updated to 123 on connection 0x0.
    max_rx_octets: 123
    max_tx_octets: 123
    max_rx_time: 1096
    max_tx_time: 1096
    ATT MTU exchange completed. central 0xf7 peripheral 0xf7
    BLE event: 0x12.
    BLE event: 0x23.
    Peer on connection 0x0 requested a data length of 123 bytes.
    Updating data length to 123 on connection 0x0.
    BLE event: 0x24.
    Data length updated to 123 on connection 0x0.
    max_rx_octets: 123
    max_tx_octets: 123
    max_rx_time: 1096
    max_tx_time: 1096
    ATT MTU exchange completed. central 0xf7 peripheral 0xf7
    BLE event: 0x12.
    BLE event: 0x13.
    Event PM_EVT_CONN_SEC_START
    Connection security procedure started: role: Peripheral, conn_handle: 0, procedure: Bonding
    Event PM_EVT_CONN_SEC_PARAMS_REQ
    Security parameter request
    BLE event: 0x18.
    BLE_GAP_EVT_LESC_DHKEY_REQUEST
    BLE_GAP_EVT_LESC_DHKEY_REQUEST
    Calling sd_ble_gap_lesc_dhkey_reply on conn_handle: 0
    BLE event: 0x12.
    BLE event: 0x12.
    BLE event: 0x1a.
    BLE event: 0x19.

    situation are same both get BLE event fleg : 0x19 "Authentication procedure completed with status"

    and send PM_EVT_CONN_SEC_SUCCEEDED and stuck in somewhere

    after that log, device go to reset mode via watch-dog

    ( when i block watch-dog, stuck in somewhere and no-respons)

    nrf_ble_lesc_request_handler() function

    this function is run on another thread,

    it means using freeRTOS, useing several thread, initialize in main thread and lesc handler is working on ble thread

    ble thread's job is only work update app's time and call lesc handler

    ++ test that run (initialize and lesc handler) as same thread, it's situation result is same

    Thanks

    Best Regards, Empe

  • Empe said:
    situation are same both get BLE event fleg : 0x19 "Authentication procedure completed with status"

     What's the status code? PM_EVT_CONN_SEC_SUCCEEDED indicate that the bonding procedure completed succesfully, so maybe it's something else that causes your program to hang. Have you tried to debug the app to see if the program maybe gets stuck in one of your threads?

    Best regards,

    Vidar

Reply
  • Empe said:
    situation are same both get BLE event fleg : 0x19 "Authentication procedure completed with status"

     What's the status code? PM_EVT_CONN_SEC_SUCCEEDED indicate that the bonding procedure completed succesfully, so maybe it's something else that causes your program to hang. Have you tried to debug the app to see if the program maybe gets stuck in one of your threads?

    Best regards,

    Vidar

Children
Related