Added WiFi kernel drivers and refactored Wifi service (#557)

+ other improvements
This commit is contained in:
Ken Van Hoeylandt
2026-07-09 21:03:38 +02:00
committed by GitHub
parent dbb96a891c
commit 1c2806bddf
104 changed files with 2347 additions and 1428 deletions
+6 -6
View File
@@ -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;