update setString() to use setValCheck() and setValFinish()
This commit is contained in:
parent
11bd605a03
commit
cbe26c7c41
|
|
@ -677,32 +677,11 @@ class SpanCharacteristic{
|
||||||
|
|
||||||
void setString(const char *val, boolean notify=true){
|
void setString(const char *val, boolean notify=true){
|
||||||
|
|
||||||
if(updateFlag==1)
|
setValCheck();
|
||||||
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);
|
|
||||||
|
|
||||||
uvSet(value,val);
|
uvSet(value,val);
|
||||||
uvSet(newValue,value);
|
setValFinish(notify);
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
size_t getData(uint8_t *data, size_t len){
|
size_t getData(uint8_t *data, size_t len){
|
||||||
if(format<FORMAT::DATA)
|
if(format<FORMAT::DATA)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,10 @@ struct HomeSpanTV : Service::Television {
|
||||||
SpanCharacteristic *settingsKey = new Characteristic::PowerModeSelection(); // Adds "View TV Setting" option to Selection Screen
|
SpanCharacteristic *settingsKey = new Characteristic::PowerModeSelection(); // Adds "View TV Setting" option to Selection Screen
|
||||||
SpanCharacteristic *displayOrder = new Characteristic::DisplayOrder();
|
SpanCharacteristic *displayOrder = new Characteristic::DisplayOrder();
|
||||||
SpanCharacteristic *testData = new Characteristic::TestData();
|
SpanCharacteristic *testData = new Characteristic::TestData();
|
||||||
|
SpanCharacteristic *tvname;
|
||||||
|
|
||||||
HomeSpanTV(const char *name) : Service::Television() {
|
HomeSpanTV(const char *name) : Service::Television() {
|
||||||
new Characteristic::ConfiguredName(name); // Name of TV
|
tvname = new Characteristic::ConfiguredName(name); // Name of TV
|
||||||
Serial.printf("Configured TV: %s\n",name);
|
Serial.printf("Configured TV: %s\n",name);
|
||||||
|
|
||||||
TLV8 orderTLV;
|
TLV8 orderTLV;
|
||||||
|
|
@ -60,6 +61,7 @@ struct HomeSpanTV : Service::Television {
|
||||||
testData->setData(blob,1);
|
testData->setData(blob,1);
|
||||||
|
|
||||||
new SpanUserCommand('P', "- change order of inputs", changeOrder, this);
|
new SpanUserCommand('P', "- change order of inputs", changeOrder, this);
|
||||||
|
new SpanUserCommand('C', "- change name of TV", setTVName, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update() override {
|
boolean update() override {
|
||||||
|
|
@ -111,6 +113,11 @@ struct HomeSpanTV : Service::Television {
|
||||||
return(true);
|
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){
|
static void changeOrder(const char *buf, void *arg){
|
||||||
HomeSpanTV *hsTV=(HomeSpanTV *)arg;
|
HomeSpanTV *hsTV=(HomeSpanTV *)arg;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue