pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT

Dependencies:   mbed MMA8451Q USBDevice WakeUp vt100

Fork of afero_node_suntory_2017_06_15 by Orefatoi

Revision:
6:88cc04eb613a
Parent:
4:b38e09f24711
Child:
13:c7d1ef8c57b3
--- a/spi/AferoCommHndlr.cpp	Tue Feb 28 02:09:06 2017 +0000
+++ b/spi/AferoCommHndlr.cpp	Wed Mar 22 23:39:41 2017 +0000
@@ -29,6 +29,14 @@
 AferoCommHndlr::AferoCommHndlr() : flowControlEnabled(false)
 {
     necochan = new Necochan();
+    deathWish = new Timeout();
+}
+
+void
+AferoCommHndlr::kick_the_bucket()
+{
+    SERIAL_PRINT_DBG("bucket kicked!!\n");
+    wtd.kick_the_bucket();   
 }
 
 void
@@ -50,7 +58,7 @@
        AferoCommHndlr::myOnAttributeSetComplete, spi);
      self->todoQ = ToDoQ::create(AferoCommHndlr::onGetTodo);
      SERIAL_PRINT_DBG("AferoCommHndlr init done\n");
-     self->piafLib->setAttribute8(1,1);
+     self->piafLib->setAttribute8(1,1) != afSUCCESS ? SERIAL_PRINT_DBG("set attr failed!!\n") : NULL ;
      
      return self;
 }
@@ -62,7 +70,7 @@
     const uint16_t valueLen,
     const uint8_t *value)
 {
-    self->piafLib->setAttributeComplete(requestId, attributeId, valueLen, value);
+    self->piafLib->setAttributeComplete(requestId, attributeId, valueLen, value) != afSUCCESS ? SERIAL_PRINT_DBG("set attr failed!!\n") : NULL ;
 }
 
 int32_t
@@ -71,7 +79,7 @@
     if(interval < 5)
     {
         interval = 5;
-        self->piafLib->setAttribute32(attributeId, interval);
+        self->piafLib->setAttribute32(attributeId, interval) != afSUCCESS ? SERIAL_PRINT_DBG("set attr failed!!\n") : NULL ;
     }
     return interval;
 }
@@ -90,6 +98,8 @@
 //    delete[] buf;
 //    buf = NULL;
     
+    //self->deathWish->attach(&AferoCommHndlr::kick_the_bucket,10);
+    
     int32_t sensing_interval;
     char *buf = NULL;
     if(attributeId >= 4 && attributeId <= 8)
@@ -129,7 +139,12 @@
     else if(attributeId==9)
     {
         SERIAL_PRINT_DBG("time stamp:%ld\n", *((uint32_t*)value));
-        RTC_Handler::getInstance()->setUTC(*((uint32_t*)value));
+        time_t t;
+        RTC_GET_UTC(t);
+        if(*((uint32_t*)value) > ((uint32_t)t))
+        {
+            RTC_Handler::getInstance()->setUTC(*((uint32_t*)value));
+        }
     }
     else if(attributeId==1024)
     {
@@ -163,14 +178,14 @@
         {
             PREFERENCES::_crc32 crc32;
             todo->toBASE64(buf,&crc32);
-            self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf);
-            self->piafLib->setAttribute64(3,crc32.ui32);
+            self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf) != afSUCCESS ? SERIAL_PRINT_DBG("set attr failed!!\n") : NULL ;
+            self->piafLib->setAttribute64(3,crc32.ui32) != afSUCCESS ? SERIAL_PRINT_DBG("set attr failed!!\n") : NULL ;
         }
         else
         {
             todo->toJSON(buf);
             SERIAL_PRINT_DBG("%s\n",buf);
-            self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf);
+            self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf) != afSUCCESS ? SERIAL_PRINT_DBG("set attr failed!!\n") : NULL ;
         }
     }
 }