Last updated
Last updated
The smallest concept in GATT is the Characteristic, which encapsulates a single data point (though it may contain an array of related data, such as X/Y/Z values from a 3-axis accelerometer, longitude and latitude from a GPS, etc.).
The following class allows you to manage Server characteristics.
Gets or sets the value of the characteristic. Can take an integer, a string or a bytes object.
Creates a callback that will be executed when any of the triggers occurs. The arguments are:
trigger
can be either Bluetooth.CHAR_READ_EVENT
or Bluetooth.CHAR_WRITE_EVENT
.
handler
is the function that will be executed when the callback is triggered.
arg
is the argument that gets passed to the callback. If nothing is given, the characteristic object that owns the callback will be used.
An example of how this could be implemented can be seen in the section.
Returns a value with bit flags identifying the events that have occurred since the last call. Calling this function clears the events.
An example of advertising and creating services on the device: