The ZCL codes uses endpoint indices internally (index to psZCL_Common->psZCL_EndPointRecord) and maps between IDs provided on registration via eZCL_SearchForEPIndex and u8ZCL_GetEPIdFromIndex.
The current ZCL OTA code mistakenly uses indices where IDs are expected in two locations. The problem this causes is hidden when endpoint IDs are continuous and begin at 1.
Details:
- SDK Version: 2.6.15
- JN5189DK6/middleware/wireless/zigbee/ZCL/Clusters/OTA/Source/OTA.c
//
// The u8SourceEndPointId > u8ZCL_GetNumberOfEndpointsRegistered
// range check is incorrect and needs to be removed
//
PUBLIC teZCL_Status eOtaFindCluster(
uint8 u8SourceEndPointId,
tsZCL_EndPointDefinition **ppsEndPointDefinition,
tsZCL_ClusterInstance **ppsClusterInstance,
tsOTA_Common **ppsOTACustomDataStructure,
bool_t bIsServer)
{
if(u8SourceEndPointId > u8ZCL_GetNumberOfEndpointsRegistered())
{
return(E_ZCL_ERR_EP_RANGE);
}
// check EP is registered and cluster is present in the send device
if(eZCL_SearchForEPentry(u8SourceEndPointId, ppsEndPointDefinition) != E_ZCL_SUCCESS)
{
return(E_ZCL_ERR_EP_RANGE);
}
if(eZCL_SearchForClusterEntry(u8SourceEndPointId, OTA_CLUSTER_ID, bIsServer, ppsClusterInstance) != E_ZCL_SUCCESS)
{
return(E_ZCL_ERR_CLUSTER_NOT_FOUND);
}
// initialise custom data pointer
*ppsOTACustomDataStructure = (tsOTA_Common *)(*ppsClusterInstance)->pvEndPointCustomStructPtr;
if(*ppsOTACustomDataStructure==NULL)
{
return(E_ZCL_ERR_PARAMETER_NULL);
}
return(E_ZCL_SUCCESS);
}
//
// FIXED
//
PUBLIC teZCL_Status eOtaFindCluster(
uint8 u8SourceEndPointId,
tsZCL_EndPointDefinition **ppsEndPointDefinition,
tsZCL_ClusterInstance **ppsClusterInstance,
tsOTA_Common **ppsOTACustomDataStructure,
bool_t bIsServer)
{
// check EP is registered and cluster is present in the send device
if(eZCL_SearchForEPentry(u8SourceEndPointId, ppsEndPointDefinition) != E_ZCL_SUCCESS)
{
return(E_ZCL_ERR_EP_RANGE);
}
if(eZCL_SearchForClusterEntry(u8SourceEndPointId, OTA_CLUSTER_ID, bIsServer, ppsClusterInstance) != E_ZCL_SUCCESS)
{
return(E_ZCL_ERR_CLUSTER_NOT_FOUND);
}
// initialise custom data pointer
*ppsOTACustomDataStructure = (tsOTA_Common *)(*ppsClusterInstance)->pvEndPointCustomStructPtr;
if(*ppsOTACustomDataStructure==NULL)
{
return(E_ZCL_ERR_PARAMETER_NULL);
}
return(E_ZCL_SUCCESS);
}
and