M module-cellular/at/cmd/src/CLCC.cpp => module-cellular/at/cmd/src/CLCC.cpp +0 -1
@@ 5,7 5,6 @@
#include <memory>
#include <string>
#include <string_view>
-#include <service-cellular/call/CellularCall.hpp>
namespace at
{
M module-services/service-cellular/CMakeLists.txt => module-services/service-cellular/CMakeLists.txt +3 -6
@@ 5,7 5,6 @@ set(SOURCES
src/ServiceCellularPriv.cpp
src/State.cpp
src/SimCard.cpp
- src/CallManager.cpp
src/NetworkTime.cpp
src/SimContacts.cpp
src/SMSPartsHandler.cpp
@@ 16,11 15,6 @@ set(SOURCES
src/URCCounter.cpp
src/CSQHandler.cpp
- call/CellularCall.cpp
- call/CallAudio.cpp
- call/CallGUI.cpp
- call/CallDB.cpp
- call/CallRingGuard.cpp
CellularServiceAPI.cpp
CellularUrcHandler.cpp
checkSmsCenter.cpp
@@ 59,6 53,8 @@ target_include_directories(${PROJECT_NAME}
${CMAKE_CURRENT_LIST_DIR}/src
)
+add_subdirectory(call)
+
target_link_libraries(${PROJECT_NAME}
PRIVATE
Microsoft.GSL::GSL
@@ 72,6 68,7 @@ target_link_libraries(${PROJECT_NAME}
json::json
utils-time
PUBLIC
+ service-cellular-call
eventstore
utf8
hal
M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +9 -33
@@ 4,7 4,6 @@
#include "endpoints/developerMode/event/ATRequest.hpp"
#include "handler/RawATHandler.hpp"
#include "CellularUrcHandler.hpp"
-#include "service-cellular/call/CellularCall.hpp"
#include "service-cellular/CellularMessage.hpp"
#include "service-cellular/CellularServiceAPI.hpp"
#include "service-cellular/ServiceCellular.hpp"
@@ 492,11 491,6 @@ void ServiceCellular::registerMessageHandlers()
return handleCellularRingingMessage(msg);
});
- connect(typeid(CellularCallerIdMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto msg = static_cast<CellularCallerIdMessage *>(request);
- return handleCellularCallerIdMessage(msg);
- });
-
connect(typeid(CellularGetIMSIMessage),
[&](sys::Message *request) -> sys::MessagePointer { return handleCellularGetIMSIMessage(request); });
@@ 1857,7 1851,6 @@ void ServiceCellular::handleCellularHangupCallMessage(CellularHangupCallMessage
auto channel = cmux->get(CellularMux::Channel::Commands);
if (channel) {
if (channel->cmd(at::AT::ATH)) {
- callManager.hangUp();
callStateTimer.stop();
callEndedRecentlyTimer.start();
if (!ongoingCall.endCall(CellularCall::Forced::True)) {
@@ 1946,17 1939,6 @@ auto ServiceCellular::handleCellularRingingMessage(CellularRingingMessage *msg)
return std::make_shared<CellularResponseMessage>(ongoingCall.startOutgoing(msg->number));
}
-auto ServiceCellular::handleCellularCallerIdMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
-{
- auto message = static_cast<CellularCallerIdMessage *>(msg);
- if (not ongoingCall.handleCLIP(message->number)) {
- CellularServiceAPI::DismissCall(
- this, phoneModeObserver->getCurrentPhoneMode() == sys::phone_modes::PhoneMode::DoNotDisturb);
- }
-
- return sys::MessageNone{};
-}
-
auto ServiceCellular::handleCellularGetIMSIMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
{
std::string temp;
@@ 2143,8 2125,10 @@ auto ServiceCellular::handleCallActiveNotification(sys::Message *msg) -> std::sh
auto ServiceCellular::handleCallAbortedNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
{
callStateTimer.stop();
- auto ret = ongoingCall.endCall();
- callManager.hangUp();
+ const auto ret = ongoingCall.endCall();
+ if (not ret) {
+ LOG_ERROR("failed to end call");
+ }
return std::make_shared<CellularResponseMessage>(ret);
}
auto ServiceCellular::handlePowerUpProcedureCompleteNotification(sys::Message *msg)
@@ 2219,14 2203,6 @@ auto ServiceCellular::handleCellularRingNotification(sys::Message *msg) -> std::
}
ongoingCall.handleRING();
- /// NOTE: the code below should be investigated as there is something weird in this flow
- /// most probably should be done on not dropped clip/ring
- /// please see that in this case we lock antena, which makes sense when call is in progress
- if (!callManager.isIncomingCallPropagated()) {
- bus.sendMulticast(std::make_shared<CellularIncominCallMessage>(),
- sys::BusChannel::ServiceCellularNotifications);
- callManager.ring();
- }
return std::make_shared<CellularResponseMessage>(true);
}
@@ 2242,11 2218,11 @@ auto ServiceCellular::handleCellularCallerIdNotification(sys::Message *msg) -> s
return std::make_shared<CellularResponseMessage>(hangUpCallBusy());
}
- if (!callManager.isCallerInfoComplete()) {
- bus.sendMulticast(std::make_shared<CellularCallerIdMessage>(message->getNubmer()),
- sys::BusChannel::ServiceCellularNotifications);
- callManager.completeCallerInfo();
+ if (not ongoingCall.handleCLIP(message->getNubmer())) {
+ CellularServiceAPI::DismissCall(
+ this, phoneModeObserver->getCurrentPhoneMode() == sys::phone_modes::PhoneMode::DoNotDisturb);
}
+
return std::make_shared<CellularResponseMessage>(true);
}
@@ 2268,7 2244,7 @@ auto ServiceCellular::hangUpCall() -> bool
auto channel = cmux->get(CellularMux::Channel::Commands);
if (channel != nullptr) {
if (channel->cmd(at::factory(at::AT::ATH))) {
- callManager.hangUp();
+ ongoingCall.endCall();
return true;
}
}
A module-services/service-cellular/call/CMakeLists.txt => module-services/service-cellular/call/CMakeLists.txt +26 -0
@@ 0,0 1,26 @@
+project(service-cellular-call)
+message( "${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}" )
+
+add_library(${PROJECT_NAME} STATIC
+ CellularCall.cpp
+ CallAudio.cpp
+ CallGUI.cpp
+ CallDB.cpp
+ CallMulticast.cpp
+ CallRingGuard.cpp
+)
+
+target_include_directories(${PROJECT_NAME}
+ PUBLIC
+ ./include/
+)
+
+target_link_libraries(${PROJECT_NAME}
+ PRIVATE
+ module-sys
+ )
+
+# uncomment to add tests:
+# if (${ENABLE_TESTS})
+# add_subdirectory(tests)
+# endif ()
A module-services/service-cellular/call/CallMulticast.cpp => module-services/service-cellular/call/CallMulticast.cpp +18 -0
@@ 0,0 1,18 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "CallMulticast.hpp"
+#include "service-cellular/CellularMessage.hpp"
+#include <Service/Service.hpp>
+
+void CallMulticast::notifyIncommingCall()
+{
+ owner.bus.sendMulticast(std::make_shared<CellularIncominCallMessage>(),
+ sys::BusChannel::ServiceCellularNotifications);
+}
+
+void CallMulticast::notifyIdentifiedCall(const utils::PhoneNumber::View &number)
+{
+ owner.bus.sendMulticast(std::make_shared<CellularCallerIdMessage>(number),
+ sys::BusChannel::ServiceCellularNotifications);
+}
A module-services/service-cellular/call/CallMulticast.hpp => module-services/service-cellular/call/CallMulticast.hpp +22 -0
@@ 0,0 1,22 @@
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <PhoneNumber.hpp>
+
+namespace sys
+{
+ class Service;
+}
+
+class CallMulticast
+{
+ sys::Service &owner;
+
+ public:
+ explicit CallMulticast(sys::Service &owner) : owner(owner)
+ {}
+ void notifyIncommingCall();
+ void notifyIdentifiedCall(const utils::PhoneNumber::View &number);
+};
M module-services/service-cellular/call/CallRingGuard.cpp => module-services/service-cellular/call/CallRingGuard.cpp +1 -1
@@ 2,7 2,7 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "CallRingGuard.hpp"
-#include "service-cellular/call/CellularCall.hpp"
+#include "call/CellularCall.hpp"
bool callRingGuard(CellularCall::Call &call)
{
M module-services/service-cellular/call/CellularCall.cpp => module-services/service-cellular/call/CellularCall.cpp +4 -2
@@ 1,7 1,7 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "service-cellular/call/CellularCall.hpp"
+#include "call/CellularCall.hpp"
#include "service-cellular/call/CallRingGuard.hpp"
#include "service-cellular/ServiceCellular.hpp"
#include "service-db/agents/settings/SystemSettings.hpp"
@@ 22,7 22,7 @@
namespace CellularCall
{
- Call::Call(ServiceCellular &owner) : owner(owner), audio(owner), gui(owner), db(owner)
+ Call::Call(ServiceCellular &owner) : owner(owner), audio(owner), multicast(owner), gui(owner), db(owner)
{
utils::PhoneNumber::View number = utils::PhoneNumber::View();
const CallType type = CallType::CT_NONE;
@@ 47,6 47,7 @@ namespace CellularCall
if (!wasRinging) {
wasRinging = true;
gui.notifyRING();
+ multicast.notifyIncommingCall();
}
return true;
}
@@ 65,6 66,7 @@ namespace CellularCall
if (!isNumberDisplayed) {
isNumberDisplayed = true;
gui.notifyCLIP(number);
+ multicast.notifyIdentifiedCall(number);
}
return true;
}
A module-services/service-cellular/call/README.md => module-services/service-cellular/call/README.md +10 -0
@@ 0,0 1,10 @@
+Encapsulated cellular call processing
+=====================================
+
+This library's goal is to encapsulate the whole call flow/flows we can have.
+It's end goal is to provide: actions and guards to write call state machine to asure full control over call processing.
+
+# library organisation
+
+Public api headers should be placed in `include/call/` catalog - these are exported in cmake to include paths for related libraries
+All other headers should **not** be placed there. These are private internals of the library
R module-services/service-cellular/service-cellular/call/CellularCall.hpp => module-services/service-cellular/call/include/call/CellularCall.hpp +2 -0
@@ 6,6 6,7 @@
#include "call/CallAudio.hpp"
#include "call/CallGUI.hpp"
#include "call/CallDB.hpp"
+#include "call/CallMulticast.hpp"
#include "PhoneModes/PhoneMode.hpp"
#include <service-cellular/CellularMessage.hpp>
#include <Interface/CalllogRecord.hpp>
@@ 70,6 71,7 @@ namespace CellularCall
ServiceCellular &owner;
CallRingAudio audio;
+ CallMulticast multicast;
CallGUI gui;
CallDB db;
M module-services/service-cellular/service-cellular/ServiceCellular.hpp => module-services/service-cellular/service-cellular/ServiceCellular.hpp +1 -3
@@ 3,12 3,11 @@
#pragma once
-#include "call/CellularCall.hpp"
+#include <call/CellularCall.hpp>
#include "CellularMessage.hpp"
#include "USSD.hpp"
#include "PacketData.hpp"
#include "PacketDataCellularMessage.hpp"
-#include "src/CallManager.hpp"
#include <service-cellular/connection-manager/ConnectionManager.hpp>
#include "src/URCCounter.hpp"
@@ 318,7 317,6 @@ class ServiceCellular : public sys::Service
auto tetheringTurnOnURC() -> bool;
auto logTetheringCalls() -> void;
std::unique_ptr<cellular::internal::ServiceCellularPriv> priv;
- cellular::internal::SimpleCallManager callManager;
TaskHandle_t getTaskHandle();
};
D module-services/service-cellular/src/CallManager.cpp => module-services/service-cellular/src/CallManager.cpp +0 -33
@@ 1,33 0,0 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#include "CallManager.hpp"
-
-namespace cellular::internal
-{
- void SimpleCallManager::hangUp() noexcept
- {
- incomingCallPropagated = false;
- callerInfoComplete = false;
- }
-
- void SimpleCallManager::ring() noexcept
- {
- incomingCallPropagated = true;
- }
-
- void SimpleCallManager::completeCallerInfo() noexcept
- {
- callerInfoComplete = true;
- }
-
- auto SimpleCallManager::isIncomingCallPropagated() const noexcept -> bool
- {
- return incomingCallPropagated;
- }
-
- auto SimpleCallManager::isCallerInfoComplete() const noexcept -> bool
- {
- return callerInfoComplete;
- }
-} // namespace cellular::internal
D module-services/service-cellular/src/CallManager.hpp => module-services/service-cellular/src/CallManager.hpp +0 -22
@@ 1,22 0,0 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#pragma once
-
-namespace cellular::internal
-{
- class SimpleCallManager
- {
- public:
- void hangUp() noexcept;
- void ring() noexcept;
- void completeCallerInfo() noexcept;
-
- [[nodiscard]] auto isIncomingCallPropagated() const noexcept -> bool;
- [[nodiscard]] auto isCallerInfoComplete() const noexcept -> bool;
-
- private:
- bool incomingCallPropagated{false};
- bool callerInfoComplete{false};
- };
-} // namespace cellular::internal