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

nrf_ble_gq_item_add error

I am creating an original service using the example of Multilink Central.

I'm trying to reference an LBS to send data to a particular peripheral.

I tried to send using m_lbs_c [], but the connection was lost and an error occurred.

It seems that an error has occurred because it stops at nrf_ble_gq_item_add.

Unknown function at 0x00000A60

When executed with evt_handler, it will be sent to the correct destination.

An error occurs when trying to execute with a button interrupt.
I think it's a conn_handle problem, but I don't know the solution.

Thank you for your cooperation.

uint32_t ble_original_time_reply(ble_original_c_t * p_ble_original_c, ble_sync_data_t data)
{
    VERIFY_PARAM_NOT_NULL(p_ble_original_c);

    if (p_ble_original_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
        return NRF_ERROR_INVALID_STATE;
    }

    uint32_t next_timing;
    next_timing = data.next_timing;

    uint32_t err_code;
    nrf_ble_gq_req_t write_req;
    //ble_gattc_write_params_t write_param;
    uint8_t    encorded_data[30];
    uint16_t len=1;
    uint16_t hvx_len=1;

    encorded_data[0] = 0;
    len += uint32_encode(next_timing, &encorded_data[len]);
    encorded_data[len++] = data.pettern;
    hvx_len = len;
   

    memset(&write_req, 0, sizeof(nrf_ble_gq_req_t));
    write_req.type                        = NRF_BLE_GQ_REQ_GATTC_WRITE;
    write_req.error_handler.cb            = gatt_error_handler;
    write_req.error_handler.p_ctx         = p_ble_original_c;
    write_req.params.gattc_write.handle   = p_ble_original_c->peer_original_db.time_handle;
    write_req.params.gattc_write.len      = hvx_len;
    write_req.params.gattc_write.p_value  = encorded_data;
    write_req.params.gattc_write.offset   = 0;
    write_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_CMD; 
/*
    memset(&write_param, 0, sizeof(write_param));
    write_param.handle      = p_ble_original_c->peer_original_db.time_handle;
    write_param.len         = hvx_len;
    write_param.p_value     = encorded_data;
    write_param.offset      = 0;
*/

    //NRF_LOG_INFO("reply send. %d",next_timing);
    err_code = nrf_ble_gq_item_add(p_ble_original_c->p_gatt_queue, &write_req, p_ble_original_c->conn_handle);
    //return err_code;
    //err_code = sd_ble_gattc_write(p_ble_original_c->conn_handle, &write_param);
}
case BSP_EVENT_KEY_2:
        {
            data.pettern = 1;
            data.next_timing = 0;
            ret_code_t err_code;

            for (uint32_t i = 0; i< NRF_SDH_BLE_CENTRAL_LINK_COUNT; i++)
            {
                err_code = ble_original_time_reply(&m_original_c[i], data); <-I can't do this
                if (err_code != NRF_SUCCESS &&
                    err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
                    err_code != NRF_ERROR_INVALID_STATE)
                {
                    return err_code;
                }
            }
static void original_c_evt_handler(ble_original_c_t * p_original_c, ble_original_c_evt_t * p_original_c_evt)
{
    ・
    ・
    ・
    ble_original_time_reply(p_original_c, data);//<-Can do this
    
    ・
    ・
    ・
}
Parents
  • Hi,

    0x00000A60 is the HardFault handler inside the MBR. What interrupt priority is the bsp_event_handler running at? Since you are able to trigger the function from another function, and the hardfault seems to happen in the call to sd_ble_gattc_write, this could be caused by trying to call a softdevice function from an interrupt priority above 4.

    I see that you are also using different input parameters to the two different calls to ble_original_time_reply(), so that may also explain why one work and one does not, in case my first suggestion does not solve the issue.

    If you can share the full project, it would be easier to get an overview of what happens, and help reproduce/debug the problem.

    Best regards,
    Jørgen

  • The BSP event handler is called from the app_timer event when a button press/release is detected. App_timer is initialized and configured in your application, you can change the interrupt priority by setting APP_TIMER_CONFIG_IRQ_PRIORITY in your sdk_config.h file.

    As mentioned in the softdevice documentation:

    "Note: The priorities of the interrupts reserved by the SoftDevice cannot be changed. This includes the SVC interrupt. Handlers running at a priority level higher than 4 (lower numerical priority value) have neither access to SoftDevice functions nor to application specific SVCs or RTOS functions running at lower priority levels (higher numerical priority values)."

    This means that you cannot call any softdevice APIs from handlers running at priority 2 or 3.

  • When I checked PRIORITY, I made a mistake and changed the settings.
    The default value solved the problem.
    It's my mistake.
    sorry. I apologize for the trouble.

Reply Children
No Data
Related