Koteyk0o

C++ BLE Header

Jan 26th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.64 KB | None | 0 0
  1. #ifndef BLUETOOTH_BRIDGE_H
  2. #define BLUETOOTH_BRIDGE_H
  3.  
  4. #include <QObject>
  5. #include <QBluetoothDeviceDiscoveryAgent>
  6. #include <QBluetoothLocalDevice>
  7. #include <QLowEnergyController>
  8. #include "device_info.h"
  9.  
  10. class device_Info;
  11. class service_Info;
  12.  
  13. class bluetooth_Bridge : public QObject {
  14.     Q_OBJECT
  15.  
  16. public:
  17.     bluetooth_Bridge(QObject *parent = nullptr);
  18.  
  19.     Q_INVOKABLE void scan_Devices();
  20.     void clear_Devices();
  21.     void connect_Device(device_Info *device);
  22.  
  23. private slots:
  24.     void S_add_Device(const QBluetoothDeviceInfo&);
  25.     void S_device_Scan_Finished();
  26.     void S_device_Scan_Error(QBluetoothDeviceDiscoveryAgent::Error);
  27.  
  28.     void S_device_Connected();
  29.     void S_device_Disconnected();
  30.     void S_service_Discovered(const QBluetoothUuid &gatt);
  31.     void S_service_Scan_Done();
  32.     void S_BLE_Controller_Error(QLowEnergyController::Error);
  33.  
  34.     void S_service_State_Changed(QLowEnergyService::ServiceState state);
  35.     void S_service_Characteristic_Changed(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
  36.     void S_service_Characteristic_Read(const QLowEnergyCharacteristic &characteristic, const QByteArray &value);
  37.     void S_service_Error(QLowEnergyService::ServiceError error);
  38.  
  39. signals:
  40.     void devices_Changed();
  41.  
  42. private:
  43.     bool _display_Service_Found;
  44.     QList<QObject*> _BLE_Devices;
  45.     QList<QBluetoothUuid> _BLE_Services_UUID;
  46.     device_Info *_current_Device = nullptr;
  47.  
  48.     QBluetoothDeviceDiscoveryAgent *_device_Discovery_Agent;
  49.     QLowEnergyController *_BLE_Controller = nullptr;
  50.     QLowEnergyService *_BLE_Service = nullptr;
  51.  
  52. };
  53.  
  54. #endif // BLUETOOTH_BRIDGE_H
  55.  
Add Comment
Please, Sign In to add comment