How to add System ID characteristic (0x2A23) using Kconfig

Hi,

How do I add the System ID characteristic (UUID 0x2A23) from the Device Information Service (DIS) using Kconfig commands in the prj.conf file?

For example, I can add the Manufacturer Name String Characteristic (UUID 0x2A29) using the following line in the prj.conf file: CONFIG_BT_DIS_MANUF="manufacturer".

Thanks,

Adam

Parents
  • Hi,

    Looks like the DIS service does not implement this characteristic. The service is located in the upstream Zephyr repo. If you would like this characteristic implemented, I suggest adding a request for it here: https://github.com/zephyrproject-rtos/zephyr/issues/new?assignees=&labels=Feature+Request&template=feature_request.md&title=

  • Thank you,

    How can I go about adding a custom characteristic to the DIS service even though I am implementing the other characteristics using Kconfig commands in the prj.conf file?

    Adam

  • Hi,

    DIS is a Bluetooth SIG defined service, with defined characteristics that belong to that service. If you want to add a custom characteristic, I recommend adding that to a custom service. See e.g. this guide on how to do that:  nRF Connect SDK Bluetooth Low Energy tutorial part 1: Custom Service in Peripheral role 

  • Hi Sigurd,

    Thank you for sharing the link - I have actually used that link to create numerous custom services and to implement SIG services.

    I have now created a file for the Device Information Service and have succesfully implemented the characteristics including the System ID (this is a characteristic according to this SIG specification). However, the System ID characteristic is behaving weirdly. It does not print out the data on my smartphone that I entered into the firmware code - I imagine this is because the data format for the SIG characteristic is different to what I expect... I have added the relevant code below. On line 6, I define the system ID. However, this is what I see on my smartphone (client): Value: (0x) 35-35-2D-34-34-2D-33-33-2D-32-32-2D-31-31-2D-38-38-2D-37-37-00. Any idea why this is happening?

    Kind Regards,

    Adam

    /* System ID characteristic read callback function */
    static ssize_t read_system_ID(struct bt_conn *conn,
    				   const struct bt_gatt_attr *attr, void *buf,
    				   uint16_t len, uint16_t offset)
    {
    	char system_ID[] = "55-44-33-22-11-88-77";
    
    	if (offset) {
    		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
    	}
    
    	LOG_INF("System ID read: %s\n", system_ID);
    
    	return bt_gatt_attr_read(conn, attr, buf, len, offset,
    				 &system_ID,
    				 sizeof(system_ID));
    }
    
    
    /*Service Declaration and Registration */
    BT_GATT_SERVICE_DEFINE(dis_service,
    BT_GATT_PRIMARY_SERVICE(BT_UUID_DIS),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_MANUFACTURER_NAME,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_manufacturer_name, NULL, NULL),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_MODEL_NUMBER,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_model_number, NULL, NULL),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_SERIAL_NUMBER,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_serial_number, NULL, NULL),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_SYSTEM_ID,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_system_ID, NULL, NULL),
    );

Reply
  • Hi Sigurd,

    Thank you for sharing the link - I have actually used that link to create numerous custom services and to implement SIG services.

    I have now created a file for the Device Information Service and have succesfully implemented the characteristics including the System ID (this is a characteristic according to this SIG specification). However, the System ID characteristic is behaving weirdly. It does not print out the data on my smartphone that I entered into the firmware code - I imagine this is because the data format for the SIG characteristic is different to what I expect... I have added the relevant code below. On line 6, I define the system ID. However, this is what I see on my smartphone (client): Value: (0x) 35-35-2D-34-34-2D-33-33-2D-32-32-2D-31-31-2D-38-38-2D-37-37-00. Any idea why this is happening?

    Kind Regards,

    Adam

    /* System ID characteristic read callback function */
    static ssize_t read_system_ID(struct bt_conn *conn,
    				   const struct bt_gatt_attr *attr, void *buf,
    				   uint16_t len, uint16_t offset)
    {
    	char system_ID[] = "55-44-33-22-11-88-77";
    
    	if (offset) {
    		return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
    	}
    
    	LOG_INF("System ID read: %s\n", system_ID);
    
    	return bt_gatt_attr_read(conn, attr, buf, len, offset,
    				 &system_ID,
    				 sizeof(system_ID));
    }
    
    
    /*Service Declaration and Registration */
    BT_GATT_SERVICE_DEFINE(dis_service,
    BT_GATT_PRIMARY_SERVICE(BT_UUID_DIS),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_MANUFACTURER_NAME,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_manufacturer_name, NULL, NULL),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_MODEL_NUMBER,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_model_number, NULL, NULL),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_SERIAL_NUMBER,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_serial_number, NULL, NULL),
    
        BT_GATT_CHARACTERISTIC(BT_UUID_DIS_SYSTEM_ID,
    			        BT_GATT_CHRC_READ,
                        BT_GATT_PERM_READ,
                        read_system_ID, NULL, NULL),
    );

Children
Related