Allocate necessary memory for struct members
This commit is contained in:
@@ -3,21 +3,24 @@
|
||||
|
||||
#include "FS.h"
|
||||
#include "LittleFS.h"
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
struct Config {
|
||||
typedef struct {
|
||||
const char *ssid;
|
||||
const char *psk;
|
||||
const char *mqtt_host;
|
||||
const char *mqtt_user;
|
||||
const char *mqtt_password;
|
||||
int mqtt_port;
|
||||
const char *topic;
|
||||
const char *device_id;
|
||||
int mqtt_port;
|
||||
long sleep_time;
|
||||
int connection_attempts;
|
||||
};
|
||||
} Config;
|
||||
|
||||
bool load_config_file(const char *file_path, struct Config &config);
|
||||
void initialize_config(Config *config, StaticJsonDocument<512> json);
|
||||
|
||||
bool load_config_file(const char *file_path, Config *config);
|
||||
|
||||
long minutes_to_microseconds(int minutes);
|
||||
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
#ifndef WLAN_H
|
||||
#define WLAN_H
|
||||
|
||||
#include "config.h"
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
void initial_connection(const char *ssid, const char *psk);
|
||||
void connect_wlan(const char *ssid, const char *psk, const int max_retries,
|
||||
const int sleep_time);
|
||||
void connect_mqtt(PubSubClient &client, const char *mqtt_host,
|
||||
const int mqtt_port, const char *mqtt_user,
|
||||
const char *mqtt_password, const char *device_id,
|
||||
const char *topic);
|
||||
void connect_wlan(Config *config);
|
||||
void connect_mqtt(PubSubClient &client, Config *config);
|
||||
void disconnect_mqtt(PubSubClient &client, const char *topic);
|
||||
size_t construct_json(float *data, char *buffer, int buffer_size);
|
||||
void mqtt_transfer(PubSubClient &client, const char *mqtt_host,
|
||||
const int mqtt_port, const char *mqtt_user,
|
||||
const char *mqtt_password, const char *device_id,
|
||||
const char *topic, float *data);
|
||||
void mqtt_transfer(PubSubClient &client, Config *config, float *data);
|
||||
void enter_deep_sleep(bool wifi_timeout, int sleep_time);
|
||||
|
||||
#endif /* WLAN_H */
|
||||
|
||||
Reference in New Issue
Block a user