~aleteoryx/muditaos

ref: master muditaos/module-cellular/modem/ATParser.hpp -rw-r--r-- 1.4 KiB
2cd0e472 — Lefucjusz [BH-000] Update Harmony 2.10.0 changelog 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#ifndef PUREPHONE_ATPARSER_HPP
#define PUREPHONE_ATPARSER_HPP

#include "ATCommon.hpp"
#include <FreeRTOS.h>
#include <Service/Service.hpp>
#include <memory>
#include <optional>
#include <task.h>
#include <vector>
#include <message_buffer.h>

#include <bsp/cellular/CellularResult.hpp>

namespace bsp
{
    class Cellular;
}

class ATParser : public at::Channel
{
  public:
    enum class Urc
    {
        MeInitializationSuccessful,
        FullFuncionalityAvailable,
        SimCardReady,
        SMSInitializationComplete,
        PhonebookInitializationComplete,
        Fota,
        NotHandled,
    };

    ATParser(bsp::Cellular *cellular);
    virtual ~ATParser() = default;

    at::Result processNewData(sys::Service *service, const bsp::cellular::CellularResult &cellularResult);

    virtual void cmdInit() override final;
    virtual void cmdSend(std::string cmd) override final;
    virtual size_t cmdReceive(std::uint8_t *buffer, std::chrono::milliseconds timeout) override final;
    virtual void cmdPost() override final;

  private:
    std::vector<Urc> parseUrc();
    bsp::Cellular *cellular              = nullptr;
    MessageBufferHandle_t responseBuffer = nullptr;
    std::string urcBuffer                = {};
    std::vector<ATParser::Urc> urcs      = {};
};

#endif // PUREPHONE_ATPARSER_HPP