55#include " wifi_spi.h"
66#include " IPAddress.h"
77
8+ // Key index length
89#define KEY_IDX_LEN 1
10+ // 5 secs of delay to have the connection established
911#define WL_DELAY_START_CONNECTION 5000
10- #define WL_DELAY_RETRY_START_CONNECTION 1000
1112
1213class WiFiDrv
1314{
@@ -25,44 +26,159 @@ class WiFiDrv
2526 static uint8_t _subnetMask[WL_IPV4_LENGTH];
2627 static uint8_t _gatewayIp[WL_IPV4_LENGTH];
2728
29+ /*
30+ * Get network Data information
31+ */
2832 static void getNetworkData (uint8_t *ip, uint8_t *mask, uint8_t *gwip);
2933
3034public:
3135
36+ /*
37+ * Driver initialization
38+ */
3239 static void wifiDriverInit ();
3340
41+ /*
42+ * Set the desired network which the connection manager should try to
43+ * connect to.
44+ *
45+ * The ssid of the desired network should be specified.
46+ *
47+ * param ssid: The ssid of the desired network.
48+ * param ssid_len: Lenght of ssid string.
49+ * return: WL_SUCCESS or WL_FAILURE
50+ */
3451 static uint8_t wifiSetNetwork (char * ssid, uint8_t ssid_len);
3552
53+ /* Start Wifi connection with passphrase
54+ * the most secure supported mode will be automatically selected
55+ *
56+ * param ssid: Pointer to the SSID string.
57+ * param ssid_len: Lenght of ssid string.
58+ * param passphrase: Passphrase. Valid characters in a passphrase
59+ * must be between ASCII 32-126 (decimal).
60+ * param len: Lenght of passphrase string.
61+ * return: WL_SUCCESS or WL_FAILURE
62+ */
3663 static uint8_t wifiSetPassphrase (char * ssid, uint8_t ssid_len, const char *passphrase, const uint8_t len);
3764
65+ /* Start Wifi connection with WEP encryption.
66+ * Configure a key into the device. The key type (WEP-40, WEP-104)
67+ * is determined by the size of the key (5 bytes for WEP-40, 13 bytes for WEP-104).
68+ *
69+ * param ssid: Pointer to the SSID string.
70+ * param ssid_len: Lenght of ssid string.
71+ * param key_idx: The key index to set. Valid values are 0-3.
72+ * param key: Key input buffer.
73+ * param len: Lenght of key string.
74+ * return: WL_SUCCESS or WL_FAILURE
75+ */
3876 static uint8_t wifiSetKey (char * ssid, uint8_t ssid_len, uint8_t key_idx, const void *key, const uint8_t len);
3977
78+ /*
79+ * Disconnect from the network
80+ *
81+ * return: WL_SUCCESS or WL_FAILURE
82+ */
4083 static uint8_t disconnect ();
41-
84+
85+ /*
86+ * Disconnect from the network
87+ *
88+ * return: one value of wl_status_t enum
89+ */
4290 static uint8_t getConnectionStatus ();
4391
92+ /*
93+ * Get the interface MAC address.
94+ *
95+ * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
96+ */
4497 static uint8_t * getMacAddress ();
4598
99+ /*
100+ * Get the interface IP address.
101+ *
102+ * return: copy the ip address value in IPAddress object
103+ */
46104 static void getIpAddress (IPAddress& ip);
47105
48- static void getSubnetMask (IPAddress& ip);
49-
106+ /*
107+ * Get the interface subnet mask address.
108+ *
109+ * return: copy the subnet mask address value in IPAddress object
110+ */
111+ static void getSubnetMask (IPAddress& mask);
112+
113+ /*
114+ * Get the gateway ip address.
115+ *
116+ * return: copy the gateway ip address value in IPAddress object
117+ */
50118 static void getGatewayIP (IPAddress& ip);
51119
120+ /*
121+ * Return the current SSID associated with the network
122+ *
123+ * return: ssid string
124+ */
52125 static char * getCurrentSSID ();
53126
127+ /*
128+ * Return the current BSSID associated with the network.
129+ * It is the MAC address of the Access Point
130+ *
131+ * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
132+ */
54133 static uint8_t * getCurrentBSSID ();
55134
135+ /*
136+ * Return the current RSSI /Received Signal Strength in dBm)
137+ * associated with the network
138+ *
139+ * return: signed value
140+ */
56141 static int32_t getCurrentRSSI ();
57142
143+ /*
144+ * Return the Encryption Type associated with the network
145+ *
146+ * return: one value of wl_enc_type enum
147+ */
58148 static uint8_t getCurrentEncryptionType ();
59149
150+ /*
151+ * Start scan WiFi networks available
152+ *
153+ * return: Number of discovered networks
154+ */
60155 static uint8_t scanNetworks ();
61156
157+ /*
158+ * Return the SSID discovered during the network scan.
159+ *
160+ * param networkItem: specify from which network item want to get the information
161+ *
162+ * return: ssid string of the specified item on the networks scanned list
163+ */
62164 static char * getSSIDNetoworks (uint8_t networkItem);
63165
166+ /*
167+ * Return the RSSI of the networks discovered during the scanNetworks
168+ *
169+ * param networkItem: specify from which network item want to get the information
170+ *
171+ * return: signed value of RSSI of the specified item on the networks scanned list
172+ */
64173 static int32_t getRSSINetoworks (uint8_t networkItem);
65174
175+ /*
176+ * Return the encryption type of the networks discovered during the scanNetworks
177+ *
178+ * param networkItem: specify from which network item want to get the information
179+ *
180+ * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
181+ */
66182 static uint8_t getEncTypeNetowrks (uint8_t networkItem);
67183
68184};
0 commit comments