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

concurrent characteristic write and notify

Hi,

I was just wondering what the sequence of events would be in the following scenario:

A S110 peripheral device (GATT server) has a characteristic with write access and notifications enabled (by the GATT client). The GATT client performs a write to the charteristic at the same time as the GATT server issues a notification (changing it to different value).

What would happen in the first connection interval following these events?

  • Hi Ned, From what you described, in the first connection interval following the events, we will have 2 packets. First is the packet from central to peripheral which contains the write command. Right after this packet, in same connection interval, is the packet from peripheral to central with the notification . Note that the value in the notification is the old value, not the new one comes with write command.

  • Just to clarify: Will each change of the characteristic (from either central or peripheral) be handled as a sequential atomic operation, meaning that there is no risk of one overwriting the other in some unexpected way?

    And is it predefined that the central's write will happen first, or will the notification come first if it happens first (but both still happen before the same connection interval)?

  • Ned_zeppelin: I don't see any chance of one overwriting the other here. Write command from central change the value of the attribute on the server. Value of the attribute on the client is not synchronized with this value. It's only synchronized with value when reading attribute value or receiving notification from server.

    It's predefined that the packet from central (TX packet) is sent first, following is the packet from peripheral (RX packet). If there are more than 1 packet need to be sent from one peer in one connection interval, the sequence will be: TX-RX-TX-RX ...

    A TX/RX packet can be an empty payload packet

Related