|
@@ -9,22 +9,19 @@
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
-/**
|
|
|
- * WiFi functions
|
|
|
- */
|
|
|
namespace kbf::wifi {
|
|
|
/**
|
|
|
- * WiFi station (STA) mode.
|
|
|
+ * @brief WiFi station (STA) mode.
|
|
|
*/
|
|
|
class STA { // TODO turn this into singleton? doesn't make sense to have multiple instances
|
|
|
public:
|
|
|
- /** Tag used for logging. */
|
|
|
+ /** @brief Tag used for logging. */
|
|
|
static constexpr const char *TAG = "kbf::wifi::STA";
|
|
|
|
|
|
/**
|
|
|
- * Initializes the WiFi hardware.
|
|
|
+ * @brief Initializes the WiFi hardware.
|
|
|
*
|
|
|
- * @note Note that WiFi requires NVS. If NVS hasn't been initialized yet, this ctor will call kbf::nvs::init()
|
|
|
+ * @note WiFi requires NVS. If NVS hasn't been initialized yet, this constructor will call kbf::nvs::init()
|
|
|
* and try again.
|
|
|
*/
|
|
|
STA();
|
|
@@ -32,7 +29,7 @@ namespace kbf::wifi {
|
|
|
~STA();
|
|
|
|
|
|
/**
|
|
|
- * Initiates connection to an AP.
|
|
|
+ * @brief Initiates connection to an AP.
|
|
|
*
|
|
|
* @param ssid SSID of AP
|
|
|
* @param password Password
|
|
@@ -41,14 +38,12 @@ namespace kbf::wifi {
|
|
|
void connect(const string &ssid, const string &password, int maxRetryAttempts = 3);
|
|
|
|
|
|
/**
|
|
|
- * Disconnects from the AP.
|
|
|
- *
|
|
|
- * @warning not yet implemented
|
|
|
+ * @brief Disconnects from the AP.
|
|
|
*/
|
|
|
void disconnect();
|
|
|
|
|
|
/**
|
|
|
- * Called when the connection to the AP was successful.
|
|
|
+ * @brief Called when the connection to the AP was successful.
|
|
|
*
|
|
|
* @note Connection may be useless until an IP address is assigned by the AP. See onIp().
|
|
|
* @see onIp()
|
|
@@ -56,12 +51,12 @@ namespace kbf::wifi {
|
|
|
void (*onConnect)(){};
|
|
|
|
|
|
/**
|
|
|
- * Called once an IP address is assigned by the AP. The connection should be ready to use at this point.
|
|
|
+ * @brief Called once an IP address is assigned by the AP. The connection should be ready to use at this point.
|
|
|
*/
|
|
|
void (*onIp)(){};
|
|
|
|
|
|
/**
|
|
|
- * Called before reconnect attempts.
|
|
|
+ * @brief Called before reconnect attempts.
|
|
|
*
|
|
|
* Reconnect is attempted after disconnect events if retryMax hasn't been reached yet.
|
|
|
*
|
|
@@ -74,10 +69,11 @@ namespace kbf::wifi {
|
|
|
bool (*onReconnecting)(int attempt, int max){};
|
|
|
|
|
|
/**
|
|
|
- * Called if disconnected and retryMax has been reached.
|
|
|
+ * @brief Called if disconnected and retryMax has been reached.
|
|
|
*/
|
|
|
void (*onDisconnect)(){};
|
|
|
|
|
|
+ /** @brief Returns the IP address for the connection. */
|
|
|
[[nodiscard]] const kbf::net::IP &ip() const { return m_ip; };
|
|
|
|
|
|
private:
|