From 4bb5046e1f42d07e5579674f1d9d41a16dc81b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Tue, 7 Aug 2018 16:47:55 +0200 Subject: [PATCH] sculpt_manager: adapt to new wifi_drv front end --- repos/gems/run/sculpt.run | 6 +-- repos/gems/run/sculpt/leitzentrale.config | 4 +- repos/gems/run/sculpt/wifi.config | 3 ++ repos/gems/run/sculpt/wlan.config | 1 - .../app/sculpt_manager/model/access_point.h | 7 +-- .../sculpt_manager/model/wifi_connection.h | 2 +- repos/gems/src/app/sculpt_manager/network.h | 47 ++++++++++++++----- .../app/sculpt_manager/runtime/wifi_drv.cc | 14 ++---- .../app/sculpt_manager/view/network_dialog.cc | 4 +- 9 files changed, 54 insertions(+), 34 deletions(-) create mode 100644 repos/gems/run/sculpt/wifi.config delete mode 100644 repos/gems/run/sculpt/wlan.config diff --git a/repos/gems/run/sculpt.run b/repos/gems/run/sculpt.run index 067959eb8..a26c1a331 100644 --- a/repos/gems/run/sculpt.run +++ b/repos/gems/run/sculpt.run @@ -91,7 +91,7 @@ install_config { - + @@ -149,8 +149,8 @@ install_config { - - + + diff --git a/repos/gems/run/sculpt/leitzentrale.config b/repos/gems/run/sculpt/leitzentrale.config index 69d701b17..994094105 100644 --- a/repos/gems/run/sculpt/leitzentrale.config +++ b/repos/gems/run/sculpt/leitzentrale.config @@ -166,8 +166,8 @@ - - + + diff --git a/repos/gems/run/sculpt/wifi.config b/repos/gems/run/sculpt/wifi.config new file mode 100644 index 000000000..29bc2ccd3 --- /dev/null +++ b/repos/gems/run/sculpt/wifi.config @@ -0,0 +1,3 @@ + + + diff --git a/repos/gems/run/sculpt/wlan.config b/repos/gems/run/sculpt/wlan.config deleted file mode 100644 index b10cde0e4..000000000 --- a/repos/gems/run/sculpt/wlan.config +++ /dev/null @@ -1 +0,0 @@ - diff --git a/repos/gems/src/app/sculpt_manager/model/access_point.h b/repos/gems/src/app/sculpt_manager/model/access_point.h index 4fd2a764b..4d3218976 100644 --- a/repos/gems/src/app/sculpt_manager/model/access_point.h +++ b/repos/gems/src/app/sculpt_manager/model/access_point.h @@ -47,7 +47,7 @@ struct Sculpt::Access_point : List_model::Element /** - * Policy for transforming a 'wlan_accesspoints' report into a list model + * Policy for transforming a 'accesspoints' report into a list model */ struct Sculpt::Access_point_update_policy : List_model::Update_policy { @@ -60,12 +60,13 @@ struct Sculpt::Access_point_update_policy : List_model::Update_pol Access_point &create_element(Xml_node node) { auto const protection = node.attribute_value("protection", String<16>()); + bool const use_protection = protection == "WPA" || protection == "WPA2"; return *new (_alloc) Access_point(node.attribute_value("bssid", Access_point::Bssid()), node.attribute_value("ssid", Access_point::Ssid()), - protection == "WPA-PSK" ? Access_point::Protection::WPA_PSK : - Access_point::Protection::UNPROTECTED); + use_protection ? Access_point::Protection::WPA_PSK + : Access_point::Protection::UNPROTECTED); } void update_element(Access_point &ap, Xml_node node) diff --git a/repos/gems/src/app/sculpt_manager/model/wifi_connection.h b/repos/gems/src/app/sculpt_manager/model/wifi_connection.h index e4e548f33..85f906c4b 100644 --- a/repos/gems/src/app/sculpt_manager/model/wifi_connection.h +++ b/repos/gems/src/app/sculpt_manager/model/wifi_connection.h @@ -29,7 +29,7 @@ struct Sculpt::Wifi_connection Access_point::Ssid ssid; /** - * Create 'Wifi_connection' object from 'wlan_state' report + * Create 'Wifi_connection' object from 'state' report */ static Wifi_connection from_xml(Xml_node node) { diff --git a/repos/gems/src/app/sculpt_manager/network.h b/repos/gems/src/app/sculpt_manager/network.h index 96f011e69..e0b98b61e 100644 --- a/repos/gems/src/app/sculpt_manager/network.h +++ b/repos/gems/src/app/sculpt_manager/network.h @@ -53,10 +53,10 @@ struct Sculpt::Network : Network_dialog::Action bool _use_wifi_drv = false; Attached_rom_dataspace _wlan_accesspoints_rom { - _env, "report -> runtime/wifi_drv/wlan_accesspoints" }; + _env, "report -> runtime/wifi_drv/accesspoints" }; Attached_rom_dataspace _wlan_state_rom { - _env, "report -> runtime/wifi_drv/wlan_state" }; + _env, "report -> runtime/wifi_drv/state" }; Attached_rom_dataspace _nic_router_state_rom { _env, "report -> runtime/nic_router/state" }; @@ -102,7 +102,7 @@ struct Sculpt::Network : Network_dialog::Action _pci_info }; Managed_config _wlan_config { - _env, "selected_network", "wlan", *this, &Network::_handle_wlan_config }; + _env, "config", "wifi", *this, &Network::_handle_wlan_config }; void _handle_wlan_config(Xml_node) { @@ -157,12 +157,24 @@ struct Sculpt::Network : Network_dialog::Action _wifi_connection.state = Wifi_connection::CONNECTING; _wlan_config.generate([&] (Xml_generator &xml) { - xml.attribute("ssid", ap.ssid); - if (ap.protection == Access_point::WPA_PSK) { - xml.attribute("protection", "WPA-PSK"); - String<128> const psk(wpa_passphrase); - xml.attribute("psk", psk); - } + + xml.attribute("connected_scan_interval", 0U); + xml.attribute("scan_interval", 10U); + xml.attribute("use_11n", false); + + xml.attribute("verbose_state", false); + xml.attribute("verbose", false); + + xml.node("accesspoint", [&]() { + xml.attribute("ssid", ap.ssid); + + /* for now always try to use WPA2 */ + if (ap.protection == Access_point::WPA_PSK) { + xml.attribute("protection", "WPA2"); + String<128> const psk(wpa_passphrase); + xml.attribute("passphrase", psk); + } + }); }); }); } @@ -177,10 +189,19 @@ struct Sculpt::Network : Network_dialog::Action _wlan_config.generate([&] (Xml_generator &xml) { - /* generate attributes to ease subsequent manual tweaking */ - xml.attribute("ssid", ""); - xml.attribute("protection", "WPA-PSK"); - xml.attribute("psk", ""); + xml.attribute("connected_scan_interval", 0U); + xml.attribute("scan_interval", 10U); + xml.attribute("use_11n", false); + + xml.node("accesspoints", [&]() { + xml.node("accesspoint", [&]() { + + /* generate attributes to ease subsequent manual tweaking */ + xml.attribute("ssid", ""); + xml.attribute("protection", "NONE"); + xml.attribute("passphrase", ""); + }); + }); }); _runtime_config_generator.generate_runtime_config(); diff --git a/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc b/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc index 1da8a3051..f208ca6b3 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/wifi_drv.cc @@ -15,13 +15,11 @@ void Sculpt::gen_wifi_drv_start_content(Xml_generator &xml) { - gen_common_start_content(xml, "wifi_drv", Cap_quota{300}, Ram_quota{54*1024*1024}); + gen_common_start_content(xml, "wifi_drv", Cap_quota{200}, Ram_quota{24*1024*1024}); gen_provides(xml); xml.node("config", [&] () { - xml.attribute("connected_scan_interval", "0"); - xml.attribute("use_11n", "no"); xml.node("vfs", [&] () { gen_named_node(xml, "dir", "dev", [&] () { @@ -29,16 +27,14 @@ void Sculpt::gen_wifi_drv_start_content(Xml_generator &xml) xml.node("zero", [&] () {}); xml.node("rtc", [&] () {}); xml.node("log", [&] () {}); + xml.node("null", [&] () {}); gen_named_node(xml, "jitterentropy", "random"); gen_named_node(xml, "jitterentropy", "urandom"); }); - - gen_named_node(xml, "dir", "config", [&] () { - xml.node("ram", [&] () {}); }); }); xml.node("libc", [&] () { xml.attribute("stdout", "/dev/null"); - xml.attribute("stderr", "/dev/log"); + xml.attribute("stderr", "/dev/null"); xml.attribute("rtc", "/dev/rtc"); }); }); @@ -75,9 +71,9 @@ void Sculpt::gen_wifi_drv_start_content(Xml_generator &xml) gen_parent_route (xml); gen_service_node(xml, [&] () { - xml.attribute("label", "wlan_configuration"); + xml.attribute("label", "wifi_config"); xml.node("parent", [&] () { - xml.attribute("label", "config -> managed/wlan"); }); }); + xml.attribute("label", "config -> managed/wifi"); }); }); gen_service_node(xml, [&] () { xml.node("parent", [&] () { diff --git a/repos/gems/src/app/sculpt_manager/view/network_dialog.cc b/repos/gems/src/app/sculpt_manager/view/network_dialog.cc index ce40a439c..bc9a99a48 100644 --- a/repos/gems/src/app/sculpt_manager/view/network_dialog.cc +++ b/repos/gems/src/app/sculpt_manager/view/network_dialog.cc @@ -151,7 +151,7 @@ void Sculpt::Network_dialog::_gen_access_point_list(Xml_generator &xml) const }); /* - * Present motivational message until we get the first 'wlan_accesspoints' + * Present motivational message until we get the first 'accesspoints' * report. */ if (cnt == 0) @@ -177,7 +177,7 @@ void Sculpt::Network_dialog::_gen_connected_ap(Xml_generator &xml) const /* * If access point is not present in the list, fall back to the information - * given in the 'wlan_state' report. + * given in the 'state' report. */ if (!done) _gen_access_point(xml, Access_point { _wifi_connection.bssid,