// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #ifndef PUREPHONE_SERVICECELLULAR_HPP #define PUREPHONE_SERVICECELLULAR_HPP #include // for DLC_channel::Callback_t, DLC_channel #include // for TS0710 #include // for Service #include #include // for uint32_t #include // for optional #include // for unique_ptr, allocator, make_unique, shared_ptr #include // for string #include // for vector #include "CellularCall.hpp" // for CellularCall #include "USSD.hpp" // for State, State::none #include "SMSRecord.hpp" // for SMSRecord #include "messages/CellularMessage.hpp" // for CellularUSSDMessage, CellularUSSDMessage::RequestType #include "State.hpp" // for State #include "bsp/common.hpp" // for Board, Board::none #include "Modem/TS0710/TS0710_types.h" // for PS460800, PortSpeed_e #include "Service/Common.hpp" // for ReturnCodes, ServicePowerMode #include "Service/Message.hpp" // for Message_t, DataMessage (ptr only), ResponseMessage (ptr only) class MuxDaemon; namespace db { namespace query { class SMSSearchByTypeResult; } // namespace query } // namespace db namespace sys { class Timer; } // namespace sys class ServiceCellular : public sys::Service { public: ServiceCellular(); ~ServiceCellular() override; sys::Message_t DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp = nullptr) override; // Invoked during initialization sys::ReturnCodes InitHandler() override; sys::ReturnCodes DeinitHandler() override; sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final; /** Register message handlers. */ void registerMessageHandlers(); static const char *serviceName; bool sendSMS(SMSRecord record); bool receiveSMS(std::string messageNumber); /** * @brief Its getting selected SIM card own number. * @param destination Reference to destination string. * @return true when succeed, false when fails */ bool getOwnNumber(std::string &destination); /** * @brief Its getting IMSI from selected SIM card. * @param fullNumber Its returning full IMSI number when fullNumber is true, otherwise its returning only country * identification number * @param destination Reference to destination string. * @return true when succeed, false when fails */ bool getIMSI(std::string &destination, bool fullNumber = false); std::vector getNetworkInfo(void); std::vector scanOperators(void); private: std::unique_ptr cmux = std::make_unique(PortSpeed_e::PS460800, this); // used for polling for call state std::unique_ptr callStateTimer; std::unique_ptr stateTimer; std::unique_ptr ussdTimer; void CallStateTimerHandler(); DLC_channel::Callback_t notificationCallback = nullptr; cellular::State state; bsp::Board board = bsp::Board::none; /// URC GSM notification handler std::optional> identifyNotification(const std::string &data); std::vector messageParts; CellularCall::CellularCall ongoingCall; ussd::State ussdState = ussd::State::none; enum class ResetType { SoftReset, // bool; // ussd handlers uint32_t ussdTimeout = 0; bool handleUSSDRequest(CellularUSSDMessage::RequestType requestType, const std::string &request = ""); bool handleUSSDURC(void); void handleUSSDTimer(void); }; #endif // PUREPHONE_SERVICECELLULAR_HPP