M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +53 -46
@@ 28,6 28,7 @@
#include <service-appmgr/Controller.hpp>
#include <service-cellular/ServiceCellular.hpp>
#include <service-cellular/CellularMessage.hpp>
+#include <service-cellular-api>
#include <service-db/QueryMessage.hpp>
#include <module-services/service-db/agents/settings/SystemSettings.hpp>
#include <module-utils/magic_enum/include/magic_enum.hpp>
@@ 73,13 74,13 @@ namespace app
addActionReceiver(app::manager::actions::RequestPinDisable, [this](auto &&data) {
lockHandler.handlePinEnableRequest(std::forward<decltype(data)>(data),
- CellularSimCardLockDataMessage::SimCardLock::Unlocked);
+ cellular::api::SimLockState::Disabled);
return actionHandled();
});
addActionReceiver(app::manager::actions::RequestPinEnable, [this](auto &&data) {
lockHandler.handlePinEnableRequest(std::forward<decltype(data)>(data),
- CellularSimCardLockDataMessage::SimCardLock::Locked);
+ cellular::api::SimLockState::Enabled);
return actionHandled();
});
@@ 214,7 215,7 @@ namespace app
auto ApplicationDesktop::handle(cellular::StateChange *msg) -> bool
{
assert(msg);
- if (msg->request == cellular::State::ST::URCReady) {
+ if (msg->request == cellular::service::State::ST::URCReady) {
if (need_sim_select && !lockHandler.isScreenLocked()) {
manager::Controller::sendAction(this, manager::actions::SelectSimCard);
return true;
@@ 223,7 224,7 @@ namespace app
bus.sendUnicast(std::make_shared<CellularSimProcedureMessage>(), ServiceCellular::serviceName);
}
}
- if (msg->request == cellular::State::ST::ModemFatalFailure) {
+ if (msg->request == cellular::service::State::ST::ModemFatalFailure) {
switchWindow(app::window::name::desktop_reboot);
}
return false;
@@ 277,48 278,54 @@ namespace app
}});
};
- connect(typeid(CellularSimNewPinResponseMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto response = dynamic_cast<CellularSimNewPinResponseMessage *>(request);
- if (response->retCode) {
- auto metaData = createPinChangedSuccessfullyDialog(this);
- switchWindow(gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
- }
- else {
- lockHandler.handlePinChangeRequestFailed();
- }
- return sys::MessageNone{};
- });
-
- connect(typeid(CellularSimPukResponseMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto response = dynamic_cast<CellularSimPukResponseMessage *>(request);
- if (response->retCode) {
- auto metaData = createPinChangedSuccessfullyDialog(this);
- switchWindow(gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
- }
- return sys::MessageNone{};
- });
-
- connect(typeid(CellularSimCardLockResponseMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto response = dynamic_cast<CellularSimCardLockResponseMessage *>(request);
- if (response->retCode) {
- auto metaData = std::make_unique<gui::DialogMetadataMessage>(gui::DialogMetadata{
- "",
- "success_icon_W_G",
- response->getSimCardLock() == CellularSimCardLockDataMessage::SimCardLock::Unlocked
- ? utils::translate("app_desktop_sim_card_unlocked")
- : utils::translate("app_desktop_sim_card_locked"),
- "",
- [this]() {
- switchWindow(app::window::name::desktop_main_window);
- return true;
- }});
- switchWindow(gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
- }
- else {
- lockHandler.handlePinEnableRequestFailed(response->getSimCardLock());
- }
- return sys::MessageNone{};
- });
+ connect(typeid(cellular::msg::request::sim::ChangePin::Response),
+ [&](sys::Message *request) -> sys::MessagePointer {
+ auto response = dynamic_cast<cellular::msg::request::sim::ChangePin::Response *>(request);
+ if (response->retCode) {
+ auto metaData = createPinChangedSuccessfullyDialog(this);
+ switchWindow(
+ gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
+ }
+ else {
+ lockHandler.handlePinChangeRequestFailed();
+ }
+ return sys::MessageNone{};
+ });
+
+ connect(typeid(cellular::msg::request::sim::UnblockWithPuk::Response),
+ [&](sys::Message *request) -> sys::MessagePointer {
+ auto response = dynamic_cast<cellular::msg::request::sim::UnblockWithPuk::Response *>(request);
+ if (response->retCode) {
+ auto metaData = createPinChangedSuccessfullyDialog(this);
+ switchWindow(
+ gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
+ }
+ return sys::MessageNone{};
+ });
+
+ connect(typeid(cellular::msg::request::sim::SetPinLock::Response),
+ [&](sys::Message *request) -> sys::MessagePointer {
+ auto response = dynamic_cast<cellular::msg::request::sim::SetPinLock::Response *>(request);
+ if (response->retCode) {
+ auto metaData = std::make_unique<gui::DialogMetadataMessage>(
+ gui::DialogMetadata{"",
+ "success_icon_W_G",
+ response->lock == cellular::api::SimLockState::Disabled
+ ? utils::translate("app_desktop_sim_card_unlocked")
+ : utils::translate("app_desktop_sim_card_locked"),
+ "",
+ [this]() {
+ switchWindow(app::window::name::desktop_main_window);
+ return true;
+ }});
+ switchWindow(
+ gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
+ }
+ else {
+ lockHandler.handlePinEnableRequestFailed(response->lock);
+ }
+ return sys::MessageNone{};
+ });
connect(typeid(db::NotificationMessage), [&](sys::Message *request) {
auto notificationMessage = static_cast<db::NotificationMessage *>(request);
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +23 -15
@@ 58,6 58,7 @@
#include <service-evtmgr/EventManagerServiceAPI.hpp>
#include <service-cellular/CellularServiceAPI.hpp>
+#include <service-cellular-api>
#include <service-bluetooth/BluetoothMessage.hpp>
#include <service-bluetooth/Constants.hpp>
#include <service-bluetooth/messages/Status.hpp>
@@ 121,13 122,6 @@ namespace app
}
if (auto phoneMsg = dynamic_cast<CellularNotificationMessage *>(msgl); nullptr != phoneMsg) {
- selectedSim = Store::GSM::get()->selected;
- if (CellularNotificationMessage::Content::SIM_READY == phoneMsg->content) {
- CellularServiceAPI::RequestForOwnNumber(this);
- }
- else if (CellularNotificationMessage::Content::SIM_NOT_READY == phoneMsg->content) {
- selectedSimNumber = {};
- }
auto currentWindow = getCurrentWindow();
if (gui::window::name::network == currentWindow->getName()) {
updateWindow(gui::window::name::network, nullptr);
@@ 153,6 147,21 @@ namespace app
if (ret != sys::ReturnCodes::Success) {
return ret;
}
+ connect(typeid(cellular::msg::notification::SimReady), [&](sys::Message *msg) {
+ auto simReadyMsg = static_cast<cellular::msg::notification::SimReady *>(msg);
+ selectedSim = Store::GSM::get()->selected;
+ if (simReadyMsg->ready) {
+ CellularServiceAPI::RequestForOwnNumber(this);
+ }
+ else {
+ selectedSimNumber = {};
+ }
+ auto currentWindow = getCurrentWindow();
+ if (gui::window::name::network == currentWindow->getName()) {
+ updateWindow(gui::window::name::network, nullptr);
+ }
+ return sys::MessageNone{};
+ });
connect(typeid(::message::bluetooth::ResponseStatus), [&](sys::Message *msg) {
auto responseStatusMsg = static_cast<::message::bluetooth::ResponseStatus *>(msg);
@@ 271,13 280,11 @@ namespace app
return sys::MessageNone{};
});
- connect(typeid(CellularSimCardPinLockStateResponseDataMessage), [&](sys::Message *msg) {
- auto simCardPinLockState = dynamic_cast<CellularSimCardPinLockStateResponseDataMessage *>(msg);
- if (simCardPinLockState != nullptr) {
- auto pinSettingsLockStateData =
- std::make_unique<gui::PINSettingsLockStateData>(simCardPinLockState->getSimCardPinLockState());
- updateWindow(gui::window::name::pin_settings, std::move(pinSettingsLockStateData));
- }
+ connect(typeid(cellular::msg::request::sim::GetLockState::Response), [&](sys::Message *msg) {
+ auto simCardPinLockState = static_cast<cellular::msg::request::sim::GetLockState::Response *>(msg);
+ auto pinSettingsLockStateData =
+ std::make_unique<gui::PINSettingsLockStateData>(simCardPinLockState->locked);
+ updateWindow(gui::window::name::pin_settings, std::move(pinSettingsLockStateData));
return sys::MessageNone{};
});
@@ 509,7 516,8 @@ namespace app
void ApplicationSettingsNew::setSim(Store::GSM::SIM sim)
{
- CellularServiceAPI::SetSimCard(this, sim);
+ auto arg = (sim == Store::GSM::SIM::SIM2) ? cellular::api::SimSlot::SIM2 : cellular::api::SimSlot::SIM1;
+ bus.sendUnicast<cellular::msg::request::sim::SetActiveSim>(arg);
}
Store::GSM::SIM ApplicationSettingsNew::getSim()
M module-apps/application-settings-new/windows/PINSettingsWindow.cpp => module-apps/application-settings-new/windows/PINSettingsWindow.cpp +3 -2
@@ 8,13 8,14 @@
#include "OptionSetting.hpp"
#include <service-appmgr/Controller.hpp>
-#include "service-cellular/CellularServiceAPI.hpp"
+#include <service-appmgr/service-appmgr/data/SimActionsParams.hpp>
+#include <service-cellular-api>
namespace gui
{
PINSettingsWindow::PINSettingsWindow(app::Application *app) : BaseSettingsWindow(app, window::name::pin_settings)
{
- CellularServiceAPI::RequestSimCardPinLockState(app);
+ app->bus.sendUnicast<cellular::msg::request::sim::GetLockState>();
}
void PINSettingsWindow::onBeforeShow(ShowMode /*mode*/, SwitchData *data)
M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +3 -2
@@ 21,7 21,7 @@
#include "ApplicationSettings.hpp"
#include "service-cellular/ServiceCellular.hpp"
-#include <service-cellular/CellularServiceAPI.hpp>
+#include <service-cellular-api>
#include "windows/SettingsMainWindow.hpp"
#include "windows/SimSelectWindow.hpp"
#include "windows/CellularPassthroughWindow.hpp"
@@ 164,7 164,8 @@ namespace app
void ApplicationSettings::setSim(Store::GSM::SIM sim)
{
- CellularServiceAPI::SetSimCard(this, sim);
+ auto arg = (sim == Store::GSM::SIM::SIM2) ? cellular::api::SimSlot::SIM2 : cellular::api::SimSlot::SIM1;
+ bus.sendUnicast<cellular::msg::request::sim::SetActiveSim>(arg);
}
void ApplicationSettings::timeDateChanged(std::string value)
M module-apps/locks/handlers/PinLockHandler.cpp => module-apps/locks/handlers/PinLockHandler.cpp +32 -30
@@ 10,6 10,9 @@
#include <service-appmgr/service-appmgr/data/SimActionsParams.hpp>
#include <service-desktop/Constants.hpp>
+#include <service-cellular/CellularMessage.hpp>
+#include <service-cellular-api>
+
namespace gui
{
namespace
@@ 67,27 70,27 @@ namespace gui
LOG_DEBUG("Handling RequestPinChange action");
handlePasscodeParams(Lock::LockType::SimPin, Lock::LockState::InputRequired, std::move(data));
promptSimLockWindow = true;
- auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) {
handlePasscodeChange(data);
};
switchToPinLockWindow(onActivatedCallback);
}
void PinLockHandler::handlePinEnableRequest(app::manager::actions::ActionParamsPtr &&data,
- CellularSimCardLockDataMessage::SimCardLock simCardLock)
+ cellular::api::SimLockState simCardLock)
{
+ using namespace cellular::msg;
+ using namespace cellular::api;
LOG_DEBUG("Handling PinEnableRequest action, simCardLock = %d", static_cast<int>(simCardLock));
handlePasscodeParams(Lock::LockType::SimPin, Lock::LockState::InputRequired, std::move(data));
promptSimLockWindow = true;
- auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const std::vector<unsigned int> &data) {
- app->bus.sendUnicast(
- std::make_shared<CellularSimCardLockDataMessage>(Store::GSM::get()->selected, simCardLock, data),
- serviceCellular);
+ auto onActivatedCallback = [this, simCardLock](Lock::LockType, const cellular::api::SimCode &data) {
+ app->bus.sendUnicast<request::sim::SetPinLock>(simCardLock, data);
};
switchToPinLockWindow(onActivatedCallback);
}
- void PinLockHandler::handlePinEnableRequestFailed(CellularSimCardLockDataMessage::SimCardLock simCardLock)
+ void PinLockHandler::handlePinEnableRequestFailed(cellular::api::SimLockState simCardLock)
{
LOG_DEBUG("Handling PinEnableRequestFailed action, simCardLock = %d, simLock.value = %u",
static_cast<int>(simCardLock),
@@ 101,7 104,7 @@ namespace gui
}
if (simLock.attemptsLeft > 0) {
simLock.lockState = Lock::LockState::InputInvalid;
- auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const cellular::api::SimCode &data) {
auto params = std::make_unique<PasscodeParams>(
Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName);
handlePinEnableRequest(std::move(params), simCardLock);
@@ 127,7 130,7 @@ namespace gui
}
if (simLock.attemptsLeft > 0) {
simLock.lockState = Lock::LockState::InputInvalid;
- auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) {
auto params = std::make_unique<PasscodeParams>(
Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName);
handlePinChangeRequest(std::move(params));
@@ 169,7 172,7 @@ namespace gui
auto params = static_cast<app::manager::actions::UnhandledCMEParams *>(data.get());
auto lock = std::make_unique<gui::Lock>(
params->getSim(), Lock::LockState::ErrorOccurred, Lock::LockType::SimPin, params->getCMECode());
- lock->onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
+ lock->onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) {
app->switchWindow(app::window::name::desktop_main_window);
};
app->switchWindow(
@@ 177,18 180,18 @@ namespace gui
}
void PinLockHandler::switchToPinLockWindow(
- std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
+ std::function<void(Lock::LockType, const cellular::api::SimCode &)> onLockActivatedCallback)
{
auto lock = std::make_unique<gui::Lock>(getStrongestLock());
if (lock->isState(Lock::LockState::InputInvalid)) {
getStrongestLock().consumeState();
lock->onActivatedCallback = [this, onLockActivatedCallback](Lock::LockType,
- const std::vector<unsigned int> &) {
+ const cellular::api::SimCode &) {
switchToPinLockWindow(onLockActivatedCallback);
};
}
else if (lock->isState(gui::Lock::LockState::Blocked)) {
- lock->onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
+ lock->onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) {
setSimLockHandled();
app->switchWindow(app::window::name::desktop_main_window);
};
@@ 207,7 210,7 @@ namespace gui
void PinLockHandler::switchToPinLockWindow(
Lock::LockState state,
- std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
+ std::function<void(Lock::LockType, const cellular::api::SimCode &)> onLockActivatedCallback)
{
auto lock = std::make_unique<gui::Lock>(getStrongestLock());
lock->lockState = state;
@@ 216,30 219,30 @@ namespace gui
app::window::name::desktop_pin_lock, gui::ShowMode::GUI_SHOW_INIT, std::make_unique<gui::LockData>(*lock));
}
- void PinLockHandler::handlePasscode(Lock::LockType type, const std::vector<unsigned int> passcode)
+ void PinLockHandler::handlePasscode(Lock::LockType type, const cellular::api::SimCode &passcode)
{
if (type == Lock::LockType::SimPin) {
setSimLockHandled();
- app->bus.sendUnicast(std::make_shared<CellularSimPinDataMessage>(simLock.sim, passcode), serviceCellular);
+ app->bus.sendUnicast<cellular::msg::request::sim::PinUnlock>(passcode);
}
else if (type == Lock::LockType::SimPuk) {
handlePasscodeChange(passcode);
}
}
- void PinLockHandler::handlePasscodeChange(const std::vector<unsigned int> passcode)
+ void PinLockHandler::handlePasscodeChange(const cellular::api::SimCode &passcode)
{
- auto onActivatedCallback = [this, passcode](Lock::LockType, const std::vector<unsigned int> &pin) {
+ auto onActivatedCallback = [this, passcode](Lock::LockType, const cellular::api::SimCode &pin) {
handleNewPasscodeUnconfirmed(passcode, pin);
};
switchToPinLockWindow(Lock::LockState::NewInputRequired, onActivatedCallback);
}
- void PinLockHandler::handleNewPasscodeUnconfirmed(const std::vector<unsigned int> &passcode,
- const std::vector<unsigned int> &pin)
+ void PinLockHandler::handleNewPasscodeUnconfirmed(const cellular::api::SimCode &passcode,
+ const cellular::api::SimCode &pin)
{
auto onActivatedCallback = [this, passcode, pin](Lock::LockType type,
- const std::vector<unsigned int> &pinConfirmed) {
+ const cellular::api::SimCode &pinConfirmed) {
if (pin == pinConfirmed) {
handleNewPasscodeConfirmed(type, passcode, pin);
}
@@ 251,29 254,28 @@ namespace gui
}
void PinLockHandler::handleNewPasscodeConfirmed(Lock::LockType type,
- const std::vector<unsigned int> &passcode,
- const std::vector<unsigned int> &pin)
+ const cellular::api::SimCode &passcode,
+ const cellular::api::SimCode &pin)
{
+ using namespace cellular::msg;
if (type == Lock::LockType::SimPin) {
- app->bus.sendUnicast(std::make_shared<CellularSimNewPinDataMessage>(simLock.sim, passcode, pin),
- serviceCellular);
+ app->bus.sendUnicast<request::sim::ChangePin>(passcode, pin);
}
else if (type == Lock::LockType::SimPuk) {
- app->bus.sendUnicast(std::make_shared<CellularSimPukDataMessage>(simLock.sim, passcode, pin),
- serviceCellular);
+ app->bus.sendUnicast<request::sim::UnblockWithPuk>(passcode, pin);
}
}
- void PinLockHandler::handleNewPasscodeInvalid(const std::vector<unsigned int> &passcode)
+ void PinLockHandler::handleNewPasscodeInvalid(const cellular::api::SimCode &passcode)
{
- auto onActivatedCallback = [this, passcode](Lock::LockType type, const std::vector<unsigned int> &pin) {
+ auto onActivatedCallback = [this, passcode](Lock::LockType type, const cellular::api::SimCode &pin) {
handlePasscodeChange(passcode);
};
switchToPinLockWindow(Lock::LockState::NewInputInvalid, onActivatedCallback);
}
void PinLockHandler::unlock()
{
- auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
+ auto onActivatedCallback = [this](Lock::LockType type, const cellular::api::SimCode &data) {
handlePasscode(type, data);
};
switchToPinLockWindow(onActivatedCallback);
M module-apps/locks/handlers/PinLockHandler.hpp => module-apps/locks/handlers/PinLockHandler.hpp +11 -12
@@ 7,7 7,7 @@
#include <module-services/service-appmgr/service-appmgr/messages/ActionRequest.hpp>
#include <module-services/service-appmgr/service-appmgr/Actions.hpp>
-#include <service-cellular/CellularMessage.hpp>
+#include <service-cellular/api/common.hpp>
namespace app
{
@@ 25,22 25,21 @@ namespace gui
Lock simLock;
bool promptSimLockWindow = true;
- void handlePasscode(Lock::LockType type, const std::vector<unsigned int> passcode);
- void handlePasscodeChange(const std::vector<unsigned int> passcode);
- void handleNewPasscodeUnconfirmed(const std::vector<unsigned int> &passcode,
- const std::vector<unsigned int> &pin);
+ void handlePasscode(Lock::LockType type, const cellular::api::SimCode &passcode);
+ void handlePasscodeChange(const cellular::api::SimCode &passcode);
+ void handleNewPasscodeUnconfirmed(const cellular::api::SimCode &passcode, const cellular::api::SimCode &pin);
void handleNewPasscodeConfirmed(Lock::LockType type,
- const std::vector<unsigned int> &passcode,
- const std::vector<unsigned int> &pin);
- void handleNewPasscodeInvalid(const std::vector<unsigned int> &passcode);
+ const cellular::api::SimCode &passcode,
+ const cellular::api::SimCode &pin);
+ void handleNewPasscodeInvalid(const cellular::api::SimCode &passcode);
void handlePasscodeParams(Lock::LockType type,
Lock::LockState state,
app::manager::actions::ActionParamsPtr &&data);
void switchToPinLockWindow(
- std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
+ std::function<void(Lock::LockType, const cellular::api::SimCode &)> onLockActivatedCallback);
void switchToPinLockWindow(
Lock::LockState type,
- std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
+ std::function<void(Lock::LockType, const cellular::api::SimCode &)> onLockActivatedCallback);
auto getStrongestLock() noexcept -> gui::Lock &;
void unlock();
@@ 52,8 51,8 @@ namespace gui
void handlePasscodeRequest(Lock::LockType type, app::manager::actions::ActionParamsPtr &&data);
void handlePinChangeRequest(app::manager::actions::ActionParamsPtr &&data);
void handlePinEnableRequest(app::manager::actions::ActionParamsPtr &&data,
- CellularSimCardLockDataMessage::SimCardLock simCardLock);
- void handlePinEnableRequestFailed(CellularSimCardLockDataMessage::SimCardLock simCardLock);
+ cellular::api::SimLockState simCardLock);
+ void handlePinEnableRequestFailed(cellular::api::SimLockState simCardLock);
void handleSimBlocked(app::manager::actions::ActionParamsPtr &&data);
void handleUnlockSim(app::manager::actions::ActionParamsPtr &&data);
void handleCMEError(app::manager::actions::ActionParamsPtr &&data) const;
M module-services/service-antenna/ServiceAntenna.cpp => module-services/service-antenna/ServiceAntenna.cpp +1 -1
@@ 122,7 122,7 @@ sys::MessagePointer ServiceAntenna::DataReceivedHandler(sys::DataMessage *msgl,
case CellularMessage::Type::StateRequest: {
auto msg = dynamic_cast<cellular::StateChange *>(msgl);
if (msg != nullptr) {
- if (msg->request == cellular::State::ST::Ready) {
+ if (msg->request == cellular::service::State::ST::Ready) {
state->set(antenna::State::init);
}
}
M module-services/service-appmgr/model/ApplicationManager.cpp => module-services/service-appmgr/model/ApplicationManager.cpp +77 -5
@@ 144,6 144,7 @@ namespace app::manager
bus.channels.push_back(sys::BusChannel::PhoneModeChanges);
bus.channels.push_back(sys::BusChannel::ServiceAudioNotifications);
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
+ bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);
registerMessageHandlers();
}
@@ 453,11 454,6 @@ namespace app::manager
connect(typeid(app::manager::DOMRequest), [&](sys::Message *request) { return handleDOMRequest(request); });
auto convertibleToActionHandler = [this](sys::Message *request) { return handleMessageAsAction(request); };
- connect(typeid(CellularSimRequestPinMessage), convertibleToActionHandler);
- connect(typeid(CellularSimRequestPukMessage), convertibleToActionHandler);
- connect(typeid(CellularUnlockSimMessage), convertibleToActionHandler);
- connect(typeid(CellularBlockSimMessage), convertibleToActionHandler);
- connect(typeid(CellularDisplayCMEMessage), convertibleToActionHandler);
connect(typeid(CellularMMIResultMessage), convertibleToActionHandler);
connect(typeid(CellularMMIResponseMessage), convertibleToActionHandler);
connect(typeid(CellularMMIPushMessage), convertibleToActionHandler);
@@ 471,6 467,33 @@ namespace app::manager
connect(typeid(sys::TetheringQuestionAbort), convertibleToActionHandler);
connect(typeid(sys::TetheringPhoneModeChangeProhibitedMessage), convertibleToActionHandler);
connect(typeid(VolumeChanged), convertibleToActionHandler);
+
+ /* Notifications from sys::BusChannel::ServiceCellularNotifications */
+ connect(typeid(cellular::msg::notification::SimReady), [&](sys::Message *request) {
+ auto msg = static_cast<cellular::msg::notification::SimReady *>(request);
+ handleSimReady(msg);
+ return sys::MessageNone{};
+ });
+ connect(typeid(cellular::msg::notification::SimNeedPin), [&](sys::Message *request) {
+ auto msg = static_cast<cellular::msg::notification::SimNeedPin *>(request);
+ handleSimNeedPin(msg);
+ return sys::MessageNone{};
+ });
+ connect(typeid(cellular::msg::notification::SimNeedPuk), [&](sys::Message *request) {
+ auto msg = static_cast<cellular::msg::notification::SimNeedPuk *>(request);
+ handleSimNeedPuk(msg);
+ return sys::MessageNone{};
+ });
+ connect(typeid(cellular::msg::notification::SimBlocked), [&](sys::Message *request) {
+ auto msg = static_cast<cellular::msg::notification::SimBlocked *>(request);
+ handleSimBlocked(msg);
+ return sys::MessageNone{};
+ });
+ connect(typeid(cellular::msg::notification::UnhandledCME), [&](sys::Message *request) {
+ auto msg = static_cast<cellular::msg::notification::UnhandledCME *>(request);
+ handleUnhandledCME(msg);
+ return sys::MessageNone{};
+ });
}
sys::ReturnCodes ApplicationManager::SwitchPowerModeHandler(const sys::ServicePowerMode mode)
@@ 618,6 641,55 @@ namespace app::manager
actionsRegistry.enqueue(std::move(entry));
}
+ void ApplicationManager::handleSimReady(cellular::msg::notification::SimReady *msg)
+ {
+ if (msg->ready) {
+ auto action = std::make_unique<app::manager::ActionRequest>(
+ msg->sender,
+ app::manager::actions::UnlockSim,
+ std::make_unique<app::manager::actions::SimStateParams>(Store::GSM::get()->selected));
+ handleActionRequest(action.get());
+ }
+ }
+
+ void ApplicationManager::handleSimNeedPin(cellular::msg::notification::SimNeedPin *msg)
+ {
+ auto action = std::make_unique<app::manager::ActionRequest>(
+ msg->sender,
+ app::manager::actions::RequestPin,
+ std::make_unique<app::manager::actions::PasscodeParams>(
+ Store::GSM::get()->selected, msg->attempts, std::string()));
+ handleActionRequest(action.get());
+ }
+
+ void ApplicationManager::handleSimNeedPuk(cellular::msg::notification::SimNeedPuk *msg)
+ {
+ auto action = std::make_unique<app::manager::ActionRequest>(
+ msg->sender,
+ app::manager::actions::RequestPuk,
+ std::make_unique<app::manager::actions::PasscodeParams>(
+ Store::GSM::get()->selected, msg->attempts, std::string()));
+ handleActionRequest(action.get());
+ }
+
+ void ApplicationManager::handleSimBlocked(cellular::msg::notification::SimBlocked *msg)
+ {
+ auto action = std::make_unique<app::manager::ActionRequest>(
+ msg->sender,
+ app::manager::actions::BlockSim,
+ std::make_unique<app::manager::actions::SimStateParams>(Store::GSM::get()->selected));
+ handleActionRequest(action.get());
+ }
+
+ void ApplicationManager::handleUnhandledCME(cellular::msg::notification::UnhandledCME *msg)
+ {
+ auto action = std::make_unique<app::manager::ActionRequest>(
+ msg->sender,
+ app::manager::actions::DisplayCMEError,
+ std::make_unique<app::manager::actions::UnhandledCMEParams>(Store::GSM::get()->selected, msg->code));
+ handleActionRequest(action.get());
+ }
+
void ApplicationManager::handlePhoneModeChanged(sys::phone_modes::PhoneMode phoneMode)
{
for (const auto app : getRunningApplications()) {
M module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp => module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp +6 -0
@@ 32,6 32,7 @@
#include <notifications/NotificationProvider.hpp>
#include <locks/handlers/PhoneLockHandler.hpp>
+#include <service-cellular-api>
namespace app
{
@@ 148,6 149,11 @@ namespace app::manager
auto handleDBResponse(db::QueryResponse *msg) -> bool;
auto handlePowerSavingModeInit() -> bool;
auto handleMessageAsAction(sys::Message *request) -> std::shared_ptr<sys::ResponseMessage>;
+ void handleSimReady(cellular::msg::notification::SimReady *msg);
+ void handleSimNeedPin(cellular::msg::notification::SimNeedPin *msg);
+ void handleSimNeedPuk(cellular::msg::notification::SimNeedPuk *msg);
+ void handleSimBlocked(cellular::msg::notification::SimBlocked *msg);
+ void handleUnhandledCME(cellular::msg::notification::UnhandledCME *msg);
auto handleDeveloperModeRequest(sys::Message *request) -> sys::MessagePointer;
/// handles dom request by passing this request to application which should provide the dom
auto handleDOMRequest(sys::Message *request) -> std::shared_ptr<sys::ResponseMessage>;
M module-services/service-cellular/CMakeLists.txt => module-services/service-cellular/CMakeLists.txt +1 -2
@@ 3,7 3,7 @@ message( "${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}" )
set(SOURCES
src/ServiceCellularPriv.cpp
- src/state.cpp
+ src/State.cpp
src/SimCard.cpp
CellularCall.cpp
@@ 12,7 12,6 @@ set(SOURCES
checkSmsCenter.cpp
ServiceCellular.cpp
SignalStrength.cpp
- SimCard.cpp
NetworkSettings.cpp
PacketData.cpp
QMBNManager.cpp
M module-services/service-cellular/CellularServiceAPI.cpp => module-services/service-cellular/CellularServiceAPI.cpp +2 -32
@@ 29,8 29,7 @@ bool CellularServiceAPI::DialNumber(sys::Service *serv, const utils::PhoneNumber
bool CellularServiceAPI::DialEmergencyNumber(sys::Service *serv, const utils::PhoneNumber &number)
{
- auto msg = std::make_shared<CellularCallRequestMessage>(number.getView(),
- CellularCallRequestMessage::RequestMode::Emergency);
+ auto msg = std::make_shared<CellularCallRequestMessage>(number.getView(), cellular::api::CallMode::Emergency);
return serv->bus.sendUnicast(msg, ServiceCellular::serviceName);
}
@@ 264,35 263,6 @@ bool CellularServiceAPI::USSDRequest(sys::Service *serv, CellularUSSDMessage::Re
;
}
-bool CellularServiceAPI::ChangeSimPin(sys::Service *serv,
- Store::GSM::SIM sim,
- const std::vector<unsigned int> &passcode,
- const std::vector<unsigned int> &pin)
-{
- return serv->bus.sendUnicast(std::make_shared<CellularSimPukDataMessage>(sim, passcode, pin),
- ServiceCellular::serviceName);
-}
-
-bool CellularServiceAPI::RequestSimCardPinLockState(sys::Service *serv)
-{
- return serv->bus.sendUnicast(std::make_shared<CellularSimCardPinLockStateRequestDataMessage>(),
- ServiceCellular::serviceName);
-}
-
-bool CellularServiceAPI::SetSimCardLock(sys::Service *serv,
- Store::GSM::SIM sim,
- CellularSimCardLockDataMessage::SimCardLock lock,
- const std::vector<unsigned int> &pin)
-{
- return serv->bus.sendUnicast(std::make_shared<CellularSimCardLockDataMessage>(sim, lock, pin),
- ServiceCellular::serviceName);
-}
-
-bool CellularServiceAPI::SetSimCard(sys::Service *serv, Store::GSM::SIM sim)
-{
- return serv->bus.sendUnicast(std::make_shared<CellularChangeSimDataMessage>(sim), ServiceCellular::serviceName);
-}
-
bool CellularServiceAPI::GetAPN(sys::Service *serv)
{
return serv->bus.sendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName);
@@ 342,7 312,7 @@ bool CellularServiceAPI::SetVoLTE(sys::Service *serv, bool voLTE)
return serv->bus.sendUnicast(std::make_shared<CellularChangeVoLTEDataMessage>(voLTE), ServiceCellular::serviceName);
}
-bool CellularServiceAPI::ChangeModulePowerState(sys::Service *serv, cellular::State::PowerState newState)
+bool CellularServiceAPI::ChangeModulePowerState(sys::Service *serv, cellular::service::State::PowerState newState)
{
return serv->bus.sendUnicast(std::make_shared<CellularPowerStateChange>(newState), ServiceCellular::serviceName);
}
M module-services/service-cellular/CellularUrcHandler.cpp => module-services/service-cellular/CellularUrcHandler.cpp +2 -1
@@ 4,6 4,7 @@
#include "CellularUrcHandler.hpp"
#include "service-cellular/CellularMessage.hpp"
+#include "messages.hpp"
#include "service-cellular/CellularServiceAPI.hpp"
#include <service-antenna/AntennaServiceAPI.hpp>
@@ 152,7 153,7 @@ void CellularUrcHandler::Handle(Cpin &urc)
LOG_INFO("Invalid cpin - ignore");
}
else {
- response = std::make_unique<CellularSimStateMessage>(*state, *urc.getMessage());
+ response = std::make_unique<cellular::internal::msg::SimStateChanged>(*state);
urc.setHandled(true);
}
}
M module-services/service-cellular/CellularUrcHandler.hpp => module-services/service-cellular/CellularUrcHandler.hpp +2 -2
@@ 44,12 44,12 @@ class CellularUrcHandler : public at::urc::UrcHandler
* Gets the response that should be returned after handling Urc
* @return
*/
- std::optional<std::shared_ptr<CellularMessage>> getResponse()
+ std::optional<std::shared_ptr<sys::Message>> getResponse()
{
return std::move(response);
};
private:
ServiceCellular &cellularService;
- std::optional<std::unique_ptr<CellularMessage>> response;
+ std::optional<std::unique_ptr<sys::Message>> response;
};
M module-services/service-cellular/PacketData.cpp => module-services/service-cellular/PacketData.cpp +3 -0
@@ 3,12 3,15 @@
#include "PacketData.hpp"
+#include <service-cellular/ServiceCellular.hpp>
+
#include <optional>
#include <algorithm>
#include <iterator>
#include <response.hpp>
#include <Utils.hpp>
#include <at/ATFactory.hpp>
+
namespace at
{
namespace response
M module-services/service-cellular/PacketData.hpp => module-services/service-cellular/PacketData.hpp +5 -1
@@ 7,7 7,11 @@
#include <unordered_map>
#include "service-cellular/PacketDataTypes.hpp"
-#include "service-cellular/ServiceCellular.hpp"
+
+#include <at/Result.hpp>
+
+class ServiceCellular;
+class DLCChannel;
namespace at
{
M module-services/service-cellular/QMBNManager.cpp => module-services/service-cellular/QMBNManager.cpp +1 -0
@@ 5,6 5,7 @@
#include "Utils.hpp"
#include "response.hpp"
#include <at/ATFactory.hpp>
+#include <modem/mux/DLCChannel.h>
namespace at
{
M module-services/service-cellular/QMBNManager.hpp => module-services/service-cellular/QMBNManager.hpp +2 -1
@@ 4,7 4,8 @@
#pragma once
#include "Result.hpp"
-#include "service-cellular/ServiceCellular.hpp"
+
+class DLCChannel;
namespace nv_paths
{
M module-services/service-cellular/RequestFactory.cpp => module-services/service-cellular/RequestFactory.cpp +6 -6
@@ 23,9 23,9 @@ namespace cellular
{
RequestFactory::RequestFactory(const std::string &data,
at::BaseChannel &channel,
- CellularCallRequestMessage::RequestMode requestMode,
- SimStatus simCardStatus)
- : request(data), channel(channel), requestMode(requestMode), simStatus(simCardStatus)
+ cellular::api::CallMode callMode,
+ bool simInserted)
+ : request(data), channel(channel), callMode(callMode), simInserted(simInserted)
{
registerRequest(ImeiRegex, ImeiRequest::create);
registerRequest(PasswordRegistrationRegex, PasswordRegistrationRequest::create);
@@ 54,14 54,14 @@ namespace cellular
qeccnumResponse.eccNumbersNoSim.end();
if (isSimEmergency || isNoSimEmergency) {
- if (simStatus == SimStatus::SimInsterted || isNoSimEmergency) {
+ if (simInserted || isNoSimEmergency) {
return std::make_unique<CallRequest>(request);
}
else {
return std::make_unique<RejectRequest>(RejectRequest::RejectReason::NoSim, request);
}
}
- else if (requestMode == CellularCallRequestMessage::RequestMode::Emergency) {
+ else if (callMode == cellular::api::CallMode::Emergency) {
return std::make_unique<RejectRequest>(RejectRequest::RejectReason::NotAnEmergencyNumber, request);
}
return nullptr;
@@ 116,7 116,7 @@ namespace cellular
}
}
- if (simStatus == SimStatus::SimSlotEmpty) {
+ if (!simInserted) {
return std::make_unique<RejectRequest>(RejectRequest::RejectReason::NoSim, request);
}
return std::make_unique<CallRequest>(request);
M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +83 -455
@@ 95,83 95,22 @@
#include <gsl/gsl_util>
#include <ticks.hpp>
-const char *ServiceCellular::serviceName = "ServiceCellular";
+#include "ServiceCellularPriv.hpp"
+#include <service-cellular/api/request/sim.hpp>
+#include <service-cellular/api/notification/notification.hpp>
+
+const char *ServiceCellular::serviceName = cellular::service::name;
inline constexpr auto cellularStack = 8000;
using namespace cellular;
-
-const char *State::c_str(State::ST state)
-{
- switch (state) {
- case ST::Idle:
- return "Idle";
- case ST::WaitForStartPermission:
- return "WaitForStartPermission";
- case ST::PowerUpRequest:
- return "PowerUpRequest";
- case ST::StatusCheck:
- return "StatusCheck";
- case ST::PowerUpInProgress:
- return "PowerUpInProgress";
- case ST::PowerUpProcedure:
- return "PowerUpProcedure";
- case ST::BaudDetect:
- return "BaudDetect";
- case ST::AudioConfigurationProcedure:
- return "AudioConfigurationProcedure";
- case ST::APNConfProcedure:
- return "APNConfProcedure";
- case ST::ModemOn:
- return "ModemOn";
- case ST::URCReady:
- return "URCReady";
- case ST::SimSelect:
- return "SimSelect";
- case ST::Failed:
- return "Failed";
- case ST::SanityCheck:
- return "SanityCheck";
- case ST::SimInit:
- return "SimInit";
- case ST::ModemFatalFailure:
- return "ModemFatalFailure";
- case ST::CellularConfProcedure:
- return "CellularStartConfProcedure";
- case ST::Ready:
- return "Ready";
- case ST::PowerDownStarted:
- return "PowerDownStarted";
- case ST::PowerDownWaiting:
- return "PowerDownWaiting";
- case ST::PowerDown:
- return "PowerDown";
- }
- return "";
-}
-
-const char *State::c_str()
-{
- return State::c_str(state);
-}
-
-void State::set(ServiceCellular *owner, ST state)
-{
- assert(owner);
- LOG_DEBUG("GSM state: (%s) -> (%s)", c_str(this->state), c_str(state));
- this->state = state;
- auto msg = std::make_shared<StateChange>(state);
- owner->bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications);
-}
-
-State::ST State::get() const
-{
- return this->state;
-}
+using namespace cellular::msg;
+using cellular::service::State;
ServiceCellular::ServiceCellular()
: sys::Service(serviceName, "", cellularStack, sys::ServicePriority::Idle),
- phoneModeObserver{std::make_unique<sys::phone_modes::Observer>()}
+ phoneModeObserver{std::make_unique<sys::phone_modes::Observer>()},
+ priv{std::make_unique<internal::ServiceCellularPriv>(this)}
{
LOG_INFO("[ServiceCellular] Initializing");
@@ 258,7 197,7 @@ void ServiceCellular::SleepTimerHandler()
? currentTime - lastCommunicationTimestamp
: std::numeric_limits<TickType_t>::max() - lastCommunicationTimestamp + currentTime;
- if (!ongoingCall.isValid() && state.get() == cellular::State::ST::Ready &&
+ if (!ongoingCall.isValid() && priv->state->get() == State::ST::Ready &&
timeOfInactivity >= constants::enterSleepModeTime.count()) {
cmux->enterSleepMode();
cpuSentinel->ReleaseMinimumFrequency();
@@ 277,7 216,7 @@ sys::ReturnCodes ServiceCellular::InitHandler()
board = EventManagerServiceAPI::GetBoard(this);
settings = std::make_unique<settings::Settings>();
- settings->init(service::ServiceProxy(shared_from_this()));
+ settings->init(::service::ServiceProxy(shared_from_this()));
connectionManager = std::make_unique<ConnectionManager>(
utils::getNumericValue<bool>(
@@ 286,7 225,7 @@ sys::ReturnCodes ServiceCellular::InitHandler()
settings->getValue(settings::Offline::connectionFrequency, settings::SettingsScope::Global)))),
std::make_shared<ConnectionManagerCellularCommands>(*this));
- state.set(this, State::ST::WaitForStartPermission);
+ priv->state->set(State::ST::WaitForStartPermission);
settings->registerValueChange(
settings::Cellular::volte_on,
[this](const std::string &value) { volteChanged(value); },
@@ 300,7 239,7 @@ sys::ReturnCodes ServiceCellular::InitHandler()
ongoingCall.setCpuSentinel(cpuSentinel);
auto sentinelRegistrationMsg = std::make_shared<sys::SentinelRegistrationMessage>(cpuSentinel);
- bus.sendUnicast(sentinelRegistrationMsg, service::name::system_manager);
+ bus.sendUnicast(sentinelRegistrationMsg, ::service::name::system_manager);
cmux->registerCellularDevice();
@@ 335,9 274,6 @@ sys::ReturnCodes ServiceCellular::SwitchPowerModeHandler(const sys::ServicePower
return sys::ReturnCodes::Success;
}
-void handleCellularSimNewPinDataMessage(CellularSimNewPinDataMessage *msg)
-{}
-
void ServiceCellular::registerMessageHandlers()
{
phoneModeObserver->connect(this);
@@ 350,32 286,7 @@ void ServiceCellular::registerMessageHandlers()
: PassthroughState::DISABLED);
});
- connect(typeid(CellularSimCardPinLockStateRequestDataMessage),
- [&](sys::Message * /*request*/) -> sys::MessagePointer {
- return std::make_shared<CellularSimCardPinLockStateResponseDataMessage>(isPinLocked());
- });
-
- connect(typeid(CellularSimNewPinDataMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto msg = static_cast<CellularSimNewPinDataMessage *>(request);
- return std::make_shared<CellularSimNewPinResponseMessage>(
- changePin(SimCard::pinToString(msg->getOldPin()), SimCard::pinToString(msg->getNewPin())));
- });
-
- connect(typeid(CellularSimCardLockDataMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto msg = static_cast<CellularSimCardLockDataMessage *>(request);
- return std::make_shared<CellularSimCardLockResponseMessage>(
- setPinLock(msg->getLock() == CellularSimCardLockDataMessage::SimCardLock::Locked,
- SimCard::pinToString(msg->getPin())),
- msg->getLock());
- });
-
- connect(typeid(CellularChangeSimDataMessage), [&](sys::Message *request) -> sys::MessagePointer {
- auto msg = static_cast<CellularChangeSimDataMessage *>(request);
- Store::GSM::get()->selected = msg->getSim();
- bsp::cellular::sim::simSelect();
- bsp::cellular::sim::hotSwapTrigger();
- return std::make_shared<CellularResponseMessage>(true);
- });
+ priv->connectSimCard();
connect(typeid(CellularStartOperatorsScanMessage), [&](sys::Message *request) -> sys::MessagePointer {
auto msg = static_cast<CellularStartOperatorsScanMessage *>(request);
@@ 450,8 361,8 @@ void ServiceCellular::registerMessageHandlers()
});
connect(typeid(CellularPowerStateChange), [&](sys::Message *request) -> sys::MessagePointer {
- auto msg = static_cast<CellularPowerStateChange *>(request);
- nextPowerState = msg->getNewState();
+ auto msg = static_cast<CellularPowerStateChange *>(request);
+ priv->nextPowerState = msg->getNewState();
handle_power_state_change();
return sys::MessageNone{};
});
@@ 459,20 370,21 @@ void ServiceCellular::registerMessageHandlers()
connect(typeid(sdesktop::developerMode::DeveloperModeRequest), [&](sys::Message *request) -> sys::MessagePointer {
auto msg = static_cast<sdesktop::developerMode::DeveloperModeRequest *>(request);
if (typeid(*msg->event.get()) == typeid(sdesktop::developerMode::CellularHotStartEvent)) {
+ priv->simCard->setChannel(nullptr);
cmux->closeChannels();
///> change state - simulate hot start
handle_power_up_request();
}
if (typeid(*msg->event.get()) == typeid(sdesktop::developerMode::CellularStateInfoRequestEvent)) {
- auto event = std::make_unique<sdesktop::developerMode::CellularStateInfoRequestEvent>(state.c_str());
+ auto event = std::make_unique<sdesktop::developerMode::CellularStateInfoRequestEvent>(priv->state->c_str());
auto message = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
- bus.sendUnicast(std::move(message), service::name::service_desktop);
+ bus.sendUnicast(std::move(message), ::service::name::service_desktop);
}
if (typeid(*msg->event.get()) == typeid(sdesktop::developerMode::CellularSleepModeInfoRequestEvent)) {
auto event = std::make_unique<sdesktop::developerMode::CellularSleepModeInfoRequestEvent>(
cmux->isCellularInSleepMode());
auto message = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
- bus.sendUnicast(std::move(message), service::name::service_desktop);
+ bus.sendUnicast(std::move(message), ::service::name::service_desktop);
}
if (typeid(*msg->event.get()) == typeid(sdesktop::developerMode::ATResponseEvent)) {
auto channel = cmux->get(CellularMux::Channel::Commands);
@@ 585,15 497,6 @@ void ServiceCellular::registerMessageHandlers()
connect(typeid(CellularUSSDMessage),
[&](sys::Message *request) -> sys::MessagePointer { return handleCellularUSSDMessage(request); });
- connect(typeid(CellularSimStateMessage),
- [&](sys::Message *request) -> sys::MessagePointer { return handleSimStateMessage(request); });
-
- connect(typeid(CellularSimPinDataMessage),
- [&](sys::Message *request) -> sys::MessagePointer { return handleSimPinMessage(request); });
-
- connect(typeid(CellularSimPukDataMessage),
- [&](sys::Message *request) -> sys::MessagePointer { return handleSimPukMessage(request); });
-
connect(typeid(cellular::StateChange),
[&](sys::Message *request) -> sys::MessagePointer { return handleStateRequestMessage(request); });
@@ 618,9 521,6 @@ void ServiceCellular::registerMessageHandlers()
connect(typeid(CellularNewIncomingSMSNotification),
[&](sys::Message *request) -> sys::MessagePointer { return handleNewIncomingSMSNotification(request); });
- connect(typeid(CellularSimReadyNotification),
- [&](sys::Message *request) -> sys::MessagePointer { return handleSimReadyNotification(request); });
-
connect(typeid(CellularSmsDoneNotification),
[&](sys::Message *request) -> sys::MessagePointer { return handleSmsDoneNotification(request); });
@@ 632,9 532,6 @@ void ServiceCellular::registerMessageHandlers()
return handleNetworkStatusUpdateNotification(request);
});
- connect(typeid(CellularSimNotReadyNotification),
- [&](sys::Message *request) -> sys::MessagePointer { return handleSimNotReadyNotification(request); });
-
connect(typeid(CellularUrcIncomingNotification),
[&](sys::Message *request) -> sys::MessagePointer { return handleUrcIncomingNotification(request); });
@@ 771,7 668,7 @@ bool ServiceCellular::handle_idle()
bool ServiceCellular::handle_wait_for_start_permission()
{
auto msg = std::make_shared<CellularCheckIfStartAllowedMessage>();
- bus.sendUnicast(msg, service::name::system_manager);
+ bus.sendUnicast(msg, ::service::name::system_manager);
return true;
}
@@ 781,13 678,13 @@ bool ServiceCellular::handle_power_up_request()
cmux->selectAntenna(bsp::cellular::antenna::lowBand);
switch (board) {
case bsp::Board::T4:
- state.set(this, State::ST::StatusCheck);
+ priv->state->set(State::ST::StatusCheck);
break;
case bsp::Board::T3:
- state.set(this, State::ST::PowerUpProcedure);
+ priv->state->set(State::ST::PowerUpProcedure);
break;
case bsp::Board::Linux:
- state.set(this, State::ST::PowerUpProcedure);
+ priv->state->set(State::ST::PowerUpProcedure);
break;
case bsp::Board::none:
return false;
@@ 811,7 708,7 @@ bool ServiceCellular::handle_power_up_procedure()
if (ret == CellularMux::ConfState::Success) {
// it's on aka hot start.
LOG_DEBUG("T3 - hot start");
- state.set(this, State::ST::CellularConfProcedure);
+ priv->state->set(State::ST::CellularConfProcedure);
break;
}
else {
@@ 820,7 717,7 @@ bool ServiceCellular::handle_power_up_procedure()
cmux->turnOnModem();
// if it's T3, then wait for status pin to become active, to align its starting position with T4
vTaskDelay(pdMS_TO_TICKS(8000));
- state.set(this, State::ST::PowerUpInProgress);
+ priv->state->set(State::ST::PowerUpInProgress);
break;
}
}
@@ 831,7 728,7 @@ bool ServiceCellular::handle_power_up_procedure()
if (ret == CellularMux::ConfState::Success) {
// it's on aka hot start.
LOG_DEBUG("Linux - hot start");
- state.set(this, State::ST::CellularConfProcedure);
+ priv->state->set(State::ST::CellularConfProcedure);
break;
}
else {
@@ 841,7 738,7 @@ bool ServiceCellular::handle_power_up_procedure()
vTaskDelay(pdMS_TO_TICKS(2000)); // give some 2 secs more for user input
// if it's Linux (T3), then wait for status pin to become active, to align its starting position with T4
vTaskDelay(pdMS_TO_TICKS(8000));
- state.set(this, State::ST::PowerUpInProgress);
+ priv->state->set(State::ST::PowerUpInProgress);
break;
}
}
@@ 862,7 759,7 @@ bool ServiceCellular::handle_power_up_in_progress_procedure(void)
isAfterForceReboot = false;
}
- state.set(this, cellular::State::ST::BaudDetect);
+ priv->state->set(State::ST::BaudDetect);
return true;
}
@@ 870,11 767,11 @@ bool ServiceCellular::handle_baud_detect()
{
auto ret = cmux->baudDetectProcedure();
if (ret == CellularMux::ConfState::Success) {
- state.set(this, cellular::State::ST::CellularConfProcedure);
+ priv->state->set(State::ST::CellularConfProcedure);
return true;
}
else {
- state.set(this, cellular::State::ST::ModemFatalFailure);
+ priv->state->set(State::ST::ModemFatalFailure);
return false;
}
}
@@ 895,7 792,7 @@ bool ServiceCellular::handle_power_down_waiting()
case bsp::Board::T3:
// if it's T3, then wait for status pin to become inactive, to align with T4
vTaskDelay(pdMS_TO_TICKS(17000)); // according to docs this shouldn't be needed, but better be safe than Quectel
- state.set(this, cellular::State::ST::PowerDown);
+ priv->state->set(State::ST::PowerDown);
break;
default:
LOG_ERROR("Powering 'down an unknown device not handled");
@@ 920,10 817,10 @@ bool ServiceCellular::handle_start_conf_procedure()
// Start configuration procedure, if it's first run modem will be restarted
auto confRet = cmux->confProcedure();
if (confRet == CellularMux::ConfState::Success) {
- state.set(this, State::ST::AudioConfigurationProcedure);
+ priv->state->set(State::ST::AudioConfigurationProcedure);
return true;
}
- state.set(this, State::ST::Failed);
+ priv->state->set(State::ST::Failed);
return false;
}
@@ 935,7 832,7 @@ bool ServiceCellular::handle_audio_conf_procedure()
LOG_DEBUG("Setting baudrate %i baud", ATPortSpeeds_text[cmux->getStartParams().PortSpeed]);
if (!cmux->getParser()->cmd(cmd)) {
LOG_ERROR("Baudrate setup error");
- state.set(this, State::ST::Failed);
+ priv->state->set(State::ST::Failed);
return false;
}
cmux->getCellular()->setSpeed(ATPortSpeeds_text[cmux->getStartParams().PortSpeed]);
@@ 945,6 842,8 @@ bool ServiceCellular::handle_audio_conf_procedure()
LOG_DEBUG("[ServiceCellular] Modem is fully operational");
+ priv->simCard->setChannel(cmux->get(CellularMux::Channel::Commands));
+
// open channel - notifications
DLCChannel *notificationsChannel = cmux->get(CellularMux::Channel::Notifications);
if (notificationsChannel != nullptr) {
@@ 962,26 861,26 @@ bool ServiceCellular::handle_audio_conf_procedure()
connectionManager->setInterval(std::chrono::minutes{interval});
}
if (!connectionManager->onPhoneModeChange(phoneModeObserver->getCurrentPhoneMode())) {
- state.set(this, State::ST::Failed);
+ priv->state->set(State::ST::Failed);
LOG_ERROR("Failed to handle phone mode");
return false;
}
- state.set(this, State::ST::APNConfProcedure);
+ priv->state->set(State::ST::APNConfProcedure);
return true;
}
else {
- state.set(this, State::ST::Failed);
+ priv->state->set(State::ST::Failed);
return false;
}
}
else if (audioRet == CellularMux::ConfState::Failure) {
/// restart
- state.set(this, State::ST::AudioConfigurationProcedure);
+ priv->state->set(State::ST::AudioConfigurationProcedure);
return true;
}
// Reset procedure started, do nothing here
- state.set(this, State::ST::Idle);
+ priv->state->set(State::ST::Idle);
return true;
}
@@ 1020,7 919,7 @@ auto ServiceCellular::handle(db::query::SMSSearchByTypeResult *response) -> bool
* any AT commands is not allowed here (also in URC handlers and other functions called from here)
* @return
*/
-std::optional<std::shared_ptr<CellularMessage>> ServiceCellular::identifyNotification(const std::string &data)
+std::optional<std::shared_ptr<sys::Message>> ServiceCellular::identifyNotification(const std::string &data)
{
CellularUrcHandler urcHandler(*this);
@@ 1040,257 939,6 @@ std::optional<std::shared_ptr<CellularMessage>> ServiceCellular::identifyNotific
return urcHandler.getResponse();
}
-bool ServiceCellular::requestPin(unsigned int attempts, const std::string msg)
-{
- auto message = std::make_shared<CellularSimRequestPinMessage>(Store::GSM::get()->selected, attempts, msg);
- bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
- LOG_DEBUG("REQUEST PIN");
- return true;
-}
-
-bool ServiceCellular::requestPuk(unsigned int attempts, const std::string msg)
-{
- auto message = std::make_shared<CellularSimRequestPukMessage>(Store::GSM::get()->selected, attempts, msg);
- bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
- LOG_DEBUG("REQUEST PUK");
- return true;
-}
-
-bool ServiceCellular::sendSimUnlocked()
-{
- auto message = std::make_shared<CellularUnlockSimMessage>(Store::GSM::get()->selected);
- bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
- LOG_DEBUG("SIM UNLOCKED");
- return true;
-}
-
-bool ServiceCellular::sendSimBlocked()
-{
- auto message = std::make_shared<CellularBlockSimMessage>(Store::GSM::get()->selected);
- bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
- LOG_ERROR("SIM BLOCKED");
- return true;
-}
-
-bool ServiceCellular::sendUnhandledCME(unsigned int cme_error)
-{
- auto message = std::make_shared<CellularDisplayCMEMessage>(Store::GSM::get()->selected, cme_error);
- bus.sendUnicast(message, app::manager::ApplicationManager::ServiceName);
- LOG_ERROR("UNHANDLED CME %d", cme_error);
- return true;
-}
-
-bool ServiceCellular::sendBadPin()
-{
- LOG_DEBUG("SEND BAD PIN");
- SimCard simCard(*this);
- std::string msg;
- if (auto state = simCard.simStateWithMessage(msg); state) {
- return handleSimState(*state, msg);
- }
- return false;
-}
-
-bool ServiceCellular::sendBadPuk()
-{
- LOG_DEBUG("SEND BAD PUK");
- SimCard simCard(*this);
- std::string msg;
- if (auto state = simCard.simStateWithMessage(msg); state) {
- return handleSimState(*state, msg);
- }
- return false;
-}
-
-bool ServiceCellular::sendChangePinResult(SimCardResult res)
-{
- LOG_DEBUG("SEND CHANGE PIN RESULT");
- return true;
-}
-
-bool ServiceCellular::isPinLocked()
-{
- SimCard simCard(*this);
- return simCard.isPinLocked();
-}
-
-bool ServiceCellular::changePin(const std::string oldPin, const std::string newPin)
-{
- SimCard simCard(*this);
- auto result = simCard.changePin(oldPin, newPin);
- sendChangePinResult(result);
- return result == SimCardResult::OK;
-}
-
-bool ServiceCellular::setPinLock(bool lock, const std::string pin)
-{
- SimCard simCard(*this);
- auto result = simCard.setPinLock(lock, pin);
- return result == SimCardResult::OK;
-}
-
-bool ServiceCellular::unlockSimPin(std::string pin)
-{
- LOG_ERROR("Unlock pin %s", pin.c_str());
- SimCard simCard(*this);
- SimCardResult sime;
- sime = simCard.supplyPin(pin);
-
- if (sime == SimCardResult::IncorrectPassword) {
- sendBadPin();
- return false;
- }
-
- if (sime == SimCardResult::OK) {
- return true;
- }
- else {
- sendUnhandledCME(static_cast<unsigned int>(sime));
- return false;
- }
-}
-
-bool ServiceCellular::unlockSimPuk(std::string puk, std::string pin)
-{
- SimCard simCard(*this);
- SimCardResult sime;
- LOG_DEBUG("PUK: %s %s", puk.c_str(), pin.c_str());
- sime = simCard.supplyPuk(puk, pin);
-
- if (sime == SimCardResult::IncorrectPassword) {
- sendBadPuk();
- return false;
- }
-
- if (sime == SimCardResult::OK) {
- return true;
- }
- sendUnhandledCME(static_cast<unsigned int>(sime));
- return false;
-}
-
-auto ServiceCellular::handleSimPinMessage(sys::Message *msgl) -> std::shared_ptr<sys::ResponseMessage>
-{
-
- auto msgSimPin = dynamic_cast<CellularSimPinDataMessage *>(msgl);
- if (msgSimPin != nullptr) {
- LOG_DEBUG("Unlocking sim");
- return std::make_shared<CellularResponseMessage>(unlockSimPin(SimCard::pinToString(msgSimPin->getPin())));
- }
- LOG_ERROR("Request message is not CellularSimPinDataMessage!");
- return std::make_shared<CellularResponseMessage>(false);
-}
-
-auto ServiceCellular::handleSimPukMessage(sys::Message *msgl) -> std::shared_ptr<sys::ResponseMessage>
-{
- auto msgSimPuk = dynamic_cast<CellularSimPukDataMessage *>(msgl);
- if (msgSimPuk != nullptr) {
- LOG_DEBUG("Unlocking puk");
- return std::make_shared<CellularSimPukResponseMessage>(
- unlockSimPuk(SimCard::pinToString(msgSimPuk->getPuk()), SimCard::pinToString(msgSimPuk->getNewPin())));
- }
- LOG_ERROR("Request message is not CellularSimPukDataMessage!");
- return std::make_shared<CellularResponseMessage>(false);
-}
-
-bool ServiceCellular::handleSimState(at::SimState state, const std::string message)
-{
-
- std::shared_ptr<CellularMessage> response;
- switch (state) {
- case at::SimState::Ready:
- Store::GSM::get()->sim = Store::GSM::get()->selected;
- settings->setValue(settings::SystemProperties::activeSim,
- utils::enumToString(Store::GSM::get()->selected),
- settings::SettingsScope::Global);
- // SIM causes SIM INIT, only on ready
- response = std::move(std::make_unique<CellularSimReadyNotification>());
- bus.sendMulticast(response, sys::BusChannel::ServiceCellularNotifications);
- sendSimUnlocked();
- break;
- case at::SimState::NotReady:
- LOG_DEBUG("Not ready");
- Store::GSM::get()->sim = Store::GSM::SIM::SIM_FAIL;
- response = std::move(std::make_unique<CellularSimNotReadyNotification>());
- bus.sendMulticast(response, sys::BusChannel::ServiceCellularNotifications);
- break;
- case at::SimState::SimPin: {
- SimCard simCard(*this);
- if (auto pc = simCard.getAttemptsCounters(); pc) {
- if (pc.value().PukCounter != 0) {
- requestPin(pc.value().PinCounter, message);
- break;
- }
- }
- sendSimBlocked();
- break;
- }
- case at::SimState::SimPuk: {
- SimCard simCard(*this);
- if (auto pc = simCard.getAttemptsCounters(); pc) {
- if (pc.value().PukCounter != 0) {
- requestPuk(pc.value().PukCounter, message);
- break;
- }
- }
- sendSimBlocked();
- break;
- }
- case at::SimState::SimPin2: {
- SimCard simCard(*this);
- if (auto pc = simCard.getAttemptsCounters(SimPinType::SimPin2); pc) {
- if (pc.value().PukCounter != 0) {
- requestPin(pc.value().PinCounter, message);
- break;
- }
- }
- sendSimBlocked();
- break;
- }
- case at::SimState::SimPuk2: {
- SimCard simCard(*this);
- if (auto pc = simCard.getAttemptsCounters(SimPinType::SimPin2); pc) {
- if (pc.value().PukCounter != 0) {
- requestPuk(pc.value().PukCounter, message);
- break;
- }
- }
- sendSimBlocked();
- break;
- }
- case at::SimState::PhNetPin:
- [[fallthrough]];
- case at::SimState::PhNetPuk:
- [[fallthrough]];
- case at::SimState::PhNetSPin:
- [[fallthrough]];
- case at::SimState::PhNetSPuk:
- [[fallthrough]];
- case at::SimState::PhSpPin:
- [[fallthrough]];
- case at::SimState::PhSpPuk:
- [[fallthrough]];
- case at::SimState::PhCorpPin:
- [[fallthrough]];
- case at::SimState::PhCorpPuk:
- Store::GSM::get()->sim = Store::GSM::SIM::SIM_UNKNOWN;
- LOG_ERROR("SimState not supported");
- break;
- case at::SimState::Locked:
- Store::GSM::get()->sim = Store::GSM::SIM::SIM_FAIL;
- sendSimBlocked();
- break;
- case at::SimState::Unknown:
- LOG_ERROR("SimState not supported");
- Store::GSM::get()->sim = Store::GSM::SIM::SIM_UNKNOWN;
- break;
- }
- auto simMessage = std::make_shared<sevm::SIMMessage>();
- bus.sendUnicast(simMessage, service::name::evt_manager);
-
- return true;
-}
-
auto ServiceCellular::sendSMS(SMSRecord record) -> bool
{
LOG_INFO("Trying to send SMS");
@@ 1713,12 1361,12 @@ bool ServiceCellular::handle_sim_sanity_check()
{
auto ret = sim_check_hot_swap(cmux->get(CellularMux::Channel::Commands));
if (ret) {
- state.set(this, State::ST::ModemOn);
+ priv->state->set(State::ST::ModemOn);
bsp::cellular::sim::simSelect();
}
else {
LOG_ERROR("Sanity check failure - user will be promped about full shutdown");
- state.set(this, State::ST::ModemFatalFailure);
+ priv->state->set(State::ST::ModemFatalFailure);
}
return ret;
}
@@ 1743,7 1391,7 @@ bool ServiceCellular::handle_select_sim()
// NO SIM IN
Store::GSM::get()->sim = Store::GSM::SIM::SIM_FAIL;
}
- bus.sendUnicast(std::make_shared<sevm::SIMMessage>(), service::name::evt_manager);
+ bus.sendUnicast(std::make_shared<sevm::SIMMessage>(), ::service::name::evt_manager);
bool ready = false;
while (!ready) {
auto response = channel->cmd("AT+CPIN?");
@@ 1753,7 1401,7 @@ bool ServiceCellular::handle_select_sim()
}
}
}
- state.set(this, cellular::State::ST::SimInit);
+ priv->state->set(State::ST::SimInit);
}
#endif
return true;
@@ 1765,7 1413,7 @@ bool ServiceCellular::handle_modem_on()
channel->cmd("AT+CCLK?");
// inform host ap ready
cmux->informModemHostWakeup();
- state.set(this, State::ST::URCReady);
+ priv->state->set(State::ST::URCReady);
LOG_DEBUG("AP ready");
return true;
}
@@ 1780,7 1428,7 @@ bool ServiceCellular::handle_URCReady()
}
ret = ret && channel->cmd(at::AT::ENABLE_NETWORK_REGISTRATION_URC);
- LOG_DEBUG("%s", state.c_str());
+ LOG_DEBUG("%s", priv->state->c_str());
return ret;
}
@@ 1789,7 1437,7 @@ bool ServiceCellular::handle_sim_init()
auto channel = cmux->get(CellularMux::Channel::Commands);
if (channel == nullptr) {
LOG_ERROR("Cant configure sim! no Commands channel!");
- state.set(this, State::ST::Failed);
+ priv->state->set(State::ST::Failed);
return false;
}
bool success = true;
@@ 1802,7 1450,7 @@ bool ServiceCellular::handle_sim_init()
}
}
- state.set(this, State::ST::Ready);
+ priv->state->set(State::ST::Ready);
return success;
}
@@ 1896,7 1544,7 @@ bool ServiceCellular::receiveAllMessages()
bool ServiceCellular::handle_failure()
{
- state.set(this, State::ST::Idle);
+ priv->state->set(State::ST::Idle);
return true;
}
@@ 1911,7 1559,7 @@ bool ServiceCellular::handle_fatal_failure()
bool ServiceCellular::handle_ready()
{
- LOG_DEBUG("%s", state.c_str());
+ LOG_DEBUG("%s", priv->state->c_str());
sleepTimer.start();
return true;
}
@@ 1986,10 1634,10 @@ bool ServiceCellular::handle_status_check(void)
// modem is already turned on, call configutarion procedure
LOG_INFO("Modem is already turned on.");
LOG_DEBUG("T4 - hot start");
- state.set(this, cellular::State::ST::PowerUpInProgress);
+ priv->state->set(State::ST::PowerUpInProgress);
}
else {
- state.set(this, cellular::State::ST::PowerUpProcedure);
+ priv->state->set(State::ST::PowerUpProcedure);
}
return true;
}
@@ 2011,8 1659,8 @@ void ServiceCellular::handleStateTimer(void)
stateTimeout--;
if (stateTimeout == 0) {
stopStateTimer();
- LOG_FATAL("State %s timeout occured!", state.c_str(state.get()));
- state.set(this, cellular::State::ST::ModemFatalFailure);
+ LOG_FATAL("State %s timeout occured!", priv->state->c_str());
+ priv->state->set(State::ST::ModemFatalFailure);
}
}
@@ 2021,41 1669,43 @@ void ServiceCellular::handle_power_state_change()
nextPowerStateChangeAwaiting = false;
auto modemActive = cmux->isModemActive();
- if (nextPowerState == State::PowerState::On) {
- if (state.get() == State::ST::PowerDownWaiting) {
+ if (priv->nextPowerState == State::PowerState::On) {
+ if (priv->state->get() == State::ST::PowerDownWaiting) {
LOG_DEBUG("Powerdown in progress. Powerup request queued.");
nextPowerStateChangeAwaiting = true;
}
- else if (state.get() == State::ST::PowerUpProcedure || state.get() == State::ST::PowerUpInProgress) {
+ else if (priv->state->get() == State::ST::PowerUpProcedure ||
+ priv->state->get() == State::ST::PowerUpInProgress) {
LOG_DEBUG("Powerup already in progress");
}
- else if (state.get() == State::ST::PowerDown || state.get() == State::ST::WaitForStartPermission) {
+ else if (priv->state->get() == State::ST::PowerDown ||
+ priv->state->get() == State::ST::WaitForStartPermission) {
LOG_INFO("Modem Power UP.");
- state.set(this, State::ST::PowerUpRequest);
+ priv->state->set(State::ST::PowerUpRequest);
}
else {
LOG_DEBUG("Modem already powered up.");
}
}
else {
- if (state.get() == State::ST::PowerUpProcedure || state.get() == State::ST::PowerUpInProgress) {
+ if (priv->state->get() == State::ST::PowerUpProcedure || priv->state->get() == State::ST::PowerUpInProgress) {
LOG_DEBUG("Powerup in progress. Powerdown request queued.");
nextPowerStateChangeAwaiting = true;
}
- else if (state.get() == State::ST::PowerDownWaiting) {
+ else if (priv->state->get() == State::ST::PowerDownWaiting) {
LOG_DEBUG("Powerdown already in progress.");
}
- else if (state.get() == State::ST::PowerDown) {
+ else if (priv->state->get() == State::ST::PowerDown) {
LOG_DEBUG("Modem already powered down.");
}
- else if (state.get() == State::ST::WaitForStartPermission && !modemActive) {
+ else if (priv->state->get() == State::ST::WaitForStartPermission && !modemActive) {
LOG_DEBUG("Modem already powered down.");
- state.set(this, State::ST::PowerDown);
+ priv->state->set(State::ST::PowerDown);
}
else {
LOG_INFO("Modem Power DOWN.");
cmux->turnOffModem();
- state.set(this, State::ST::PowerDownWaiting);
+ priv->state->set(State::ST::PowerDownWaiting);
}
}
}
@@ 2145,7 1795,7 @@ bool ServiceCellular::handle_apn_conf_procedure()
{
LOG_DEBUG("APN on modem configuration");
packetData->setupAPNSettings();
- state.set(this, State::ST::SanityCheck);
+ priv->state->set(State::ST::SanityCheck);
return true;
}
@@ 2287,11 1937,8 @@ auto ServiceCellular::handleCellularCallRequestMessage(CellularCallRequestMessag
return std::make_shared<CellularResponseMessage>(false);
}
- cellular::RequestFactory factory(msg->number.getEntered(),
- *channel,
- msg->requestMode,
- Store::GSM::get()->simCardInserted() ? RequestFactory::SimStatus::SimInsterted
- : RequestFactory::SimStatus::SimSlotEmpty);
+ cellular::RequestFactory factory(
+ msg->number.getEntered(), *channel, msg->callMode, Store::GSM::get()->simCardInserted());
auto request = factory.create();
@@ 2404,7 2051,7 @@ auto ServiceCellular::handleCellularCallerIdMessage(sys::Message *msg) -> std::s
auto ServiceCellular::handleCellularSimProcedureMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
{
- state.set(this, State::ST::SimSelect);
+ priv->state->set(State::ST::SimSelect);
return std::make_shared<CellularResponseMessage>(true);
}
@@ 2489,17 2136,17 @@ auto ServiceCellular::handleEVMStatusMessage(sys::Message *msg) -> std::shared_p
if (board == bsp::Board::T4) {
auto status_pin = message->state;
if (status_pin == value::ACTIVE) {
- if (state.get() == State::ST::PowerUpProcedure) {
- state.set(this, State::ST::PowerUpInProgress); // and go to baud detect as usual
+ if (priv->state->get() == State::ST::PowerUpProcedure) {
+ priv->state->set(State::ST::PowerUpInProgress); // and go to baud detect as usual
}
else {
// asynchronous power toggle should fall back to PowerDown regardless the state
- state.set(this, State::ST::PowerDown);
+ priv->state->set(State::ST::PowerDown);
}
}
else if (status_pin == value::INACTIVE) {
- if (isAfterForceReboot == true || state.get() == State::ST::PowerDownWaiting) {
- state.set(this, State::ST::PowerDown);
+ if (isAfterForceReboot == true || priv->state->get() == State::ST::PowerDownWaiting) {
+ priv->state->set(State::ST::PowerDown);
}
}
}
@@ 2559,12 2206,6 @@ auto ServiceCellular::handleCellularUSSDMessage(sys::Message *msg) -> std::share
return std::make_shared<CellularResponseMessage>(handleUSSDRequest(message->type, message->data));
}
-auto ServiceCellular::handleSimStateMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
-{
- auto message = static_cast<CellularSimStateMessage *>(msg);
- return std::make_shared<CellularResponseMessage>(handleSimState(message->getState(), message->getMessage()));
-}
-
auto ServiceCellular::handleStateRequestMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
{
change_state(dynamic_cast<cellular::StateChange *>(msg));
@@ 2585,15 2226,15 @@ auto ServiceCellular::handlePowerUpProcedureCompleteNotification(sys::Message *m
-> std::shared_ptr<sys::ResponseMessage>
{
if (board == bsp::Board::T3 || board == bsp::Board::Linux) {
- state.set(this, State::ST::CellularConfProcedure);
+ priv->state->set(State::ST::CellularConfProcedure);
}
return std::make_shared<CellularResponseMessage>(true);
}
auto ServiceCellular::handlePowerDownDeregisteringNotification(sys::Message *msg)
-> std::shared_ptr<sys::ResponseMessage>
{
- if (state.get() != State::ST::PowerDownWaiting) {
- state.set(this, State::ST::PowerDownStarted);
+ if (priv->state->get() != State::ST::PowerDownWaiting) {
+ priv->state->set(State::ST::PowerDownStarted);
return std::make_shared<CellularResponseMessage>(true);
}
return std::make_shared<CellularResponseMessage>(false);
@@ 2601,7 2242,7 @@ auto ServiceCellular::handlePowerDownDeregisteringNotification(sys::Message *msg
auto ServiceCellular::handlePowerDownDeregisteredNotification(sys::Message *msg)
-> std::shared_ptr<sys::ResponseMessage>
{
- state.set(this, State::ST::PowerDownWaiting);
+ priv->state->set(State::ST::PowerDownWaiting);
return std::make_shared<CellularResponseMessage>(true);
}
auto ServiceCellular::handleNewIncomingSMSNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
@@ 2612,14 2253,6 @@ auto ServiceCellular::handleNewIncomingSMSNotification(sys::Message *msg) -> std
return std::make_shared<CellularResponseMessage>(true);
}
-auto ServiceCellular::handleSimReadyNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
-{
- if (Store::GSM::get()->tray == Store::GSM::Tray::IN) {
- state.set(this, cellular::State::ST::SimInit);
- }
- return std::make_shared<CellularResponseMessage>(true);
-}
-
auto ServiceCellular::handleSmsDoneNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
{
auto resp = handleTextMessagesInit();
@@ 2634,11 2267,6 @@ auto ServiceCellular::handleNetworkStatusUpdateNotification(sys::Message *msg) -
return std::make_shared<CellularResponseMessage>(false);
}
-auto ServiceCellular::handleSimNotReadyNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
-{
- return std::make_shared<CellularResponseMessage>(false);
-}
-
auto ServiceCellular::handleUrcIncomingNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>
{
// when handling URC, the CPU frequency does not go below a certain level
D module-services/service-cellular/SimCard.cpp => module-services/service-cellular/SimCard.cpp +0 -178
@@ 1,178 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 "SimCard.hpp"
-#include <log/log.hpp>
-#include <variant>
-#include "Result.hpp"
-#include "UrcCpin.hpp" //for Cpin parseState
-#include "UrcFactory.hpp"
-#include <at/ATFactory.hpp>
-#include <at/Cmd.hpp>
-
-SimCardResult SimCard::convertErrorFromATResult(const at::Result atres) const
-{
- if (std::holds_alternative<at::EquipmentErrorCode>(atres.errorCode)) {
-
- auto cerr = static_cast<int>(std::get<at::EquipmentErrorCode>(atres.errorCode));
- if ((cerr > static_cast<int>(SimCardResult::AT_ERROR_Begin)) &&
- (cerr < static_cast<int>(SimCardResult::AT_ERROR_End))) {
- return static_cast<SimCardResult>(cerr);
- }
- }
- return SimCardResult::Unknown;
-}
-
-std::optional<at::response::qpinc::AttemptsCounters> SimCard::getAttemptsCounters(const std::string &type) const
-{
- auto channel = cellularService.cmux->get(CellularMux::Channel::Commands);
- if (channel) {
- auto resp = channel->cmd(at::factory(at::AT::QPINC) + "\"" + type + "\"");
- at::response::qpinc::AttemptsCounters ret;
- if (at::response::parseQPINC(resp, ret)) {
- return ret;
- }
- }
-
- return std::nullopt;
-}
-
-SimCardResult SimCard::supplyPin(const std::string pin) const
-{
- if (auto pc = getAttemptsCounters(); pc) {
- if (pc.value().PinCounter > 0) {
- if (auto channel = cellularService.cmux->get(CellularMux::Channel::Commands); channel) {
- auto resp = channel->cmd(at::factory(at::AT::CPIN) + "\"" + pin + "\"");
-
- if (resp.code == at::Result::Code::OK) {
- return SimCardResult::OK;
- }
- else {
- return convertErrorFromATResult(resp);
- }
- }
- }
- else {
- if (pc.value().PukCounter > 0) {
- return SimCardResult::SIM_PUKRequired;
- }
- else {
- return SimCardResult::Locked;
- }
- }
- }
- return SimCardResult::Unknown;
-}
-
-SimCardResult SimCard::supplyPuk(const std::string puk, const std::string pin) const
-{
- if (auto pc = getAttemptsCounters(); pc) {
- if (pc.value().PukCounter != 0) {
- if (auto channel = cellularService.cmux->get(CellularMux::Channel::Commands); channel) {
- auto resp = channel->cmd(at::factory(at::AT::CPIN) + "\"" + puk + "\"" + ",\"" + pin + "\"");
- if (resp.code == at::Result::Code::OK) {
- return SimCardResult::OK;
- }
- else {
- return convertErrorFromATResult(resp);
- }
- }
- }
- else {
- return SimCardResult::Locked;
- }
- }
-
- return SimCardResult::Unknown;
-}
-
-bool SimCard::isPinLocked() const
-{
- if (auto channel = cellularService.cmux->get(CellularMux::Channel::Commands); channel) {
- auto resp = channel->cmd(at::factory(at::AT::CLCK) + "\"SC\",2\r");
- int val = 0;
- if (at::response::parseCLCK(resp, val)) {
- return val != 0;
- }
- }
- return true;
-}
-
-SimCardResult SimCard::setPinLock(bool lock, const std::string &pin) const
-{
- if (auto pc = getAttemptsCounters(); pc) {
- if (pc.value().PukCounter != 0) {
- auto channel = cellularService.cmux->get(CellularMux::Channel::Commands);
- if (channel) {
- auto resp =
- channel->cmd(at::factory(at::AT::CLCK) + "\"SC\"," + (lock ? "1" : "0") + ",\"" + pin + "\"");
- if (resp.code == at::Result::Code::OK) {
- return SimCardResult::OK;
- }
- else {
- return convertErrorFromATResult(resp);
- }
- }
- }
- else {
- return SimCardResult::Locked;
- }
- }
-
- return SimCardResult::Unknown;
-}
-
-SimCardResult SimCard::changePin(const std::string oldPin, const std::string newPin) const
-{
- if (auto pc = getAttemptsCounters(); pc) {
- if (pc.value().PukCounter != 0) {
- auto channel = cellularService.cmux->get(CellularMux::Channel::Commands);
- if (channel) {
- auto resp = channel->cmd(at::factory(at::AT::CPWD) + "\"SC\", \"" + oldPin + "\",\"" + newPin + "\"");
- if (resp.code == at::Result::Code::OK) {
- return SimCardResult::OK;
- }
- else {
- return convertErrorFromATResult(resp);
- }
- }
- }
- else {
- return SimCardResult::Locked;
- }
- }
-
- return SimCardResult::Unknown;
-}
-
-std::optional<at::SimState> SimCard::simState() const
-{
- std::string buf;
- return simStateWithMessage(buf);
-}
-
-std::optional<at::SimState> SimCard::simStateWithMessage(std::string &message) const
-{
- if (auto channel = cellularService.cmux->get(CellularMux::Channel::Commands); channel) {
- auto resp = channel->cmd(at::factory(at::AT::GET_CPIN));
- if (resp.code == at::Result::Code::OK) {
- if (resp.response.size()) {
- for (auto el : resp.response) {
- auto urc = at::urc::UrcFactory::Create(el);
- auto cpin = std::unique_ptr<at::urc::Cpin>{static_cast<at::urc::Cpin *>(urc.release())};
- if (cpin) {
- return cpin->getState();
- }
- }
- }
- }
- }
- return at::SimState::Unknown;
-}
-
-std::string SimCard::pinToString(std::vector<unsigned int> v)
-{
- std::string buf;
- std::transform(v.begin(), v.end(), std::back_inserter(buf), [](auto &&c) { return '0' + c; });
- return buf;
-}
D module-services/service-cellular/SimCard.hpp => module-services/service-cellular/SimCard.hpp +0 -77
@@ 1,77 0,0 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#pragma once
-
-#include <string>
-
-#include <SimState.hpp>
-
-#include "service-cellular/SimCardResult.hpp"
-#include "service-cellular/CellularMessage.hpp"
-#include "service-cellular/CellularServiceAPI.hpp"
-#include "service-cellular/ServiceCellular.hpp"
-#include "response.hpp"
-
-class SimCard
-{
- public:
- explicit SimCard(ServiceCellular &cellularService) : cellularService(cellularService)
- {}
-
- /** Get information about attempts of PIN and PUK for standard sim card (eg. not PIN2)
- * @return As optional SimCard::AttemptsCounters, in case of error nullopt. Should be noted that in some case could
- * return SIMFailure which could mean 0 attempts (happen if lock during session, on modem/sim reboot again return
- * 0,0);
- */
- std::optional<at::response::qpinc::AttemptsCounters> getAttemptsCounters(
- const std::string &type = SimPinType::SimPin) const;
-
- /** Supply pin for modem
- * \param pin digits as a string from 4-8 digits
- * \return return OK on success in other case see details in SimCardResult
- */
- SimCardResult supplyPin(const std::string pin) const;
-
- /** Supply pin for modem
- * \param puk puk as standard 8 digits
- * \param pin, new pin digits as a string from 4-8 digits
- * \return return OK on success in other case see details in SimCardResult
- */
- SimCardResult supplyPuk(const std::string puk, const std::string pin) const;
-
- /** return whether the pin needs to be provided, only for standard pin.
- * \return true if need pin to unlock SIM card functionality
- */
- bool isPinLocked() const;
-
- /** Set whether to provide pin. Always need to provide actual pin for sim card, only for standard PIN
- * \param lock true for lock SIM card
- * \param pin actual pin for SIM card
- * \return
- */
- SimCardResult setPinLock(bool lock, const std::string &pin) const;
-
- /** Change pin, only for standard pin. To get effect of change pin, SIM cart or modem should be restarted
- * simplest solution is to call AT+CFUN=0/1
- * \param oldPin
- * \param newPin
- * \return return OK on success, else see SimCardResult
- */
- SimCardResult changePin(const std::string oldPin, const std::string newPin) const;
-
- /** Return SIM state based on CPIN AT commands
- */
- std::optional<at::SimState> simState() const;
- std::optional<at::SimState> simStateWithMessage(std::string &message) const;
-
- static std::string pinToString(std::vector<unsigned int> v);
-
- private:
- ServiceCellular &cellularService;
-
- /** Helper function to convert from one enum to another (only with part of them). Base on continuous range of sim
- * errors in AT.
- */
- SimCardResult convertErrorFromATResult(const at::Result) const;
-};
R module-services/service-cellular/include/service-cellular/state.hpp => module-services/service-cellular/include/service-cellular/State.hpp +0 -0
M module-services/service-cellular/include/service-cellular/api/common.hpp => module-services/service-cellular/include/service-cellular/api/common.hpp +2 -2
@@ 22,8 22,8 @@ namespace cellular
enum class SimLockState
{
- Locked,
- Unlocked
+ Enabled,
+ Disabled
};
enum class SimSlot
M module-services/service-cellular/include/service-cellular/api/request/sim.hpp => module-services/service-cellular/include/service-cellular/api/request/sim.hpp +20 -4
@@ 15,7 15,11 @@ namespace cellular::msg::request::sim
{}
const api::SimSlot sim;
- using Response = msg::Response;
+ struct Response : msg::Response
+ {
+ explicit Response(bool retCode) : msg::Response(retCode)
+ {}
+ };
};
/** Get current state of PIN lock
@@ 38,7 42,11 @@ namespace cellular::msg::request::sim
{}
const api::SimCode pin;
- using Response = msg::Response;
+ struct Response : msg::Response
+ {
+ explicit Response(bool retCode) : msg::Response(retCode)
+ {}
+ };
};
/** Change current PIN
@@ 50,7 58,11 @@ namespace cellular::msg::request::sim
const api::SimCode oldPin;
const api::SimCode pin;
- using Response = msg::Response;
+ struct Response : msg::Response
+ {
+ explicit Response(bool retCode) : msg::Response(retCode)
+ {}
+ };
};
/** Reset PIN using PUK
@@ 62,7 74,11 @@ namespace cellular::msg::request::sim
const api::SimCode puk;
const api::SimCode pin;
- using Response = msg::Response;
+ struct Response : msg::Response
+ {
+ explicit Response(bool retCode) : msg::Response(retCode)
+ {}
+ };
};
/** Enable or disable PIN lock on SIM
M module-services/service-cellular/service-cellular/CellularMessage.hpp => module-services/service-cellular/service-cellular/CellularMessage.hpp +15 -349
@@ 4,9 4,8 @@
#pragma once
#include "SignalStrength.hpp"
-#include "State.hpp"
+#include <service-cellular/State.hpp>
-#include <MessageType.hpp>
#include <modem/mux/CellularMux.h>
#include <PhoneNumber.hpp>
#include <Service/Message.hpp>
@@ 24,6 23,8 @@
#include <service-appmgr/service-appmgr/data/SimActionsParams.hpp>
#include <service-appmgr/service-appmgr/data/MmiActionsParams.hpp>
+#include <service-cellular/api/common.hpp>
+
class CellularMessage : public sys::DataMessage
{
public:
@@ 41,9 42,8 @@ class CellularMessage : public sys::DataMessage
PowerStateChange, ///< Change power state of the module
ListCurrentCalls,
- SimProcedure, // Broadcast on sim state changed
- SimResponse, // Send to PIN window (show, error state, hide)
- SimVerifyPinRequest, // Send from PIN window with PIN, PUK, ... number
+ SimProcedure, // Broadcast on sim state changed
+ SimResponse, // Send to PIN window (show, error state, hide)
SetVoLTE,
SetFlightMode,
@@ 139,8 139,6 @@ class CellularNotificationMessage : public CellularMessage
NetworkStatusUpdate, // update of the status of the network
PowerUpProcedureComplete, // modem without cmux on initialization complete (cold start || reset modem -> and
// cold start)
- SIM_READY, // change on SIM from URC
- SIM_NOT_READY, // change to not existing/not valid SIM
PowerDownDeregistering, // modem informed it has started to disconnect from network
PowerDownDeregistered, // modem informed it has disconnected from network
SMSDone, // SMS initialization finished
@@ 217,17 215,17 @@ class CellularSetOperatorMessage : public sys::DataMessage
class CellularPowerStateChange : public CellularMessage
{
public:
- explicit CellularPowerStateChange(cellular::State::PowerState new_state)
+ explicit CellularPowerStateChange(cellular::service::State::PowerState new_state)
: CellularMessage(Type::PowerStateChange), newState(new_state)
{}
- cellular::State::PowerState getNewState() const noexcept
+ cellular::service::State::PowerState getNewState() const noexcept
{
return newState;
}
private:
- cellular::State::PowerState newState;
+ cellular::service::State::PowerState newState;
};
class CellularStartOperatorsScanMessage : public CellularMessage
@@ 245,28 243,6 @@ class CellularStartOperatorsScanMessage : public CellularMessage
}
};
-class CellularSimStateMessage : public CellularMessage
-{
- private:
- at::SimState state;
- std::string message;
-
- public:
- explicit CellularSimStateMessage(at::SimState state, std::string message)
- : CellularMessage(Type::SimState), state(state), message(std::move(message))
- {}
-
- at::SimState getState() const noexcept
- {
- return state;
- }
-
- std::string getMessage() const
- {
- return message;
- }
-};
-
class CellularTimeNotificationMessage : public CellularMessage
{
private:
@@ 354,17 330,12 @@ class CellularAntennaRequestMessage : public CellularMessage
class CellularCallRequestMessage : public CellularMessage
{
public:
- enum class RequestMode
- {
- Normal,
- Emergency
- };
-
- CellularCallRequestMessage(const utils::PhoneNumber::View &number, RequestMode requestMode = RequestMode::Normal)
- : CellularMessage(Type::CallRequest), number(number), requestMode(requestMode)
+ CellularCallRequestMessage(const utils::PhoneNumber::View &number,
+ cellular::api::CallMode callMode = cellular::api::CallMode::Regular)
+ : CellularMessage(Type::CallRequest), number(number), callMode(callMode)
{}
utils::PhoneNumber::View number;
- RequestMode requestMode = RequestMode::Normal;
+ cellular::api::CallMode callMode = cellular::api::CallMode::Regular;
};
class CellularSmsNoSimRequestMessage : public CellularMessage, public app::manager::actions::ConvertibleToAction
@@ 380,267 351,6 @@ class CellularSmsNoSimRequestMessage : public CellularMessage, public app::manag
}
};
-class CellularSimMessage : public CellularMessage
-{
- public:
- CellularSimMessage(Type type, Store::GSM::SIM sim) : CellularMessage(type), sim(sim)
- {}
- virtual ~CellularSimMessage() = default;
- Store::GSM::SIM getSimCard() const noexcept
- {
- return sim;
- }
-
- private:
- Store::GSM::SIM sim = defaultSimCard;
- static const Store::GSM::SIM defaultSimCard = Store::GSM::SIM::SIM1;
-};
-
-/// Message use only for mockup GUI purposes
-class CellularSimVerifyPinRequestMessage : public CellularSimMessage
-{
- public:
- CellularSimVerifyPinRequestMessage(Store::GSM::SIM sim, std::vector<unsigned int> pinValue)
- : CellularSimMessage(Type::SimVerifyPinRequest, sim), pinValue(std::move(pinValue))
- {}
- CellularSimVerifyPinRequestMessage(Store::GSM::SIM sim,
- std::vector<unsigned int> pinValue,
- std::vector<unsigned int> pukValue)
- : CellularSimMessage(Type::SimVerifyPinRequest, sim), pinValue(std::move(pinValue)),
- pukValue(std::move(pukValue))
- {}
-
- std::vector<unsigned int> getPinValue() const
- {
- return pinValue;
- }
- std::vector<unsigned int> getPukValue() const
- {
- return pukValue;
- }
-
- private:
- std::vector<unsigned int> pinValue;
- std::vector<unsigned int> pukValue;
-};
-
-class CellularSimPasscodeRequest : public CellularMessage
-{
- protected:
- app::manager::actions::PasscodeParams params;
-
- CellularSimPasscodeRequest(Store::GSM::SIM _sim, unsigned int _attempts, std::string _passcodeName)
- : CellularMessage(Type::SimResponse), params(_sim, _attempts, std::move(_passcodeName))
- {}
-};
-
-class CellularSimRequestPinMessage : public CellularSimPasscodeRequest,
- public app::manager::actions::ConvertibleToAction
-{
- public:
- CellularSimRequestPinMessage(Store::GSM::SIM _sim, unsigned int _attempts, std::string _passcodeName)
- : CellularSimPasscodeRequest(_sim, _attempts, std::move(_passcodeName))
- {}
-
- [[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
- {
- return std::make_unique<app::manager::ActionRequest>(
- sender, app::manager::actions::RequestPin, std::make_unique<app::manager::actions::PasscodeParams>(params));
- }
-};
-
-class CellularSimRequestPukMessage : public CellularSimPasscodeRequest,
- public app::manager::actions::ConvertibleToAction
-{
- public:
- CellularSimRequestPukMessage(Store::GSM::SIM _sim, unsigned int _attempts, std::string _passcodeName)
- : CellularSimPasscodeRequest(_sim, _attempts, std::move(_passcodeName))
- {}
-
- [[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
- {
- return std::make_unique<app::manager::ActionRequest>(
- sender, app::manager::actions::RequestPuk, std::make_unique<app::manager::actions::PasscodeParams>(params));
- }
-};
-
-class CellularUnlockSimMessage : public CellularMessage, public app::manager::actions::ConvertibleToAction
-{
- app::manager::actions::SimStateParams params;
-
- public:
- CellularUnlockSimMessage(Store::GSM::SIM _sim) : CellularMessage(Type::SimResponse), params(_sim)
- {}
-
- [[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
- {
- return std::make_unique<app::manager::ActionRequest>(
- sender, app::manager::actions::UnlockSim, std::make_unique<app::manager::actions::SimStateParams>(params));
- }
-};
-
-class CellularBlockSimMessage : public CellularMessage, public app::manager::actions::ConvertibleToAction
-{
- app::manager::actions::SimStateParams params;
-
- public:
- explicit CellularBlockSimMessage(Store::GSM::SIM _sim) : CellularMessage(Type::SimResponse), params(_sim)
- {}
-
- [[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
- {
- return std::make_unique<app::manager::ActionRequest>(
- sender, app::manager::actions::BlockSim, std::make_unique<app::manager::actions::SimStateParams>(params));
- }
-};
-
-class CellularDisplayCMEMessage : public CellularMessage, public app::manager::actions::ConvertibleToAction
-{
- app::manager::actions::UnhandledCMEParams params;
-
- public:
- CellularDisplayCMEMessage(Store::GSM::SIM _sim, unsigned int _cmeCode)
- : CellularMessage(Type::SimResponse), params(_sim, _cmeCode)
- {}
-
- [[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
- {
- return std::make_unique<app::manager::ActionRequest>(
- sender,
- app::manager::actions::DisplayCMEError,
- std::make_unique<app::manager::actions::UnhandledCMEParams>(params));
- }
-};
-
-class CellularSimDataMessage : public CellularMessage
-{
- Store::GSM::SIM sim = Store::GSM::SIM::NONE;
-
- public:
- explicit CellularSimDataMessage(Store::GSM::SIM _sim) : CellularMessage{Type::SimResponse}, sim{_sim}
- {}
- [[nodiscard]] Store::GSM::SIM getSim() const noexcept
- {
- return sim;
- }
-};
-
-class CellularChangeSimDataMessage : public CellularSimDataMessage
-{
- public:
- CellularChangeSimDataMessage(Store::GSM::SIM _sim) : CellularSimDataMessage{_sim}
- {}
-};
-
-class CellularSimPinDataMessage : public CellularSimDataMessage
-{
- std::vector<unsigned int> pinValue;
-
- public:
- CellularSimPinDataMessage(Store::GSM::SIM _sim, std::vector<unsigned int> _pinValue)
- : CellularSimDataMessage{_sim}, pinValue{std::move(_pinValue)}
- {}
-
- [[nodiscard]] const std::vector<unsigned int> &getPin() const noexcept
- {
- return pinValue;
- }
-};
-
-class CellularSimNewPinDataMessage : public CellularSimDataMessage
-{
- std::vector<unsigned int> oldPin;
- std::vector<unsigned int> newPin;
-
- public:
- CellularSimNewPinDataMessage(Store::GSM::SIM _sim,
- std::vector<unsigned int> _oldPin,
- std::vector<unsigned int> _newPin)
- : CellularSimDataMessage{_sim}, oldPin{std::move(_oldPin)}, newPin{std::move(_newPin)}
- {}
-
- [[nodiscard]] const std::vector<unsigned int> &getOldPin() const noexcept
- {
- return oldPin;
- }
- [[nodiscard]] const std::vector<unsigned int> &getNewPin() const noexcept
- {
- return newPin;
- }
-};
-
-class CellularSimCardPinLockStateRequestDataMessage : public sys::DataMessage
-{};
-
-class CellularSimCardPinLockStateResponseDataMessage : public sys::DataMessage
-{
- public:
- explicit CellularSimCardPinLockStateResponseDataMessage(bool state) : simCardPinLockState(state)
- {}
-
- [[nodiscard]] bool getSimCardPinLockState() const noexcept
- {
- return simCardPinLockState;
- }
-
- private:
- const bool simCardPinLockState;
-};
-
-class CellularSimCardLockDataMessage : public CellularSimDataMessage
-{
-
- public:
- enum class SimCardLock
- {
- Locked,
- Unlocked
- };
- CellularSimCardLockDataMessage(Store::GSM::SIM _sim, SimCardLock _simCardLock, std::vector<unsigned int> _pin)
- : CellularSimDataMessage{_sim}, simCardLock{_simCardLock}, pin{std::move(_pin)}
- {}
-
- [[nodiscard]] SimCardLock getLock() const noexcept
- {
- return simCardLock;
- }
- [[nodiscard]] const std::vector<unsigned int> &getPin() const noexcept
- {
- return pin;
- }
-
- private:
- SimCardLock simCardLock;
- std::vector<unsigned int> pin;
-};
-
-class CellularSimPukDataMessage : public CellularSimDataMessage
-{
- std::vector<unsigned int> puk;
- std::vector<unsigned int> newPin;
-
- public:
- CellularSimPukDataMessage(Store::GSM::SIM _sim, std::vector<unsigned int> _puk, std::vector<unsigned int> _newPin)
- : CellularSimDataMessage{_sim}, puk{std::move(_puk)}, newPin{std::move(_newPin)}
- {}
-
- [[nodiscard]] const std::vector<unsigned int> &getPuk() const noexcept
- {
- return puk;
- }
- [[nodiscard]] const std::vector<unsigned int> &getNewPin() const noexcept
- {
- return newPin;
- }
-};
-
-class CellularSimAbortMessage : public CellularSimDataMessage
-{
- public:
- explicit CellularSimAbortMessage(Store::GSM::SIM _sim) : CellularSimDataMessage{_sim}
- {}
-};
-
class CellularGetChannelMessage : public CellularMessage
{
public:
@@ 677,35 387,6 @@ class CellularResponseMessage : public sys::ResponseMessage
CellularMessage::Type cellResponse;
};
-class CellularSimNewPinResponseMessage : public CellularResponseMessage
-{
- public:
- explicit CellularSimNewPinResponseMessage(bool retCode) : CellularResponseMessage(retCode)
- {}
-};
-
-class CellularSimPukResponseMessage : public CellularResponseMessage
-{
- public:
- explicit CellularSimPukResponseMessage(bool retCode) : CellularResponseMessage(retCode)
- {}
-};
-
-class CellularSimCardLockResponseMessage : public CellularResponseMessage
-{
- CellularSimCardLockDataMessage::SimCardLock cardLock;
-
- public:
- CellularSimCardLockResponseMessage(bool retCode, CellularSimCardLockDataMessage::SimCardLock cardLock)
- : CellularResponseMessage(retCode), cardLock(cardLock)
- {}
-
- [[nodiscard]] auto getSimCardLock() const noexcept -> CellularSimCardLockDataMessage::SimCardLock
- {
- return cardLock;
- }
-};
-
class CellularGetOwnNumberResponseMessage : public CellularResponseMessage
{
public:
@@ 1040,14 721,6 @@ class CellularNewIncomingSMSNotification : public CellularNotificationMessage
{}
};
-class CellularSimReadyNotification : public CellularNotificationMessage
-{
- public:
- explicit CellularSimReadyNotification(const std::string &data = "")
- : CellularNotificationMessage(CellularNotificationMessage::Content::SIM_READY, data)
- {}
-};
-
class CellularSmsDoneNotification : public CellularNotificationMessage
{
public:
@@ 1072,14 745,6 @@ class CellularNetworkStatusUpdateNotification : public CellularNotificationMessa
{}
};
-class CellularSimNotReadyNotification : public CellularNotificationMessage
-{
- public:
- explicit CellularSimNotReadyNotification(const std::string &data = "")
- : CellularNotificationMessage(CellularNotificationMessage::Content::SIM_NOT_READY, data)
- {}
-};
-
class CellularUrcIncomingNotification : public CellularNotificationMessage
{
public:
@@ 1190,8 855,9 @@ namespace cellular
class StateChange : public CellularMessage
{
public:
- const State::ST request;
- StateChange(const State::ST request = State::ST::Failed) : CellularMessage(Type::StateRequest), request(request)
+ const service::State::ST request;
+ StateChange(const service::State::ST request = service::State::ST::Failed)
+ : CellularMessage(Type::StateRequest), request(request)
{}
};
M module-services/service-cellular/service-cellular/CellularServiceAPI.hpp => module-services/service-cellular/service-cellular/CellularServiceAPI.hpp +1 -11
@@ 92,16 92,6 @@ namespace CellularServiceAPI
bool USSDRequest(sys::Service *serv, CellularUSSDMessage::RequestType type, std::string data = "");
- bool ChangeSimPin(sys::Service *serv,
- Store::GSM::SIM sim,
- const std::vector<unsigned int> &passcode,
- const std::vector<unsigned int> &pin);
- bool RequestSimCardPinLockState(sys::Service *serv);
- bool SetSimCardLock(sys::Service *serv,
- Store::GSM::SIM sim,
- CellularSimCardLockDataMessage::SimCardLock lock,
- const std::vector<unsigned int> &pin);
- bool SetSimCard(sys::Service *serv, Store::GSM::SIM sim);
/**
* @brief get all APNs from phone configuration
*/
@@ 144,7 134,7 @@ namespace CellularServiceAPI
bool GetDataTransfer(sys::Service *serv);
bool SetVoLTE(sys::Service *serv, bool value);
- bool ChangeModulePowerState(sys::Service *serv, cellular::State::PowerState newState);
+ bool ChangeModulePowerState(sys::Service *serv, cellular::service::State::PowerState newState);
bool SetFlightMode(sys::Service *serv, bool flightModeOn);
M module-services/service-cellular/service-cellular/RequestFactory.hpp => module-services/service-cellular/service-cellular/RequestFactory.hpp +4 -10
@@ 21,16 21,10 @@ namespace cellular
class RequestFactory
{
public:
- enum class SimStatus
- {
- SimInsterted,
- SimSlotEmpty
- };
-
RequestFactory(const std::string &data,
at::BaseChannel &channel,
- CellularCallRequestMessage::RequestMode requestMode,
- SimStatus simCardStatus);
+ cellular::api::CallMode callMode,
+ bool simInserted);
std::unique_ptr<IRequest> create();
private:
@@ 41,7 35,7 @@ namespace cellular
std::vector<std::pair<std::string, CreateCallback>> requestMap;
at::BaseChannel &channel;
- const CellularCallRequestMessage::RequestMode requestMode;
- const SimStatus simStatus;
+ const cellular::api::CallMode callMode;
+ const bool simInserted;
};
} // namespace cellular
M module-services/service-cellular/service-cellular/ServiceCellular.hpp => module-services/service-cellular/service-cellular/ServiceCellular.hpp +11 -84
@@ 3,11 3,8 @@
#pragma once
-#include "SimCardResult.hpp"
-
#include "CellularCall.hpp"
#include "CellularMessage.hpp"
-#include "State.hpp"
#include "USSD.hpp"
#include "PacketData.hpp"
#include "PacketDataCellularMessage.hpp"
@@ 37,7 34,6 @@
#include <vector> // for vector
#include <cstdint>
-
namespace db
{
namespace query
@@ 61,6 57,11 @@ namespace constants
class ConnectionManager;
+namespace cellular::internal
+{
+ class ServiceCellularPriv;
+}
+
class ServiceCellular : public sys::Service
{
@@ 104,75 105,6 @@ class ServiceCellular : public sys::Service
bool getIMSI(std::string &destination, bool fullNumber = false);
std::vector<std::string> getNetworkInfo();
- /** group of action/messages send "outside" eg. GUI
- * requestPin is call anytime modem need pin, here should be called any action
- * which allow user input (or mockup) pin. Then send appropriate action to notify the modem
- * \param attempts Attempts counter for current action
- * \param msg Literal name of action eg. SIM PIN
- * \return
- */
- bool requestPin(unsigned int attempts, const std::string msg);
-
- /** requestPuk is call anytime modem need puk, here should be called any action
- * which allow user input (or mockup) puk and new pin. Then send appropriate action to notify the modem
- * \param attempts Attempts counter for current action
- * \param msg Literal name of action eg. SIM PUK
- * \return
- */
- bool requestPuk(unsigned int attempts, const std::string msg);
-
- /** Call in case of SIM card unlocked, MT ready. Place for sending message/action inform rest
- * \return
- */
- bool sendSimUnlocked();
-
- /** Call in case of SIM card locked (card fail, eg. to many bad PUK). Place for sending message/action inform rest
- * \return
- */
- bool sendSimBlocked();
-
- /** From this point should be send message/action call interaction in other layers eg. GUI
- * \param cme_error
- * \return
- */
- bool sendUnhandledCME(unsigned int cme_error);
-
- /** Similar to sendBadPin
- * \return
- */
- bool sendBadPin();
-
- /** Message send, when modem return incorrect password for PIN message.
- * Probably modem firmware depend. On current version last bad message (attempts=1) return PUK request
- * and generate PUK URC, so finally action on puk request will be call. This implementation allow to
- * rethrow URC (so achive similar behavior in all cases).
- * \return
- */
- bool sendBadPuk();
-
- /** Place to send action notifying eg. GUI
- * \param res
- * \return
- */
- bool sendChangePinResult(SimCardResult res);
-
- /// sim functionality
-
- /** Function checks if sim pin is locked (enabled)
- * @return True if sim pin is locked, False if it's not
- */
- bool isPinLocked();
-
- /** Function ready for change pin action send to Service Cellular form eg. GUI
- * \param oldPin
- * \param newPin
- * \return
- */
- bool changePin(const std::string oldPin, const std::string newPin);
- bool unlockSimPin(std::string pin);
- bool unlockSimPuk(std::string puk, std::string pin);
- bool setPinLock(bool lock, const std::string pin);
-
private:
at::ATURCStream atURCStream;
std::unique_ptr<CellularMux> cmux = std::make_unique<CellularMux>(PortSpeed_e::PS460800, this);
@@ 198,11 130,10 @@ class ServiceCellular : public sys::Service
std::unique_ptr<packet_data::PacketData> packetData;
std::unique_ptr<sys::phone_modes::Observer> phoneModeObserver;
std::unique_ptr<ConnectionManager> connectionManager;
- cellular::State state;
bsp::Board board = bsp::Board::none;
/// URC GSM notification handler
- std::optional<std::shared_ptr<CellularMessage>> identifyNotification(const std::string &data);
+ std::optional<std::shared_ptr<sys::Message>> identifyNotification(const std::string &data);
std::vector<std::string> messageParts;
@@ 218,9 149,8 @@ class ServiceCellular : public sys::Service
};
bool resetCellularModule(ResetType type);
- bool isAfterForceReboot = false;
- bool nextPowerStateChangeAwaiting = false;
- cellular::State::PowerState nextPowerState = cellular::State::PowerState::Off;
+ bool isAfterForceReboot = false;
+ bool nextPowerStateChangeAwaiting = false;
/// one point of state change handling
void change_state(cellular::StateChange *msg);
@@ 305,10 235,6 @@ class ServiceCellular : public sys::Service
bool handleUSSDURC();
void handleUSSDTimer();
- bool handleSimState(at::SimState state, const std::string message);
- auto handleSimPinMessage(sys::Message *msgl) -> std::shared_ptr<sys::ResponseMessage>;
- auto handleSimPukMessage(sys::Message *msgl) -> std::shared_ptr<sys::ResponseMessage>;
-
std::shared_ptr<cellular::RawCommandRespAsync> handleCellularStartOperatorsScan(
CellularStartOperatorsScanMessage *msg);
@@ 376,11 302,9 @@ class ServiceCellular : public sys::Service
auto handlePowerDownDeregisteredNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleNewIncomingSMSNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleRawCommandNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
- auto handleSimReadyNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleSmsDoneNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleSignalStrengthUpdateNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleNetworkStatusUpdateNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
- auto handleSimNotReadyNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleUrcIncomingNotification(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleCellularSetFlightModeMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
auto handleCellularSetRadioOnOffMessage(sys::Message *msg) -> std::shared_ptr<sys::ResponseMessage>;
@@ 392,6 316,9 @@ class ServiceCellular : public sys::Service
auto isIncommingCallAllowed() -> bool;
auto hangUpCall() -> bool;
+
+ private:
+ std::unique_ptr<cellular::internal::ServiceCellularPriv> priv;
};
namespace sys
D module-services/service-cellular/service-cellular/SimCardResult.hpp => module-services/service-cellular/service-cellular/SimCardResult.hpp +0 -33
@@ 1,33 0,0 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#pragma once
-class SimPinType
-{
- public:
- static constexpr auto SimPin = "SC";
- static constexpr auto SimPin2 = "P2";
-};
-enum class SimCardResult
-{
- OK = 0,
- Ready = 1,
- Locked = 2, /*!< In case of attempt counters set to 0 */
-
- AT_ERROR_Begin =
- 9, /*!< this is only for separate AT SIM errors from new one added, AT errors list end with AT_ERROR_End */
-
- SIMNotInserted = 10,
- SIM_PIN_required = 11,
- SIM_PUKRequired = 12,
- Failure = 13,
- Busy = 14,
- Wrong = 15,
- IncorrectPassword = 16,
-
- AT_ERROR_End = 17,
-
- Unknown = 0xFF /*!< Unknown, any reason (not only AT), in some case AT commends return just error, eg. twice
- supply good pin, second AT commend return ERROR */
-
-};
D module-services/service-cellular/service-cellular/State.hpp => module-services/service-cellular/service-cellular/State.hpp +0 -59
@@ 1,59 0,0 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#pragma once
-
-class ServiceCellular;
-
-namespace cellular
-{
- class State
- {
- public:
- enum class ST
- {
- Idle, /// does nothing
- WaitForStartPermission, /// waiting for permission to start the module
- PowerUpRequest, /// process request of power up
- StatusCheck, /// set on service start - check for modem status - skipped on T3 board
- PowerUpProcedure, /// due to lack of Status pin on T3, we don't know whether is on or off
- PowerUpInProgress, /// waiting for modem powered up by polling various bauds
- BaudDetect, /// baud detection procedure
- CellularConfProcedure, /// configuration procedure
- AudioConfigurationProcedure, /// audio configuration for modem (could be in ModemConfiguration)
- APNConfProcedure, /// Configure APN set by user, check if modem have similar
- SanityCheck, /// prior to ModemOn last sanity checks for one time configurations etc
- ModemOn, /// modem ready - indicates that modem is fully configured, ( **SIM is not yet configured** )
- URCReady, /// State indicates that URC handling is enabled
- SimInit, /// initialize sim card
- SimSelect, /// triggers hw SIM selection (! state now will be **changed on URC** )
- ModemFatalFailure, /// modem full shutdown need
- Failed,
- Ready, /// Service is fully initialized
- PowerDownStarted, /// modem is disconnecting from network. It might take a while if poor coverage
- PowerDownWaiting, /// modem has deregistered and is now approaching low power state
- PowerDown, /// modem is known to be turned off
- };
-
- enum class PowerState
- {
- Off,
- On
- };
-
- private:
- enum ST state = ST::Idle;
-
- public:
- [[nodiscard]] static const char *c_str(ST state);
- [[nodiscard]] const char *c_str();
-
- /// 1. sets state of ServiceCellular
- /// 2. sends Multicast notification of ServiceCellular state
- ///
- /// \note This is for service cellular only it could be private and friend
- void set(ServiceCellular *owner, ST state);
-
- ST get() const;
- };
-} // namespace cellular
M module-services/service-cellular/src/ServiceCellularPriv.hpp => module-services/service-cellular/src/ServiceCellularPriv.hpp +3 -1
@@ 4,7 4,7 @@
#pragma once
#include <service-cellular/ServiceCellular.hpp>
-#include <service-cellular/state.hpp>
+#include <service-cellular/State.hpp>
#include "SimCard.hpp"
@@ 29,5 29,7 @@ namespace cellular::internal
private:
void initSimCard();
+
+ friend class ::ServiceCellular;
};
} // namespace cellular::internal
M module-services/service-cellular/src/SimCard.cpp => module-services/service-cellular/src/SimCard.cpp +1 -1
@@ 80,7 80,7 @@ namespace cellular
bool SimCard::handleSetPinLock(const api::SimCode &pin, api::SimLockState lock)
{
const auto _pin = internal::simCodeToString(pin);
- return processPinResult(setPinLock(_pin, lock == cellular::api::SimLockState::Locked));
+ return processPinResult(setPinLock(_pin, lock == cellular::api::SimLockState::Enabled));
}
bool SimCard::handlePinUnlock(const api::SimCode &pin)
M module-services/service-cellular/src/SimCard.hpp => module-services/service-cellular/src/SimCard.hpp +1 -1
@@ 71,7 71,7 @@ namespace cellular::service
/** Set cmd channel
* \param channel channel (or nullptr to block communication)
*/
- void setChannel(at::BaseChannel *channel = nullptr);
+ void setChannel(at::BaseChannel *channel);
/**
* Request message handlers
R module-services/service-cellular/src/state.cpp => module-services/service-cellular/src/State.cpp +2 -2
@@ 1,7 1,7 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include <service-cellular/state.hpp>
+#include <service-cellular/State.hpp>
#include <Service/Service.hpp>
#include <service-cellular/CellularMessage.hpp>
@@ 68,7 68,7 @@ namespace cellular::service
{
LOG_DEBUG("GSM state: (%s) -> (%s)", c_str(this->state), c_str(state));
this->state = state;
- auto msg = std::make_shared<StateChange>(static_cast<cellular::State::ST>(state));
+ auto msg = std::make_shared<StateChange>(state);
owner->bus.sendMulticast(msg, sys::BusChannel::ServiceCellularNotifications);
}
M module-services/service-cellular/tests/unittest_datatransfer.cpp => module-services/service-cellular/tests/unittest_datatransfer.cpp +0 -2
@@ 8,8 8,6 @@
#include "Result.hpp"
#include <service-cellular/PacketData.hpp>
-using namespace cellular;
-
TEST_CASE("Quectel AT DataTransfer commands")
{
SECTION("QIACT")
M module-services/service-cellular/tests/unittest_qmbn.cpp => module-services/service-cellular/tests/unittest_qmbn.cpp +0 -2
@@ 6,8 6,6 @@
#include <catch2/catch.hpp>
#include <service-cellular/QMBNManager.hpp>
-using namespace cellular;
-
TEST_CASE("Quectel MBN test")
{
SECTION("Parse list of MBN")
M module-services/service-cellular/tests/unittest_request_factory.cpp => module-services/service-cellular/tests/unittest_request_factory.cpp +4 -8
@@ 111,10 111,9 @@ TEST_CASE("Emergency handling")
RequestFactory requestFactory(test.number,
dummyChannel,
- test.isEmergencyRequest ? CellularCallRequestMessage::RequestMode::Emergency
- : CellularCallRequestMessage::RequestMode::Normal,
- test.insertSim ? RequestFactory::SimStatus::SimInsterted
- : RequestFactory::SimStatus::SimSlotEmpty);
+ test.isEmergencyRequest ? cellular::api::CallMode::Emergency
+ : cellular::api::CallMode::Regular,
+ test.insertSim);
std::shared_ptr<IRequest> request = requestFactory.create();
INFO("Failed test case idx: " + std::to_string(idx));
@@ 445,10 444,7 @@ TEST_CASE("MMI requests")
for (auto &testCase : testCases) {
auto mockChannel = at::GenericChannel(at::Result::Code::OK, {});
- RequestFactory requestFactory(testCase.requestString,
- mockChannel,
- CellularCallRequestMessage::RequestMode::Normal,
- RequestFactory::SimStatus::SimInsterted);
+ RequestFactory requestFactory(testCase.requestString, mockChannel, cellular::api::CallMode::Regular, true);
auto request = requestFactory.create();
auto requestCommand = request->command();
M module-services/service-cellular/tests/unittest_simcard.cpp => module-services/service-cellular/tests/unittest_simcard.cpp +1 -1
@@ 43,7 43,7 @@ namespace at
TEST_CASE("SimCard functionality test")
{
- SECTION("pinToString from vector")
+ SECTION("simCodeToString()")
{
cellular::api::SimCode v{1, 2, 3, 4};
cellular::api::SimCode empty;
M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp +6 -7
@@ 11,6 11,7 @@
#include <service-cellular/ServiceCellular.hpp>
#include <service-bluetooth/messages/Status.hpp>
#include <service-cellular/CellularServiceAPI.hpp>
+#include <service-cellular-api>
#include <gui/Common.hpp>
#include <service-appmgr/Actions.hpp>
@@ 254,21 255,19 @@ bool DeveloperModeHelper::sendKeypress(bsp::KeyCodes keyCode, gui::InputEvent::S
void DeveloperModeHelper::requestSimChange(const int simSelected)
{
- Store::GSM::SIM sim = Store::GSM::SIM::SIM1;
- if (simSelected == static_cast<int>(Store::GSM::SIM::SIM2)) {
- sim = Store::GSM::SIM::SIM2;
- }
- CellularServiceAPI::SetSimCard(owner, sim);
+ auto arg = (simSelected == static_cast<int>(cellular::api::SimSlot::SIM2)) ? cellular::api::SimSlot::SIM2
+ : cellular::api::SimSlot::SIM1;
+ owner->bus.sendUnicast<cellular::msg::request::sim::SetActiveSim>(arg);
}
bool DeveloperModeHelper::requestCellularPowerStateChange(const int cellularState)
{
bool res = false;
if (cellularState == 1) {
- res = CellularServiceAPI::ChangeModulePowerState(owner, cellular::State::PowerState::Off);
+ res = CellularServiceAPI::ChangeModulePowerState(owner, cellular::service::State::PowerState::Off);
}
else if (cellularState == 2) {
- res = CellularServiceAPI::ChangeModulePowerState(owner, cellular::State::PowerState::On);
+ res = CellularServiceAPI::ChangeModulePowerState(owner, cellular::service::State::PowerState::On);
}
else if (cellularState == 3) {
auto event = std::make_unique<sdesktop::developerMode::CellularHotStartEvent>();
M module-services/service-fota/ServiceFota.cpp => module-services/service-fota/ServiceFota.cpp +2 -2
@@ 105,8 105,8 @@ namespace FotaService
sys::MessagePointer Service::handleServiceCellularNotifications(sys::Message *req)
{
if (auto msg = dynamic_cast<cellular::StateChange *>(req)) {
- LOG_DEBUG("cellular::StageChange: %s", cellular::State::c_str(msg->request));
- if (msg->request == cellular::State::ST::Ready) {
+ LOG_DEBUG("cellular::StageChange: %s", cellular::service::State::c_str(msg->request));
+ if (msg->request == cellular::service::State::ST::Ready) {
LOG_DEBUG("Modem is \"Ready\"");
if (dataChannel == nullptr) {
LOG_DEBUG("Requesting channel");
M module-sys/SystemManager/SystemManager.cpp => module-sys/SystemManager/SystemManager.cpp +4 -4
@@ 436,7 436,7 @@ namespace sys
void SystemManager::batteryCriticalLevelAction(bool charging)
{
LOG_INFO("Battery Critical Level reached!");
- CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::Off);
+ CellularServiceAPI::ChangeModulePowerState(this, cellular::service::State::PowerState::Off);
auto msg = std::make_shared<CriticalBatteryLevelNotification>(true, charging);
bus.sendUnicast(std::move(msg), app::manager::ApplicationManager::ServiceName);
}
@@ 450,7 450,7 @@ namespace sys
void SystemManager::batteryNormalLevelAction()
{
LOG_INFO("Battery level normal.");
- CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::On);
+ CellularServiceAPI::ChangeModulePowerState(this, cellular::service::State::PowerState::On);
auto battNormalMsg = std::make_shared<CriticalBatteryLevelNotification>(false);
bus.sendUnicast(std::move(battNormalMsg), app::manager::ApplicationManager::ServiceName);
}
@@ 535,12 535,12 @@ namespace sys
connect(CellularCheckIfStartAllowedMessage(), [&](Message *) {
switch (Store::Battery::get().levelState) {
case Store::Battery::LevelState::Normal:
- CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::On);
+ CellularServiceAPI::ChangeModulePowerState(this, cellular::service::State::PowerState::On);
break;
case Store::Battery::LevelState::CriticalCharging:
[[fallthrough]];
case Store::Battery::LevelState::CriticalNotCharging:
- CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::Off);
+ CellularServiceAPI::ChangeModulePowerState(this, cellular::service::State::PowerState::Off);
break;
case Store::Battery::LevelState::Shutdown:
break;
M module-utils/common_data/EventStore.hpp => module-utils/common_data/EventStore.hpp +3 -2
@@ 10,6 10,7 @@
// it's not meant to serve as polling interface - rather to serve data
#include <cstddef>
+#include <service-cellular/api/common.hpp>
namespace cpp_freertos
{
@@ 107,8 108,8 @@ namespace Store
/// selected - tray selection settings settable sim tray
enum class SIM
{
- SIM1,
- SIM2,
+ SIM1 = static_cast<int>(cellular::api::SimSlot::SIM1),
+ SIM2 = static_cast<int>(cellular::api::SimSlot::SIM2),
SIM_FAIL,
SIM_UNKNOWN,
NONE,