Example of Characteristic Aggregate Format Descriptor?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Example of Characteristic Aggregate Format Descriptor?

2,749 Views
skv
Contributor II

Bluetooth specification describe Characteristic Aggregate Format Descriptor:

The Characteristic Presentation Format descriptor defines the format of the Characteristic Value. One or more Characteristic Presentation Format descriptors may be present. If multiple of these descriptors are present, then a Aggregate Formate descriptor is present. 

I make a device on QN9080 and use MCUXpresso 10.3.0 and SDK_2.x_QN908XCDK (SDK version 2.2.0).

I define a characteristic that contain four values: acceleration for X, Y and Z axis (each 16 bit signed integer) and timestamp (32-bit integer) in gatt_db.h this way:

PRIMARY_SERVICE_UUID128(service_accelerometer, uuid_service_accelerometer)
   CHARACTERISTIC_UUID128(char_accel_measurement, uuid_char_accelerometer, (gGattCharPropRead_c | gGattCharPropNotify_c))
      VALUE_UUID128_VARLEN(value_accel_measurement, uuid_char_accelerometer, (gPermissionFlagReadable_c), 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

The next step is creation descriptors to my characteristic that describes format of each value. I add to file ble_sig_defines.h declaration for Characteristic Aggregate Format Descriptor:

/*! Characteristic Aggregate Format Description UUID */
#define gBleSig_CharAggregateFormat_d 0x2905

Then, I think I should add 3 Characteristic Presentation Format descriptor and one Characteristic Aggregate Format descriptor like below:

DESCRIPTOR(desc_int_accel_measurement_x, gBleSig_CharPresFormatDescriptor_d, (gPermissionFlagReadable_c), 7, 0x0E, 0x00, 0x00, 0x27, 0x01, 0x01, 0x00)
DESCRIPTOR(desc_int_accel_measurement_y, gBleSig_CharPresFormatDescriptor_d, (gPermissionFlagReadable_c), 7, 0x0E, 0x00, 0x00, 0x27, 0x01, 0x01, 0x00)
DESCRIPTOR(desc_int_accel_measurement_z, gBleSig_CharPresFormatDescriptor_d, (gPermissionFlagReadable_c), 7, 0x0E, 0x00, 0x00, 0x27, 0x01, 0x01, 0x00)
DESCRIPTOR(desc_int_accel_measurement_a, gBleSig_CharAggregateFormat_d, (gPermissionFlagReadable_c), ... )

but I don't know how to make it right way.

Is there anybody who could advise me a how to add multiple Characteristic Presentation Format descriptors to a single characteristic?

Thank you!

Labels (1)
5 Replies

1,726 Views
skv
Contributor II

The description of Characteristic Aggregate Format descriptor says:

 If 3 Characteristic Presentation Format declarations exist at Attribute Handles 0x40, 0x50 and 0x60, the Characteris Aggregate Format Value is 0x405060.

So, I tried define 

DESCRIPTOR(desc_int_accel_measurement_a, gBleSig_CharAggregateFormat_d, (gPermissionFlagReadable_c), 3,  desc_int_accel_measurement_x, desc_int_accel_measurement_y, desc_int_accel_measurement_z)

it makes all above declared descriptors (desc_int_accel_measurement_x ... desc_int_accel_measurement_a) invisible in the nRF connect app and bring incorrect value to the CCCD, defined below in my code.

Then, I tried

DESCRIPTOR(desc_int_accel_measurement_a, gBleSig_CharAggregateFormat_d, (gPermissionFlagReadable_c), 6, desc_int_accel_measurement_x, 0x00, desc_int_accel_measurement_y, 0x00, desc_int_accel_measurement_z, 0x00)

In this case descriptors desc_int_accel_measurement_x ... desc_int_accel_measurement_z are readable, but attempt to read descriptor desc_int_accel_measurement_a leads to exception in the nRF Connect app.

What is right way to add multiple Characteristic Presentation Format descriptors to a single characteristic?

0 Kudos

1,726 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

 

I'm not sure if you have checked these posts, could you please help me checking those? I believe this can guide you through your development as it seems that you need to create your custom profile.

Creating a custom profile using NXP BLE stack – Server  

How to create a Custom Profile - Client 

 

If these posts do not help you, just let me know 

Regards ,

Estephania

0 Kudos

1,726 Views
skv
Contributor II

Thank you for your answer, I've read this documents and is familiar with creating custom profile with NXP BLE stack on the Server side (My own custom profile is successfully realized).

However, these documents doesn't describe creation of descriptor that I mention above in my post.

Since I didn't found declaration of Characteristic Aggregate Format descriptor in file ble_sig_defines.h and in the BLE-examples of SDK, I may only rely on Bluetooth specification to create my own realisation of mention above descriptor.

I try to make it this way (gatt_db.h):

#define LOBYTE(value) (uint8_t) (((value) >> 8) & 0xFF)
#define HIBYTE(value) (uint8_t) ((value) & 0xFF)
/*! Signed 16-bit integer */
#define gBleTypes_Sint16_d 0x0E

DESCRIPTOR(desc_int_accel_measurement_x, gBleSig_CharPresFormatDescriptor_d,       (gPermissionFlagReadable_c), 7, gBleTypes_Sint16_d, 0x00, 0x00, 0x27, 0x01, 0x01, 0x00)
DESCRIPTOR(desc_int_accel_measurement_y, gBleSig_CharPresFormatDescriptor_d,       (gPermissionFlagReadable_c), 7, gBleTypes_Sint16_d, 0x00, 0x00, 0x27, 0x01, 0x01, 0x00)
DESCRIPTOR(desc_int_accel_measurement_z, gBleSig_CharPresFormatDescriptor_d,       (gPermissionFlagReadable_c), 7, gBleTypes_Sint16_d, 0x00, 0x00, 0x27, 0x01, 0x01, 0x00)
DESCRIPTOR(desc_int_accel_measurement_a, gBleSig_CharAggregateFormat_d,       (gPermissionFlagReadable_c), 6,
      LOBYTE(desc_int_accel_measurement_x), HIBYTE(desc_int_accel_measurement_x),
      LOBYTE(desc_int_accel_measurement_y), HIBYTE(desc_int_accel_measurement_y),
      LOBYTE(desc_int_accel_measurement_z), HIBYTE(desc_int_accel_measurement_z))

but result is the same - nRF Connect crashs when reading Characteristic Aggregate Format descriptor.

My question is how to create the attribute table entry list of handles for Characteristic Aggregate Format descriptor?

Thank you!

0 Kudos

1,726 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

When trying to test the default examples in the specification, for example you can try this in the HRS code and this was able to run correctly and be shown as Characteristic Aggregate Format 

PRIMARY_SERVICE(service_device_info, gBleSig_DeviceInformationService_d)
    CHARACTERISTIC(char_manuf_name, gBleSig_ManufacturerNameString_d, (gGattCharPropRead_c) )
        VALUE(value_manuf_name, gBleSig_ManufacturerNameString_d, (gPermissionFlagReadable_c), sizeof(MANUFACTURER_NAME), MANUFACTURER_NAME)
        DESCRIPTOR(test_aggregate, gBleSig_CharAggregateFormat_d, (gPermissionFlagReadable_c),4,0x24,0x2a,0x25,0x2a)
    CHARACTERISTIC(char_model_no, gBleSig_ModelNumberString_d, (gGattCharPropRead_c) )
        VALUE(value_model_no, gBleSig_ModelNumberString_d, (gPermissionFlagReadable_c), 8, "HRS Demo")
    CHARACTERISTIC(char_serial_no, gBleSig_SerialNumberString_d, (gGattCharPropRead_c) )
        VALUE(value_serial_no, gBleSig_SerialNumberString_d, (gPermissionFlagReadable_c), 7, "BLESN01")
    CHARACTERISTIC(char_hw_rev, gBleSig_HardwareRevisionString_d, (gGattCharPropRead_c) )
        VALUE(value_hw_rev, gBleSig_HardwareRevisionString_d, (gPermissionFlagReadable_c), sizeof(BOARD_NAME), BOARD_NAME)
    CHARACTERISTIC(char_fw_rev, gBleSig_FirmwareRevisionString_d, (gGattCharPropRead_c) )
        VALUE(value_fw_rev, gBleSig_FirmwareRevisionString_d, (gPermissionFlagReadable_c), 5, "1.1.1")
    CHARACTERISTIC(char_sw_rev, gBleSig_SoftwareRevisionString_d, (gGattCharPropRead_c) )
        VALUE(value_sw_rev, gBleSig_SoftwareRevisionString_d, (gPermissionFlagReadable_c), 5, "1.1.4")
    CHARACTERISTIC(char_system_id, gBleSig_SystemId_d, (gGattCharPropRead_c) )
        VALUE(value_system_id, gBleSig_SystemId_d, (gPermissionFlagReadable_c), 8, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0x9F, 0x04, 0x00)
    CHARACTERISTIC(char_rcdl, gBleSig_IeeeRcdl_d, (gGattCharPropRead_c) )
        VALUE(value_rcdl, gBleSig_IeeeRcdl_d, (gPermissionFlagReadable_c), 4, 0x00, 0x00, 0x00, 0x00)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope this helps

Regards,
Estephania

0 Kudos

1,726 Views
skv
Contributor II

Thank you!