/*************************************************************************************************** * @fn MT_UtilAssocGetWithAddress * * @brief Get an associated device by address. * * @param pBuf - pointer to the received buffer * * @return void ***************************************************************************************************/ static void MT_UtilAssocGetWithAddress(uint8 *pBuf) { extern associated_devices_t *AssocGetWithAddress(uint8 *extAddr, uint16 shortAddr); uint8 cmdId = pBuf[MT_RPC_POS_CMD1]; uint8 buf[sizeof(associated_devices_t)]; pBuf += MT_RPC_FRAME_HDR_SZ; packDev_t(buf, AssocGetWithAddress(((AddrMgrExtAddrValid(pBuf)) ? pBuf : NULL), BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN+1]))); MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_UTIL), cmdId, sizeof(associated_devices_t), buf); }
/*************************************************************************************************** * @fn MT_SapiBindDevice * * @brief Process SAPI Bind Device Command * * @param pBuf - pointer to received buffer * * @return none ***************************************************************************************************/ void MT_SapiBindDevice(uint8 *pBuf) { uint8 cmdId; /* parse header */ cmdId = pBuf[MT_RPC_POS_CMD1]; pBuf += MT_RPC_FRAME_HDR_SZ; if (AddrMgrExtAddrValid(pBuf+3)) { zb_BindDevice(pBuf[0], BUILD_UINT16(pBuf[1], pBuf[2]), &pBuf[3]); } else { zb_BindDevice(pBuf[0], BUILD_UINT16(pBuf[1], pBuf[2]), (uint8 *)NULL); } /* Build and send back the response */ MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 0, NULL); }
/*************************************************************************************************** * @fn MT_UtilAssocGetWithAddress * * @brief Get an associated device by address. * * @param pBuf - pointer to the received buffer * * @return void ***************************************************************************************************/ static void MT_UtilAssocGetWithAddress(uint8 *pBuf) { extern associated_devices_t *AssocGetWithAddress(uint8 *extAddr, uint16 shortAddr); associated_devices_t *pDev; uint8 cmdId = pBuf[MT_RPC_POS_CMD1]; pBuf += MT_RPC_FRAME_HDR_SZ; pDev = AssocGetWithAddress(((AddrMgrExtAddrValid(pBuf)) ? pBuf : NULL), BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN+1])); if (NULL != pDev) { MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_NWK), cmdId, sizeof(associated_devices_t), (uint8 *)pDev); } else { associated_devices_t dev; dev.shortAddr = INVALID_NODE_ADDR; MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_NWK), cmdId, sizeof(associated_devices_t), (uint8 *)(&dev)); } }