diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index c9463a2..a05214e 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -1771,6 +1771,11 @@ void SpanCharacteristic::setVal(int val){ newValue.UINT64=(uint64_t)val; break; + case FLOAT: + value.FLOAT=(double)val; + newValue.FLOAT=(double)val; + break; + default: break; } @@ -1787,6 +1792,38 @@ void SpanCharacteristic::setVal(int val){ /////////////////////////////// +void SpanCharacteristic::setVal(uint32_t val){ + + value.UINT32=(uint32_t)val; + newValue.UINT32=(uint32_t)val; + updateTime=homeSpan.snapTime; + + SpanBuf sb; // create SpanBuf object + sb.characteristic=this; // set characteristic + sb.status=StatusCode::OK; // set status + char dummy[]=""; + sb.val=dummy; // set dummy "val" so that sprintfNotify knows to consider this "update" + homeSpan.Notifications.push_back(sb); // store SpanBuf in Notifications vector +} + +/////////////////////////////// + +void SpanCharacteristic::setVal(uint64_t val){ + + value.UINT64=(uint64_t)val; + newValue.UINT64=(uint64_t)val; + updateTime=homeSpan.snapTime; + + SpanBuf sb; // create SpanBuf object + sb.characteristic=this; // set characteristic + sb.status=StatusCode::OK; // set status + char dummy[]=""; + sb.val=dummy; // set dummy "val" so that sprintfNotify knows to consider this "update" + homeSpan.Notifications.push_back(sb); // store SpanBuf in Notifications vector +} + +/////////////////////////////// + void SpanCharacteristic::setVal(double val){ value.FLOAT=(double)val; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index 1b9953c..f28e1ff 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -273,8 +273,10 @@ struct SpanCharacteristic{ template T getNewVal(){return(getValue(newValue));} // returns UVal newValue template T getValue(UVal v); // returns UVal v - void setVal(int value); // sets value of UVal value for all integer-based Characterstic types - void setVal(double value); // sets value of UVal value for FLOAT Characteristic type + void setVal(uint64_t value); // sets value of UVal value for UINT64 Characteristic when parameter type is uint64_t + void setVal(uint32_t value); // sets value of UVal value for UINT32 Characteristic when parameter type is uint32_t + void setVal(double value); // sets value of UVal value for FLOAT Characteristic when parameter type is float or double + void setVal(int value); // sets value of UVal value for ANY Characteristic (except char *) when parameter type does not exactly match uint64_t, uint32_t, double, or float boolean updated(){return(isUpdated);} // returns isUpdated unsigned long timeVal(); // returns time elapsed (in millis) since value was last updated