struct Core::Bluetooth::IGattCentral

Overview

Top-level interface to handle creation of device connections. More…

#include <coregattcentral.h>

struct IGattCentral: public Core::IPropertyHandler
{
    // fields

    static const InterfaceID kIID = FOUR_CHAR_ID('B', 'T', 'G', 'C');

    // methods

    virtual GattCentralState getState() const = 0;

    virtual ErrorCode startScanning(
        const IDFilter& serviceFilter,
        const GattCentralScanOptions& scanOptions = {}
    ) = 0;

    virtual ErrorCode stopScanning() = 0;
    virtual ErrorCode connectAsync(IGattCentralDevice* device, tbool autoReconnect) = 0;
    virtual ErrorCode disconnectAsync(IGattCentralDevice* device) = 0;
    virtual void addObserver(IGattCentralObserver* observer) = 0;
    virtual void removeObserver(IGattCentralObserver* observer) = 0;
};

Inherited Members

public:
    // fields

    static const InterfaceID kIID = 0;

    // methods

    virtual void setProperty(const Property& value) = 0;
    virtual void getProperty(Property& value) = 0;
    virtual void release() = 0;

Detailed Documentation

Top-level interface to handle creation of device connections.

Methods

virtual GattCentralState getState() const = 0

Returns the current state of the bluetooth adapter.

Scan and connect methods may only be called when the state is kPoweredOn.

virtual ErrorCode startScanning(
    const IDFilter& serviceFilter,
    const GattCentralScanOptions& scanOptions = {}
) = 0

Listen for advertisements from Bluetooth LE devices.

If the serviceFilter is not empty, the device needs to provide all services in the serviceFilter. When receiving an advertisement from a previously unknown device, onDeviceAdded() is called.

virtual ErrorCode stopScanning() = 0

Stop listening for advertisements.

virtual ErrorCode connectAsync(IGattCentralDevice* device, tbool autoReconnect) = 0

Connects to a discovered device and establishing the communication with the device.

virtual ErrorCode disconnectAsync(IGattCentralDevice* device) = 0

Disconnects a connected device, but keeps it around for reconnecting to it in the future without having to scan again.

virtual void addObserver(IGattCentralObserver* observer) = 0

Start receiving callbacks.

virtual void removeObserver(IGattCentralObserver* observer) = 0

Stop receiving callbacks.