diff --git a/src/HAP.cpp b/src/HAP.cpp index 322219f..a036ba8 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -998,10 +998,10 @@ int HAPClient::putCharacteristicsURL(char *json){ if(!homeSpan.updateCharacteristics(json, pObj)) // perform update return(0); // return if failed to update (error message will have been printed in update) - int multiCast=0; // check if all status is OK, or if multicast response is request - for(int i=0;i>>>>>>>>> %s >>>>>>>>>>\n",client.remoteIP().toString().c_str()); diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 876b329..1dde9af 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -1378,6 +1378,9 @@ int Span::updateCharacteristics(char *buf, SpanBuf *pObj){ pObj[nObj].ev=t3; okay|=8; } else + if(!strcmp(t2,"r") && (t3=strtok_r(t1,"}[]:, \"\t\n\r",&p2))){ + pObj[nObj].wr=(t3 && (!strcmp(t3,"1") || !strcmp(t3,"true"))); + } else if(!strcmp(t2,"pid") && (t3=strtok_r(t1,"}[]:, \"\t\n\r",&p2))){ uint64_t pid=strtoull(t3,NULL,0); if(!TimedWrites.count(pid)){ @@ -1395,7 +1398,9 @@ int Span::updateCharacteristics(char *buf, SpanBuf *pObj){ } // parse property tokens if(!t1){ // at least one token was found that was not initial "characteristics" - if(okay==7 || okay==11 || okay==15){ // all required properties found + if(okay==7 || okay==11 || okay==15){ // all required properties found + if(!pObj[nObj].val) // if value is NOT being updated + pObj[nObj].wr=false; // ignore any request for write-response nObj++; // increment number of characteristic objects found } else { LOG0("\n*** ERROR: Problems parsing JSON characteristics object - missing required properties\n\n"); @@ -1507,7 +1512,10 @@ void Span::printfAttributes(SpanBuf *pObj, int nObj){ hapOut << "{\"characteristics\":["; for(int i=0;iuvPrint(pObj[i].characteristic->value).c_str(); + hapOut << "}"; if(i+1