diff --git a/clickable.yaml b/clickable.yaml index 021679b1..4308e62c 100644 --- a/clickable.yaml +++ b/clickable.yaml @@ -22,6 +22,7 @@ dependencies_target: - libkf5archive-dev - libkf5coreaddons-dev - libdbus-1-dev +- libtelepathy-qt5-dev libraries: qtmpris: diff --git a/daemon/daemon.pro b/daemon/daemon.pro index d7369f68..0001ace7 100644 --- a/daemon/daemon.pro +++ b/daemon/daemon.pro @@ -41,6 +41,12 @@ flavor_silica { voicecall \ notificationmonitor \ calendar +} else:flavor_uuitk { + DEFINES += UUITK_EDITION + WATCHFISH_FEATURES += music \ + voicecall \ + notificationmonitor \ + calendar } else { WATCHFISH_FEATURES += music \ notificationmonitor \ @@ -137,6 +143,7 @@ SOURCES += \ src/services/deviceinfoservice.cpp \ src/services/bipfirmwareservice.cpp \ src/services/batteryservice.cpp \ + src/services/immediatealertservice.cpp \ src/operations/abstractoperation.cpp \ src/operations/activityfetchoperation.cpp \ src/operations/logfetchoperation.cpp \ @@ -199,6 +206,7 @@ HEADERS += \ src/services/infinitimeweatherservice.h \ src/services/pinetimemusicservice.h \ src/services/uartservice.h \ + src/services/immediatealertservice.h \ src/typeconversion.h \ src/bipbatteryinfo.h \ src/deviceinterface.h \ diff --git a/daemon/libwatchfish b/daemon/libwatchfish index 772bbb33..39536c2c 160000 --- a/daemon/libwatchfish +++ b/daemon/libwatchfish @@ -1 +1 @@ -Subproject commit 772bbb3375bd9ac4f38b2bb52dcf82f953f76db7 +Subproject commit 39536c2c17763f04762717597a1fb8e5955f8954 diff --git a/daemon/src/deviceinterface.cpp b/daemon/src/deviceinterface.cpp index 71de4240..be494ed6 100644 --- a/daemon/src/deviceinterface.cpp +++ b/daemon/src/deviceinterface.cpp @@ -47,7 +47,7 @@ DeviceInterface::DeviceInterface() connect(&m_notificationMonitor, &watchfish::NotificationMonitor::notification, this, &DeviceInterface::onNotification); // Calls -#ifdef MER_EDITION_SAILFISH +#if defined(MER_EDITION_SAILFISH) || defined(UUITK_EDITION) connect(&m_voiceCallController, &watchfish::VoiceCallController::ringingChanged, this, &DeviceInterface::onRingingChanged); #endif //Weather @@ -178,7 +178,7 @@ void DeviceInterface::onNotification(watchfish::Notification *notification) void DeviceInterface::onRingingChanged() { -#ifdef MER_EDITION_SAILFISH +#if defined(MER_EDITION_SAILFISH) || defined(UUITK_EDITION) qDebug() << Q_FUNC_INFO << m_voiceCallController.ringing(); if (!m_device) { @@ -421,6 +421,11 @@ void DeviceInterface::slot_informationChanged(AbstractDevice::Info key, const QS { qDebug() << Q_FUNC_INFO << key << val; + + if (key == AbstractDevice::INFO_IMMEDIATE_ALERT) { + qWarning() << "Not implemented: Immediate Alert Service" << val; + } + //Handle notification of low battery if (key == AbstractDevice::INFO_BATTERY) { if (val.toInt() != m_lastBatteryLevel) { @@ -471,13 +476,16 @@ void DeviceInterface::deviceEvent(AbstractDevice::Events event) case AbstractDevice::EVENT_APP_MUSIC: musicChanged(); break; -#ifdef MER_EDITION_SAILFISH +#if defined(MER_EDITION_SAILFISH) || defined(UUITK_EDITION) case AbstractDevice::EVENT_IGNORE_CALL: m_voiceCallController.silence(); break; case AbstractDevice::EVENT_DECLINE_CALL: m_voiceCallController.hangup(); break; + case AbstractDevice::EVENT_ANSWER_CALL: + m_voiceCallController.answer(); + break; #endif } } diff --git a/daemon/src/deviceinterface.h b/daemon/src/deviceinterface.h index 6dec20d8..86a06097 100644 --- a/daemon/src/deviceinterface.h +++ b/daemon/src/deviceinterface.h @@ -124,7 +124,7 @@ class DeviceInterface : public QObject //Watchfish watchfish::MusicController m_musicController; -#ifdef MER_EDITION_SAILFISH +#if defined(MER_EDITION_SAILFISH) || defined(UUITK_EDITION) watchfish::VoiceCallController m_voiceCallController; #endif watchfish::NotificationMonitor m_notificationMonitor; diff --git a/daemon/src/devices/abstractdevice.h b/daemon/src/devices/abstractdevice.h index 405c6c53..285dcc15 100644 --- a/daemon/src/devices/abstractdevice.h +++ b/daemon/src/devices/abstractdevice.h @@ -36,7 +36,8 @@ class AbstractDevice : public QBLEDevice INFO_HEARTRATE, INFO_MODEL, INFO_FW_REVISION, - INFO_MANUFACTURER + INFO_MANUFACTURER, + INFO_IMMEDIATE_ALERT }; Q_ENUM(Info) diff --git a/daemon/src/devices/pinetimejfdevice.cpp b/daemon/src/devices/pinetimejfdevice.cpp index 4a05172d..85964d69 100644 --- a/daemon/src/devices/pinetimejfdevice.cpp +++ b/daemon/src/devices/pinetimejfdevice.cpp @@ -7,6 +7,7 @@ #include "dfuservice.h" #include "dfuoperation.h" #include "infinitimenavservice.h" +#include "immediatealertservice.h" #include "hrmservice.h" #include "infinitimemotionservice.h" #include "infinitimeweatherservice.h" @@ -158,6 +159,8 @@ void PinetimeJFDevice::parseServices() addService(AdafruitBleFsService::UUID_SERVICE_FS, new AdafruitBleFsService(path, this, transferMtu)); } else if (uuid == BatteryService::UUID_SERVICE_BATTERY && !service(BatteryService::UUID_SERVICE_BATTERY)) { addService(BatteryService::UUID_SERVICE_BATTERY, new BatteryService(path, this)); + } else if (uuid == ImmediateAlertService::UUID_SERVICE_IMMEDIATE_ALERT && !service(ImmediateAlertService::UUID_SERVICE_IMMEDIATE_ALERT)) { + addService(ImmediateAlertService::UUID_SERVICE_IMMEDIATE_ALERT, new ImmediateAlertService(path, this)); } else if ( !service(uuid)) { addService(uuid, new QBLEService(uuid, path, this)); } diff --git a/daemon/src/services/immediatealertservice.cpp b/daemon/src/services/immediatealertservice.cpp new file mode 100644 index 00000000..eb34f855 --- /dev/null +++ b/daemon/src/services/immediatealertservice.cpp @@ -0,0 +1,36 @@ +#include "immediatealertservice.h" + +const char* ImmediateAlertService::UUID_SERVICE_IMMEDIATE_ALERT = "00001802-0000-1000-8000-00805f9b34fb"; +const char* ImmediateAlertService::UUID_CHARACTERISTIC_IMMEDIATE_ALERT_LEVEL = "00002a06-0000-1000-8000-00805f9b34fb"; + + +ImmediateAlertService::ImmediateAlertService(const QString &path, QObject *parent) : QBLEService(UUID_SERVICE_IMMEDIATE_ALERT, path, parent) +{ + qDebug() << Q_FUNC_INFO; + + connect(this, &QBLEService::characteristicRead, this, &ImmediateAlertService::characteristicRead); +} + +void ImmediateAlertService::refreshInformation() +{ + qDebug() << Q_FUNC_INFO; + + readAsync(UUID_CHARACTERISTIC_IMMEDIATE_ALERT_LEVEL); +} + +void ImmediateAlertService::characteristicRead(const QString &characteristic, const QByteArray &value) +{ + qDebug() << Q_FUNC_INFO << "Read:" << characteristic << value; + if (characteristic == UUID_CHARACTERISTIC_IMMEDIATE_ALERT_LEVEL) { + m_alertLevel = value[0]; + emit informationChanged(AbstractDevice::INFO_IMMEDIATE_ALERT, QString::number(m_alertLevel)); + } else { + qWarning() << "Unknown value"; + } +} + +int ImmediateAlertService::alertLevel() const +{ + qDebug() << Q_FUNC_INFO << m_alertLevel; + return m_alertLevel; +} diff --git a/daemon/src/services/immediatealertservice.h b/daemon/src/services/immediatealertservice.h new file mode 100644 index 00000000..83d8fa15 --- /dev/null +++ b/daemon/src/services/immediatealertservice.h @@ -0,0 +1,30 @@ +#ifndef IMMEDIATE_ALERT_SERVICE_H +#define IMMEDIATE_ALERT_SERVICE_H + +#include "qble/qbleservice.h" +#include "devices/abstractdevice.h" + +// https://www.bluetooth.com/specifications/specs/immediate-alert-service-1-0/ + +class ImmediateAlertService : public QBLEService +{ + Q_OBJECT +public: + ImmediateAlertService(const QString &path, QObject *parent); + + static const char* UUID_SERVICE_IMMEDIATE_ALERT; + static const char* UUID_CHARACTERISTIC_IMMEDIATE_ALERT_LEVEL; + enum class Levels : uint8_t { NoAlert = 0, MildAlert = 1, HighAlert = 2 }; + + Q_INVOKABLE void refreshInformation(); + + int alertLevel() const; + + Q_SIGNAL void informationChanged(AbstractDevice::Info key, const QString &val); + +private: + int m_alertLevel; + Q_SLOT void characteristicRead(const QString &c, const QByteArray &value); +}; + +#endif // IMMEDIATE_ALERT_SERVICE_H