Skip to content

Commit

Permalink
Organize private members
Browse files Browse the repository at this point in the history
Organize private members and drop superfluous
ESP8266Interface::_disable_default_softap()
  • Loading branch information
Veijo Pesonen committed Oct 10, 2018
1 parent 570d96f commit 0023892
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
11 changes: 3 additions & 8 deletions ESP8266Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
#if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX
ESP8266Interface::ESP8266Interface()
: _esp(MBED_CONF_ESP8266_TX, MBED_CONF_ESP8266_RX, MBED_CONF_ESP8266_DEBUG, MBED_CONF_ESP8266_RTS, MBED_CONF_ESP8266_CTS),
_ap_sec(NSAPI_SECURITY_UNKNOWN),
_initialized(false),
_started(false),
_ap_sec(NSAPI_SECURITY_UNKNOWN),
_conn_stat(NSAPI_STATUS_DISCONNECTED),
_conn_stat_cb(NULL)
{
Expand All @@ -69,9 +69,9 @@ ESP8266Interface::ESP8266Interface()
// ESP8266Interface implementation
ESP8266Interface::ESP8266Interface(PinName tx, PinName rx, bool debug, PinName rts, PinName cts)
: _esp(tx, rx, debug, rts, cts),
_ap_sec(NSAPI_SECURITY_UNKNOWN),
_initialized(false),
_started(false),
_ap_sec(NSAPI_SECURITY_UNKNOWN),
_conn_stat(NSAPI_STATUS_DISCONNECTED),
_conn_stat_cb(NULL)
{
Expand Down Expand Up @@ -271,11 +271,6 @@ bool ESP8266Interface::_get_firmware_ok()
return true;
}

bool ESP8266Interface::_disable_default_softap()
{
return _esp.set_default_wifi_mode(ESP8266::WIFIMODE_STATION);
}

nsapi_error_t ESP8266Interface::_init(void)
{
if (!_initialized) {
Expand All @@ -294,7 +289,7 @@ nsapi_error_t ESP8266Interface::_init(void)
if (!_get_firmware_ok()) {
return NSAPI_ERROR_DEVICE_ERROR;
}
if (!_disable_default_softap()) {
if (!_esp.set_default_wifi_mode(ESP8266::WIFIMODE_STATION)) {
return NSAPI_ERROR_DEVICE_ERROR;
}
if (!_esp.cond_enable_tcp_passive_mode()) {
Expand Down
29 changes: 16 additions & 13 deletions ESP8266Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,16 @@ class ESP8266Interface : public NetworkStack, public WiFiInterface
}

private:
// AT layer
ESP8266 _esp;

// Credentials
static const int ESP8266_SSID_MAX_LENGTH = 32; /* 32 is what 802.11 defines as longest possible name */
char ap_ssid[ESP8266_SSID_MAX_LENGTH + 1]; /* The longest possible name; +1 for the \0 */
static const int ESP8266_PASSPHRASE_MAX_LENGTH = 63; /* The longest allowed passphrase */
static const int ESP8266_PASSPHRASE_MIN_LENGTH = 8; /* The shortest allowed passphrase */

ESP8266 _esp;
char ap_pass[ESP8266_PASSPHRASE_MAX_LENGTH + 1]; /* The longest possible passphrase; +1 for the \0 */
nsapi_security_t _ap_sec;

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

// Driver's state
int _initialized;
int _started;

char ap_ssid[ESP8266_SSID_MAX_LENGTH + 1]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */
nsapi_security_t _ap_sec;
char ap_pass[ESP8266_PASSPHRASE_MAX_LENGTH + 1];

bool _disable_default_softap();
void event();
void update_conn_state_cb();
bool _get_firmware_ok();
nsapi_error_t _init(void);
int _started;
nsapi_error_t _startup(const int8_t wifi_mode);

//sigio
struct {
void (*callback)(void *);
void *data;
} _cbs[ESP8266_SOCKET_COUNT];
void event();

// Connection state reporting
// Connection state reporting to application
nsapi_connection_status_t _conn_stat;
Callback<void(nsapi_event_t, intptr_t)> _conn_stat_cb; // Application registered
Callback<void(nsapi_event_t, intptr_t)> _conn_stat_cb;

// Connection state from AT layer
void update_conn_state_cb();
};

#endif

0 comments on commit 0023892

Please sign in to comment.