AT Parser and bufferedSerial based SPWF library

Dependencies:   ATParser

Dependents:   X_NUCLEO_IDW01M1v2

Fork of SPWF01SA by ST Expansion SW Team

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Fri Jan 13 14:35:49 2017 +0000
Parent:
26:70852d26853e
Commit message:
Added gettime API

Changed in this revision

SPWFSA01.cpp Show annotated file Show diff for this revision Revisions of this file
SPWFSA01.h Show annotated file Show diff for this revision Revisions of this file
diff -r 70852d26853e -r 0dc1402f42a9 SPWFSA01.cpp
--- a/SPWFSA01.cpp	Fri Jan 13 09:56:54 2017 +0000
+++ b/SPWFSA01.cpp	Fri Jan 13 14:35:49 2017 +0000
@@ -293,7 +293,6 @@
     return false;
 }
 
-
 int32_t SPWFSA01::recv(int id, void *data, uint32_t amount)
 {
     uint32_t recv_amount=0;
@@ -409,6 +408,25 @@
     return false;   
 }
 
+int32_t SPWFSA01::gettime(time_t *ctTime)
+{
+    _parser.flush();
+    //May take a second try if device is busy or error is returned
+    for (unsigned i = 0; i < 2; i++) {
+        if (_parser.send("AT+S.STS=current_time")
+            && _parser.recv("#  current_time = %u", ctTime)          
+            && _parser.recv("OK")) { 
+            return true;
+        }
+        else
+        {
+            debug_if(dbg_on, "SPWF> ERROR!!!!\r\n");
+            return false;
+        }
+    }    
+    return false;   
+}
+
 int32_t SPWFSA01::setTLScertificate(char * cert, unsigned int size, CertType_t type)
 {   
     _parser.flush();
diff -r 70852d26853e -r 0dc1402f42a9 SPWFSA01.h
--- a/SPWFSA01.h	Fri Jan 13 09:56:54 2017 +0000
+++ b/SPWFSA01.h	Fri Jan 13 14:35:49 2017 +0000
@@ -155,6 +155,7 @@
     bool writeable();
  
     int settime(time_t ctTime);
+    int gettime(time_t *ctTime);
  
     int32_t setTLScertificate(char * cert, unsigned int size, CertType_t type);
     int32_t setTLSSRVdomain(char * cert, CertType_t type);