@@ -39,51 +39,45 @@ class WiFiInterface: public NetworkInterface
39
39
40
40
/* * WiFiInterface lifetime
41
41
*/
42
- WiFiInterface ();
43
- virtual ~WiFiInterface ();
42
+ virtual ~WiFiInterface () {};
44
43
45
44
/* * Set the WiFi network credentials
46
45
*
47
- * @param ssid Name of the network to connect to
48
- * @param pass Security passphrase to connect to the network
49
- * @param security Type of encryption for connection
50
- * (defaults to NSAPI_SECURITY_NONE)
46
+ * @param ssid Name of the network to connect to
47
+ * @param pass Security passphrase to connect to the network
48
+ * @param security Type of encryption for connection
49
+ * (defaults to NSAPI_SECURITY_NONE)
50
+ * @return 0 on success, or error code on failure
51
51
*/
52
- virtual int set_credentials (const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE);
52
+ virtual int set_credentials (const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE) = 0 ;
53
53
54
- /* * Start the interface
54
+ /* * Set the WiFi network channel
55
55
*
56
- * Attempts to connect to a WiFi network.
57
- *
58
- * @param ssid Name of the network to connect to
59
- * @param pass Security passphrase to connect to the network
60
- * @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
61
56
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
62
- * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
63
57
* @return 0 on success, or error code on failure
64
58
*/
65
- virtual int connect (const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE,
66
- uint8_t channel = 0 , unsigned timeout = 0 ) = 0;
59
+ virtual int set_channel (uint8_t channel) = 0;
67
60
68
- /* * Start the interface
61
+ /* * Gets the current radio signal strength for active connection
69
62
*
70
- * Attempts to connect to a WiFi network asynchronously, the call will return straight away. If the @a cb was NULL
71
- * you'll need to query @a get_state until it's in NSAPI_IF_STATE_CONNECTED state, otherwise the @a cb will be
72
- * called with connection results, connected AP details and user data.
63
+ * @return Connection strength in dBm (negative value),
64
+ * or 0 if measurement impossible
65
+ */
66
+ virtual int8_t get_rssi () = 0;
67
+
68
+ /* * Start the interface
73
69
*
74
- * Note: @a ssid and @a pass must be kept until the connection is made, that is the callback has been called or the
75
- * state changed to @a NSAPI_IF_STATE_CONNECTED as they are passed by value.
70
+ * Attempts to connect to a WiFi network.
76
71
*
77
72
* @param ssid Name of the network to connect to
78
73
* @param pass Security passphrase to connect to the network
79
- * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
80
74
* @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
81
- * @param cb Function to be called when the connect finishes (Default: NULL )
82
- * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
75
+ * @param channel Channel on which the connection is to be made, or 0 for any (Default: 0 )
76
+ * @return 0 on success, or error code on failure
83
77
*/
84
- virtual void connect_async (const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE ,
85
- uint8_t channel = 0 , mbed::Callback< void ( nsapi_error_t , wifi_ap_t *)> cb = NULL ,
86
- unsigned timeout = 0) = 0 ;
78
+ virtual int connect (const char *ssid, const char *pass,
79
+ nsapi_security_t security = NSAPI_SECURITY_NONE ,
80
+ uint8_t channel = 0 );
87
81
88
82
/* * Start the interface
89
83
*
@@ -96,51 +90,24 @@ class WiFiInterface: public NetworkInterface
96
90
97
91
/* * Stop the interface
98
92
*
99
- * @return 0 on success, or error code on failure
93
+ * @return 0 on success, or error code on failure
100
94
*/
101
95
virtual int disconnect () = 0;
102
96
103
- /* * Get the current WiFi interface state
104
- *
105
- * @returns Interface state enum
106
- */
107
- virtual nsapi_if_state_t get_state () = 0;
108
-
109
- /* * Gets the current radio signal strength for active connection
110
- *
111
- * @return Connection strength in dBm (negative value), or 0 if measurement impossible
112
- */
113
- virtual int8_t get_rssi () = 0;
114
-
115
97
/* * Scan for available networks
116
98
*
117
- * This function will block.
99
+ * The scan will
100
+ * If the network interface is set to non-blocking mode, scan will attempt to scan
101
+ * for WiFi networks asynchronously and return NSAPI_ERROR_WOULD_BLOCK. If a callback
102
+ * is attached, the callback will be called when the operation has completed.
118
103
*
119
104
* @param ap Pointer to allocated array to store discovered AP
120
105
* @param count Size of allocated @a res array, or 0 to only count available AP
121
106
* @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
122
107
* @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
123
108
* see @a nsapi_error
124
109
*/
125
- virtual int scan (wifi_ap_t *res, unsigned count, unsigned timeout = 0 ) = 0;
126
-
127
- /* * Scan for available networks
128
- *
129
- * This function won't block, it'll return immediately and call provided callback for each discovered network with
130
- * AP data and user @a data. After the last discovered network @a cb will be called with NULL as @a ap, so it
131
- * will be always called at least once.
132
- *
133
- * @param cb Function to be called for every discovered network
134
- * @param data User handle that will be passed to @a cb along with the AP data (Default: NULL)
135
- * @param timeout Timeout in milliseconds; 0 for no timeout (Default: 0)
136
- */
137
- virtual void scan_async (mbed::Callback<void (wifi_ap_t *)> cb, unsigned timeout = 0) = 0;
138
-
139
- protected:
140
- char *_ssid;
141
- char *_pass;
142
- nsapi_security_t _security;
143
- char _ip_address[16 ]; // IPv4 only thus 16
110
+ virtual int scan (wifi_ap_t *res, unsigned count) = 0;
144
111
};
145
112
146
113
#endif
0 commit comments