Skip to content

Commit

Permalink
Update content apps array only when adding endpoint succeeds. updated…
Browse files Browse the repository at this point in the history
… documentation.
  • Loading branch information
amitnj committed Aug 30, 2022
1 parent 890a0f5 commit a04cd27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/app-platform/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
index++;
continue;
}
mContentApps[index] = app;
EmberAfStatus ret;
EndpointId initEndpointId = mCurrentEndpointId;

Expand All @@ -127,6 +126,7 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
ChipLogProgress(DeviceLayer, "Added ContentApp %s to dynamic endpoint %d (index=%d)", vendorApp.applicationId,
mCurrentEndpointId, index);
app->SetEndpointId(mCurrentEndpointId);
mContentApps[index] = app;
IncrementCurrentEndpointID();
return app->GetEndpointId();
}
Expand Down Expand Up @@ -181,7 +181,6 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
index++;
continue;
}
mContentApps[index] = app;
EmberAfStatus ret = emberAfSetDynamicEndpoint(index, desiredEndpointId, ep, dataVersionStorage, deviceTypeList);
if (ret != EMBER_ZCL_STATUS_SUCCESS)
{
Expand All @@ -191,6 +190,7 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy
ChipLogProgress(DeviceLayer, "Added ContentApp %s to dynamic endpoint %d (index=%d)", vendorApp.applicationId,
desiredEndpointId, index);
app->SetEndpointId(desiredEndpointId);
mContentApps[index] = app;
return app->GetEndpointId();
}
ChipLogError(DeviceLayer, "Failed to add dynamic endpoint: max endpoint count reached!");
Expand Down
4 changes: 2 additions & 2 deletions src/app/app-platform/ContentAppPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DLL_EXPORT ContentAppPlatform

// add apps to the platform.
// This will assign the app to an endpoint (if it is not already added) and make it accessible via Matter
// returns the global endpoint for this app, or 0 if an error occurred.
// returns the global endpoint for this app, or kNoCurrentEndpointId if an error occurred.
// dataVersionStorage.size() needs to be at least as big as the number of
// server clusters in the EmberAfEndpointType passed in.
EndpointId AddContentApp(ContentApp * app, EmberAfEndpointType * ep, const Span<DataVersion> & dataVersionStorage,
Expand All @@ -89,7 +89,7 @@ class DLL_EXPORT ContentAppPlatform
// add apps to the platform.
// This will assign the app to the desiredEndpointId (if it is not already used)
// and make it accessible via Matter, return the global endpoint for this app(if app is already added)
// , or 0 if an error occurred. desiredEndpointId cannot be less that Fixed endpoint count
// , or kNoCurrentEndpointId if an error occurred. desiredEndpointId cannot be less that Fixed endpoint count
// dataVersionStorage.size() needs to be at least as big as the number of
// server clusters in the EmberAfEndpointType passed in.
EndpointId AddContentApp(ContentApp * app, EmberAfEndpointType * ep, const Span<DataVersion> & dataVersionStorage,
Expand Down

0 comments on commit a04cd27

Please sign in to comment.