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

Characteristic tutorial : error when adding a characteristic to a service

I have a question concerning this tutorial : devzone.nordicsemi.com/.../ble-characteristics-a-beginners-tutorial

i have same problem than Milton (comment under the tutorial) : "I was able to add a custom service and verify it successfully on MCP. However, when I included the code to add a characteristic to the service, I always get "NRF_ERROR_INVALID_PARAM'."

he found a solution :

//for service
err_code = sd_ble_uuid_vs_add(&base_uuid, &m_base_uuid_type);
uuid.type   = m_base_uuid_type;
uuid.uuid   = BLE_UUID_OUR_SERVICE_UUID;

//For the characteristic:

char_uuid.uuid      = BLE_UUID_OUR_CHARACTERISTC_UUID;
char_uuid.type      = m_base_uuid_type;

i tryed his solution but i failed, i think it's because i do'nt know how to implement correctly the solution ...

(the tutorial work and advertise for me until this problem)

Parents Reply Children
  • OK - the sd_... calls are all SVC "calls" into the SoftDevice - so you can't step into them.

    So use the debugger to look at all the parameters you are passing - do they all look OK?

    The comment describing sd_ble_gatts_characteristic_add() says this about when it will return NRF_ERROR_INVALID_PARAM:

     * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
    

    wonder if it could be due to bad values for defines (like in config_sdk.h).

    Did you Try increasing NRF_SDH_BLE_VS_UUID_COUNT to 4 - as said?

  • yes i try ed to increase NRF_SDH_BLE_VS_UUID_COUNT to 4

    without success, same error

  • Which question was that a "yes" to?

    EDIT

    So what about the other question, then?

    use the debugger to look at all the parameters you are passing - do they all look OK
  • for p_our_service->service_handle i get 0x000B

    i don't know yet where does it come from, maybe :

    #define BLE_L2CAP_CH_STATUS_CODE_UNACCEPTABLE_PARAMS    (0x000B)  /**< Unacceptable parameters. */

    edit p_our_service->service_handle is modified in our_service_init in fucntion sd_ble_gatts_service_add but i can't go further becase it's macro...

  • Sorry p_our_service->service_handle found 0x000B isn't theproblem. (i'll explain it under)

     

    I Undo all modifications progressivly according to the tutorial to find when comes the error 0x07.

    There is no error at STEP 2.H include. At STEP 3.A error occurs adding this code :

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
    		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
    		cccd_md.vloc                = BLE_GATTS_VLOC_STACK;
    		char_md.p_cccd_md           = &cccd_md;
    		char_md.char_props.notify   = 1;

    AT STEP 2.H my module is Advertising i can connect and then see the service and its characteristics write and read...

    And at STEP2.H p_our_service->service_handle is already at value 0x000B

    AT STEP 3.A there is err_code 0x07 in return from sd_ble_gatts_characteristic_add. if i comment APP_ERROR_CHECK where err_code = 0x07, i can see my module advertising but i don't see the service and its characteritics

Related