Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CLI Example - how to write a characteristic?

This (in SDK v17.0.2): 

Experimental: BLE Interactive Command Line Interface Example

https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/ble_sdk_app_interactive.html

The documentation says:

:
:
│
├── gatt
│   ├── characteristics <address> <service uuid> Discover service characteristics.
│   │
│   :
│   :
│   │
│   └── write <sub_cmd> Write a characteristic value.
│       ├── command <address> <char uuid> <value> Use a Write Command.
│       └── request <address> <char uuid> <value> Use a Write Request.
:
:

But this seems to be missing anywhere to specify the Service UUID.

If I just enter the Characteristic UUID, as suggested, it says, "The selected service does not contain the characteristic"

So how does one "select" a Service ?

Parents Reply Children
  • Hi Andrew, 

    It seems that we don't support having multiple characteristics with same (short) UUID. 
    This is the struct to handle characteristics in the interactive firmware: 

    typedef struct
    {
        ble_uuid_t            uuid;              /**< UUID of the characteristic. */
        uint16_t              decl_handle;       /**< Handle of the characteristic declaration. */
        uint16_t              value_handle;      /**< Handle of the characteristic value. */
        uint16_t              cccd_desc_handle;  /**< Handle of the CCCD descriptors. */
        ble_gatt_char_props_t char_props;        /**< GATT Characteristic Properties. */
    } char_data_t;

    I would consider it's a limitation of the interactive example. 


    I don't have any issue with writing to the characteristic using only the characteristic UUID. Could you try to test with the ble_app_uart example ? 


  • Looking back through my logs, I can see some messages saying, "Too many characteristics discovered".

    What I was doing was:

    1. Scan for devices
    2. Connect to a device
    3. Discover the Services
    4. For each Service, discover the Characteristics

    So, I guess, the Characteristic I then tried to write had just got "lost" among the "Too many characteristics discovered" ?

    If, instead, I just discover Characteristics for the one Service I require, the write then works.

Related