sigfox
Fork of Sigfox by
Revision 6:799a482a7024, committed 2017-05-29
- Comitter:
- Raffaello
- Date:
- Mon May 29 19:42:14 2017 +0000
- Parent:
- 5:66e05787ad5c
- Child:
- 7:48396d48ae12
- Commit message:
- Added voltage message reader
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 Sat May 27 10:55:06 2017 +0000
+++ b/Sigfox.cpp Mon May 29 19:42:14 2017 +0000
@@ -64,7 +64,7 @@
char buff[8+2];
_at->send("AT$I=10");
_at->read(buff, 8+2);
- memcpy(&ID[0],&buff[2],8);
+ memcpy(&ID[0],&buff[2],8-2);
return &ID[0];
}
@@ -72,6 +72,21 @@
char buff[16+2];
_at->send("AT$I=11");
_at->read(buff, 16+2);
- memcpy(&PAC[0],&buff[2],16);
+ memcpy(&PAC[0],&buff[2],16-2);
return &PAC[0];
+}
+
+sigfoxvoltage_t Sigfox::getVoltages() {
+ sigfoxvoltage_t volt;
+ char buff[12];
+ _at->send("AT$V?");
+ _at->read(buff, 12);
+ char buff2[5];
+ memset(buff2,0,5);
+ memcpy(buff2, &buff[0], 4);
+ volt.current = ((double)atoi(buff2))/1000;
+ memset(buff2,0,5);
+ memcpy(buff2, &buff[6], 4);
+ volt.last = ((double)atoi(buff2))/1000;
+ return volt;
}
\ No newline at end of file
--- a/Sigfox.h Sat May 27 10:55:06 2017 +0000
+++ b/Sigfox.h Mon May 29 19:42:14 2017 +0000
@@ -17,16 +17,24 @@
* Send command to Sigfox
*
*/
+#ifndef SIGFOX_H
+#define SIGFOX_H
#include "ATParser.h"
#include "mbed.h"
+typedef struct _sigfoxvoltage {
+ double current;
+ double last;
+} sigfoxvoltage_t;
+
class Sigfox
{
private:
ATParser *_at;
char ID[9];
char PAC[17];
+ char tmp[12];
public:
Sigfox(ATParser &at) : _at(&at) {
@@ -53,4 +61,8 @@
char *getID();
char *getPAC();
-};
\ No newline at end of file
+
+ sigfoxvoltage_t getVoltages();
+};
+
+#endif /* SIGFOX_H */
\ No newline at end of file
