Hi all:
there is a attribute which was set as NULL.
I want to transmit the data of this attribute by using the application's callback function.
1. I register the callback function at the end of initial function
zcl_registerReadWriteCB( Test_ENDPOINT,&zcl_GetAttrFSUserIDsReadCB,NULL);
2. zcl_GetAttrFSUserIDsReadCB() is like that :
static ZStatus_t zcl_GetAttrFSUserIDsReadCB(uint16 clusterId, uint16 attrId, uint8 oper,uint8 *pValue, uint16 *pLen) { uint8 status; switch (oper) { case ZCL_OPER_READ: uint8 *temp = (uint8*)osal_mem_alloc(datalength+1); temp[0]=datalength ; for(uint8 i= 1; i<datalength+1; i++) { temp[i]=i; } osal_memcpy(pValue,temp,datalength +1); osal_mem_free( temp ); break; case ZCL_OPER_LEN: *pLen = datalength ; status = ZCL_STATUS_SUCCESS; break; } }
PS: datalength is dynamic, it will be changed.
but when a read attribute cmd coming , the devices was shut down. it seems memory leak...
maybe i can't osal_memcpy(pValue,temp,datalength +1) , but i don't konw why and how to copy the array to pVaule.