|
ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
|
#include "wifi.h"#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <stm32_systime.h>#include "app_lorawan.h"#include "../user_config.h"#include "board.h"#include "controller/controller.h"#include "dma.h"#include "fifo.h"#include "payload.h"#include "sensors.h"Go to the source code of this file.
Functions | |
| void | UploadEvent (void *context) |
| Function call for upload event. | |
| void | Upload (void) |
| Upload data to hub. | |
| bool | Connect (void) |
| Connect to WiFi. | |
| bool | Disconnect (void) |
| Disconnect from WiFi. | |
| bool | TimeSync (void) |
| Timesync with NTP server. | |
| bool | Check (void) |
| Check API health. | |
| void | StartUploads (void) |
| Setup upload timer. | |
| void | StopUploads (void) |
| Stop upload timer. | |
| void | ResumeUploads (void) |
| Resumes upload timer. | |
| void | ErrorHandler (void) |
| Error handler. | |
| bool | Esp32Init (void) |
| Call initialization functions for ESP32. | |
| void | WiFiInit (void) |
| Initialize WiFi uploading method. | |
Variables | |
| const unsigned int | max_retries = 5 |
| Maximum number of retries for any event. | |
| const unsigned int | retry_delay = 1000 |
| Delay in milliseconds between retries. | |
| bool Check | ( | void | ) |
Check API health.
Definition at line 353 of file wifi.c.
References ControllerWiFiCheckApi(), ControllerWiFiCheckRequest(), ControllerWiFiResponse::http_code, max_retries, retry_delay, and UserConfigGet().
Referenced by Esp32Init(), and ModuleIrrigation::OnReceive().
| bool Connect | ( | void | ) |
Connect to WiFi.
Connects to WiFi network and sets the system time.
Definition at line 245 of file wifi.c.
References CONTROLLER_WIFI_CONNECT_FAILED, CONTROLLER_WIFI_CONNECTED, CONTROLLER_WIFI_DISCONNECTED, CONTROLLER_WIFI_NO_SSID_AVAIL, ControllerWiFiCheckWiFi(), ControllerWiFiConnect(), max_retries, retry_delay, ssid, and UserConfigGet().
Referenced by Esp32Init(), and ModuleWiFi::OnReceive().
| bool Disconnect | ( | void | ) |
Disconnect from WiFi.
Definition at line 289 of file wifi.c.
References CONTROLLER_WIFI_DISCONNECTED, CONTROLLER_WIFI_IDLE_STATUS, ControllerWiFiCheckWiFi(), ControllerWiFiDisconnect(), max_retries, and retry_delay.
Referenced by ErrorHandler(), ModuleWiFi::OnReceive(), and WiFiInit().
| void ErrorHandler | ( | void | ) |
Error handler.
Turns on LEDs, waits for a reconnection, and resumes uploads.
Definition at line 231 of file wifi.c.
References Disconnect(), Esp32Init(), ResumeUploads(), and StopUploads().
Referenced by Upload().
| bool Esp32Init | ( | void | ) |
Call initialization functions for ESP32.
Connects to a WiFi network, checks API health, and syncs time.
Definition at line 400 of file wifi.c.
References Check(), Connect(), and TimeSync().
Referenced by ErrorHandler(), and WiFiInit().
| void ResumeUploads | ( | void | ) |
| void StartUploads | ( | void | ) |
Setup upload timer.
Start sensor measurements and setup upload task/timer.
Definition at line 197 of file wifi.c.
References Upload(), UploadEvent(), and UserConfigGet().
Referenced by WiFiInit().
| void StopUploads | ( | void | ) |
| bool TimeSync | ( | void | ) |
Timesync with NTP server.
Definition at line 318 of file wifi.c.
References ControllerWiFiNtpSync(), ControllerWiFiTime(), max_retries, and retry_delay.
Referenced by Esp32Init().
| void Upload | ( | void | ) |
Upload data to hub.
Posts data to configured url.
Definition at line 130 of file wifi.c.
References buffer, ControllerWiFiCheckRequest(), ControllerWiFiPost(), ErrorHandler(), ControllerWiFiResponse::http_code, i, max_retries, retry_delay, and UploadEvent().
Referenced by StartUploads().
| void UploadEvent | ( | void * | context | ) |
Function call for upload event.
| context | Timer context. |
Definition at line 125 of file wifi.c.
Referenced by StartUploads(), and Upload().
| void WiFiInit | ( | void | ) |
Initialize WiFi uploading method.
Connect to WiFi network, sync time, check API health, and start upload timer.
Definition at line 113 of file wifi.c.
References Disconnect(), Esp32Init(), and StartUploads().
| const unsigned int max_retries = 5 |
Maximum number of retries for any event.
Definition at line 29 of file wifi.c.
Referenced by Check(), Connect(), Disconnect(), TimeSync(), and Upload().
| const unsigned int retry_delay = 1000 |
Delay in milliseconds between retries.
Definition at line 34 of file wifi.c.
Referenced by Check(), Connect(), Disconnect(), TimeSync(), and Upload().