1
0
mirror of https://github.com/peterantypas/maiana.git synced 2025-06-07 02:00:12 -07:00
2022-12-11 12:53:36 -08:00

129 lines
2.4 KiB
C

#ifndef __CONFIGURATION_H__
#define __CONFIGURATION_H__
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "types.h"
#include <esp_event.h>
ESP_EVENT_DECLARE_BASE(CONFIG_EVENT);
#define WIFI_CONFIG_CHANGED_EVENT 1
#define AIS_CONFIG_CHANGED_EVENT 2
#define NMEA_CONFIG_CHANGED_EVENT 3
void config_init();
/*** WiFi Configuration ***/
/**
* @brief Returns the WiFi operation mode
*
* @return wifi_operation_mode_t
*/
wifi_operation_mode_t config_get_wifi_operation_mode();
/**
* @brief Returns the SSID (regardless of mode)
*
* @return const char*
*/
const char *config_get_ssid();
/**
* @brief Returns the password (if applicable)
*
* @return const char*
*/
const char *config_get_password();
/**
* @brief Configures the WiFi interface. Will not take effect until reboot.
*
* @param mode Desired mode
* @param ssid Desired SSID
* @param password Desired password. May be NULL if not applicable.
*/
void config_wifi(wifi_operation_mode_t mode, const char *ssid, const char *password);
/*** NMEA configuration ***/
/**
* @brief Returns NMEA gateway mode
*
* @return nmea_gateway_mode_t
*/
nmea_gateway_mode_t config_get_nmea_gateway_mode();
/**
* @brief Returns the IP address (not applicable for NMEA_TCP_LISTENER)
*
* @return const char*
*/
const char *config_get_nmea_gateway_ip();
/**
* @brief Returns the TCP port (applicable to all modes)
*
* @return uint16_t
*/
uint16_t config_get_nmea_gateway_port();
/**
* @brief Congigures the NMEA gateway
*
* @param mode Desired mode
* @param ip Target IP (for senders only)
* @param port TCP port
*/
void config_nmea_gateway(nmea_gateway_mode_t mode, const char *ip, uint16_t port);
/*** Misc ***/
/**
* @brief Returns the AP MAC address
*
* @return const char*
*/
const char *config_ap_mac_address();
/**
* @brief Returns the station MAC address
*
* @return const char*
*/
const char *config_st_mac_address();
/**
* @brief Resets WiFi configuration to default
*
*/
void config_reset_wifi();
/**
* @brief Resets everything to defaults. Will take effect after reboot.
*
*/
void config_reset_all();
/**
* @brief Sets a flag that indicates successul association with the target AP
*
*/
void config_set_wifi_success();
/**
* @brief Returns true if association with the target AP worked at least once before
*
* @return true
* @return false
*/
bool config_has_wifi_success();
#endif