1
OK
# Add a battery measurement characteristic (UUID = 0x2A19), notify enabled
AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100
1
OK
# Clear any previous custom services/characteristics
AT+GATTCLEAR
OK
# Add a custom service to the peripheral
AT+GATTADDSERVICE=UUID128=00-11-00-11-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF
1
OK
# Add a custom characteristic to the above service (making sure that there
# is no conflict between the 16-bit UUID and bytes 3+4 of the 128-bit service UUID)
AT+GATTADDCHAR=UUID=0x0002,PROPERTIES=0x02,MIN_LEN=1,VALUE=100
1
OK
AT+GATTADDCHAR
Adds a custom characteristic to the last service that was added to the peripheral (via AT+GATTADDSERVICE).
AT+GATTADDCHAR must be run AFTER AT+GATTADDSERVICE, and will add the new characteristic to the last service definition that was
added.
As of version 0.6.6 of the Bluefruit LE firmware you can now use custom 128-bit UUIDs with this command. See the example at the bottom of this
command description.
Codebase Revision: 0.3.0
Parameters: This command accepts a set of comma-separated key-value pairs that are used to define the characteristic properties. The following
key-value pais can be used:
UUID: The 16-bit UUID to use for the characteristic (which will be insert in the 3rd and 4th bytes of the parent services 128-bit UUID). This
value should be entered in hexadecimal format (ex. 'UUID=0x1234'). This value must be unique, and should not conflict with bytes 3+4 of the
parent service's 128-bit UUID.
PROPERTIES: The 8-bit characteristic properties field, as defined by the Bluetooth SIG. The following values can be used:
0x02 - Read
0x04 - Write Without Response
0x08 - Write
0x10 - Notify
0x20 - Indicate
MIN_LEN: The minimum size of the values for this characteristic (in bytes, min = 1, max = 20, default = 1)
MAX_LEN: The maximum size of the values for the characteristic (in bytes, min = 1, max = 20, default = 1)
VALUE: The initial value to assign to this characteristic (within the limits of 'MIN_LEN' and 'MAX_LEN'). Value can be an integer ("-100",
"27"), a hexadecimal value ("0xABCD"), a byte array ("aa-bb-cc-dd") or a string ("GATT!").
>=0.7.0 - DATATYPE: This argument indicates the data type stored in the characteristic, and is used to help parse data properly. It can be
one of the following values:
AUTO (0, default)
STRING (1)
BYTEARRAY (2)
INTEGER (3)
>=0.7.0 - DESCRIPTION: Adds the specified string as the characteristic description entry
>=0.7.0 - PRESENTATION: Adds the specified value as the characteristic presentation format entry
Response: The index value of the characteristic in the custom GATT characteristic lookup table. (It's important to keep track of these
characteristic index values to work with the characteristic later.)
Note: Key values are not case-sensitive
Make sure that the 16-bit UUID is unique and does not conflict with bytes 3+4 of the 128-bit service UUID
# Clear any previous custom services/characteristics
AT+GATTCLEAR
OK
# Add a battery service (UUID = 0x180F) to the peripheral
AT+GATTADDSERVICE=UUID=0x180F
1
OK