mch2022-talktopics/main/include/wifi_connection.h

38 lines
1.1 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-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-05-24 12:35:05 +00:00
bool wifi_connect_ent(const char* aSsid, const char *aIdent, const char *aAnonIdent, const char* aPassword, 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);