Add new helper to convert IP to str

Add new helper to convert IP to str
This commit is contained in:
luc lebosse 2015-04-20 20:35:58 +08:00
parent 3db280e18e
commit b71cab9830
2 changed files with 9 additions and 0 deletions

View File

@ -69,6 +69,14 @@ char * WIFI_CONFIG::mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH])
return macstr; return macstr;
} }
//just simple helper to convert IP address to string
char * WIFI_CONFIG::ip2str(IPAddress Ip )
{
static char ipstr [16];
if (0>sprintf(ipstr, "%i.%i.%i.%i",Ip[0],Ip[1],Ip[2],Ip[3])) strcpy (ipstr, "0.0.0.0");
return ipstr;
}
//Read configuration settings and apply them //Read configuration settings and apply them
bool WIFI_CONFIG::Setup() bool WIFI_CONFIG::Setup()
{ {

View File

@ -29,6 +29,7 @@ class WIFI_CONFIG
public: public:
bool Setup(); bool Setup();
char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]); char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]);
char * ip2str(IPAddress Ip );
void configAP(IPAddress local_ip, IPAddress gateway, IPAddress subnet); void configAP(IPAddress local_ip, IPAddress gateway, IPAddress subnet);
private: private:
byte split_ip (char * ptr,byte * part); byte split_ip (char * ptr,byte * part);