Skip to content

Commit 0023892

Browse files
author
Veijo Pesonen
committed
Organize private members
Organize private members and drop superfluous ESP8266Interface::_disable_default_softap()
1 parent 570d96f commit 0023892

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

ESP8266Interface.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
4646
ESP8266Interface::ESP8266Interface()
4747
: _esp(MBED_CONF_ESP8266_TX, MBED_CONF_ESP8266_RX, MBED_CONF_ESP8266_DEBUG, MBED_CONF_ESP8266_RTS, MBED_CONF_ESP8266_CTS),
48+
_ap_sec(NSAPI_SECURITY_UNKNOWN),
4849
_initialized(false),
4950
_started(false),
50-
_ap_sec(NSAPI_SECURITY_UNKNOWN),
5151
_conn_stat(NSAPI_STATUS_DISCONNECTED),
5252
_conn_stat_cb(NULL)
5353
{
@@ -69,9 +69,9 @@ ESP8266Interface::ESP8266Interface()
6969
// ESP8266Interface implementation
7070
ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
7171
: _esp(tx, rx, debug, rts, cts),
72+
_ap_sec(NSAPI_SECURITY_UNKNOWN),
7273
_initialized(false),
7374
_started(false),
74-
_ap_sec(NSAPI_SECURITY_UNKNOWN),
7575
_conn_stat(NSAPI_STATUS_DISCONNECTED),
7676
_conn_stat_cb(NULL)
7777
{
@@ -271,11 +271,6 @@ bool ESP8266Interface::_get_firmware_ok()
271271
return true;
272272
}
273273

274-
bool ESP8266Interface::_disable_default_softap()
275-
{
276-
return _esp.set_default_wifi_mode(ESP8266::WIFIMODE_STATION);
277-
}
278-
279274
nsapi_error_t ESP8266Interface::_init(void)
280275
{
281276
if (!_initialized) {
@@ -294,7 +289,7 @@ nsapi_error_t ESP8266Interface::_init(void)
294289
if (!_get_firmware_ok()) {
295290
return NSAPI_ERROR_DEVICE_ERROR;
296291
}
297-
if (!_disable_default_softap()) {
292+
if (!_esp.set_default_wifi_mode(ESP8266::WIFIMODE_STATION)) {
298293
return NSAPI_ERROR_DEVICE_ERROR;
299294
}
300295
if (!_esp.cond_enable_tcp_passive_mode()) {

ESP8266Interface.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,16 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface
318318
}
319319

320320
private:
321+
// AT layer
322+
ESP8266 _esp;
323+
324+
// Credentials
321325
static const int ESP8266_SSID_MAX_LENGTH = 32; /* 32 is what 802.11 defines as longest possible name */
326+
char ap_ssid[ESP8266_SSID_MAX_LENGTH + 1]; /* The longest possible name; +1 for the \0 */
322327
static const int ESP8266_PASSPHRASE_MAX_LENGTH = 63; /* The longest allowed passphrase */
323328
static const int ESP8266_PASSPHRASE_MIN_LENGTH = 8; /* The shortest allowed passphrase */
324-
325-
ESP8266 _esp;
329+
char ap_pass[ESP8266_PASSPHRASE_MAX_LENGTH + 1]; /* The longest possible passphrase; +1 for the \0 */
330+
nsapi_security_t _ap_sec;
326331

327332
// Drivers's socket info
328333
struct _sock_info {
@@ -331,28 +336,26 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface
331336
};
332337
struct _sock_info _sock_i[ESP8266_SOCKET_COUNT];
333338

339+
// Driver's state
334340
int _initialized;
335-
int _started;
336-
337-
char ap_ssid[ESP8266_SSID_MAX_LENGTH + 1]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */
338-
nsapi_security_t _ap_sec;
339-
char ap_pass[ESP8266_PASSPHRASE_MAX_LENGTH + 1];
340-
341-
bool _disable_default_softap();
342-
void event();
343-
void update_conn_state_cb();
344341
bool _get_firmware_ok();
345342
nsapi_error_t _init(void);
343+
int _started;
346344
nsapi_error_t _startup(const int8_t wifi_mode);
347345

346+
//sigio
348347
struct {
349348
void (*callback)(void *);
350349
void *data;
351350
} _cbs[ESP8266_SOCKET_COUNT];
351+
void event();
352352

353-
// Connection state reporting
353+
// Connection state reporting to application
354354
nsapi_connection_status_t _conn_stat;
355-
Callback<void(nsapi_event_t, intptr_t)> _conn_stat_cb; // Application registered
355+
Callback<void(nsapi_event_t, intptr_t)> _conn_stat_cb;
356+
357+
// Connection state from AT layer
358+
void update_conn_state_cb();
356359
};
357360

358361
#endif

0 commit comments

Comments
 (0)