| 247 | } |
| 248 | |
| 249 | std::vector<ApRecord> getScanResults() { |
| 250 | LOGGER.info("getScanResults()"); |
| 251 | auto wifi = wifi_singleton; |
| 252 | |
| 253 | std::vector<ApRecord> records; |
| 254 | |
| 255 | if (wifi == nullptr) { |
| 256 | return records; |
| 257 | } |
| 258 | |
| 259 | auto lock = wifi->dataMutex.asScopedLock(); |
| 260 | if (!lock.lock(10 / portTICK_PERIOD_MS)) { |
| 261 | return records; |
| 262 | } |
| 263 | |
| 264 | if (wifi->scan_list_count > 0) { |
| 265 | uint16_t i = 0; |
| 266 | for (; i < wifi->scan_list_count; ++i) { |
| 267 | const auto& scanned_item = wifi->scan_list[i]; |
| 268 | records.push_back((ApRecord) { |
| 269 | .ssid = reinterpret_cast<const char*>(scanned_item.ssid), |
| 270 | .rssi = scanned_item.rssi, |
| 271 | .channel = scanned_item.primary, |
| 272 | .auth_mode = scanned_item.authmode |
| 273 | }); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return records; |
| 278 | } |
| 279 | |
| 280 | void setEnabled(bool enabled) { |
| 281 | LOGGER.info("setEnabled({})", enabled); |
nothing calls this directly
no test coverage detected