Loom 4 v4.5
Arduino library for Internet of Things Rapid Prototyping in environmental sensing
Loading...
Searching...
No Matches
Loom_LTE.h
1#pragma once
2
3// GSM Model Number
4//#define TINY_GSM_MODEM_UBLOX
5#define TINY_GSM_MODEM_SARAR4
6
7#include "Module.h"
8#include "Loom_Manager.h"
9
10#include <TinyGsmClient.h>
11
12#include "../../../Hardware/Loom_BatchSD/Loom_BatchSD.h"
13
14// Specify what serial interface we want to use
15#define SerialAT Serial1
16
22class Loom_LTE : public Module{
23 protected:
24 /* These aren't used with the Wifi manager */
25 void measure() override {};
26
27
28
29 public:
30
40 Manager& man,
41 const char* apn,
42 const char* user,
43 const char* pass,
44 const int powerPin = A5
45 );
46
51 Loom_LTE(Manager& man);
52
53 // Initialize the device and connect to the network
54 void initialize() override;
55
56 // Reconnect to the network
57 void power_up() override;
58
59 // Disconnect from the network
60 void power_down() override;
61
62
63 // Signal Strength
64 void package() override;
65
70 void loadConfigFromJSON(char* json);
71
76 void setBatchSD(Loom_BatchSD& batch) { batch_sd = &batch; };
77
81 bool connect();
82
86 void disconnect();
87
91 bool verifyConnection();
92
96 TinyGsmClient& getClient();
97
101 bool isConnected();
102
103 /* Restart the modem */
104 void restartModem() {
105 TIMER_RESET;
106 modem.poweroff();
107 delay(3000);
108 modem.restart();
109 delay(1000);
110 TIMER_RESET;
111 };
112
116 void ipToString(IPAddress ip, char array[16]) {
117 snprintf(array, 16, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
118 };
119
120 private:
121 Manager* manInst; // Instance of the manager
122
123 char APN[100]; // LTE Network Name
124 char gprsUser[100]; // GPRS Username
125 char gprsPass[100]; // GPRS Password
126
127 int powerPin = A5; // Analog pin to power the LTE board
128
129 TinyGsm modem; // LTE Modem
130 TinyGsmClient client; // LTE Client
131
132 bool powerUp = true;
133 bool firstInit = true; // First time it was initialized
134 Loom_BatchSD* batch_sd = nullptr; // If we are using batch publish
135
136};
Definition: Loom_BatchSD.h:9
Definition: Loom_LTE.h:22
void disconnect()
Definition: Loom_LTE.cpp:199
bool isConnected()
Definition: Loom_LTE.cpp:283
bool verifyConnection()
Definition: Loom_LTE.cpp:210
void loadConfigFromJSON(char *json)
Definition: Loom_LTE.cpp:252
TinyGsmClient & getClient()
Definition: Loom_LTE.cpp:287
void ipToString(IPAddress ip, char array[16])
Definition: Loom_LTE.h:116
void setBatchSD(Loom_BatchSD &batch)
Definition: Loom_LTE.h:76
bool connect()
Definition: Loom_LTE.cpp:148
Definition: Loom_Manager.h:18
Definition: Module.h:30