diff --git a/src/app/app-platform/ContentAppPlatform.cpp b/src/app/app-platform/ContentAppPlatform.cpp index 63bb80b1a3efca..9e98c016c63d14 100644 --- a/src/app/app-platform/ContentAppPlatform.cpp +++ b/src/app/app-platform/ContentAppPlatform.cpp @@ -115,7 +115,6 @@ EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointTy index++; continue; } - mContentApps[index] = app; EmberAfStatus ret; EndpointId initEndpointId = mCurrentEndpointId; @@ -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(); } @@ -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) { @@ -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!"); diff --git a/src/app/app-platform/ContentAppPlatform.h b/src/app/app-platform/ContentAppPlatform.h index 03420715457f2b..3a39365e95c754 100644 --- a/src/app/app-platform/ContentAppPlatform.h +++ b/src/app/app-platform/ContentAppPlatform.h @@ -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 & dataVersionStorage, @@ -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 & dataVersionStorage,