To create characteristics, following classes are provided:
LBLECharacteristicInt
LBLECharacteristicString
These classes represents values in GATT service that can be read and write by the connected central device. These characteristic object needs to be added to a service with LBLEService::addAttribute() to be accessed by the underlying GATT server.
Constructor
LBLECharacteristicInt()
LBLECharacteristicString()
Create characteristic with an integer as value type.
In most cases the characteristic should be created in global scope, to ensure it is alive after LBLEPeripheral.begin().
Syntax
Parameters
uuid: The UUID of the characteristic.
Returns
Instance of LBLECharacteristicInt
Create characteristic with an string as value type.
In most cases the characteristic should be created in global scope, to ensure it is alive after LBLEPeripheral.begin()
This represents a GATT characterstic that is a NULL-terminated strings.
This is a "string" attribute. A NULL terminater is always automatically inserted after each write operation.
That is, the string value is always "reset" after each write operation, instead of appending/replacing part of the existing string value.
Example:
the central device sends "YES" (3 bytes)
the central device then sends "NO"(2 bytes)
the resulting value is "NO\0" instead of "NOS\0".
The reason for this design is to make it more intuitive to use with AppInventor's BluetoothLE.WriteStringValue block.
Syntax
Parameters
uuid: The UUID of the characteristic.
Returns
Instance of LBLECharacteristicString
Methods
isWritten()
getValue()
setValue()
Check if a characteristic has been updated by the remote central device.
Syntax
Parameters
none
Returns
true if the characteristic has been update by remote device.
false if the characteristic remains unchanged.
Set value of the characteristic.
Syntax
Parameters
none
Returns
the int(LBLECharacteristicInt ) or String(LBLECharacteristicString) value of the characteristic.
Set value of the characteristic.
Syntax
Parameters
value: the int(LBLECharacteristicInt ) or String(LBLECharacteristicString) value to set to the characteristic