GATTSCharacteristic
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.
Methods
characteristic.value([value])
Gets or sets the value of the characteristic. Can take an integer, a string or a bytes object.
characteristic.callback(trigger=None, handler=None, arg=None)
Creates a callback that will be executed when any of the triggers occurs. The arguments are:
trigger
can be eitherBluetooth.CHAR_READ_EVENT
orBluetooth.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 characteristic.events()
section.
characteristic.events()
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:
Last updated