Updated setVal() logic
Updated setVal() logic to ensure that every possible combination of parameter type and Characteristic type is handled properly, and without generating a compile-time error related to ambiguous parameters.
This commit is contained in:
parent
f536db83aa
commit
433e1cd59a
|
|
@ -1771,6 +1771,11 @@ void SpanCharacteristic::setVal(int val){
|
||||||
newValue.UINT64=(uint64_t)val;
|
newValue.UINT64=(uint64_t)val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FLOAT:
|
||||||
|
value.FLOAT=(double)val;
|
||||||
|
newValue.FLOAT=(double)val;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
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){
|
void SpanCharacteristic::setVal(double val){
|
||||||
|
|
||||||
value.FLOAT=(double)val;
|
value.FLOAT=(double)val;
|
||||||
|
|
|
||||||
|
|
@ -273,8 +273,10 @@ struct SpanCharacteristic{
|
||||||
template <class T=int> T getNewVal(){return(getValue<T>(newValue));} // returns UVal newValue
|
template <class T=int> T getNewVal(){return(getValue<T>(newValue));} // returns UVal newValue
|
||||||
template <class T> T getValue(UVal v); // returns UVal v
|
template <class T> T getValue(UVal v); // returns UVal v
|
||||||
|
|
||||||
void setVal(int value); // sets value of UVal value for all integer-based Characterstic types
|
void setVal(uint64_t value); // sets value of UVal value for UINT64 Characteristic when parameter type is uint64_t
|
||||||
void setVal(double value); // sets value of UVal value for FLOAT Characteristic type
|
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
|
boolean updated(){return(isUpdated);} // returns isUpdated
|
||||||
unsigned long timeVal(); // returns time elapsed (in millis) since value was last updated
|
unsigned long timeVal(); // returns time elapsed (in millis) since value was last updated
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue