BSB Developer Docs
Loading...
Searching...
No Matches
wifi_common.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <stdint.h>
8
9#include <core/state.h>
10#include <core/pubsub.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
17#define SSID_MAX_LEN (34U)
19#define PASSPHRASE_MAX_LEN (64U)
21#define SCAN_MAX_RESULTS (28U)
23#define HW_ADDRESS_LEN (6U)
24
25#define WIFI_IP4_ADDR_FORMAT "%hhu.%hhu.%hhu.%hhu"
26#define WIFI_IP4_ADDR_SPREAD(addr) \
27 (addr)->bytes[0], (addr)->bytes[1], (addr)->bytes[2], (addr)->bytes[3]
28
34#define RECORD_WIFI "wifi"
35
37typedef struct Wifi Wifi;
38
52
63
65typedef enum {
67 WifiSecurityModeWpa,
68 WifiSecurityModeWpa2,
69 WifiSecurityModeWep,
70 WifiSecurityModeWpaWpa2Mixed,
71 WifiSecurityModeWpa3,
72 WifiSecurityModeWpa3Transition,
76
78typedef struct {
79 char ssid[SSID_MAX_LEN];
80 char passphrase[PASSPHRASE_MAX_LEN];
83
85typedef struct {
86 char ssid[SSID_MAX_LEN];
88 uint8_t rssi;
90
97
104
106typedef union {
107 uint32_t value;
108 uint8_t bytes[4];
109} WifiIpv4;
110
112typedef struct {
113 WifiIpv4 address;
114 WifiIpv4 gateway;
115 WifiIpv4 mask;
116 WifiIpv4 dns;
118
120typedef union {
121 uint32_t value[4];
122 uint16_t words[8];
123 uint8_t bytes[16];
124} WifiIpv6;
125
127typedef struct {
128 WifiIpv6 local;
129 WifiIpv6 global;
130 WifiIpv6 gateway;
132
140
155
156#ifdef __cplusplus
157}
158#endif
Credentials to connect to a Wifi access point.
Definition wifi_common.h:78
WifiSecurityMode security_mode
Type of protection to be used (usually WPA2 or 3)
Definition wifi_common.h:81
Definition wifi_backend_i.h:15
Wifi information structure.
Definition wifi_common.h:146
uint16_t channel
Channel number.
Definition wifi_common.h:150
WifiState state
State of the Wifi system.
Definition wifi_common.h:153
WifiIpConfig ip_config
Current IP configuration.
Definition wifi_common.h:152
int32_t rssi
Signal strength (RSSI) in dBm.
Definition wifi_common.h:149
WifiSecurityMode security_mode
Type of protection used by the current access point.
Definition wifi_common.h:151
IP configuration structure.
Definition wifi_common.h:134
WifiIpType type
IP version to use.
Definition wifi_common.h:136
WifiIpManagement mgmt
Address management method to use.
Definition wifi_common.h:135
All 3 parts of IPv4.
Definition wifi_common.h:112
All 3 parts of IPv6.
Definition wifi_common.h:127
One element of the scan result array returned as a response to the scan request.
Definition wifi_common.h:85
uint8_t rssi
Received signal level (bigger numbers mean weaker signal)
Definition wifi_common.h:88
WifiSecurityMode security_mode
Type of protection used by the AP.
Definition wifi_common.h:87
Union which represents IPv4 as byte sequence and single uint32_t (big-endian)
Definition wifi_common.h:106
uint32_t value
IPv4 address as a uint32_t.
Definition wifi_common.h:107
Union which represents IPv6 as byte, uint16_t, and uint32_t sequences.
Definition wifi_common.h:120
WifiIpType
Enumeration of supported IP protocol types.
Definition wifi_common.h:99
@ WifiIpTypeV6
IP version 6.
Definition wifi_common.h:101
@ WifiIpTypeMax
Special value, internal use.
Definition wifi_common.h:102
@ WifiIpTypeV4
IP version 4.
Definition wifi_common.h:100
#define PASSPHRASE_MAX_LEN
Maximum length of the passphrase field.
Definition wifi_common.h:19
WifiSecurityMode
Enumeration of supported security modes.
Definition wifi_common.h:65
@ WifiSecurityModeUnsupported
The security mode is not supported by this device.
Definition wifi_common.h:73
@ WifiSecurityModeMax
Special value, internal use.
Definition wifi_common.h:74
@ WifiSecurityModeOpen
No password, the network is open for everyone.
Definition wifi_common.h:66
WifiStatus
Enumeration of possible statuses returned by Wifi functions.
Definition wifi_common.h:40
@ WifiStatusMax
Special value, internal use.
Definition wifi_common.h:50
@ WifiStatusTimeout
Command timed out.
Definition wifi_common.h:43
@ WifiStatusScanNotPossible
Failed to scan due to Wifi being connected.
Definition wifi_common.h:46
@ WifiStatusAuthenticationFailed
Wifi authentication failed.
Definition wifi_common.h:48
@ WifiStatusAlreadyConnected
Wifi has already been connected.
Definition wifi_common.h:44
@ WifiStatusAlreadyDisconnected
Wifi has already been disconnected.
Definition wifi_common.h:45
@ WifiStatusAccessPointNotFound
Wifi access point was not found.
Definition wifi_common.h:47
@ WifiStatusOk
No error has occurred.
Definition wifi_common.h:41
@ WifiStatusError
A generic error has occurred.
Definition wifi_common.h:42
@ WifiStatusConfigurationFailed
Wifi configuration failed (e.g.
Definition wifi_common.h:49
#define HW_ADDRESS_LEN
MAC address length in bytes.
Definition wifi_common.h:23
#define SSID_MAX_LEN
Maximum length of the SSID field.
Definition wifi_common.h:17
WifiIpManagement
Enumeration of supported address management methods.
Definition wifi_common.h:92
@ WifiIpManagementMax
Special value, internal use.
Definition wifi_common.h:95
@ WifiIpManagementDynamic
Dynamic IP address - set automatically via DHCP.
Definition wifi_common.h:94
@ WifiIpManagementStatic
Static IP address - set manually.
Definition wifi_common.h:93
WifiState
Enumeration of possible states for the Wifi system.
Definition wifi_common.h:54
@ WifiStateConnected
The Wifi system is in connected state.
Definition wifi_common.h:57
@ WifiStateConnecting
The Wifi system is trying to connect.
Definition wifi_common.h:58
@ WifiStateMax
Special value, internal use.
Definition wifi_common.h:61
@ WifiStateDisconnected
The Wifi system is in disconnected state.
Definition wifi_common.h:56
@ WifiStateDisconnecting
The Wifi system is disconnecting.
Definition wifi_common.h:59
@ WifiStateReconnecting
The Wifi system is trying to reconnect.
Definition wifi_common.h:60