M module-services/service-cellular/requests/CallBarringRequest.cpp => module-services/service-cellular/requests/CallBarringRequest.cpp +2 -2
@@ 24,7 24,7 @@ namespace cellular
return nullptr;
}
- auto CallBarringRequest::command() -> std::string
+ auto CallBarringRequest::command() -> at::Cmd
{
std::vector<commandBuilderFunc> commandParts = {
[this]() { return getCommandFacility(); },
@@ 33,7 33,7 @@ namespace cellular
[this]() { return getCommandClass(); },
};
- return buildCommand(at::AT::CLCK, commandParts);
+ return at::Cmd(buildCommand(at::AT::CLCK, commandParts), at::default_doc_timeout);
}
auto CallBarringRequest::getCommandFacility() const -> std::string
M module-services/service-cellular/requests/CallForwardingRequest.cpp => module-services/service-cellular/requests/CallForwardingRequest.cpp +2 -2
@@ 35,7 35,7 @@ namespace cellular
return nullptr;
}
- auto CallForwardingRequest::command() -> std::string
+ auto CallForwardingRequest::command() -> at::Cmd
{
std::vector<commandBuilderFunc> commandParts = {[this]() { return getCommandReason(); },
[this]() { return getCommandMode(); },
@@ 56,7 56,7 @@ namespace cellular
trimEmpty = false;
}
- return buildCommand(at::AT::CCFC, commandParts, trimEmpty);
+ return at::Cmd(buildCommand(at::AT::CCFC, commandParts, trimEmpty), at::default_doc_timeout);
}
auto CallForwardingRequest::getCommandReason() const -> std::string
M module-services/service-cellular/requests/CallRequest.cpp => module-services/service-cellular/requests/CallRequest.cpp +2 -2
@@ 11,9 11,9 @@
namespace cellular
{
- std::string CallRequest::command()
+ at::Cmd CallRequest::command()
{
- return std::string(at::factory(at::AT::ATD) + request + ";");
+ return at::Cmd(std::string(at::factory(at::AT::ATD) + request + ";"), at::default_doc_timeout);
}
void CallRequest::handle(RequestHandler &h, at::Result &result)
M module-services/service-cellular/requests/CallWaitingRequest.cpp => module-services/service-cellular/requests/CallWaitingRequest.cpp +2 -2
@@ 23,7 23,7 @@ namespace cellular
}
}
- auto CallWaitingRequest::command() -> std::string
+ auto CallWaitingRequest::command() -> at::Cmd
{
std::vector<commandBuilderFunc> commandParts = {
[this]() { return getCommandPresentation(); },
@@ 31,7 31,7 @@ namespace cellular
[this]() { return getCommandClass(); },
};
- return buildCommand(at::AT::CCWA, commandParts);
+ return at::Cmd(buildCommand(at::AT::CCWA, commandParts), at::default_doc_timeout);
}
auto CallWaitingRequest::getCommandPresentation() const noexcept -> std::string
M module-services/service-cellular/requests/ClipRequest.cpp => module-services/service-cellular/requests/ClipRequest.cpp +3 -2
@@ 23,9 23,10 @@ namespace cellular
}
}
- auto ClipRequest::command() -> std::string
+ auto ClipRequest::command() -> at::Cmd
{
- return isValid() ? std::string(at::factory(at::AT::CLIP_GET)) : std::string();
+ return at::Cmd(isValid() ? std::string(at::factory(at::AT::CLIP_GET)) : std::string(),
+ at::default_long_doc_timeout);
}
auto ClipRequest::isValid() const noexcept -> bool
M module-services/service-cellular/requests/ClirRequest.cpp => module-services/service-cellular/requests/ClirRequest.cpp +11 -7
@@ 23,23 23,27 @@ namespace cellular
}
}
- auto ClirRequest::command() -> std::string
+ auto ClirRequest::command() -> at::Cmd
{
+ std::string body;
switch (procedureType) {
case ProcedureType::Deactivation:
- return std::string(at::factory(at::AT::CLIR_DISABLE));
+ body = at::factory(at::AT::CLIR_DISABLE);
+ break;
case ProcedureType::Activation:
- return std::string(at::factory(at::AT::CLIR_ENABLE));
+ body = at::factory(at::AT::CLIR_ENABLE);
+ break;
case ProcedureType::Interrogation:
- return std::string(at::factory(at::AT::CLIR_GET));
+ body = at::factory(at::AT::CLIR_GET);
+ break;
case ProcedureType::Registration:
// not supported
- return std::string();
+ break;
case ProcedureType::Erasure:
// not supported
- return std::string();
+ break;
}
- return std::string();
+ return at::Cmd(body, at::default_long_doc_timeout);
}
void ClirRequest::handle(RequestHandler &h, at::Result &result)
M module-services/service-cellular/requests/ColpRequest.cpp => module-services/service-cellular/requests/ColpRequest.cpp +11 -7
@@ 23,23 23,27 @@ namespace cellular
}
}
- auto ColpRequest::command() -> std::string
+ auto ColpRequest::command() -> at::Cmd
{
+ std::string body;
switch (procedureType) {
case ProcedureType::Deactivation:
- return std::string(at::factory(at::AT::COLP_DISABLE));
+ body = at::factory(at::AT::COLP_DISABLE);
+ break;
case ProcedureType::Activation:
- return std::string(at::factory(at::AT::COLP_ENABLE));
+ body = at::factory(at::AT::COLP_ENABLE);
+ break;
case ProcedureType::Interrogation:
- return std::string(at::factory(at::AT::COLP_GET));
+ body = at::factory(at::AT::COLP_GET);
+ break;
case ProcedureType::Registration:
// not supported
- return std::string();
+ break;
case ProcedureType::Erasure:
// not supported
- return std::string();
+ break;
}
- return std::string();
+ return at::Cmd(body, at::default_long_doc_timeout);
}
void ColpRequest::handle(RequestHandler &h, at::Result &result)
M module-services/service-cellular/requests/ImeiRequest.cpp => module-services/service-cellular/requests/ImeiRequest.cpp +2 -2
@@ 11,9 11,9 @@
namespace cellular
{
- std::string ImeiRequest::command()
+ at::Cmd ImeiRequest::command()
{
- return std::string(at::factory(at::AT::GET_IMEI));
+ return at::Cmd(at::factory(at::AT::GET_IMEI));
}
void ImeiRequest::handle(RequestHandler &h, at::Result &result)
M module-services/service-cellular/requests/PasswordRegistrationRequest.cpp => module-services/service-cellular/requests/PasswordRegistrationRequest.cpp +2 -2
@@ 23,7 23,7 @@ namespace cellular
return std::make_unique<PasswordRegistrationRequest>(data, matchGroups);
}
- auto PasswordRegistrationRequest::command() -> std::string
+ auto PasswordRegistrationRequest::command() -> at::Cmd
{
std::vector<commandBuilderFunc> commandParts = {
[this]() { return getCommandFacility(); },
@@ 31,7 31,7 @@ namespace cellular
[this]() { return getNewPassword(); },
};
- return buildCommand(at::AT::CPWD, commandParts);
+ return at::Cmd(buildCommand(at::AT::CPWD, commandParts));
}
auto PasswordRegistrationRequest::getCommandFacility() const noexcept -> std::string
M module-services/service-cellular/requests/PinChangeRequest.cpp => module-services/service-cellular/requests/PinChangeRequest.cpp +3 -3
@@ 42,7 42,7 @@ namespace cellular
return std::make_unique<PinChangeRequest>(data, matchGroups);
}
- auto PinChangeRequest::command() -> std::string
+ auto PinChangeRequest::command() -> at::Cmd
{
std::array<std::function<std::string()>, 2> commandParts = {
[this]() { return this->getOldPinOrPuk(); },
@@ 50,7 50,7 @@ namespace cellular
};
if (!isValid()) {
- return std::string();
+ return at::Cmd(std::string());
}
std::string cmd;
@@ 70,7 70,7 @@ namespace cellular
cmd.append(cmdPart());
}
- return cmd;
+ return at::Cmd(cmd, at::default_doc_timeout);
}
auto PinChangeRequest::getOldPinOrPuk() const noexcept -> std::string
M module-services/service-cellular/requests/UssdRequest.cpp => module-services/service-cellular/requests/UssdRequest.cpp +7 -3
@@ 3,6 3,7 @@
#include <string>
#include <memory>
+#include <chrono>
#include <at/Result.hpp>
#include <at/Commands.hpp>
@@ 11,12 12,15 @@
namespace cellular
{
- std::string UssdRequest::command()
+ auto UssdRequest::command() -> at::Cmd
{
- return std::string(at::factory(at::AT::CUSD_SEND) + request + ",15");
+ using namespace std::chrono_literals;
+
+ const auto timeout = 120000ms;
+ return at::Cmd(at::factory(at::AT::CUSD_SEND) + request + ",15", timeout);
}
- std::unique_ptr<UssdRequest> UssdRequest::create(const std::string &data, GroupMatch)
+ auto UssdRequest::create(const std::string &data, GroupMatch) -> std::unique_ptr<UssdRequest>
{
return std::make_unique<UssdRequest>(data);
}
M module-services/service-cellular/service-cellular/requests/CallBarringRequest.hpp => module-services/service-cellular/service-cellular/requests/CallBarringRequest.hpp +1 -1
@@ 31,7 31,7 @@ namespace cellular
const std::string &data,
GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool;
M module-services/service-cellular/service-cellular/requests/CallForwardingRequest.hpp => module-services/service-cellular/service-cellular/requests/CallForwardingRequest.hpp +1 -1
@@ 18,7 18,7 @@ namespace cellular
const std::string &data,
GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/CallRequest.hpp => module-services/service-cellular/service-cellular/requests/CallRequest.hpp +1 -1
@@ 14,7 14,7 @@ namespace cellular
{
public:
CallRequest(const std::string &data) : Request(data){};
- std::string command() final;
+ at::Cmd command() final;
std::string getNumber() const
{
return request;
M module-services/service-cellular/service-cellular/requests/CallWaitingRequest.hpp => module-services/service-cellular/service-cellular/requests/CallWaitingRequest.hpp +1 -1
@@ 18,7 18,7 @@ namespace cellular
const std::string &data,
GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/ClipRequest.hpp => module-services/service-cellular/service-cellular/requests/ClipRequest.hpp +1 -1
@@ 17,7 17,7 @@ namespace cellular
const std::string &data,
GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/ClirRequest.hpp => module-services/service-cellular/service-cellular/requests/ClirRequest.hpp +1 -1
@@ 17,7 17,7 @@ namespace cellular
const std::string &data,
GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/ColpRequest.hpp => module-services/service-cellular/service-cellular/requests/ColpRequest.hpp +1 -1
@@ 17,7 17,7 @@ namespace cellular
const std::string &data,
GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/ImeiRequest.hpp => module-services/service-cellular/service-cellular/requests/ImeiRequest.hpp +2 -2
@@ 16,9 16,9 @@ namespace cellular
{
public:
ImeiRequest(const std::string &data) : Request(data){};
- std::string command() final;
+ auto command() -> at::Cmd final;
- static std::unique_ptr<ImeiRequest> create(const std::string &data, GroupMatch);
+ static auto create(const std::string &data, GroupMatch) -> std::unique_ptr<ImeiRequest>;
void handle(RequestHandler &h, at::Result &result) final;
};
} // namespace cellular
M module-services/service-cellular/service-cellular/requests/PasswordRegistrationRequest.hpp => module-services/service-cellular/service-cellular/requests/PasswordRegistrationRequest.hpp +1 -1
@@ 40,7 40,7 @@ namespace cellular
static std::unique_ptr<PasswordRegistrationRequest> create(const std::string &data, GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/PinChangeRequest.hpp => module-services/service-cellular/service-cellular/requests/PinChangeRequest.hpp +1 -1
@@ 34,7 34,7 @@ namespace cellular
static std::unique_ptr<PinChangeRequest> create(const std::string &data, GroupMatch matchGroups);
- auto command() -> std::string final;
+ auto command() -> at::Cmd final;
void handle(RequestHandler &h, at::Result &result) final;
auto isValid() const noexcept -> bool final;
M module-services/service-cellular/service-cellular/requests/RejectRequest.hpp => module-services/service-cellular/service-cellular/requests/RejectRequest.hpp +2 -2
@@ 22,9 22,9 @@ namespace cellular
RejectRequest(RejectReason rejectReason, const std::string &number)
: Request(number), rejectReason(rejectReason){};
- std::string command() final
+ at::Cmd command() final
{
- return std::string();
+ return at::Cmd(std::string());
}
void handle(RequestHandler &h, at::Result &result)
M module-services/service-cellular/service-cellular/requests/Request.hpp => module-services/service-cellular/service-cellular/requests/Request.hpp +1 -1
@@ 15,7 15,7 @@ namespace cellular
class IRequest
{
public:
- virtual std::string command() = 0;
+ virtual at::Cmd command() = 0;
virtual void handle(RequestHandler &h, at::Result &result) = 0;
virtual void setHandled(bool handled) = 0;
virtual bool checkModemResponse(const at::Result &result) = 0;
M module-services/service-cellular/service-cellular/requests/UssdRequest.hpp => module-services/service-cellular/service-cellular/requests/UssdRequest.hpp +2 -2
@@ 16,9 16,9 @@ namespace cellular
{
public:
UssdRequest(const std::string &data) : Request(data){};
- std::string command() final;
+ auto command() -> at::Cmd final;
- static std::unique_ptr<UssdRequest> create(const std::string &data, GroupMatch);
+ static auto create(const std::string &data, GroupMatch) -> std::unique_ptr<UssdRequest>;
void handle(RequestHandler &h, at::Result &result) final;
};
} // namespace cellular
M module-services/service-cellular/tests/unittest_request_factory.cpp => module-services/service-cellular/tests/unittest_request_factory.cpp +5 -5
@@ 128,7 128,7 @@ TEST_CASE("Emergency handling")
if (request) {
auto requestCommand = request->command();
- REQUIRE(requestCommand == test.expectedCommand);
+ REQUIRE(requestCommand.getCmd() == test.expectedCommand);
}
idx++;
}
@@ 456,16 456,16 @@ TEST_CASE("MMI requests")
REQUIRE(typeid(*request.get()).name() == testCase.expectedType.name());
REQUIRE(request->isValid() == testCase.expectedValid);
if (typeid(*request.get()).name() == typeid(CallRequest).name()) {
- REQUIRE(requestCommand == "ATD" + testCase.requestString + ";");
+ REQUIRE(requestCommand.getCmd() == "ATD" + testCase.requestString + ";");
}
else if (typeid(*request.get()).name() == typeid(UssdRequest).name()) {
- REQUIRE(requestCommand == "AT+CUSD=1," + testCase.requestString + ",15");
+ REQUIRE(requestCommand.getCmd() == "AT+CUSD=1," + testCase.requestString + ",15");
}
else {
- if (requestCommand == testCase.expectedCommandString) {
+ if (requestCommand.getCmd() == testCase.expectedCommandString) {
LOG_ERROR("HERE");
}
- REQUIRE(requestCommand == testCase.expectedCommandString);
+ REQUIRE(requestCommand.getCmd() == testCase.expectedCommandString);
}
}
}