4#include <ArduinoJson.h>
5#include <dpiclimate-12.h>
9size_t readFromStreamUntil(Stream& stream,
const char delim,
char *
const buffer,
const size_t max);
14JsonObjectConst
getSensorDefn(
const char*
const vendor,
const char*
const model);
33int read_spiffs_file(
const char* filename,
char* buffer,
size_t max_length,
size_t &bytes_read);
47int read_r5_file(
const String& filename,
char* buffer,
size_t length,
size_t &bytes_read, SARA_R5_error_t& r5_err);
63 URC(
bool v, T c,
int r) {
77 void addPair(
const T& value,
int intValue) {
78 this->emplace_back(
true, value, intValue);
89 bool hasURC(
const T command,
int *result) {
90 auto iter = this->begin();
91 while (iter != this->end()) {
92 ESP_LOGI(
"CommandURCVector",
"valid = %d, command = %d, result = %d, err1 = %d, err2 = %d", iter->valid, iter->command, iter->result, iter->err1, iter->err2);
93 if (iter->command == command) {
94 *result = iter->result;
95 log_to_sdcardf(
"valid = %d, command = %d, result = %d, err1 = %d, err2 = %d", iter->valid, iter->command, iter->result, iter->err1, iter->err2);
107 bool waitForURC(
const T command,
int *result,
int retries,
const long delay_ms) {
108 bool found_urc =
false;
109 while (retries > 0) {
111 found_urc =
hasURC(command, result);
120 ESP_LOGI(
"CommandURCVector",
"command = %d, result = %d, found_urc = %d, retries = %d", command, *result, found_urc, retries);
121 log_to_sdcardf(
"command = %d, result = %d, found_urc = %d, retries = %d", command, *result, found_urc, retries);
static char msg[CLI::MAX_CLI_MSG_LEN+1]
Message buffer.
Definition: CLI.cpp:26
void disable12V(void)
Disable the SDI-12 power line.
Definition: Utils.cpp:154
void log_to_sdcard(const char *msg)
Definition: Utils.cpp:180
void enable12V(void)
Enable the SDI-12 power line if it is not already enabled.
Definition: Utils.cpp:144
void streamPassthrough(Stream *s1, Stream *s2)
Definition: Utils.cpp:74
size_t readFromStreamUntil(Stream &stream, const char delim, char *const buffer, const size_t max)
Read characters from stream into buffer until the delim char is encountered.
Definition: Utils.cpp:35
void log_to_sdcardf(const char *fmt,...)
Definition: Utils.cpp:189
int read_r5_file(const String &filename, char *buffer, size_t length, size_t &bytes_read, SARA_R5_error_t &r5_err)
Definition: Utils.cpp:246
int waitForChar(Stream &stream, uint32_t timeout)
Wait up to timeout ms for any character to appear in stream.
Definition: Utils.cpp:110
const char * iso8601(void)
Definition: Utils.cpp:163
JsonObjectConst getSensorDefn(const char *const vendor, const char *const model)
Definition: Utils.cpp:124
bool connect_to_internet(void)
Get the R5 modem connected to the internet.
Definition: Utils.cpp:336
int read_spiffs_file(const char *filename, char *buffer, size_t max_length, size_t &bytes_read)
Definition: Utils.cpp:202
int get_version_string(char *buffer, size_t length)
bool wait_for_at(void)
Waits until an AT command to the R5 modem returns OK, or a timeout is reached.
Definition: Utils.cpp:283
CommandURCVector()
Definition: Utils.h:74
void addPair(const T &value, int intValue)
Definition: Utils.h:77
bool hasURC(const T command, int *result)
Definition: Utils.h:89
bool waitForURC(const T command, int *result, int retries, const long delay_ms)
Definition: Utils.h:107
sensor_list sensors
The ID information of each sensor found on the SDI-12 bus.
Definition: SensorTask.cpp:25
bool valid
Definition: Utils.h:56
int err2
Definition: Utils.h:60
int err1
Definition: Utils.h:59
URC(bool v, T c, int r)
Definition: Utils.h:63
int result
Definition: Utils.h:58
T command
Definition: Utils.h:57