Added WiFi kernel drivers and refactored Wifi service (#557)
+ other improvements
This commit is contained in:
committed by
GitHub
parent
dbb96a891c
commit
1c2806bddf
@@ -1,16 +1,15 @@
|
||||
#include "Tactility/lvgl/Lvgl.h"
|
||||
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/SystemEvents.h>
|
||||
#include <Tactility/CpuAffinity.h>
|
||||
#include <Tactility/Paths.h>
|
||||
#include <Tactility/TactilityPrivate.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/AppPaths.h>
|
||||
#include <Tactility/CpuAffinity.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/hal/display/DisplayDevice.h>
|
||||
#include <Tactility/hal/usb/Usb.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/Paths.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/settings/BootSettings.h>
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
@@ -21,8 +20,8 @@
|
||||
#include <atomic>
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "Tactility/app/crashdiagnostics/CrashDiagnostics.h"
|
||||
#include <Tactility/kernel/PanicHandler.h>
|
||||
#include <Tactility/app/crashdiagnostics/CrashDiagnostics.h>
|
||||
#include <Tactility/PanicHandler.h>
|
||||
#include <esp_system.h>
|
||||
#include <sdkconfig.h>
|
||||
#else
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <Tactility/app/crashdiagnostics/QrUrl.h>
|
||||
#include <Tactility/kernel/PanicHandler.h>
|
||||
#include <Tactility/PanicHandler.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#include <Tactility/app/files/State.h>
|
||||
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/Platform.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/file/FileLock.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
#include <Tactility/app/files/SupportedFiles.h>
|
||||
#include <Tactility/app/files/View.h>
|
||||
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/Platform.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/app/ElfApp.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/app/imageviewer/ImageViewer.h>
|
||||
#include <Tactility/app/inputdialog/InputDialog.h>
|
||||
#include <Tactility/app/notes/Notes.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <tactility/check.h>
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/MountPoints.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/Platform.h>
|
||||
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/Platform.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <tactility/check.h>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
#if TT_FEATURE_SCREENSHOT_ENABLED
|
||||
|
||||
#include <Tactility/Platform.h>
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/kernel/Platform.h>
|
||||
#include <Tactility/lvgl/Lvgl.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
|
||||
@@ -25,22 +25,19 @@ static void onConnect(const service::wifi::settings::WifiApSettings& ap_settings
|
||||
|
||||
void WifiConnect::onWifiEvent(service::wifi::WifiEvent event) {
|
||||
State& state = getState();
|
||||
switch (event) {
|
||||
case service::wifi::WifiEvent::ConnectionFailed:
|
||||
if (event.type == WIFI_EVENT_TYPE_STATION_CONNECTION_RESULT) {
|
||||
if (event.connection_error == WIFI_STATION_CONNECTION_ERROR_NONE) {
|
||||
if (state.isConnecting()) {
|
||||
state.setConnecting(false);
|
||||
stop(manifest.appId);
|
||||
}
|
||||
} else {
|
||||
if (state.isConnecting()) {
|
||||
state.setConnecting(false);
|
||||
state.setConnectionError(true);
|
||||
requestViewUpdate();
|
||||
}
|
||||
break;
|
||||
case service::wifi::WifiEvent::ConnectionSuccess:
|
||||
if (getState().isConnecting()) {
|
||||
state.setConnecting(false);
|
||||
stop(manifest.appId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
requestViewUpdate();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ void View::connect(lv_event_t* event) {
|
||||
|
||||
if (index < ap_records.size()) {
|
||||
LOG_I(TAG, "Clicked %zu/%zu", index, ap_records.size() - 1);
|
||||
auto& ssid = ap_records[index].ssid;
|
||||
std::string ssid = ap_records[index].ssid;
|
||||
LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
|
||||
std::string connection_target = service::wifi::getConnectionTarget();
|
||||
if (connection_target == ssid) {
|
||||
@@ -97,7 +97,7 @@ void View::showDetails(lv_event_t* event) {
|
||||
auto ap_records = self->state->getApRecords();
|
||||
|
||||
if (index < ap_records.size()) {
|
||||
auto& ssid = ap_records[index].ssid;
|
||||
std::string ssid = ap_records[index].ssid;
|
||||
LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
|
||||
self->bindings->onShowApSettings(ssid);
|
||||
} else {
|
||||
@@ -105,14 +105,14 @@ void View::showDetails(lv_event_t* event) {
|
||||
}
|
||||
}
|
||||
|
||||
void View::createSsidListItem(const service::wifi::ApRecord& record, bool isConnecting, size_t index) {
|
||||
void View::createSsidListItem(const WifiApRecord& record, bool isConnecting, size_t index) {
|
||||
if (isConnecting) {
|
||||
auto* button = lv_list_add_button(networks_list, LV_SYMBOL_WIFI, record.ssid.c_str());
|
||||
auto* button = lv_list_add_button(networks_list, LV_SYMBOL_WIFI, record.ssid);
|
||||
lv_obj_add_event_cb(button, showDetails, LV_EVENT_SHORT_CLICKED, this);
|
||||
} else {
|
||||
const std::string auth_info = (record.auth_mode == WIFI_AUTH_OPEN) ? "(open) " : " ";
|
||||
const std::string auth_info = (record.authentication_type == WIFI_AUTHENTICATION_TYPE_OPEN) ? "(open) " : " ";
|
||||
const auto percentage = mapRssiToPercentage(record.rssi);
|
||||
const auto label = std::format("{} {}{}%", record.ssid, auth_info, percentage);
|
||||
const auto label = std::format("{} {}{}%", std::string(record.ssid), auth_info, percentage);
|
||||
auto* button = lv_list_add_button(networks_list, nullptr, label.c_str());
|
||||
lv_obj_set_user_data(button, reinterpret_cast<void*>(index));
|
||||
if (service::wifi::settings::contains(record.ssid)) {
|
||||
|
||||
@@ -79,17 +79,16 @@ void WifiManage::onWifiEvent(service::wifi::WifiEvent event) {
|
||||
auto radio_state = service::wifi::getRadioState();
|
||||
LOG_I(TAG, "Update with state %s", service::wifi::radioStateToString(radio_state));
|
||||
getState().setRadioState(radio_state);
|
||||
switch (event) {
|
||||
using enum service::wifi::WifiEvent;
|
||||
case ScanStarted:
|
||||
switch (event.type) {
|
||||
case WIFI_EVENT_TYPE_SCAN_STARTED:
|
||||
getState().setScanning(true);
|
||||
break;
|
||||
case ScanFinished:
|
||||
case WIFI_EVENT_TYPE_SCAN_FINISHED:
|
||||
getState().setScanning(false);
|
||||
getState().updateApRecords();
|
||||
break;
|
||||
case RadioStateOn:
|
||||
if (!service::wifi::isScanning()) {
|
||||
case WIFI_EVENT_TYPE_RADIO_STATE_CHANGED:
|
||||
if (event.radio_state == WIFI_RADIO_STATE_ON && !service::wifi::isScanning()) {
|
||||
service::wifi::scan();
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user