Class GattCharacteristic
- Assembly
- nanoFramework.Device.Bluetooth.dll
Represents a Characteristic of a GATT service. The GattCharacteristic object represents a GATT Characteristic of a particular service, and is obtained from the Characteristics property of the GattDeviceService object.
public class GattCharacteristic : IGattAttribute
- Inheritance
-
GattCharacteristic
- Implements
- Inherited Members
- Extension Methods
Properties
AttributeHandle
Gets the handle used to uniquely identify GATT-based characteristic attributes as declared on the Bluetooth LE device.
public ushort AttributeHandle { get; }
Property Value
CharacteristicProperties
Gets the GATT characteristic properties, as defined by the GATT profile.
public GattCharacteristicProperties CharacteristicProperties { get; }
Property Value
PresentationFormats
Gets an array of presentation format descriptors associated with this GattCharacteristic, in the order specified by the Aggregate Format Descriptor.
public GattPresentationFormat[] PresentationFormats { get; }
Property Value
ProtectionLevel
Gets or sets the desired GATT security options for over the air communication with the device.
public GattProtectionLevel ProtectionLevel { get; set; }
Property Value
Service
Gets the GattDeviceService of which this characteristic is a member.
public GattDeviceService Service { get; }
Property Value
UserDescription
Get the user friendly description for this GattCharacteristic, if the User Description Descriptor is present, otherwise this will be an empty string.
public string UserDescription { get; }
Property Value
Uuid
Gets the GATT Characteristic UUID for this GattCharacteristic.
public Guid Uuid { get; }
Property Value
Methods
GetDescriptors()
Returns the descriptors for this GattCharacteristic instance.
public GattDescriptorsResult GetDescriptors()
Returns
- GattDescriptorsResult
GattDescriptorsResult
GetDescriptorsForUuid(Guid)
Returns the descriptors whose UUIDs match descriptorUuid.
public GattDescriptorsResult GetDescriptorsForUuid(Guid descriptorUuid)
Parameters
descriptorUuid
GuidThe UUID for the descriptors to be retrieved.
Returns
- GattDescriptorsResult
Completes with the GattDescriptorsResult which contain the descriptors whose UUIDs match descriptorUuid.
ReadClientCharacteristicConfigurationDescriptor()
Reads the current value of the ClientCharacteristicConfigurationDescriptor to enable notify / Indicate.
public GattReadClientCharacteristicConfigurationDescriptorResult ReadClientCharacteristicConfigurationDescriptor()
Returns
- GattReadClientCharacteristicConfigurationDescriptorResult
Upon completion of the method, the GattReadClientCharacteristicConfigurationDescriptorResult contains the result of the read operation, which contains the status of completed operation. The Status property on the GattReadClientCharacteristicConfigurationDescriptorResult returned indicates if the result of the operation was successful.
ReadValue()
Performs a Characteristic Value read from device.
public GattReadResult ReadValue()
Returns
WriteClientCharacteristicConfigurationDescriptorWithResult(GattClientCharacteristicConfigurationDescriptorValue, GattWriteOption)
Writes the ClientCharacteristicConfigurationDescriptor to the Bluetooth LE device, and if the value to be written represents an indication or a notification and a ValueChanged event handler is registered, enables receiving ValueChanged events from the device.
public GattWriteResult WriteClientCharacteristicConfigurationDescriptorWithResult(GattClientCharacteristicConfigurationDescriptorValue clientCharacteristicConfigurationDescriptorValue, GattWriteOption gattWriteOption = GattWriteOption.WriteWithoutResponse)
Parameters
clientCharacteristicConfigurationDescriptorValue
GattClientCharacteristicConfigurationDescriptorValueSpecifies a new value for the ClientCharacteristicConfigurationDescriptor of this Characteristic object.
gattWriteOption
GattWriteOption
Returns
- GattWriteResult
Returns an asynchronous operation that completes with a GattWriteResult object.
WriteValueWithResult(Buffer, GattWriteOption)
Performs a Characteristic Value write to a Bluetooth LE device.
public GattWriteResult WriteValueWithResult(Buffer value, GattWriteOption writeOption = GattWriteOption.WriteWithoutResponse)
Parameters
value
BufferA Buffer object which contains the data to be written to the Bluetooth LE device.
writeOption
GattWriteOptionSpecifies what type of GATT write should be performed.
Returns
- GattWriteResult
An operation completes with a GattWriteResult object.
Events
ValueChanged
An Application can register an event handler in order to receive events when notification or indications are received from a device. You will need to set the Client Characteristic Configuration Descriptor before subscribing to event.
public event GattCharacteristic.GattCharacteristicVlaueChangedEventHandler ValueChanged