O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the init method

In order to initialize the Receiver channel, we need to launch a service discovery agent on the local adapter's address, and once the service has been found, connect to it by opening a socket. Since we don't know when the service discovery agent will find the readings broadcast service, we will use a slot for the second step.

First, we will need a pointer to the service discovery agent instance so that we can stop it once the service has been found:

// receiver_bt.h#ifndef RECEIVER_BT_H#define RECEIVER_BT_H...class QBluetoothServiceDiscoveryAgent;namespace channels {class ReceiverBt : public ReceiverChannel{    Q_OBJECTpublic:    ...private:    QBluetoothServiceDiscoveryAgent* _discoveryAgent;};}#endif // RECEIVER_BT_H ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required