sigfox

Fork of Sigfox by Belkacem DAHMANI

Files at this revision

API Documentation at this revision

Comitter:
Raffaello
Date:
Wed Apr 19 20:57:38 2017 +0000
Parent:
1:93450d8b2540
Child:
3:279bed56f354
Commit message:
Improved Sigfox messages

Changed in this revision

Sigfox.cpp Show annotated file Show diff for this revision Revisions of this file
Sigfox.h Show annotated file Show diff for this revision Revisions of this file
--- a/Sigfox.cpp	Tue Apr 18 15:05:57 2017 +0000
+++ b/Sigfox.cpp	Wed Apr 19 20:57:38 2017 +0000
@@ -11,17 +11,38 @@
     return _at->recv("OK");
 }
 
+bool Sigfox::setPower(uint8_t power) {
+    _at->send("ATS302=%d", power);
+    return _at->recv("OK");
+}
+
 bool Sigfox::setPowerMode(uint8_t power) {
     _at->send("AT$P=%d", power);
     return _at->recv("OK");
 }
 
-void Sigfox::getID() {
-    _at->send("AT$I=10");
-    // TODO add return value
+void Sigfox::wakeup(DigitalInOut sig_rst, float time) {
+    // Wake up sigfox
+    sig_rst.output();
+    sig_rst = 0;
+    wait(time);
+    // Set high impendance the sigfox reset pin
+    sig_rst.input();
+    wait(time);
 }
 
-void Sigfox::getPAC() {
+char *Sigfox::getID() {
+    char buff[8+2];
+    _at->send("AT$I=10");
+    _at->read(buff, 8+2);
+    memcpy(&ID[0],&buff[2],8);
+    return &ID[0];
+}
+
+char *Sigfox::getPAC() {
+    char buff[16+2];
     _at->send("AT$I=11");
-    // TODO add return value
+    _at->read(buff, 16+2);
+    memcpy(&PAC[0],&buff[2],16);
+    return &PAC[0];
 }
\ No newline at end of file
--- a/Sigfox.h	Tue Apr 18 15:05:57 2017 +0000
+++ b/Sigfox.h	Wed Apr 19 20:57:38 2017 +0000
@@ -25,6 +25,8 @@
 {
     private:
     ATParser *_at;
+    char ID[9];
+    char PAC[17];
     
     public:
     Sigfox(ATParser &at) : _at(&at) {
@@ -35,9 +37,13 @@
     
     bool send(const char *data);
     
+    bool setPower(uint8_t power=15);
+    
     bool setPowerMode(uint8_t power);
     
-    void getID();
+    void wakeup(DigitalInOut sig_rst, float time=0.2);
     
-    void getPAC();
+    char *getID();
+    
+    char *getPAC();
 };
\ No newline at end of file