/*************************************************************************************************** * @fn MT_SapiAppRegister * * @brief Process SAPI App Register * * @param pBuf - pointer to received buffer * * @return none ***************************************************************************************************/ void MT_SapiAppRegister(uint8 *pBuf) { uint8 ret = ZApsIllegalRequest; /* check if sapi is alredy registered with an endpoint */ if ( (sapi_epDesc.endPoint == 0) && (*pBuf != 0) ) { ret = MT_BuildEndpointDesc( pBuf+MT_RPC_FRAME_HDR_SZ, &sapi_epDesc ); if ( ret == ZSuccess ) { ret = afRegister( &sapi_epDesc ); // Turn off match descriptor response by default afSetMatch(sapi_epDesc.simpleDesc->EndPoint, FALSE); } if ( ret != ZSuccess ) { sapi_epDesc.endPoint = 0; } } /* Build and send back the response */ MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_APP_REGISTER_REQ, 1, &ret); }
/*************************************************************************************************** * @fn MT_AfRegister * * @brief Process AF Register command * * @param pBuf - pointer to the received buffer * * @return none ***************************************************************************************************/ void MT_AfRegister(uint8 *pBuf) { uint8 cmdId; uint8 retValue = ZMemError; endPointDesc_t *epDesc; /* parse header */ cmdId = pBuf[MT_RPC_POS_CMD1]; pBuf += MT_RPC_FRAME_HDR_SZ; epDesc = (endPointDesc_t *)osal_mem_alloc(sizeof(endPointDesc_t)); if ( epDesc ) { epDesc->task_id = &MT_TaskID; retValue = MT_BuildEndpointDesc( pBuf, epDesc ); if ( retValue == ZSuccess ) { retValue = afRegister( epDesc ); } if ( retValue != ZSuccess ) { osal_mem_free( epDesc ); } } /* Build and send back the response */ MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_AF), cmdId, 1, &retValue); }