mch2022-template-app/main/include/wifi_connection.h

47 lines
1.4 KiB
C
Raw Normal View History

2022-04-18 00:10:44 +00:00
#pragma once
#include <stdbool.h>
#include <stdint.h>
2022-05-28 13:53:31 +00:00
#include <stddef.h>
2022-04-18 00:10:44 +00:00
#include "esp_wifi.h"
2022-06-01 16:29:44 +00:00
#include "esp_wifi_types.h"
#include "esp_wpa2.h"
#define WIFI_MCH2022_SSID "MCH2022"
#define WIFI_MCH2022_USER "mch2022"
#define WIFI_MCH2022_IDENT "mch2022"
#define WIFI_MCH2022_PASSWORD "mch2022"
#define WIFI_MCH2022_AUTH WIFI_AUTH_WPA2_ENTERPRISE
#define WIFI_MCH2022_PHASE2 ESP_EAP_TTLS_PHASE2_MSCHAPV2
2022-04-18 00:10:44 +00:00
2022-05-28 13:44:03 +00:00
// Simpler interpretation of WiFi signal strength.
typedef enum {
WIFI_STRENGTH_VERY_BAD,
WIFI_STRENGTH_BAD,
WIFI_STRENGTH_GOOD,
WIFI_STRENGTH_VERY_GOOD,
} wifi_strength_t;
// Thresholds for aforementioned signal strength definitions.
#define WIFI_THRESH_BAD -80
#define WIFI_THRESH_GOOD -70
#define WIFI_THRESH_VERY_GOOD -67
// Firt time initialisation of the WiFi stack.
void wifi_init();
2022-05-28 13:44:03 +00:00
// Connect to a traditional username/password WiFi network.
bool wifi_connect(const char* aSsid, const char* aPassword, wifi_auth_mode_t aAuthmode, uint8_t aRetryMax);
2022-05-28 13:44:03 +00:00
// Connect to a WPA2 enterprise WiFi network.
2022-06-01 16:29:44 +00:00
bool wifi_connect_ent(const char* aSsid, const char *aIdent, const char *aAnonIdent, const char* aPassword, esp_eap_ttls_phase2_types phase2, uint8_t aRetryMax);
2022-05-28 13:44:03 +00:00
// Scan for WiFi networks.
// Updates the APs pointer if non-null.
// Returns the number of APs found.
size_t wifi_scan(wifi_ap_record_t **aps);
// Get the strength value for a given RSSI.
wifi_strength_t wifi_rssi_to_strength(int8_t rssi);