#pragma once

// Only disconnect events advance the selection; a working link never roams.
class WifiProfileSelection {
public:
    explicit WifiProfileSelection(bool secondary) : secondary_(secondary) {}

    unsigned current() const { return current_; }
    void got_ip() { connected_ = true; }

    unsigned disconnected() {
        if (connected_) {
            // A lost working link gets one reconnect attempt before switching.
            connected_ = false;
        } else if (secondary_) {
            current_ ^= 1;
        }
        return current_;
    }

private:
    bool secondary_;
    bool connected_ = false;
    unsigned current_ = 0;
};
