Index: sources/bluetooth/BluetoothInterface.h =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r4a95b249fb87bf69d909452ba374c794b89d423b --- sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 4a95b249fb87bf69d909452ba374c794b89d423b) @@ -26,6 +26,8 @@ #include "MBluetooth.h" #include "MUIBloodPressureData.h" #include "DeviceModels.h" +#include "BluetoothPairingAgent.h" +#include "Agent1Adapter.h" // Define #define _BluetoothInterface Bluetooth::BluetoothInterface::I() @@ -60,8 +62,16 @@ bool _isValid = false ; - const QByteArray _bloodPressureNotifyValue = QByteArray::fromHex("0100"); - const char *_invalidLocalAddress = "00:00:00:00:00:00"; + const QByteArray _bloodPressureNotifyValue = QByteArray::fromHex("0100"); + const QString _devicePairingBondCharacteristicUuid = "{b305b680-aee7-11e1-a730-0002a5d5c51b}"; + const QString _vendorSpecificServiceUuid = "{ecbe3980-c9a2-11e1-b1bd-0002a5d5c51b}"; + const QString _pairingObjectPath = "/pairing/agent"; + + const char *_invalidLocalAddress = "00:00:00:00:00:00"; + const char _deviceConfirmKeyWriteCodeSuccess = '\x82'; + const char *_devicePairingKeyString = "0x00EE020E"; + const char *_enableKeyProgrammingString = "0x200000000000000000000000000000000"; + QStringList _supportedDeviceKeywords { "BP7000", "BLEsmart", "BLESmart" }; // Regarding to Omron Documents. QBluetoothLocalDevice *_local = nullptr ; QBluetoothDeviceDiscoveryAgent *_agent = nullptr ; @@ -71,14 +81,20 @@ QLowEnergyService *_serviceCurrentTime = nullptr ; QLowEnergyService *_serviceBloodPressure = nullptr ; QLowEnergyService *_serviceBattery = nullptr ; + QLowEnergyService *_serviceVendorSpecific = nullptr ; + Agent1Adaptor *_agentAdaptor = nullptr ; + BluetoothPairingAgent *_pairingAgent = nullptr ; + QBluetoothDeviceInfo _temp ; quint8 _tempBatt = 0 ; bool _tryingrepairActive = false ; bool _reconnectionActive = false ; const quint16 _interval = 1000 ; // the interface timer base interval in mSec + bool _isPairingKeyWritten = false; // indicate whether the pairing/bond key is written to the device + public: bool isValid( ) const { return _isValid ; } void valid(bool vValid) { _isValid = vValid; } @@ -101,6 +117,7 @@ void onLocalDeviceConnect (const QBluetoothAddress &vAddress ); void onLocalDeviceDisconnect (const QBluetoothAddress &vAddress ); void onLocalError ( QBluetoothLocalDevice::Error vError ); + void onLocalPairingFinished (const QBluetoothAddress addr , QBluetoothLocalDevice::Pairing pair ); // Discovery Agent Slots void onAgentDiscoverDevice (const QBluetoothDeviceInfo & vDevice ); @@ -168,8 +185,13 @@ void interpretBloodPressure (const QByteArray &vData); void interpretInformation (); void interpretBattery (const QByteArray &vData); + void requestDevicePairing (const BluetoothDeviceData &vDevice); - + void enableKeyProgramming(); + void writeDevicePairingKey(); + bool isVendorSpecificService (const QLowEnergyService *service ); + bool isDevicePairingCharacteristicUuid (const QLowEnergyCharacteristic &vCharacteristic); + void initializePairingAgent(); signals: void didStateChange (const BluetoothData &vData); void didActionReceive (const UIBloodPressureData &vData);