sigfox

Fork of Sigfox by Belkacem DAHMANI

Revision:
14:e858a765590a
Parent:
13:9e1c2ea4742b
Child:
15:5cac9747f00f
--- a/Sigfox.cpp	Thu Feb 15 11:01:23 2018 +0000
+++ b/Sigfox.cpp	Tue Feb 20 15:07:48 2018 +0000
@@ -5,6 +5,10 @@
     _at->send("AT");
     return _at->recv("OK");
 }
+bool Sigfox::reset() {
+    _at->send("AT$P=0");
+    return _at->recv("OK");
+}
 
 /*bool Sigfox::send(const char *data, char* response) {
     // If require a response add plus in message
@@ -38,6 +42,7 @@
     return _at->recv("OK");
 }
 
+
 bool Sigfox::setPower(uint8_t power) {
     _at->send("ATS302=%d", power);
     return _at->recv("OK");
@@ -64,18 +69,22 @@
 }
 
 char *Sigfox::getID() {
-    char buff[8+2];
+    char *id;
+    id = new char[8+2+2];
     _at->send("AT$I=10");
-    _at->read(buff, 8+2);
-    memcpy(&ID[0],&buff[0],8);
+    _at->read(id, 8+2+2);
+    memcpy(&ID[0],&id[2],9);
+    ID[9] = '\0';
     return &ID[0];
 }
 
 char *Sigfox::getPAC() {
-    char buff[16+2];
+    char *pac;
+    pac= new char[16+2+2];
     _at->send("AT$I=11");
-    _at->read(buff, 16+2);
-    memcpy(&PAC[0],&buff[0],16);
+    _at->read(pac, 16+2+2);
+    memcpy(&PAC[0],&pac[2],17);
+    PAC[17] = '\0';
     return &PAC[0];
 }