IoT::BtLE

class Peripheral

File Information

Library: IoT/BtLE
Package: BtLE
Header: IoT/BtLE/Peripheral.h

Description

This class provides a high-level interface to a Bt LE peripheral device using the Bt Generic Attribute Profile (GATT).

Inheritance

Known Derived Classes: GATTPeripheral

Member Summary

Member Functions: address, characteristic, characteristicForAssignedNumber, characteristics, connect, connectAsync, deviceName, disconnect, expandUUID, firmwareRevision, handleForDescriptor, hardwareRevision, isConnected, manufacturerName, modelNumber, readBytes, readDouble, readFloat, readInt16, readInt32, readInt64, readInt8, readString, readString0, readUInt16, readUInt32, readUInt64, readUInt8, serialNumber, serviceUUIDForAssignedNumber, services, softwareRevision, writeBytes, writeDouble, writeFloat, writeInt16, writeInt32, writeInt64, writeInt8, writeString, writeUInt16, writeUInt32, writeUInt64, writeUInt8

Types Aliases

Ptr

using Ptr = Poco::SharedPtr < Peripheral >;

Destructor

~Peripheral virtual

virtual ~Peripheral();

Destroys the Peripheral.

Member Functions

address virtual

virtual std::string address() const = 0;

Returns the address of the device.

characteristic virtual

virtual Characteristic characteristic(
    const Poco::UUID & serviceUUID,
    const Poco::UUID & characteristicUUID
) = 0;

Returns the properties and handle for accessing the value of the given characteristic.

characteristicForAssignedNumber virtual

virtual Characteristic characteristicForAssignedNumber(
    const Poco::UUID & serviceUUID,
    Poco::UInt32 assignedNumber
) = 0;

Returns the properties and handle for accessing the value of the given characteristic.

characteristics virtual

virtual std::vector < Poco::UUID > characteristics(
    const Poco::UUID & serviceUUID
) = 0;

Returns a vector containing the UUIDs of all available characteristics of the service identified by the given serviceUUID.

connect virtual

virtual void connect() = 0;

Connects to the Bt LE peripheral.

Waits for successful connection or error.

connectAsync virtual

virtual void connectAsync() = 0;

Connects to the Bt LE peripheral.

Successful connection or error will be reported through connected and error events.

deviceName virtual

virtual std::string deviceName() = 0;

Returns the peripheral's device name obtained from the Generic Access Profile.

disconnect virtual

virtual void disconnect() = 0;

Disconnects from the Bt LE peripheral.

expandUUID virtual

virtual Poco::UUID expandUUID(
    Poco::UInt32 uuid
) = 0;

Expands the given 16-bit or 32-bit UUID to a full UUID.

firmwareRevision virtual

virtual std::string firmwareRevision() = 0;

Returns the peripheral's firmware revision string obtained from the Device Information service.

handleForDescriptor virtual

virtual Handle handleForDescriptor(
    const Poco::UUID & serviceUUID,
    const Poco::UUID & characteristicUUID,
    const Poco::UUID & descriptorUUID
) = 0;

Returns the handle with the given descriptor UUID for given characteristic and service.

hardwareRevision virtual

virtual std::string hardwareRevision() = 0;

Returns the peripheral's hardware revision string obtained from the Device Information service.

isConnected virtual

virtual bool isConnected() const = 0;

Returns true if the device is connected.

manufacturerName virtual

virtual std::string manufacturerName() = 0;

Returns the peripheral's manufacturer name obtained from the Device Information service.

modelNumber virtual

virtual std::string modelNumber() = 0;

Returns the peripheral's model number string obtained from the Device Information service.

readBytes virtual

virtual std::vector < char > readBytes(
    Handle valueHandle
) = 0;

Reads a raw byte string from the given value handle.

readDouble virtual

virtual double readDouble(
    Handle valueHandle
) = 0;

Reads a 64-bit double value (little endian) from the given value handle.

readFloat virtual

virtual float readFloat(
    Handle valueHandle
) = 0;

Reads a 32-bit float value (little endian) from the given value handle.

readInt16 virtual

virtual Poco::Int16 readInt16(
    Handle valueHandle
) = 0;

Reads a signed 16-bit integer value (little endian) from the given value handle.

readInt32 virtual

virtual Poco::Int32 readInt32(
    Handle valueHandle
) = 0;

Reads a signed 32-bit integer value (little endian) from the given value handle.

readInt64 virtual

virtual Poco::Int64 readInt64(
    Handle valueHandle
) = 0;

Reads a signed 64-bit integer value (little endian) from the given value handle.

readInt8 virtual

