File Transmision_NBIOT.h
FileList > firmware > Transmision_NBIOT.h
Go to the source code of this file
#include "Configuracion.h"#include <Arduino.h>#include <ArduinoJson.h>
Public Functions
| Type | Name |
|---|---|
| void | ReiniciarDispositivo (void) Restarts the microcontroller. |
| bool | SIM7020begin (void) Initializes communication with the SIM7020 module. |
| byte | SIM7020command (String command, String response1, String response2, unsigned long timeout, uint16_t repetitions) Sends an AT command to the SIM7020 module and waits for a specific response. |
| String | SIM7020read (void) Reads messages sent by the SIM7020 module. |
| byte | SIM7020waitFor (String response1, String response2, unsigned long timeOut) Function that waits for a specific response with maximum time. |
| String | jsonToHex (const JsonDocument & doc) Converts a JSON object to a hexadecimal string. |
| void | nbiot_enviar (void) Transmits sensor data to the server. |
| void | nbiot_inicializar (void) Initializes the NB-IoT module (SIM7020). |
| void | nbiot_paquete (void) Creates the JSON payload with current sensor data. |
| void | nbiot_transmitir (void) Performs an HTTP POST request to the server. |
Macros
| Type | Name |
|---|---|
| define | NOTOK 2 |
| define | OK 1 |
| define | RST 2 |
| define | SERIALTIMEOUT 3000 |
| define | SIM7020baud 115200 |
| define | SIM7020board Serial1 |
| define | TIMEOUTERR 3 |
Public Functions Documentation
function ReiniciarDispositivo
Restarts the microcontroller.
Used for cases where it is not possible to establish a connection to the server.
function SIM7020begin
Initializes communication with the SIM7020 module.
Uses SIM7020 module-specific AT commands to detect if communication is correct and resets configuration to a predefined state.
Returns:
True if communication and configuration were successful
function SIM7020command
Sends an AT command to the SIM7020 module and waits for a specific response.
byte SIM7020command (
String command,
String response1,
String response2,
unsigned long timeout,
uint16_t repetitions
)
Parameters:
commandThe AT command to send.response1The expected response string to consider the command successful.response2String to search for if an "OK" response is not expected.timeoutMaximum wait time for the response in milliseconds.repetitionsNumber of retries if the response is not as expected.
Returns:
OK if the response is as expected, NOTOK if not, TIMEOUTERR if timeout occurs.
function SIM7020read
Reads messages sent by the SIM7020 module.
Returns:
String with the received message.
function SIM7020waitFor
Function that waits for a specific response with maximum time.
Parameters:
response1The expected response string to consider the command successful.response2String to search for if an "OK" response is not expected.timeoutMaximum wait time for the response in milliseconds.
Returns:
OK if the response is as expected, NOTOK if not, TIMEOUTERR if timeout occurs.
function jsonToHex
Converts a JSON object to a hexadecimal string.
Parameters:
docThe DynamicJsonDocument object to convert.
Returns:
String representing the JSON in hexadecimal format.
function nbiot_enviar
Transmits sensor data to the server.
This is the main function for data transmission. Builds the JSON, converts it to hexadecimal and performs the HTTP POST request.
function nbiot_inicializar
Initializes the NB-IoT module (SIM7020).
Configures the serial port for communication with the module and executes a series of AT commands to ensure the module is operational and connected to the network.
function nbiot_paquete
Creates the JSON payload with current sensor data.
Data is obtained from global variables and formatted into a JSON string.
function nbiot_transmitir
Performs an HTTP POST request to the server.
Uses SIM7020 module-specific AT commands to create an HTTP connection and send hexadecimal data as payload.
Macro Definition Documentation
define NOTOK
define OK
define RST
define SERIALTIMEOUT
define SIM7020baud
define SIM7020board
define TIMEOUTERR
The documentation for this class was generated from the following file firmware/Transmision_NBIOT.h