~aleteoryx/muditaos

ref: 6b3fdbc99f17803845fa355ddf29a3a94720a746 muditaos/module-cellular/Modem/TS0710/DLC_channel.h -rw-r--r-- 2.0 KiB
6b3fdbc9 — tomaszkrosnowski [EGD-6613] Audio assets tags are not displayed 4 years 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

/**
 * Project Untitled
 */

#ifndef _DLC_CHANNEL_H
#define _DLC_CHANNEL_H

#include <string>
#include <vector>
#include <functional>

#include "../ATCommon.hpp"
#include "TS0710_types.h"
#include <FreeRTOS.h>
#include <task.h>

class DLC_channel : public at::Channel
{
  public:
    using Callback_t = std::function<void(std::string &data)>;

  private:
    std::string pv_name;
    DLCI_t pv_DLCI;
    bool active = false;
    DLC_ESTABL_SystemParameters_t pv_chanParams;
    Callback_t pv_callback;

    std::string responseBuffer;
    bsp::Cellular *pv_cellular;

  public:
    // TS0710_DLC_ESTABL ctrlChanEstabl = TS0710_DLC_ESTABL(0);  //use default values to create control channel DLCI0

    DLC_channel(DLCI_t DLCI, std::string name, bsp::Cellular *cellular, Callback_t callback = nullptr);
    DLC_channel()
    {
        pv_DLCI = -1;
        pv_name = "none";
    } // default constructor creates empty channel
    virtual ~DLC_channel();

    void SendData(std::vector<uint8_t> &data);

    DLCI_t getDLCI()
    {
        return pv_DLCI;
    }
    std::string getName()
    {
        return pv_name;
    }
    bool getActive()
    {
        return active;
    }

    // ssize_t ReceiveData(std::vector<uint8_t> &data, uint32_t timeout);
    void setCallback(Callback_t callback)
    {
        LOG_DEBUG("[%s] Setting up callback for channel", pv_name.c_str());
        pv_callback = callback;
    }

    virtual void cmd_init() override final;
    virtual void cmd_send(std::string cmd) override final;
    virtual std::string cmd_receive() override final;
    virtual void cmd_post() override final;

    std::vector<std::string> SendCommandPrompt(const char *cmd, size_t rxCount, uint32_t timeout = 300);

    int ParseInputData(std::vector<uint8_t> &data);

    void callback(std::string &data)
    {
        pv_callback(data);
    }
};

#endif //_DLC_CHANNEL_H