From cbe26c7c4142f6159c8ea33b56090835994755f5 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sun, 31 Mar 2024 08:51:06 -0500 Subject: [PATCH] update setString() to use setValCheck() and setValFinish() --- src/HomeSpan.h | 27 +++------------------------ src/src.ino | 9 ++++++++- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/HomeSpan.h b/src/HomeSpan.h index fb1ad7f..919a213 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -677,31 +677,10 @@ class SpanCharacteristic{ void setString(const char *val, boolean notify=true){ - if(updateFlag==1) - LOG0("\n*** WARNING: Attempt to update Characteristic::%s with setString() within update() while it is being updated by Home App. This may cause device to become non-responsive!\n\n",hapName); - + setValCheck(); uvSet(value,val); - uvSet(newValue,value); - - updateTime=homeSpan.snapTime; - - if(notify){ - if(updateFlag!=2){ // do not broadcast EV if update is being done in context of write-response - 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 printfNotify knows to consider this "update" - homeSpan.Notifications.push_back(sb); // store SpanBuf in Notifications vector - } - - if(nvsKey){ - nvs_set_str(homeSpan.charNVS,nvsKey,value.STRING); // store data - nvs_commit(homeSpan.charNVS); - } - } - - } // setString() + setValFinish(notify); + } size_t getData(uint8_t *data, size_t len){ if(formatsetData(blob,1); new SpanUserCommand('P', "- change order of inputs", changeOrder, this); + new SpanUserCommand('C', "- change name of TV", setTVName, this); } boolean update() override { @@ -111,6 +113,11 @@ struct HomeSpanTV : Service::Television { return(true); } + static void setTVName(const char *buf, void *arg){ + HomeSpanTV *hsTV=(HomeSpanTV *)arg; + hsTV->tvname->setString("New Name"); + } + static void changeOrder(const char *buf, void *arg){ HomeSpanTV *hsTV=(HomeSpanTV *)arg;