sigfox
Fork of Sigfox by
Revision 3:279bed56f354, committed 2017-05-01
- Comitter:
- Raffaello
- Date:
- Mon May 01 08:26:05 2017 +0000
- Parent:
- 2:d07e3b39ff74
- Child:
- 4:c77d5019b264
- Commit message:
- Added return message from sigfox
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 Wed Apr 19 20:57:38 2017 +0000
+++ b/Sigfox.cpp Mon May 01 08:26:05 2017 +0000
@@ -6,9 +6,28 @@
return _at->recv("OK");
}
-bool Sigfox::send(const char *data) {
- _at->send("AT$SF=%s", data);
- return _at->recv("OK");
+bool Sigfox::send(const char *data, char* response) {
+ // If require a response add plus in message
+ if(response != NULL) {
+ // Add request response data
+ _at->send("AT$SF=%s,1", data);
+ // Wait response from sigfox after send
+ if(_at->recv("OK")) {
+ char message[20];
+ // Wait return
+ // TODO add loop to load data
+ if(_at->recv("+RX%s", &message)) {
+ // Check if message received is equal to " OK"
+ if(strcmp(message, " OK") == 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } else {
+ _at->send("AT$SF=%s", data);
+ return _at->recv("OK");
+ }
}
bool Sigfox::setPower(uint8_t power) {
--- a/Sigfox.h Wed Apr 19 20:57:38 2017 +0000
+++ b/Sigfox.h Mon May 01 08:26:05 2017 +0000
@@ -35,7 +35,7 @@
bool ready();
- bool send(const char *data);
+ bool send(const char *data, char* response=NULL);
bool setPower(uint8_t power=15);
