| 145 | } |
| 146 | |
| 147 | void View::updateNetworkList() { |
| 148 | lv_obj_clean(networks_list); |
| 149 | |
| 150 | // Enable on boot |
| 151 | |
| 152 | auto* enable_on_boot_wrapper = lv_obj_create(networks_list); |
| 153 | lv_obj_set_size(enable_on_boot_wrapper, LV_PCT(100), LV_SIZE_CONTENT); |
| 154 | lv_obj_set_style_pad_all(enable_on_boot_wrapper, 0, LV_STATE_DEFAULT); |
| 155 | lv_obj_set_style_border_width(enable_on_boot_wrapper, 0, LV_STATE_DEFAULT); |
| 156 | |
| 157 | auto* enable_label = lv_label_create(enable_on_boot_wrapper); |
| 158 | lv_label_set_text(enable_label, "Enable on boot"); |
| 159 | lv_obj_align(enable_label, LV_ALIGN_LEFT_MID, 0, 0); |
| 160 | |
| 161 | enable_on_boot_switch = lv_switch_create(enable_on_boot_wrapper); |
| 162 | lv_obj_align(enable_on_boot_switch, LV_ALIGN_RIGHT_MID, 0, 0); |
| 163 | lv_obj_add_event_cb(enable_on_boot_switch, onEnableOnBootSwitchChanged, LV_EVENT_VALUE_CHANGED, bindings); |
| 164 | lv_obj_add_event_cb(enable_on_boot_wrapper, onEnableOnBootParentClicked, LV_EVENT_SHORT_CLICKED, enable_on_boot_switch); |
| 165 | |
| 166 | if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) { |
| 167 | lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 2, LV_STATE_DEFAULT); |
| 168 | } else { |
| 169 | lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 8, LV_STATE_DEFAULT); |
| 170 | } |
| 171 | |
| 172 | updateEnableOnBootToggle(); |
| 173 | |
| 174 | switch (state->getRadioState()) { |
| 175 | using enum service::wifi::RadioState; |
| 176 | case OnPending: |
| 177 | case On: |
| 178 | case ConnectionPending: |
| 179 | case ConnectionActive: { |
| 180 | |
| 181 | std::string connection_target = service::wifi::getConnectionTarget(); |
| 182 | |
| 183 | // Make safe copy |
| 184 | auto ap_records = state->getApRecords(); |
| 185 | |
| 186 | bool is_connected = !connection_target.empty() && |
| 187 | state->getRadioState() == ConnectionActive; |
| 188 | bool added_connected = false; |
| 189 | if (is_connected && !ap_records.empty()) { |
| 190 | for (int i = 0; i < ap_records.size(); ++i) { |
| 191 | auto& record = ap_records[i]; |
| 192 | if (record.ssid == connection_target) { |
| 193 | lv_list_add_text(networks_list, "Connected"); |
| 194 | createSsidListItem(record, false, i); |
| 195 | added_connected = true; |
| 196 | break; |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | lv_list_add_text(networks_list, "Other networks"); |
| 202 | std::set<std::string> used_ssids; |
| 203 | if (!ap_records.empty()) { |
| 204 | for (int i = 0; i < ap_records.size(); ++i) { |
nothing calls this directly
no test coverage detected