#include <ArduinoJson.h>
#include <dpiclimate-12.h>
#include "globals.h"
Go to the source code of this file.
|
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. More...
|
|
void | streamPassthrough (Stream *s1, Stream *s2) |
|
int | waitForChar (Stream &stream, uint32_t timeout) |
| Wait up to timeout ms for any character to appear in stream. More...
|
|
JsonObjectConst | getSensorDefn (const char *const vendor, const char *const model) |
|
JsonObjectConst | getSensorDefn (const size_t sensor_idx, const sensor_list &sensors) |
|
void | enable12V (void) |
| Enable the SDI-12 power line if it is not already enabled. More...
|
|
void | disable12V (void) |
| Disable the SDI-12 power line. More...
|
|
const char * | iso8601 (void) |
|
void | log_to_sdcard (const char *msg) |
|
void | log_to_sdcardf (const char *fmt,...) |
|
int | read_spiffs_file (const char *filename, char *buffer, size_t max_length, size_t &bytes_read) |
|
int | read_r5_file (const String &filename, char *buffer, size_t length, size_t &bytes_read, SARA_R5_error_t &r5_err) |
|
bool | wait_for_at (void) |
| Waits until an AT command to the R5 modem returns OK, or a timeout is reached. More...
|
|
bool | connect_to_internet (void) |
| Get the R5 modem connected to the internet. More...
|
|
int | get_version_string (char *buffer, size_t length) |
|
◆ connect_to_internet()
bool connect_to_internet |
( |
void |
| ) |
|
Get the R5 modem connected to the internet.
This function sets the ESP32 and modem RTCs from the network time using NTP.
If this function returns true, the modem has registered to the network, brought up a packet switched profile, and obtained an IP address. MQTT, FTP, etc can be used.
- Returns
- true if the connection succeeds, otherwise false.
◆ disable12V()
Disable the SDI-12 power line.
◆ enable12V()
Enable the SDI-12 power line if it is not already enabled.
◆ get_version_string()
int get_version_string |
( |
char * |
buffer, |
|
|
size_t |
length |
|
) |
| |
◆ getSensorDefn() [1/2]
JsonObjectConst getSensorDefn |
( |
const char *const |
vendor, |
|
|
const char *const |
model |
|
) |
| |
◆ getSensorDefn() [2/2]
JsonObjectConst getSensorDefn |
( |
const size_t |
sensor_idx, |
|
|
const sensor_list & |
sensors |
|
) |
| |
◆ iso8601()
const char * iso8601 |
( |
void |
| ) |
|
◆ log_to_sdcard()
void log_to_sdcard |
( |
const char * |
msg | ) |
|
◆ log_to_sdcardf()
void log_to_sdcardf |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
◆ read_r5_file()
int read_r5_file |
( |
const String & |
filename, |
|
|
char * |
buffer, |
|
|
size_t |
length, |
|
|
size_t & |
bytes_read, |
|
|
SARA_R5_error_t & |
r5_err |
|
) |
| |
Reads a file from the R5 filesystem into buffer.
This function assumes sizeof(buffer) >= length.
- Parameters
-
filename | The name of the file to read. |
buffer | The buffer to read the file into. |
length | The size of the file in bytes. |
bytes_read | [OUT] How many bytes were read into buffer. |
r5_err | [OUT] The error code returned from the R5 library, if an error ocurred. |
- Returns
- 0 on success, otherwise a failure.
◆ read_spiffs_file()
int read_spiffs_file |
( |
const char * |
filename, |
|
|
char * |
buffer, |
|
|
size_t |
max_length, |
|
|
size_t & |
bytes_read |
|
) |
| |
Reads a file from the SPIFFS filesystem into buffer.
- Parameters
-
filename | The name of the file to read. |
buffer | The buffer to read the file into. |
max_length | The size of buffer in bytes. |
bytes_read | [OUT] How many bytes were read into buffer. |
- Returns
- 0 on success, otherwise a failure.
◆ readFromStreamUntil()
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.
This function will respect the backspace character (0x08) by moving the 'virtual cursor' back one character in buffer, if buffer is not empty.
Up to max - 1 characters will be read to ensure the resulting string is null terminated.
- Parameters
-
stream | the Stream to read from. |
delim | the character that causes reading to stop and the function to return. |
buffer | the buffer to write characters into. |
max | the maximum number of characters to be read. |
- Returns
- the length of the string read from stream.
◆ streamPassthrough()
void streamPassthrough |
( |
Stream * |
s1, |
|
|
Stream * |
s2 |
|
) |
| |
◆ wait_for_at()
bool wait_for_at |
( |
void |
| ) |
|
Waits until an AT command to the R5 modem returns OK, or a timeout is reached.
This function will try 5 times, pausing for 1 second between attempts.
This function uses g_buffer.
- Returns
- true if the modem responds, otherwise false.
◆ waitForChar()
int waitForChar |
( |
Stream & |
stream, |
|
|
uint32_t |
timeout |
|
) |
| |
Wait up to timeout ms for any character to appear in stream.
- Parameters
-
stream | the Stream to read from. |
timeout | the number of ms to wait for a character. |
- Returns
- the character read from stream, or -1 if the timeout occurred.