Skip to content

Commit

Permalink
Merge pull request #36 from SukkoPera/master
Browse files Browse the repository at this point in the history
Implemented gatewayIP() and subnetMask()
  • Loading branch information
bportaluri committed Mar 27, 2016
2 parents 2a4821c + feb5661 commit 263de13
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/WiFiEsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ IPAddress WiFiEspClass::localIP()
return ret;
}

IPAddress WiFiEspClass::subnetMask()
{
IPAddress mask;
if(espMode==1)
EspDrv::getNetmask(mask);
return mask;
}

IPAddress WiFiEspClass::gatewayIP()
{
IPAddress gw;
if(espMode==1)
EspDrv::getGateway(gw);
return gw;
}


char* WiFiEspClass::SSID()
Expand Down
26 changes: 26 additions & 0 deletions src/utility/EspDrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,32 @@ uint8_t EspDrv::getScanNetworks()
return ssidListNum;
}

bool EspDrv::getNetmask(IPAddress& mask) {
LOGDEBUG(F("> getNetmask"));

char buf[20];
if (sendCmdGet(F("AT+CIPSTA?"), F("+CIPSTA:netmask:\""), F("\""), buf, sizeof(buf)))
{
mask.fromString (buf);
return true;
}

return false;
}

bool EspDrv::getGateway(IPAddress& gw) {
LOGDEBUG(F("> getGateway"));

char buf[20];
if (sendCmdGet(F("AT+CIPSTA?"), F("+CIPSTA:gateway:\""), F("\""), buf, sizeof(buf)))
{
gw.fromString (buf);
return true;
}

return false;
}

char* EspDrv::getSSIDNetoworks(uint8_t networkItem)
{
if (networkItem >= WL_NETWORKS_LIST_MAXNUM)
Expand Down
25 changes: 20 additions & 5 deletions src/utility/EspDrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ class EspDrv

static void getIpAddressAP(IPAddress& ip);

/*
* Get the interface IP netmask.
* This can be used to retrieve settings configured through DHCP.
*
* return: true if successful
*/
static bool getNetmask(IPAddress& mask);

/*
* Get the interface IP gateway.
* This can be used to retrieve settings configured through DHCP.
*
* return: true if successful
*/
static bool getGateway(IPAddress& mask);

/*
* Return the current SSID associated with the network
Expand Down Expand Up @@ -235,8 +250,8 @@ class EspDrv
* return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
*/
static uint8_t getEncTypeNetowrks(uint8_t networkItem);


/*
* Get the firmware version
*/
Expand Down Expand Up @@ -275,10 +290,10 @@ class EspDrv

static long _bufPos;
static uint8_t _connId;

static uint16_t _remotePort;
static uint8_t _remoteIp[WL_IPV4_LENGTH];


// firmware version string
static char fwVersion[WL_FW_VER_LENGTH];
Expand All @@ -287,7 +302,7 @@ class EspDrv
static char _networkSsid[WL_NETWORKS_LIST_MAXNUM][WL_SSID_MAX_LENGTH];
static int32_t _networkRssi[WL_NETWORKS_LIST_MAXNUM];
static uint8_t _networkEncr[WL_NETWORKS_LIST_MAXNUM];


// settings of current selected network
static char _ssid[WL_SSID_MAX_LENGTH];
Expand Down

0 comments on commit 263de13

Please sign in to comment.