Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Invalid Parameter error while "nrf_ble_gq_item_add(p_gatt_queue, conn_handle)"

Hi,

I am getting error while calling the function "nrf_ble_gq_item_add(p_gatt_queue, conn_handle)" in my custom ble service. Here I am duplicated the same definitions for Specific Operation Control Point characteristic in the CGMS example (continous glucose measurement service). It works for the cgms but not in my custom service. 

Automatically disconnects while writing to this characteristic. How can I fix this problem.

The error is: Error 7 [Invalid parameter]

Looking forward for your help!!

Thanks and Regards,

Sreejith

Parents
  • Hi Sreejith,

    Can you try to debug in nrf_ble_gq_item_add() to narrow down more where NRF_ERROR_INVALID_PARAM comes from? (the function calls quite a few other functions, so there are several possibilities). If you digg down there as deep as you get then you will know more about which of your input parameters you need to look at.

  • Hi Einar,

    Thank you for your fast response!

    I am getting the error in the given below area: inside nrf_ble_gq.c

    // Check if connection handle is registered and if GATT request is valid.
    conn_id = conn_handle_id_find(p_gatt_queue, conn_handle);
    if ((p_req->type >= NRF_BLE_GQ_REQ_NUM) || (conn_id == p_gatt_queue->max_conns))
    {
    return NRF_ERROR_INVALID_PARAM;
    }

    here the conn_id == max_conns = 1 (so it shows invalid error)

    Thanks and Regards,

    Sreejith

  • Hi,

    I see. If you have more than one connection at a time you need to increase the number of connections supported by the GATT queue module as well. That is specified by the second parameter of NRF_BLE_GQ_DEF().

  • Hi,

    But I have only one connection. When I did debugging I found that while calling the conn_handle_id_find(), the p_conn_handle changes to 0xffff (I hope this meant INVALID CONNECTION) I do not know why this happens. I have done the NRF_BLE_GQ_DEF as mentioned in the cgms example itself

    Thanks and Regards,

    Sreejith

  • Hi,

    When I compare the values of the local variables of cgms service, I have found that the connection handle for p_gatt_queue is 0000 but in my custom service it shows FFFF. This is the reason why it shows invalid parameter. Why the gatt queue connection handle become invalid in my definition, how can I solve this problem?

    Thanks and Regards,

    Sreejith

  • Hi Sreejith,

    0xFFFF (BLE_CONN_HANDLE_INVALID) is used as an invalid connection handle (to indicate no active connection). If you pass BLE_CONN_HANDLE_INVALID here it is clearly wrong. You need to ensure that you pass the correct connection handle. I cannot say why you got this value without seeing your code, but I suspect you should see this if you look at how you pass the connection handle along (either you probably fail to copy/pass it on at some point, or you reset it to BLE_CONN_HANDLE_INVALID when you should not.

    Einar

Reply
  • Hi Sreejith,

    0xFFFF (BLE_CONN_HANDLE_INVALID) is used as an invalid connection handle (to indicate no active connection). If you pass BLE_CONN_HANDLE_INVALID here it is clearly wrong. You need to ensure that you pass the correct connection handle. I cannot say why you got this value without seeing your code, but I suspect you should see this if you look at how you pass the connection handle along (either you probably fail to copy/pass it on at some point, or you reset it to BLE_CONN_HANDLE_INVALID when you should not.

    Einar

Children
  • Hi Einar,

    Basically I am not setting the CONN_HANDLE_INVALID, in the time of initialization in cgms also we set p_gatt_queue connection handle to BLE_CONN_HANDLE_INVALID. but I could not find where in CGMS updating it with valid connection handle. Also in my service I am not anywhere updating it with the new valid connection handle!! So how can I debug here, or mostly where we have to update this connection handle? I thought it automatically switches to valid when connection occurs.

    Thanks and Regards,

    Sreejith

  • Hi Einar,

    Many thanks for the fast responses. You are correct, thanks for your reminder I forget to assign the connection handle to the gatt_queue. I have done now so it worked well.....

    Once again thank you for your time !!

    Thanks and Regards,

    Sreejith

Related