Index: denali.pro.user =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- denali.pro.user (.../denali.pro.user) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ denali.pro.user (.../denali.pro.user) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -1,6 +1,6 @@ - + EnvironmentId Index: scripts/bluetooth_kill.sh =================================================================== diff -u --- scripts/bluetooth_kill.sh (revision 0) +++ scripts/bluetooth_kill.sh (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -0,0 +1,31 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_reset.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 30-Aug-2021 +# @author (original) Behrouz NematiPour +# @date (original) 30-Aug-2021 +# +############################################################################ +BT_FOLDER=/var/lib/bluetooth/ +echo "Stopping the Bluetooth Adapter" +/usr/share/silex-uart/silex-uart.sh stop + +echo "Removing the Bluetooth Adapter settings" +rm -frd $BT_FOLDER* +BT_FILES=$(ls $BT_FOLDER) +if [ -z "$btfolder" ]; then + echo "[ OK ] The Bluetooth Adapter settings removed" +else + echo "[ ERRO ] The Bluetooth Adapter settings cannot be removed" + exit 1 +fi + +exit 0 Index: scripts/bluetooth_reset.sh =================================================================== diff -u --- scripts/bluetooth_reset.sh (revision 0) +++ scripts/bluetooth_reset.sh (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -0,0 +1,20 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_reset.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 30-Aug-2021 +# @author (original) Behrouz NematiPour +# @date (original) 30-Aug-2021 +# +############################################################################ + +~/scripts/bluetooth_kill.sh +~/scripts/bluetooth_start.sh + Index: scripts/bluetooth_start.sh =================================================================== diff -u --- scripts/bluetooth_start.sh (revision 0) +++ scripts/bluetooth_start.sh (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -0,0 +1,29 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_reset.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 30-Aug-2021 +# @author (original) Behrouz NematiPour +# @date (original) 30-Aug-2021 +# +############################################################################ +BT_FOLDER=/var/lib/bluetooth/ +echo "Starting the Bluetooth Adapter" +/usr/share/silex-uart/silex-uart.sh start +hciconfig hci0 up + +if [ $? -eq 0 ]; then + echo "[ OK ] The Bluetooth Adapter is up and running on hci0" +else + echo "[ ERRO ] The Bluetooth Adapter cannot be running" + exit 2 +fi + +exit 0 Index: sources/bluetooth/BluetoothInterface.cpp =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ sources/bluetooth/BluetoothInterface.cpp (.../BluetoothInterface.cpp) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -228,10 +228,55 @@ service->serviceUuid().toString() , \ service->serviceName() )); #define NOTIFY_DETAILS_INVALID notifyStateChange(MBluetooth(MBluetooth::eIS_Service_Detail_Invalid )); +#define NOTIFY_DETAILS_CHANGE notifyStateChange(MBluetooth(MBluetooth::eIS_Detail_Change , \ + _device->remoteAddress().toString() , \ + _device->remoteName(), "" , \ + _local->pairingStatus(_device->remoteAddress()), 0, 1 , \ + service->serviceUuid().toString() , \ + service->serviceName() , \ + vCharacteristic.uuid().toString() , \ + vCharacteristic.name() , \ + QString(vValue) )); +#define NOTIFY_DETAILS_READ notifyStateChange(MBluetooth(MBluetooth::eIS_Detail_Read , \ + _device->remoteAddress().toString() , \ + _device->remoteName(), "" , \ + _local->pairingStatus(_device->remoteAddress()), 0, 1 , \ + service->serviceUuid().toString() , \ + service->serviceName() , \ + vCharacteristic.uuid().toString() , \ + vCharacteristic.name() , \ + QString(vValue) )); +#define NOTIFY_DETAILS_WRITE notifyStateChange(MBluetooth(MBluetooth::eIS_Detail_Write , \ + _device->remoteAddress().toString() , \ + _device->remoteName(), "" , \ + _local->pairingStatus(_device->remoteAddress()), 0, 1 , \ + service->serviceUuid().toString() , \ + service->serviceName() , \ + vCharacteristic.uuid().toString() , \ + vCharacteristic.name() , \ + QString(vValue) )); +#define NOTIFY_CONFIG_READ notifyStateChange(MBluetooth(MBluetooth::eIS_Config_Read , \ + _device->remoteAddress().toString() , \ + _device->remoteName(), "" , \ + _local->pairingStatus(_device->remoteAddress()), 0, 1 , \ + service->serviceUuid().toString() , \ + service->serviceName() , \ + vDescriptor.uuid().toString() , \ + vDescriptor.name() , \ + QString(vValue) )); +#define NOTIFY_CONFIG_WRITE notifyStateChange(MBluetooth(MBluetooth::eIS_Config_Write , \ + _device->remoteAddress().toString() , \ + _device->remoteName(), "" , \ + _local->pairingStatus(_device->remoteAddress()), 0, 1 , \ + service->serviceUuid().toString() , \ + service->serviceName() , \ + vDescriptor.uuid().toString() , \ + vDescriptor.name() , \ + QString(vValue) )); #define NOTIFY_SERVICE_DETAILS_DONE notifyStateChange(MBluetooth(MBluetooth::eIS_Service_Detail_Done , \ _device->remoteAddress().toString() , \ _device->remoteName(), "" , \ - _local->pairingStatus(_device->remoteAddress()), vState, 0 , \ + _local->pairingStatus(_device->remoteAddress()), 0, 1 , \ service->serviceUuid().toString() , \ service->serviceName() )); @@ -252,7 +297,6 @@ */ void BluetoothInterface::onstart() { - _local->powerOn(); if ( ! isLocalValid() ) return; quitDevice(); _agent->setLowEnergyDiscoveryTimeout(5000); @@ -267,7 +311,6 @@ */ void BluetoothInterface::ondoScan() { - onstart(); // TODO: it may require in case the application needs to reset the Bluetooth Adapter. Or can be moved to Adapter Reset function(no implemented yet) if (_agent && _agent->isActive()) { NOTIFY_SCAN_REJECT return; @@ -480,8 +523,25 @@ } -void BluetoothInterface::onServiceCharacteristicChanged(const QLowEnergyCharacteristic &vCharacteristic, const QByteArray &vValue) { - qDebug() << " ..... Service Charc C:" << vCharacteristic.name() << vValue; +void BluetoothInterface::onServiceDescriptorRead (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue) { + QLowEnergyService *service = reinterpret_cast(sender()); + NOTIFY_CONFIG_READ +} +void BluetoothInterface::onServiceDescriptorWritten (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue) { + QLowEnergyService *service = reinterpret_cast(sender()); + NOTIFY_CONFIG_WRITE +} +void BluetoothInterface::onServiceCharacteristicRead (const QLowEnergyCharacteristic &vCharacteristic, const QByteArray &vValue) { + QLowEnergyService *service = reinterpret_cast(sender()); + NOTIFY_DETAILS_READ +} +void BluetoothInterface::onServiceCharacteristicWritten (const QLowEnergyCharacteristic &vCharacteristic, const QByteArray &vValue) { + QLowEnergyService *service = reinterpret_cast(sender()); + NOTIFY_DETAILS_WRITE +} +void BluetoothInterface::onServiceCharacteristicChanged (const QLowEnergyCharacteristic &vCharacteristic, const QByteArray &vValue) { + QLowEnergyService *service = reinterpret_cast(sender()); + NOTIFY_DETAILS_CHANGE if (vCharacteristic.uuid() == QBluetoothUuid(QBluetoothUuid::BloodPressureMeasurement)) { parseMeasurement(vValue); @@ -491,7 +551,6 @@ void BluetoothInterface::parseMeasurement(const QByteArray &byteArray) { MeasurementData measurement; -// const uint8_t *d = reinterpret_cast(byteArray.constData()); const uchar *d = reinterpret_cast(byteArray.constData()); measurement.flags = *d; Index: sources/bluetooth/BluetoothInterface.h =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -116,10 +116,10 @@ void onDeviceError ( QLowEnergyController::Error vError ); void onServiceCharacteristicChanged (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ); - void onServiceCharacteristicRead (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ) { qDebug() << " ..... Service Charc R:" << vCharacteristic .name() << vValue; } - void onServiceCharacteristicWritten (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ) { qDebug() << " ..... Service Charc W:" << vCharacteristic .name() << vValue; } - void onServiceDescriptorRead (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue ) { qDebug() << " ..... Service Descr R:" << vDescriptor .name() << vValue; } - void onServiceDescriptorWritten (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue ) { qDebug() << " ..... Service Descr W:" << vDescriptor .name() << vValue; } + void onServiceCharacteristicRead (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ); + void onServiceCharacteristicWritten (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ); + void onServiceDescriptorRead (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue ); + void onServiceDescriptorWritten (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue ); void onServiceError ( QLowEnergyService::ServiceError vError ); void onServiceStateChanged ( QLowEnergyService::ServiceState vState ); Index: sources/model/settings/MBluetooth.cpp =================================================================== diff -u -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- sources/model/settings/MBluetooth.cpp (.../MBluetooth.cpp) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) +++ sources/model/settings/MBluetooth.cpp (.../MBluetooth.cpp) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -26,7 +26,10 @@ qint16 vError , bool vValid , QString vServiceAddr , - QString vServiceName ): + QString vServiceName , + QString vDetailAddr , + QString vDetailName , + QString vDetailValue ): state (vState ), deviceAddr (vDeviceAddr ), deviceName (vDeviceName ), @@ -35,7 +38,10 @@ error (vError ), valid (vValid ), serviceAddr (vServiceAddr ), - serviceName (vServiceName ){ + serviceName (vServiceName ), + detailAddr (vDetailAddr ), + detailName (vDetailName ), + detailValue (vDetailValue ){ } MBluetooth::MBluetooth( @@ -50,4 +56,3 @@ error (vError ), valid (vValid ){ } - Index: sources/model/settings/MBluetooth.h =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- sources/model/settings/MBluetooth.h (.../MBluetooth.h) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ sources/model/settings/MBluetooth.h (.../MBluetooth.h) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -65,6 +65,12 @@ eIS_Service_Detail_Done , eIS_Service_Done , + eIS_Detail_Change , + eIS_Detail_Read , + eIS_Detail_Write , + eIS_Config_Read , + eIS_Config_Write , + eIS_Close , }; Q_ENUM(InterfaceStates) @@ -81,6 +87,10 @@ QString serviceAddr = ""; QString serviceName = ""; + QString detailAddr = ""; + QString detailName = ""; + QString detailValue = ""; + MBluetooth( InterfaceStates vState = eIS_Idle, QString vDeviceAddr = "", @@ -90,16 +100,19 @@ qint16 vError = 0, bool vValid = 1, QString vServiceAddr = "", - QString vServiceName = "" + QString vServiceName = "", + QString vDetailAddr = "", + QString vDetailName = "", + QString vDetailValue = "" ); + MBluetooth( InterfaceStates vState , - QString vLocalAddr , - QString vLocalName , + QString vLocalAddr , + QString vLocalName , qint16 vError , bool vValid ); - }; } Index: sources/view/settings/VBluetooth.cpp =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ sources/view/settings/VBluetooth.cpp (.../VBluetooth.cpp) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -65,10 +65,20 @@ break; case MBluetooth::eIS_Local_Init : - localAddr (vData.localAddr ); - localName (vData.localName ); + localAddr (vData.localAddr ); + localName (vData.localName ); break; + case MBluetooth::eIS_Detail_Change : + case MBluetooth::eIS_Detail_Read : + case MBluetooth::eIS_Detail_Write : + case MBluetooth::eIS_Config_Read : + case MBluetooth::eIS_Config_Write : + detailName (vData.detailName ); + detailAddr (vData.detailAddr ); + detailValue (vData.detailValue ); + break; + default: break; } @@ -114,13 +124,18 @@ case MBluetooth::eIS_Service_Detail_Done : message = tr("Service Detail Done" ); break; case MBluetooth::eIS_Service_Done : message = tr("Service Scanning Finished" ); break; + case MBluetooth::eIS_Detail_Change : message = tr("Service Characteristic Changed" ); break; + case MBluetooth::eIS_Detail_Read : message = tr("Service Characteristic Read" ); break; + case MBluetooth::eIS_Detail_Write : message = tr("Service Characteristic Write" ); break; + case MBluetooth::eIS_Config_Read : message = tr("Service Descriptor Read" ); break; + case MBluetooth::eIS_Config_Write : message = tr("Service Descriptor Write" ); break; // IMPORTANT: Do not use the "default:" to let compiler check for all the enumeration which are not handled. } notification(message); // Console Log - message = _deviceAddr + " " + message; + message = _deviceAddr + " " + message + " " + _detailName + " " + _detailValue; message = message.trimmed().simplified(); qDebug().noquote().nospace() << message; Index: sources/view/settings/VBluetooth.h =================================================================== diff -u -r068426e216f9ae5bc4879e4f75bf0f346e33a1ae -rf11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d --- sources/view/settings/VBluetooth.h (.../VBluetooth.h) (revision 068426e216f9ae5bc4879e4f75bf0f346e33a1ae) +++ sources/view/settings/VBluetooth.h (.../VBluetooth.h) (revision f11dd9cd2c07f96d9d939d70ed9c4ce2edef2a9d) @@ -51,6 +51,10 @@ PROPERTY(qint16 , error , 0 ) + PROPERTY(QString , detailAddr , "" ) + PROPERTY(QString , detailName , "" ) + PROPERTY(QString , detailValue , "" ) + VIEW_DEC_CLASS(VBluetooth) VIEW_DEC_SLOT (AdjustSerialNumberHDResponseData)