5.4.4.2 Write Remote Characteristic Value (CHW…)

Format: CHW,<hex16>,<hex value>

The command CHW writes the content of the GATT service characteristic from the remote device by addressing its handle.

This command takes two parameters. The first parameter is the 16-bit hex value of the handle corresponding to the characteristic of the client service. The user must find a match between the handle and its characteristic UUID by using command LC. The second parameter is the content to be written to the characteristic.

This command is effective under the following conditions:

  • An active connection with a peer device exists.
  • The command CI starts the client operation.
  • The handle parameter is valid and the corresponding characteristic is writable according to its property.

The content value is written to the remote peer device. The writing method depends on the property of the characteristic.

When writing a configuration handle to the remote device, Bluetooth specification defines the format as 0x0000, 0x0001 or 0x0002. Value 0x0001 (01 00 over the air in little Endian) starts the notification, value 0x0002 (02 00 over the air in little Endian) starts the indication, and value 0x0000 stops both. To start the notification or indication depends on the service specification and property of the characteristic. For more details, see Table 9-1.

Example: CHW,001A,64

// Set value of characteristic with value handle 0x001A-100 on the remote device

CHW,001B,0100

// Start notification on characteristic by writing 0x0001 to its configuration handle 0x001B on the remote device

Response: AOK // Success
Err

// Syntax error, invalid parameter, not connected or characteristic not writable