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
Diff: spi/AferoCommHndlr.cpp
- Revision:
- 2:dfe671e31221
- Parent:
- 1:b2a9a6f2c30e
- Child:
- 4:b38e09f24711
--- a/spi/AferoCommHndlr.cpp Thu Jan 19 09:17:16 2017 +0000 +++ b/spi/AferoCommHndlr.cpp Tue Jan 24 10:00:28 2017 +0000 @@ -72,26 +72,51 @@ const uint16_t valueLen, const uint8_t *value) { - uint8_t *buf = new uint8_t[valueLen+1]; - memset(buf,'\0',valueLen+1); - memcpy(buf, value, valueLen); - SERIAL_PRINT_DBG("attr id:%d value:%s\n",attributeId,buf); - delete[] buf; - buf = NULL; +// uint8_t *buf = new uint8_t[valueLen+1]; +// memset(buf,'\0',valueLen+1); +// memcpy(buf, value, valueLen); +// SERIAL_PRINT_DBG("attr id:%d value:%s\n",attributeId,buf); +// delete[] buf; +// buf = NULL; - if(attributeId==1024) + if(attributeId==2) + { + PREFERENCES::CRC32.ui32 = *((uint32_t*)value); + } + else if(attributeId==4) + { + SERIAL_PRINT_DBG("PREFERENCES::SENSING_INTERVAL[SENSORS::ACCELEROMETER]=%ld\n", *((int32_t*)value)); + PREFERENCES::SENSING_INTERVAL[SENSORS::ACCELEROMETER] = *((int32_t*)value) < 5 ? 5 : *((int32_t*)value); + } + else if(attributeId==5) + { + SERIAL_PRINT_DBG("PREFERENCES::SENSING_INTERVAL[SENSORS::COLOR]=%ld\n", *((int32_t*)value)); + PREFERENCES::SENSING_INTERVAL[SENSORS::COLOR] = *((int32_t*)value) < 5 ? 5 : *((int32_t*)value); + } + else if(attributeId==6) + { + SERIAL_PRINT_DBG("PREFERENCES::SENSING_INTERVAL[SENSORS::PRESSURE]=%ld\n", *((int32_t*)value)); + PREFERENCES::SENSING_INTERVAL[SENSORS::PRESSURE] = *((int32_t*)value) < 5 ? 5 : *((int32_t*)value); + } + else if(attributeId==7) + { + SERIAL_PRINT_DBG("PREFERENCES::SENSING_INTERVAL[SENSORS::CURRENT_TRANS]=%ld\n", *((int32_t*)value)); + PREFERENCES::SENSING_INTERVAL[SENSORS::CURRENT_TRANS] = *((int32_t*)value) < 5 ? 5 : *((int32_t*)value); + } + else if(attributeId==8) + { + SERIAL_PRINT_DBG("PREFERENCES::SENSING_INTERVAL[SENSORS::TEMPERATURE]=%ld\n", *((int32_t*)value)); + PREFERENCES::SENSING_INTERVAL[SENSORS::TEMPERATURE] = *((int32_t*)value) < 5 ? 5 : *((int32_t*)value); + } + else if(attributeId==9) + { + SERIAL_PRINT_DBG("time stamp:%ld\n", *((uint32_t*)value)); + RTC_Handler::getInstance()->setUTC(*((uint32_t*)value)); + } + else if(attributeId==1024) { self->necochan->push(); } - - if(attributeId==ATTR_ID_SENSING_INTERVAL) - { - - } - else if(attributeId==ATTR_ID_SENSE_VAL) - { - //self->timeoutUpload.attach(&AferoCommHndlr::updateToAferoCloud,1); - } } void @@ -106,17 +131,19 @@ void AferoCommHndlr::onGetTodo(ToDo *todo) { - SERIAL_PRINT_DBG("AferoCommHndlr::onGetTodo()\n"); char buf[255]; memset(buf,'\0',sizeof(buf)); if(todo!=NULL) { - if(self->flowControlEnabled==true) + if(PREFERENCES::FLOW_CONTROL==true) { - + PREFERENCES::_crc32 crc32; + todo->toBASE64(buf,&crc32); + self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf); + self->piafLib->setAttribute64(3,crc32.ui32); } else - { + { todo->toJSON(buf); SERIAL_PRINT_DBG("%s\n",buf); self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf);