Added WiFi kernel drivers and refactored Wifi service (#557)
+ other improvements
This commit is contained in:
committed by
GitHub
parent
dbb96a891c
commit
1c2806bddf
@@ -1,74 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TT_WIFI_SSID_LIMIT 32 // 32 characters/octets, according to IEEE 802.11-2020 spec
|
||||
#define TT_WIFI_CREDENTIALS_PASSWORD_LIMIT 64 // 64 characters/octets, according to IEEE 802.11-2020 spec
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Important: These values must map to tt::service::wifi::RadioState values exactly */
|
||||
typedef enum {
|
||||
WifiRadioStateOnPending,
|
||||
WifiRadioStateOn,
|
||||
WifiRadioStateConnectionPending,
|
||||
WifiRadioStateConnectionActive,
|
||||
WifiRadioStateOffPending,
|
||||
WifiRadioStateOff,
|
||||
} WifiRadioState;
|
||||
|
||||
/** @return the state of the WiFi radio */
|
||||
WifiRadioState tt_wifi_get_radio_state();
|
||||
|
||||
/** @return a textual representation of the WiFi radio state */
|
||||
const char* tt_wifi_radio_state_to_string(WifiRadioState state);
|
||||
|
||||
/** Start scanning */
|
||||
void tt_wifi_scan();
|
||||
|
||||
/** @return true if a scan is active/pending */
|
||||
bool tt_wifi_is_scanning();
|
||||
|
||||
/**
|
||||
* Return the WiFi SSID that the system tries to connect to, or is connected to.
|
||||
* @param[out] buffer an allocated string buffer. Its size must be (WIFI_SSID_LIMIT + 1).
|
||||
*/
|
||||
void tt_wifi_get_connection_target(char* buffer);
|
||||
|
||||
/**
|
||||
* @brief Enable/disable the radio. Ignores input if desired state matches current state.
|
||||
* @param[in] enabled
|
||||
*/
|
||||
void tt_wifi_set_enabled(bool enabled);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ssid The access point identifier - maximal 32 characters/octets
|
||||
* @param password the password - maximum 64 characters/octets
|
||||
* @param channel 0 means "any"
|
||||
* @param autoConnect whether we want to automatically reconnect if a disconnect occurs
|
||||
* @param remember whether the record should be stored permanently on the device (it is only stored if this connection attempt succeeds)
|
||||
*/
|
||||
void tt_wifi_connect(const char* ssid, const char* password, int32_t channel, bool autoConnect, bool remember);
|
||||
|
||||
/**
|
||||
* If WiFi is connected, this disconnects it.
|
||||
*/
|
||||
void tt_wifi_disconnect();
|
||||
|
||||
/**
|
||||
* @return true if WiFi is active and encrypted
|
||||
*/
|
||||
bool tt_wifi_is_connnection_secure();
|
||||
|
||||
/**
|
||||
* @return the current radio connection link quality
|
||||
*/
|
||||
int tt_wifi_get_rssi();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "tt_lvgl_toolbar.h"
|
||||
#include "tt_preferences.h"
|
||||
#include "tt_time.h"
|
||||
#include "tt_wifi.h"
|
||||
|
||||
#include "symbols/cplusplus.h"
|
||||
#include "symbols/esp_event.h"
|
||||
@@ -360,16 +359,6 @@ const esp_elfsym main_symbols[] {
|
||||
ESP_ELFSYM_EXPORT(tt_timezone_get_code),
|
||||
ESP_ELFSYM_EXPORT(tt_timezone_is_format_24_hour),
|
||||
ESP_ELFSYM_EXPORT(tt_timezone_set_format_24_hour),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_get_radio_state),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_radio_state_to_string),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_scan),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_is_scanning),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_get_connection_target),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_set_enabled),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_connect),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_disconnect),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_is_connnection_secure),
|
||||
ESP_ELFSYM_EXPORT(tt_wifi_get_rssi),
|
||||
// tt::lvgl
|
||||
ESP_ELFSYM_EXPORT(tt_lvgl_spinner_create),
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#include "tt_wifi.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
|
||||
using namespace tt::service;
|
||||
|
||||
extern "C" {
|
||||
|
||||
WifiRadioState tt_wifi_get_radio_state() {
|
||||
return static_cast<WifiRadioState>(wifi::getRadioState());
|
||||
}
|
||||
const char* tt_wifi_radio_state_to_string(WifiRadioState state) {
|
||||
return wifi::radioStateToString(static_cast<wifi::RadioState>(state));
|
||||
}
|
||||
|
||||
void tt_wifi_scan() {
|
||||
wifi::scan();
|
||||
}
|
||||
|
||||
bool tt_wifi_is_scanning() {
|
||||
return wifi::isScanning();
|
||||
}
|
||||
|
||||
void tt_wifi_get_connection_target(char* buffer) {
|
||||
auto target = wifi::getConnectionTarget();
|
||||
strcpy(buffer, target.c_str());
|
||||
}
|
||||
|
||||
void tt_wifi_set_enabled(bool enabled) {
|
||||
wifi::setEnabled(enabled);
|
||||
}
|
||||
|
||||
void tt_wifi_connect(const char* ssid, const char* password, int32_t channel, bool autoConnect, bool remember) {
|
||||
wifi::settings::WifiApSettings settings;
|
||||
settings.ssid = ssid;
|
||||
settings.password = password;
|
||||
settings.channel = channel;
|
||||
settings.autoConnect = autoConnect;
|
||||
wifi::connect(settings, remember);
|
||||
}
|
||||
|
||||
void tt_wifi_disconnect() {
|
||||
wifi::disconnect();
|
||||
}
|
||||
|
||||
bool tt_wifi_is_connnection_secure() {
|
||||
return wifi::isConnectionSecure();
|
||||
}
|
||||
|
||||
int tt_wifi_get_rssi() {
|
||||
return wifi::getRssi();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user