Added non-notify option to setVal()

Second optional argument to setVal() determines whether or not HomeSpan sends notification of new value to HomeKit.  Default if left blank is "true" for backwards compatibility.
This commit is contained in:
Gregg 2021-11-07 20:45:44 -06:00
parent 835d49adc5
commit 6f765e8988
1 changed files with 13 additions and 11 deletions

View File

@ -534,7 +534,7 @@ struct SpanCharacteristic{
} // setString() } // setString()
template <typename T> void setVal(T val){ template <typename T> void setVal(T val, boolean notify=true){
if((perms & EV) == 0){ if((perms & EV) == 0){
Serial.printf("\n*** WARNING: Attempt to update Characteristic::%s with setVal() ignored. No NOTIFICATION permission on this characteristic\n\n",hapName); Serial.printf("\n*** WARNING: Attempt to update Characteristic::%s with setVal() ignored. No NOTIFICATION permission on this characteristic\n\n",hapName);
@ -551,6 +551,7 @@ struct SpanCharacteristic{
updateTime=homeSpan.snapTime; updateTime=homeSpan.snapTime;
if(notify){
SpanBuf sb; // create SpanBuf object SpanBuf sb; // create SpanBuf object
sb.characteristic=this; // set characteristic sb.characteristic=this; // set characteristic
sb.status=StatusCode::OK; // set status sb.status=StatusCode::OK; // set status
@ -562,6 +563,7 @@ struct SpanCharacteristic{
nvs_set_blob(homeSpan.charNVS,nvsKey,&value,sizeof(UVal)); // store data nvs_set_blob(homeSpan.charNVS,nvsKey,&value,sizeof(UVal)); // store data
nvs_commit(homeSpan.charNVS); nvs_commit(homeSpan.charNVS);
} }
}
} // setVal() } // setVal()