Files
MuditaOS/module-cellular/Modem/ATParser.hpp
Alek-Mudita 8b167d1809 Fix for calling (#91)
* fix for not switching to active call

* Added missing icons during unaswered outgoing call + some error logging

* Added additional logging to AT commands
defult timeout set to 300 ms.
Set different timeouts per each AT command.
Minor code refactoring.

* Added some logging, fixed some timeouts and number of returned tockens.

* commented out not needed log

* Added LOG_CUSTOM logging support. Remove unnecessary LOG_ERRORS.

* set ATA cmd timeout to 90 sec

* PR fixes
2019-11-29 11:18:57 +01:00

75 lines
1.5 KiB
C++

/*
* @file ATParser.hpp
* @author Mateusz Piesta (mateusz.piesta@mudita.com)
* @date 17.07.19
* @brief
* @copyright Copyright (C) 2019 mudita.com
* @details
*/
#ifndef PUREPHONE_ATPARSER_HPP
#define PUREPHONE_ATPARSER_HPP
#include <memory>
#include <optional>
#include <vector>
#include "FreeRTOS.h"
#include "task.h"
#include "mutex.hpp"
#include "Service/Service.hpp"
#define DEBUG_MODEM_OUTPUT_RESPONSE 0
#define DEBUG_MODEM_TIMEOUT_AS_ERROR 0
#if DEBUG_MODEM_TIMEOUT_AS_ERROR
#define LOG_MODEM_TIMEOUT(...) LOG_ERROR(__VA_ARGS__)
#else
#define LOG_MODEM_TIMEOUT(...) LOG_INFO(__VA_ARGS__)
#endif
namespace bsp{
class Cellular;
}
class ATParser {
public:
enum class Urc{
MeInitializationSuccessful,
FullFuncionalityAvailable,
SimCardReady,
SMSInitializationComplete,
PhonebookInitializationComplete
};
ATParser(bsp::Cellular* cellular);
int ProcessNewData(sys::Service *service);
std::vector<std::string> SendCommand(const char *cmd, size_t rxCount, uint32_t timeout = 500);
static std::vector<std::string> Tokenizer(std::string& input,uint32_t maxTokenCount,const std::string& delimiter);
private:
std::vector<Urc> ParseURC();
bsp::Cellular* cellular = nullptr;
std::string responseBuffer;
TaskHandle_t blockedTaskHandle = nullptr;
cpp_freertos::MutexStandard mutex;
std::vector<ATParser::Urc> urcs;
bool isInitialized = false;
};
#endif //PUREPHONE_ATPARSER_HPP