//
//
//  WiFi Connection - handles the state - AP or Client
//
//

#ifndef WIFISTATEHANDLER_H
#define WIFISTATEHANDLER_H
#include <Arduino.h>

/// WiFi Connection States of connection
typedef enum {
  WFC_ConnectToAP,                ///< Connect to an Access Point
  WFC_JoiningAP,                  ///< Joining the Access Point
  WFC_JoinedAP,                   ///< Joined to the Access Point
  WFC_CreateAP,                   ///< Create an Access Point
  WFC_HostingAP,                  ///< Hosting an Access Point
  WFC_Idle,                       ///< Idle take no action, or invalid
} WiFiConnectState;

/// Get the current state
///
/// @returns the current state
///
WiFiConnectState WiFiStateGet();


/// Called from the main loop to manage the WiFi connection state
///
/// @returns current connection state
///
/// @code
/// void loop() {
///   ...
///   WiFiStateHandler();
///   ...
/// }
/// @endcode
WiFiConnectState WiFiStateHandler();        ///< WiFi interface manager

/// Used to force a specific state
///
/// @param[in] newState is the state to set the WiFi connection to
///
/// @code
/// void setup() {
///   ...
///   if (ssid == "" || pass == "")
///     WiFiStateSet(WFC_CreateAP);
///   else
///     WiFiStateSet(WFC_ConnectToAP);
///   ...
/// }
/// @endcode
///
void WiFiStateSet(WiFiConnectState newState);

#endif // WIFISTATEHANDLER_H
