/********************************************************************* * @fn ipd_Init * * @brief Initialization function for the ZCL App Application. * * @param uint8 task_id - ipd task id * * @return none */ void ipd_Init( uint8 task_id ) { ipdTaskID = task_id; ipdTransID = 0; // Device hardware initialization can be added here or in main() (Zmain.c). // If the hardware is application specific - add it here. // If the hardware is other parts of the device add it in main(). // setup ESP destination address ESPAddr.addrMode = (afAddrMode_t)Addr16Bit; ESPAddr.endPoint = IPD_ENDPOINT; ESPAddr.addr.shortAddr = 0; // Register for SE endpoint zclSE_Init( &ipdSimpleDesc ); // Register the ZCL General Cluster Library callback functions zclGeneral_RegisterCmdCallbacks( IPD_ENDPOINT, &ipd_GenCmdCallbacks ); // Register the ZCL SE Cluster Library callback functions zclSE_RegisterCmdCallbacks( IPD_ENDPOINT, &ipd_SECmdCallbacks ); // Register the application's attribute list zcl_registerAttrList( IPD_ENDPOINT, IPD_MAX_ATTRIBUTES, ipdAttrs ); // Register the application's cluster option list zcl_registerClusterOptionList( IPD_ENDPOINT, IPD_MAX_OPTIONS, ipdOptions ); // Register the application's attribute data validation callback function zcl_registerValidateAttrData( ipd_ValidateAttrDataCB ); // Register the Application to receive the unprocessed Foundation command/response messages zcl_registerForMsg( ipdTaskID ); // Register for all key events - This app will handle all key events RegisterForKeys( ipdTaskID ); #if defined ( INTER_PAN ) // Register with Stub APS StubAPS_RegisterApp( &ipdEp ); #endif // Start the timer to sync IPD timer with the osal timer osal_start_timerEx( ipdTaskID, IPD_UPDATE_TIME_EVT, IPD_UPDATE_TIME_PERIOD ); }
/*************************************************************************************************** * @fn MT_AfInterPanCtl * * @brief Process the AF Inter Pan control command. * * @param pBuf - pointer to the received buffer * * @return none ***************************************************************************************************/ static void MT_AfInterPanCtl(uint8 *pBuf) { uint8 cmd, rtrn; uint16 panId; endPointDesc_t *pEP; cmd = pBuf[MT_RPC_POS_CMD1]; pBuf += MT_RPC_FRAME_HDR_SZ; switch (*pBuf++) // Inter-pan request parameter. { case InterPanClr: rtrn = StubAPS_SetIntraPanChannel(); // Switch channel back to the NIB channel. break; case InterPanSet: rtrn = StubAPS_SetInterPanChannel(*pBuf); // Set channel for inter-pan communication. break; case InterPanReg: if ((pEP = afFindEndPointDesc(*pBuf))) { StubAPS_RegisterApp(pEP); rtrn = SUCCESS; } else { rtrn = FAILURE; } break; case InterPanChk: panId = BUILD_UINT16(pBuf[0], pBuf[1]); rtrn = (StubAPS_InterPan(panId, pBuf[2])) ? ZSuccess : ZFailure; break; default: rtrn = afStatus_INVALID_PARAMETER; break; } MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_AF), cmd, 1, &rtrn); }