/
station.h
125 lines (110 loc) · 3.2 KB
/
station.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* @file drivers/esp_wifi/station.h
*
* @section License
* Copyright (C) 2014-2016, Erik Moqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* This file is part of the Simba project.
*/
#ifndef __DRIVERS_ESP_WIFI_STATION_H__
#define __DRIVERS_ESP_WIFI_STATION_H__
#include "simba.h"
/**
* WiFi station connection status.
*/
enum esp_wifi_station_status_t {
esp_wifi_station_status_idle_t = 0,
esp_wifi_station_status_connecting_t,
esp_wifi_station_status_wrong_password_t,
esp_wifi_station_status_no_ap_found_t,
esp_wifi_station_status_connect_fail_t,
esp_wifi_station_status_got_ip_t
};
/**
* Initialize the WiFi station.
*
* @param[in] ssid_p WiFi SSID to connect to.
* @param[in] password_p WiFi password.
* @param[in] info_p Static ip configration or NULL to use DHCP.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_init(const char *ssid_p,
const char *password_p,
struct inet_if_ip_info_t *info_p);
/**
* Connect the WiFi station to the Access Point (AP).
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_connect(void);
/**
* Disconnect the WiFi station from the AP.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_disconnect(void);
/**
* Set the ip address, netmask and gateway of the WiFi station.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_set_ip_info(const struct inet_if_ip_info_t *info_p);
/**
* Get the station ip address, netmask and gateway.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_get_ip_info(struct inet_if_ip_info_t *info_p);
/**
* Set whether the station will reconnect to the AP after
* disconnection. It will do so by default.
*
* @param policy If it's true, it will enable reconnection; if it's
* false, it will disable reconnection.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_set_reconnect_policy(int policy);
/**
* Check whether the station will reconnect to the AP after
* disconnection.
*
* @return true(1) or false(0).
*/
int esp_wifi_station_get_reconnect_policy(void);
/**
* Get the connection status of the WiFi station.
*
* @return The connection status.
*/
enum esp_wifi_station_status_t esp_wifi_station_get_connect_status(void);
/**
* Enable the station DHCP client.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_dhcp_client_start(void);
/**
* Disable the station DHCP client.
*
* @return zero(0) or negative error code.
*/
int esp_wifi_station_dhcp_client_stop(void);
/**
* Get the station DHCP client status.
*
* @return Station DHCP client status.
*/
enum esp_wifi_dhcp_status_t esp_wifi_station_dhcp_client_status(void);
#endif