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

GATT Write Event data restricted to only 1 byte

The following seems to suggest each write event can only contain 1 byte of data at a time.

/**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */

typedef struct
{
  uint16_t                    handle;             /**< Attribute Handle. */
  uint8_t                     op;                 /**< Type of write operation, see @ref BLE_GATTS_OPS. */
  ble_gatts_attr_context_t    context;            /**< Attribute Context. */
  uint16_t                    offset;             /**< Offset for the write operation. */
  uint16_t                    len;                /**< Length of the received data. */
  uint8_t                     data[1];            /**< Received data, variable length. */
} ble_gatts_evt_write_t;

I would like to have an array of bytes which I loop over and can parse. Considering that when we add characteristics and update them, they are added as an array of bytes, it must be possible to write more than one byte to them.

Could I have some clarification on this?

If this is the case, why have the need for a 16-bit length, if we know it will always be 1?

I know the following will compile, however, the explicit size 1 for data must cause memory issues at some point.

	uint8_t * NewCharData = pWriteEvent->data;

If this is not the case (and you can write more than 1 byte at a time), could you explain the purpose of explicitly stating data[1]?

I'm using SDK 9.0.0 with latest softdevice S110 version and an nrf51822.

Parents Reply Children
No Data
Related