基于物联网的门禁系统设计内容摘要:

令 是否建立网络 维护网络 N 是否收到串口数据 Y 将数据发送至绑定对方 N 是否收到节点数据 Y 发送至存串口 图 41 协调器工作流程图 本系统只是运用了 zigbee 协议栈,而未升入研究 ZStack 协议栈,在运用过程中只修改应用层函数,所以在此只列出 APP 函数,其他层的程序在此不在叙述。 协调器 APP 函数: /********************************************************************* * @fn TranCenter_ProcessMSGCmd * * @brief Data message processor callback. This function processes * any ining data probably from other devices. Based * on the cluster ID, perform the intended action. * * @param pkt pointer to the ining message packet * * @return TRUE if the 39。 pkt39。 parameter is being used and will be freed later, * FALSE otherwise. */ void TranCenter_ProcessMSGCmd afIningMSGPacket_t *pkt uint8 stat。 uint8 seqnb。 uint8 delay。 switch pkt clusterId // A message with a serial data block to be transmitted on the serial case TranCenter_CLUSTERID1: // Store the address for sending and osal_memcpy amp。 TranCenter_RxAddr, amp。 pkt srcAddr , sizeof afAddrType_t。 seqnb pkt [0]。 // Keep message if not a repeat packet 如果数据包不重复,保持信息 if seqnb TranCenter_RxSeq || // Normal seqnb 0x80 amp。 amp。 TranCenter_RxSeq 0x80 // Wraparound // Transmit the data on the serial port. 在串行端口发送数据 PC if HalUARTWrite SERIAL_APP_PORT, pkt +1, pkt // Save for next ining message TranCenter_RxSeq seqnb。 stat OTA_SUCCESS。 else stat OTA_SER_BUSY。 else stat OTA_DUP_MSG。 // Select approproiate OTA flowcontrol delay. delay stat OTA_SER_BUSY ? TranCenter_NAK_DELAY : TranCenter_ACK_DELAY。 // Build amp。 send OTA response message. TranCenter_RspBuf[0] stat。 TranCenter_RspBuf[1] seqnb。 TranCenter_RspBuf[2] LO_UINT16 delay。 TranCenter_RspBuf[3] HI_UINT16 delay。 osal_set_event TranCenter_TaskID, TranCenter_RESP_EVT。 osal_stop_timerEx TranCenter_TaskID, TranCenter_RESP_EVT。 break。 // A response to a received serial data block. case TranCenter_CLUSTERID2: if pkt [1] TranCenter_TxSeq amp。 amp。 pkt [0] OTA_SUCCESS || pkt [0] OTA_DUP_MSG TranCenter_TxLen 0。 osal_stop_timerEx TranCenter_TaskID, TranCenter_SEND_EVT。 else // Restart timeout according to delay sent from other device. delay BUILD_UINT16 pkt [2], pkt [3]。 osal_start_timerEx TranCenter_TaskID, TranCenter_SEND_EVT, delay。 break。 default: break。 /********************************************************************* * @fn TranCenter_Send * * @brief Send data OTA. * * @param none * * @return none */ static void TranCenter_Send void if SERIAL_APP_LOOPBACK if TranCenter_TxLen SERIAL_APP_TX_ TranCenter_TxLen + HalUARTRead SERIAL_APP_PORT, TranCenter_TxBuf+TranCenter_TxLen+1, SERIAL_APP_TX_TranCenter_TxLen。 if TranCenter_TxLen void TranCenter_TxAddr。 if HalUARTWrite SERIAL_APP_PORT, TranCenter_TxBuf+1, TranCenter_TxLen TranCenter_TxLen 0。 else osal_set_event TranCenter_TaskID, TranCenter_SEND_EVT。 else if !TranCenter_TxLen amp。 amp。 TranCenter_TxLen HalUARTRead SERIAL_APP_PORT, TranCenter_TxBuf+1, SERIAL_APP_TX_ // Prepend sequence number to the Tx message. TranCenter_TxBuf[0] ++TranCenter_TxSeq。 if TranCenter_TxLen HalUARTWrite SERIAL_APP_PORT, TranCenter_TxBuf+1, TranCenter_TxLen。 if afStatus_SUCCESS ! AF_DataRequest amp。 TranCenter_TxAddr, endPointDesc_t * amp。 TranCenter_epDesc, TranCenter_CLUSTERID1, TranCenter_TxLen+1, TranCenter_TxBuf, amp。 TranCenter_MsgID, 0, AF_DEFAULT_RADIUS osal_set_event TranCenter_TaskID, TranCenter_SEND_EVT。 endif 终端工作流程图 图 42 终端工作流程图 终端 APP 函数 /********************************************************************* * @fn TranEnd_ProcessMSGCmd * * @brief Data message processor callback. This function processes * any ining data probably from other devices. Based * on the cluster ID, perform the intended action. * * @param pkt pointer to the ining message packet * * @return TRUE if the 39。 pkt39。 parameter is being used and will be freed later, * FALSE otherwise. */ void TranEnd_ProcessMSGCmd afIningMSGPacket_t *pkt uint8 stat。 uint8 seqnb。 uint8 delay。 switch pkt clusterId // A message with a serial data block to be transmitted on the serial port. case TranEnd_CLUSTERID1: // Store the address for sending and retrying. osal_memcpy amp。 TranEnd_RxAddr, amp。 pkt srcAddr , sizeof afAddrType_t。 seqnb pk。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。