virtual Poco::Int8 readInt8(
    Handle valueHandle
) = 0;

Reads a signed byte value from the given value handle.

readString virtual

virtual std::string readString(
    Handle valueHandle
) = 0;

Reads a raw byte string from the given value handle.

readString0 virtual

virtual std::string readString0(
    Handle valueHandle
) = 0;

Reads a 0-terminated character string from the given value handle.

readUInt16 virtual

virtual Poco::UInt16 readUInt16(
    Handle valueHandle
) = 0;

Reads an unsigned 16-bit integer value (little endian) from the given value handle.

readUInt32 virtual

virtual Poco::UInt32 readUInt32(
    Handle valueHandle
) = 0;

Reads an unsigned 32-bit integer value (little endian) from the given value handle.

readUInt64 virtual

virtual Poco::UInt64 readUInt64(
    Handle valueHandle
) = 0;

Reads an unsigned 64-bit integer value (little endian) from the given value handle.

readUInt8 virtual

virtual Poco::UInt8 readUInt8(
    Handle valueHandle
) = 0;

Reads an unsigned byte value from the given value handle.

serialNumber virtual

virtual std::string serialNumber() = 0;

Returns the peripheral's serial number string obtained from the Device Information service.

serviceUUIDForAssignedNumber virtual

virtual Poco::UUID serviceUUIDForAssignedNumber(
    Poco::UInt32 assignedNumber
) = 0;

Returns the UUID of the service with the given 32-bit assigned number, or null UUID if no such service is available.

services virtual

virtual std::vector < Poco::UUID > services() = 0;

Returns a vector containing the UUIDs of all available services.

softwareRevision virtual

virtual std::string softwareRevision() = 0;

Returns the peripheral's software revision string obtained from the Device Information service.

writeBytes virtual

virtual void writeBytes(
    Handle valueHandle,
    const std::vector < char > & value,
    bool withResponse
) = 0;

Writes a raw byte string to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeDouble virtual

virtual void writeDouble(
    Handle valueHandle,
    double value,
    bool withResponse
) = 0;

Writes a signed 64-bit double value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeFloat virtual

virtual void writeFloat(
    Handle valueHandle,
    float value,
    bool withResponse
) = 0;

Writes a signed 32-bit float value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeInt16 virtual

virtual void writeInt16(
    Handle valueHandle,
    Poco::Int16 value,
    bool withResponse
) = 0;

Writes a signed 16-bit integer value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeInt32 virtual

virtual void writeInt32(
    Handle valueHandle,
    Poco::Int32 value,
    bool withResponse
) = 0;

Writes a signed 32-bit integer value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeInt64 virtual

virtual void writeInt64(
    Handle valueHandle,
    Poco::Int64 value,
    bool withResponse
) = 0;

Writes a signed 32-bit integer value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeInt8 virtual

virtual void writeInt8(
    Handle valueHandle,
    Poco::Int8 value,
    bool withResponse
) = 0;

Writes a signed byte value to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeString virtual

virtual void writeString(
    Handle valueHandle,
    const std::string & value,
    bool withResponse
) = 0;

Writes a raw byte string to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeUInt16 virtual

virtual void writeUInt16(
    Handle valueHandle,
    Poco::UInt16 value,
    bool withResponse
) = 0;

Writes an unsigned 16-bit integer value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeUInt32 virtual

virtual void writeUInt32(
    Handle valueHandle,
    Poco::UInt32 value,
    bool withResponse
) = 0;

Writes an unsigned 32-bit integer value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeUInt64 virtual

virtual void writeUInt64(
    Handle valueHandle,
    Poco::UInt64 value,
    bool withResponse
) = 0;

Writes an unsigned 32-bit integer value (little endian) to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

writeUInt8 virtual

virtual void writeUInt8(
    Handle valueHandle,
    Poco::UInt8 value,
    bool withResponse
) = 0;

Writes an unsigned byte value to the given value handle.

If withResponse is false, uses a WriteWithoutResponse operation, otherwise a Write operation.

Variables

connected

Poco::BasicEvent < void > connected;

Fired when a connection with the peripheral has been established.

disconnected

Poco::BasicEvent < void > disconnected;

Fired when the connection with the peripheral has been disconnected.

error

Poco::BasicEvent < const std::string > error;

Fired when the connection attempt with the peripheral has failed. The event argument contains more information about the error.

indicationReceived

Poco::BasicEvent < const Indication > indicationReceived;

Fired when an Indication has been received from the peripheral.

notificationReceived

Poco::BasicEvent < const Notification > notificationReceived;

Fired when a Notification has been received from the peripheral.

Securely control IoT edge devices from anywhere   Connect a Device