From e961484331dcbe00d291fff79f440851743d2aa6 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Tue, 9 Jul 2019 09:12:35 +0200 Subject: [PATCH] WiP: cellular service API --- .../Modem/NotificationMuxChannel.cpp | 4 +-- .../service-cellular/ServiceCellular.cpp | 11 +++--- .../api/CellularServiceAPI.cpp | 12 +++++++ .../api/CellularServiceAPI.hpp | 23 ++++++++++++ .../messages/CellularMessage.hpp | 35 ++++++++++++++++++- source/MessageType.hpp | 3 ++ 6 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 module-services/service-cellular/api/CellularServiceAPI.cpp create mode 100644 module-services/service-cellular/api/CellularServiceAPI.hpp diff --git a/module-cellular/Modem/NotificationMuxChannel.cpp b/module-cellular/Modem/NotificationMuxChannel.cpp index b11df410f..7eb8ce1e0 100644 --- a/module-cellular/Modem/NotificationMuxChannel.cpp +++ b/module-cellular/Modem/NotificationMuxChannel.cpp @@ -51,13 +51,13 @@ int NotificationMuxChannel::ParseInputData(uint8_t* data, size_t size) { // Received new SMS if (msgStr.find("+CMTI: ") != std::string::npos) { LOG_TRACE((name + ": received new SMS notification").c_str()); - notificationCallback(NotificationType::NewIncomingSMS,"dummy");// TODO:M.P add SMS nr parsing + notificationCallback(NotificationType::NewIncomingSMS,"888777333");// TODO:M.P add SMS nr parsing } // Received signal strength change if (msgStr.find("+QIND: \"csq\"") != std::string::npos) { LOG_TRACE((name + ": received signal strength change notification").c_str()); - notificationCallback(NotificationType::SignalStrengthUpdate,"dummy");// TODO:M.P add signal strength parsing + notificationCallback(NotificationType::SignalStrengthUpdate,"55");// TODO:M.P add signal strength parsing } return 0; diff --git a/module-services/service-cellular/ServiceCellular.cpp b/module-services/service-cellular/ServiceCellular.cpp index c45bdc5f3..1e81a46f8 100644 --- a/module-services/service-cellular/ServiceCellular.cpp +++ b/module-services/service-cellular/ServiceCellular.cpp @@ -17,6 +17,8 @@ #include "MessageType.hpp" +#include "messages/CellularMessage.hpp" + const char *ServiceCellular::serviceName = "ServiceCellular"; @@ -24,17 +26,14 @@ ServiceCellular::ServiceCellular() : sys::Service(serviceName, 1024 * 4, sys::ServicePriority::Idle) { LOG_INFO("[ServiceCellular] Initializing"); - - busChannels.push_back(sys::BusChannels::ServiceCellularNotifications); - testTimerID = CreateTimer(3000,true); ReloadTimer(testTimerID); - muxdaemon = MuxDaemon::Create([](NotificationType type, std::string resp){ + muxdaemon = MuxDaemon::Create([this](NotificationType type, std::string resp){ - std:: + auto msg = std::make_shared(static_cast(type),resp); - sys::Bus::SendMulticast() + sys::Bus::SendMulticast(msg,sys::BusChannels::ServiceCellularNotifications,this); }); diff --git a/module-services/service-cellular/api/CellularServiceAPI.cpp b/module-services/service-cellular/api/CellularServiceAPI.cpp new file mode 100644 index 000000000..3a6bc15f3 --- /dev/null +++ b/module-services/service-cellular/api/CellularServiceAPI.cpp @@ -0,0 +1,12 @@ +/* + * @file CellularServiceAPI.cpp + * @author Mateusz Piesta (mateusz.piesta@mudita.com) + * @date 09.07.19 + * @brief + * @copyright Copyright (C) 2019 mudita.com + * @details + */ + + + +#include "CellularServiceAPI.hpp" diff --git a/module-services/service-cellular/api/CellularServiceAPI.hpp b/module-services/service-cellular/api/CellularServiceAPI.hpp new file mode 100644 index 000000000..331729564 --- /dev/null +++ b/module-services/service-cellular/api/CellularServiceAPI.hpp @@ -0,0 +1,23 @@ +/* + * @file CellularServiceAPI.hpp + * @author Mateusz Piesta (mateusz.piesta@mudita.com) + * @date 09.07.19 + * @brief + * @copyright Copyright (C) 2019 mudita.com + * @details + */ + + + +#ifndef PUREPHONE_CELLULARSERVICEAPI_HPP +#define PUREPHONE_CELLULARSERVICEAPI_HPP + + + + +class CellularServiceAPI { + +}; + + +#endif //PUREPHONE_CELLULARSERVICEAPI_HPP diff --git a/module-services/service-cellular/messages/CellularMessage.hpp b/module-services/service-cellular/messages/CellularMessage.hpp index 9820ca56b..ec14557d4 100644 --- a/module-services/service-cellular/messages/CellularMessage.hpp +++ b/module-services/service-cellular/messages/CellularMessage.hpp @@ -12,8 +12,41 @@ #ifndef PUREPHONE_CELLULARMESSAGE_HPP #define PUREPHONE_CELLULARMESSAGE_HPP +#include +#include "Service/Message.hpp" +#include "MessageType.hpp" -class CellularMessage { + +class CellularMessage : public sys::DataMessage { +public: + CellularMessage(MessageType messageType) : sys::DataMessage(static_cast(messageType)), + type(messageType) {}; + + virtual ~CellularMessage() {}; + + MessageType type; + +}; + +class CellularNotificationMessage : public CellularMessage { +public: + + enum class Type { + IncomingCall, + CallAborted, + NewIncomingSMS, + SignalStrengthUpdate + + }; + + + CellularNotificationMessage(Type type, const std::string &data) : CellularMessage( + MessageType::CellularNotification), type(type), data(data) {} + + ~CellularNotificationMessage() {} + + Type type; + std::string data; }; diff --git a/source/MessageType.hpp b/source/MessageType.hpp index 78f4740ff..2d28ecfcf 100644 --- a/source/MessageType.hpp +++ b/source/MessageType.hpp @@ -45,6 +45,9 @@ enum class MessageType { DBContactGetLimitOffset, // Get contact records by limit,offset DBContactGetCount, // Get contacts count + //Cellular messages + CellularNotification, + //application manager APMSwitch, //request to switch to given application, optionally also to specified window