sigfox
Fork of Sigfox by
Revision 14:e858a765590a, committed 2018-02-20
- Comitter:
- helmi_heyliot
- Date:
- Tue Feb 20 15:07:48 2018 +0000
- Parent:
- 13:9e1c2ea4742b
- Child:
- 15:5cac9747f00f
- Commit message:
- getID & getPAC function updated
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 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];
}
--- a/Sigfox.h Thu Feb 15 11:01:23 2018 +0000
+++ b/Sigfox.h Tue Feb 20 15:07:48 2018 +0000
@@ -34,13 +34,15 @@
{
private:
ATParser *_at;
- char ID[9];
- char PAC[17];
+ public:
+ char *ID;
+ char *PAC;
public:
- Sigfox(ATParser &at) : _at(&at) {};
+ Sigfox(ATParser &at) : _at(&at) {ID= new char[9];PAC= new char[17];};
bool ready();
+ bool reset();
bool send(const char *data);
/**
