![](/media/cache/group/orange_and_cat.png.50x50_q85.jpg)
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:
- 4:b38e09f24711
- Parent:
- 2:dfe671e31221
- Child:
- 6:88cc04eb613a
--- a/spi/AferoCommHndlr.cpp Tue Jan 24 11:22:05 2017 +0000 +++ b/spi/AferoCommHndlr.cpp Wed Jan 25 08:20:47 2017 +0000 @@ -65,6 +65,17 @@ self->piafLib->setAttributeComplete(requestId, attributeId, valueLen, value); } +int32_t +AferoCommHndlr::sanitizeSensingInterval(uint16_t attributeId, int32_t interval) +{ + if(interval < 5) + { + interval = 5; + self->piafLib->setAttribute32(attributeId, interval); + } + return interval; +} + void AferoCommHndlr::myOnAttributeSetComplete( const uint8_t requestId, @@ -79,34 +90,41 @@ // delete[] buf; // buf = NULL; + int32_t sensing_interval; + char *buf = NULL; + if(attributeId >= 4 && attributeId <= 8) + { + sensing_interval = *((int32_t*)value); + } + 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); + buf = "PREFERENCES::SENSING_INTERVAL[SENSORS::ACCELEROMETER]"; + PREFERENCES::SENSING_INTERVAL[SENSORS::ACCELEROMETER] = self->sanitizeSensingInterval(attributeId,sensing_interval); } 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); + buf = "PREFERENCES::SENSING_INTERVAL[SENSORS::COLOR]"; + PREFERENCES::SENSING_INTERVAL[SENSORS::COLOR] = self->sanitizeSensingInterval(attributeId,sensing_interval); } 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); + buf = "PREFERENCES::SENSING_INTERVAL[SENSORS::PRESSURE]"; + PREFERENCES::SENSING_INTERVAL[SENSORS::PRESSURE] = self->sanitizeSensingInterval(attributeId,sensing_interval); } 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); + buf = "PREFERENCES::SENSING_INTERVAL[SENSORS::CURRENT_TRANS]"; + PREFERENCES::SENSING_INTERVAL[SENSORS::CURRENT_TRANS] = self->sanitizeSensingInterval(attributeId,sensing_interval); } 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); + buf = "PREFERENCES::SENSING_INTERVAL[SENSORS::TEMPERATURE]"; + PREFERENCES::SENSING_INTERVAL[SENSORS::TEMPERATURE] = self->sanitizeSensingInterval(attributeId,sensing_interval); } else if(attributeId==9) { @@ -117,6 +135,12 @@ { self->necochan->push(); } + + if(attributeId >= 4 && attributeId <= 8) + { + SERIAL_PRINT_DBG("%s=%ld\n",buf,sensing_interval); + } + } void