Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
wifi.h
Go to the documentation of this file.
1/*
2 * This file is part of the Rishka distribution (https://github.com/nthnn/rishka).
3 * Copyright (c) 2024 Nathanne Isip.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
28#ifndef LIBRISHKA_DRIVERS_WIFI_H
29#define LIBRISHKA_DRIVERS_WIFI_H
30
31#include <librishka.h>
32#include <librishka/types.h>
33
38typedef enum {
52
57typedef enum {
61
66typedef enum {
70
75typedef enum {
76 WIFI_STATUS_NO_SHIELD = 0xff,
77 WIFI_STATUS_STOPPED = 0xfe,
78 WIFI_STATUS_IDLE_STATUS = 0x00,
79 WIFI_STATUS_NO_SSID_AVAIL = 0x01,
80 WIFI_STATUS_SCAN_COMPLETED = 0x02,
81 WIFI_STATUS_CONNECTED = 0x03,
82 WIFI_STATUS_CONNECT_FAILED = 0x04,
83 WIFI_STATUS_CONNECTION_LOST = 0x05,
84 WIFI_STATUS_DISCONNECTED = 0x06
86
94class WiFi final {
95public:
107 static bool connect(string ssid, string passkey, i32 channel = 0, u8* bssid = nullptr);
108
115 static bool reconnect();
116
126 static bool disconnect(bool wifi_off, bool erase_ap);
127
134 static bool erase_ap();
135
142 static bool is_connected();
143
152 static bool set_autoreconnect(bool auto_recon);
153
160 static bool is_autoreconnect();
161
170 static u8 wait_for_result(u64 timeout);
171
179 static void set_min_security(u8 auth_mode);
180
187 static void set_scan_method(u8 scan_method);
188
195 static void set_sort_method(u8 sort_method);
196
203 static u8 status();
204
211 static string ssid();
212
219 static string psk();
220
228 static string bssid();
229
236 static i8 rssi();
237
245 static bool set_local_ip(string ip);
246
254 static bool set_gateway_ip(string ip);
255};
256
257#endif
Provides an interface for managing WiFi connections on the Rishka system.
Definition: wifi.h:94
static void set_scan_method(u8 scan_method)
Sets the WiFi scanning method.
Definition: librishka_drivers_wifi.cpp:57
static string bssid()
Retrieves the BSSID of the current WiFi access point.
Definition: librishka_drivers_wifi.cpp:77
static bool connect(string ssid, string passkey, i32 channel=0, u8 *bssid=nullptr)
Connects to a WiFi network.
Definition: librishka_drivers_wifi.cpp:21
static void set_sort_method(u8 sort_method)
Sets the method for sorting access points in the scan list.
Definition: librishka_drivers_wifi.cpp:61
static string psk()
Retrieves the Pre-Shared Key (PSK) of the current WiFi network.
Definition: librishka_drivers_wifi.cpp:73
static bool reconnect()
Reconnects to the last connected WiFi network.
Definition: librishka_drivers_wifi.cpp:25
static bool is_autoreconnect()
Checks if the auto-reconnect feature is enabled.
Definition: librishka_drivers_wifi.cpp:45
static string ssid()
Retrieves the SSID of the current WiFi network.
Definition: librishka_drivers_wifi.cpp:69
static bool set_autoreconnect(bool auto_recon)
Sets the auto-reconnect feature.
Definition: librishka_drivers_wifi.cpp:41
static i8 rssi()
Retrieves the Received Signal Strength Indicator (RSSI) of the current WiFi connection.
Definition: librishka_drivers_wifi.cpp:81
static void set_min_security(u8 auth_mode)
Sets the minimum security level for WiFi connections.
Definition: librishka_drivers_wifi.cpp:53
static bool is_connected()
Checks if the device is currently connected to a WiFi network.
Definition: librishka_drivers_wifi.cpp:37
static bool set_gateway_ip(string ip)
Sets the gateway IP address for the WiFi connection.
Definition: librishka_drivers_wifi.cpp:89
static u8 status()
Retrieves the current status of the WiFi module.
Definition: librishka_drivers_wifi.cpp:65
static u8 wait_for_result(u64 timeout)
Waits for a WiFi connection result within the specified timeout period.
Definition: librishka_drivers_wifi.cpp:49
static bool disconnect(bool wifi_off, bool erase_ap)
Disconnects from the current WiFi network.
Definition: librishka_drivers_wifi.cpp:29
static bool erase_ap()
Erases the saved access point data from memory.
Definition: librishka_drivers_wifi.cpp:33
static bool set_local_ip(string ip)
Sets the local IP address for the WiFi connection.
Definition: librishka_drivers_wifi.cpp:85
Main header file for the Rishka SDK.
Header file for common data types used in Rishka applications.
signed char i8
Alias for the signed 8-bit integer type.
Definition: types.h:46
signed int i32
Alias for the signed 32-bit integer type.
Definition: types.h:58
unsigned char u8
Alias for the unsigned 8-bit integer type.
Definition: types.h:70
unsigned long int u64
Alias for the unsigned 64-bit integer type.
Definition: types.h:88
WiFiAuthMode
Enumerates the supported WiFi authentication modes.
Definition: wifi.h:38
@ WIFI_AUTH_ENTERPRISE
Definition: wifi.h:44
@ WIFI_AUTH_WPA3_PSK
Definition: wifi.h:46
@ WIFI_AUTH_MAX
Definition: wifi.h:50
@ WIFI_AUTH_WPA2_PSK
Definition: wifi.h:42
@ WIFI_AUTH_WPA3_ENT_192
Definition: wifi.h:49
@ WIFI_AUTH_WPA_WPA2_PSK
Definition: wifi.h:43
@ WIFI_AUTH_WPA2_WPA3_PSK
Definition: wifi.h:47
@ WIFI_AUTH_WEP
Definition: wifi.h:40
@ WIFI_AUTH_WAPI_PSK
Definition: wifi.h:48
@ WIFI_AUTH_WPA2_ENTERPRISE
Definition: wifi.h:45
@ WIFI_AUTH_WPA_PSK
Definition: wifi.h:41
@ WIFI_AUTH_OPEN
Definition: wifi.h:39
WiFiSortMethod
Defines the methods for sorting access points in the scan list.
Definition: wifi.h:66
@ WIFI_CONNECT_AP_BY_SECURITY
Definition: wifi.h:68
@ WIFI_CONNECT_AP_BY_SIGNAL
Definition: wifi.h:67
WiFiScanMethod
Defines the methods used for scanning WiFi networks.
Definition: wifi.h:57
@ WIFI_ALL_CHANNEL_SCAN
Definition: wifi.h:59
@ WIFI_FAST_SCAN
Definition: wifi.h:58
WiFiStatus
Enumerates the possible states of the WiFi connection.
Definition: wifi.h:75