Fixed bug in updateCharacteristics

Fixed bug that was causing a crash when trying to update to separate services at the same time.
This commit is contained in:
Gregg 2020-08-01 11:29:15 -05:00
parent 4e4108fe1c
commit 6646aae799
1 changed files with 10 additions and 10 deletions

View File

@ -576,16 +576,16 @@ int Span::updateCharacteristics(char *buf, SpanPut *pObj){
for(int i=0;i<nObj;i++){ // PASS 2: loop again over all objects for(int i=0;i<nObj;i++){ // PASS 2: loop again over all objects
if(pObj[i].status==StatusCode::TBD){ // if object status still TBD if(pObj[i].status==StatusCode::TBD){ // if object status still TBD
SpanService *svc=pObj[i].characteristic->service; // set service containing the characteristic underlying the object StatusCode status=pObj[i].characteristic->service->update(); // update service and save returned statusCode
StatusCode status=svc->update(); // update service and save returned statusCode
for(int j=i;j<nObj;j++){ // loop over this object plus any remaining objects to update values and save status for any other characteristics in this service for(int j=i;j<nObj;j++){ // loop over this object plus any remaining objects to update values and save status for any other characteristics in this service
if(pObj[j].characteristic->service==svc){ // if service matches
if(pObj[j].characteristic->service==pObj[i].characteristic->service){ // if service of this characteristic matches service that was updated
pObj[j].status=status; // save statusCode for this object pObj[j].status=status; // save statusCode for this object
LOG1("Updating aid="); LOG1("Updating aid=");
LOG1(svc->Characteristics[j]->aid); LOG1(pObj[j].characteristic->aid);
LOG1(" iid="); LOG1(" iid=");
LOG1(svc->Characteristics[j]->iid); LOG1(pObj[j].characteristic->iid);
if(status==StatusCode::OK){ // if status is okay if(status==StatusCode::OK){ // if status is okay
pObj[j].characteristic->value pObj[j].characteristic->value
=pObj[j].characteristic->newValue; // update characteristic value with new value =pObj[j].characteristic->newValue; // update characteristic value with new value