Skip to content

Commit

Permalink
Merge pull request #285 from jmlich/ubports-phone
Browse files Browse the repository at this point in the history
ubports phone calls
  • Loading branch information
piggz authored Dec 21, 2023
2 parents d2a2608 + f5f7d8f commit c02915f
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 6 deletions.
1 change: 1 addition & 0 deletions clickable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies_target:
- libkf5archive-dev
- libkf5coreaddons-dev
- libdbus-1-dev
- libtelepathy-qt5-dev

libraries:
qtmpris:
Expand Down
8 changes: 8 additions & 0 deletions daemon/daemon.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
14 changes: 11 additions & 3 deletions daemon/src/deviceinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/deviceinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion daemon/src/devices/abstractdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions daemon/src/devices/pinetimejfdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
}
Expand Down
36 changes: 36 additions & 0 deletions daemon/src/services/immediatealertservice.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
30 changes: 30 additions & 0 deletions daemon/src/services/immediatealertservice.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c02915f

Please sign in to comment.