Murata RF modules are designed to simplify wireless development and certification by minimizing the amount of RF expertise you need to wirelessly enable a wide range of applications.

Revision:
9:0ce800923eda
Parent:
1:fd19bd683e90
--- a/Type/IPAddress.cpp	Mon Feb 15 15:17:50 2016 +0000
+++ b/Type/IPAddress.cpp	Wed Mar 16 15:04:46 2016 +0000
@@ -1,20 +1,28 @@
 #include "IPAddress.h"
 
 using namespace SmartLabMuRata;
-IPAddress::IPAddress() {}
+IPAddress::IPAddress()
+{}
 
-IPAddress::IPAddress(const string & ip)
+IPAddress::IPAddress(const char * ipString)
 {
+    if (ipString == NULL)
+        return;
+
+    int size = strlen(ipString) + 1;
+    char temp[size];
+
+    memcpy(temp, ipString, size);
+
     int i = 0;
-    size_t last = 0;
-    size_t index = ip.find_first_of(".", last);
-    while (index != string::npos) {
-        address[i++] = atoi(ip.substr(last, index - last).c_str());
-        last = index + 1;
-        index = ip.find_first_of(".", last);
+    char * pch = strtok (temp, ".");
+    while (pch != NULL) {
+        address[i++] = atoi(pch);
+        pch = strtok (NULL, ".");
+
+        if (i >= 4)
+            break;
     }
-    if (index - last > 0)
-        address[i++] = atoi(ip.substr(last, index - last).c_str());
 }
 
 void IPAddress::SetValue(const char * data, int offset)
@@ -31,11 +39,8 @@
     return 4;
 }
 
-void IPAddress::ToString(string * ipString)
+const char * IPAddress::ToString()
 {
-    if (ipString == NULL)
-        return;
-    char buffer[16];
-    sprintf (buffer, "%d.%d.%d.%d", address[0], address[1], address[2], address[3]);
-    ipString->assign(buffer);
+    sprintf (ip, "%d.%d.%d.%d", address[0], address[1], address[2], address[3]);
+    return ip;
 }
\ No newline at end of file