-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlpwa_communication_controller.h
77 lines (60 loc) · 2.6 KB
/
lpwa_communication_controller.h
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
#ifndef D63F93CA_3220_48F0_B31D_F85061E24947
#define D63F93CA_3220_48F0_B31D_F85061E24947
#include "simple_mqtt_client_controller.h"
extern "C"
{
#include "esp_modem_config.h"
}
#include "cxx_include/esp_modem_api.hpp"
#include "cxx_include/esp_modem_dte.hpp"
class LpwaCommunicationController
{
enum class ENetworkMode
{
CAT_M = 1,
NB_IoT = 2,
CAT_M_AND_NB_IoT = 3
};
#if USE_LTE_M
constexpr static int PREFERRED_NETWORK_MODE = static_cast<int>(ENetworkMode::CAT_M);
#elif USE_NB_IOT
constexpr static int PREFERRED_NETWORK_MODE = static_cast<int>(ENetworkMode::NB_IoT);
#endif // USE_LTE_M
constexpr static char NB_IOT_STRING[] = "NB-IoT";
constexpr static char LTE_M_STRING[] = "CAT-M";
constexpr static int NB_IOT_BANDS[] = {1, 20};
constexpr static int LTE_M_BANDS[] = {3, 20};
constexpr static int GPIO_LEVEL_HIGH = 1;
constexpr static int GPIO_LEVEL_LOW = 0;
constexpr static int LPWA_UART_BAUDRATE = 115200;
constexpr static uart_word_length_t LPWA_UART_DATABITS = UART_DATA_8_BITS;
constexpr static uart_stop_bits_t LPWA_UART_STOP_BITS = UART_STOP_BITS_1;
constexpr static uart_parity_t LPWA_UART_PARITY = UART_PARITY_DISABLE;
constexpr static esp_modem_flow_ctrl_t LPWA_UART_FLOW_CONTROL = ESP_MODEM_FLOW_CONTROL_NONE;
constexpr static int LPWA_UART_QUEUE_SIZE = 30;
constexpr static int LPWA_UART_RX_BUFFER_SIZE = 4096;
constexpr static int LPWA_UART_TX_BUFFER_SIZE = 512;
constexpr static int LPWA_DTE_STACK_SIZE = 6144;
constexpr static int LPWA_DTE_BUFFER_SIZE = 512;
constexpr static int LPWA_NO_SIGNAL_VALUE = 99;
constexpr static int LPWA_WEAK_SIGNAL_VALUE = 9;
public:
void runTask();
static void run(void* pObject);
void _run();
void init();
void ipEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
void pppStatusEventCallback(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
private:
void powerKeyGpioInit();
void modulePowerOn();
void perform();
TaskHandle_t m_taskHandle;
esp_modem_dte_config_t m_dteConfig;
std::shared_ptr<esp_modem::DTE> m_dte;
esp_modem_dce_config_t m_dceConfig;
std::unique_ptr<esp_modem::DCE> m_dce;
EventGroupHandle_t m_eventGroup;
SimpleMqttClientController m_simpleMqttClientController;
};
#endif /* D63F93CA_3220_48F0_B31D_F85061E24947 */