- Lots of changes for migrating C code to C++ - Improved `Lockable` in several ways like adding `withLock()` (+ tests) - Improved `Semaphore` a bit for improved readability, and also added some tests - Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC - Simplification of WiFi connection - Updated funding options - (and more)
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include "service/wifi/Wifi.h"
|
|
#include "Mutex.h"
|
|
|
|
namespace tt::app::wifimanage {
|
|
|
|
/**
|
|
* View's state
|
|
*/
|
|
class State {
|
|
|
|
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
|
bool scanning = false;
|
|
bool scannedAfterRadioOn = false;
|
|
service::wifi::RadioState radioState;
|
|
std::vector<service::wifi::ApRecord> apRecords;
|
|
std::string connectSsid;
|
|
|
|
public:
|
|
State() = default;
|
|
|
|
void setScanning(bool isScanning);
|
|
bool isScanning() const;
|
|
|
|
bool hasScannedAfterRadioOn() const { return scannedAfterRadioOn; }
|
|
|
|
void setRadioState(service::wifi::RadioState state);
|
|
service::wifi::RadioState getRadioState() const;
|
|
|
|
void updateApRecords();
|
|
|
|
template <std::invocable<const std::vector<service::wifi::ApRecord>&> Func>
|
|
void withApRecords(Func&& onApRecords) const {
|
|
mutex.withLock([&]() {
|
|
std::invoke(std::forward<Func>(onApRecords), apRecords);
|
|
});
|
|
}
|
|
|
|
void setConnectSsid(const std::string& ssid);
|
|
std::string getConnectSsid() const;
|
|
};
|
|
|
|
} // namespace
|