From e48915783b2a6fb10c91e4b23c1172565ab2c5a8 Mon Sep 17 00:00:00 2001 From: -=Alx=- Date: Thu, 10 Nov 2022 20:07:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20OTA=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BB=D1=8F=201000000=20(?= =?UTF-8?q?=D0=B1=D1=83=D1=84=D0=B5=D1=80=D0=B0=20=D0=BD=D0=B5=20=D1=85?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B0=D0=BB=D0=BE=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=81=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BF=D1=83=D1=81=D1=82?= =?UTF-8?q?=D1=8B=D1=85=20(=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BD=D1=83?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9)=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B0=D1=85=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=88=D0=B8=D0=B2=D0=BA=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Заодно починился бэкап/восстановление на той же лимонной скорости, даже не в дебаг версии. Fix UART tx and rx queue size то MAX_PACKET_SIZE Случайно перенесено из зигаты: fix bindgroup command + change version Added fields for 0x8030, 0x8031. Both responses now include source endpoint, addressmode and short address. https://github.com/fairecasoimeme/ZiGate/issues/161 Proposed by @VOVAiS Tested by @VOVAiS Confirmed by @VOVAiS --- Source/ZigbeeNodeControlBridge/app_Znc_cmds.c | 11 +++- .../app_general_events_handler.c | 66 +++++++++---------- Source/ZigbeeNodeControlBridge/app_start.c | 4 +- .../app_zcl_event_handler.c | 11 +++- 4 files changed, 50 insertions(+), 42 deletions(-) diff --git a/Source/ZigbeeNodeControlBridge/app_Znc_cmds.c b/Source/ZigbeeNodeControlBridge/app_Znc_cmds.c index f3a0925..1d523b5 100644 --- a/Source/ZigbeeNodeControlBridge/app_Znc_cmds.c +++ b/Source/ZigbeeNodeControlBridge/app_Znc_cmds.c @@ -311,7 +311,7 @@ PUBLIC void APP_vProcessIncomingSerialCommands ( uint8 u8RxByte ) uint8 u8Status = 0; uint16 u16TargetAddress; tsZCL_Address sAddress; - uint8 au8values[4]; + uint8 au8values[5]; uint8 u8Length = 0; #ifdef FULL_FUNC_DEVICE tsBDB_ZCLEvent sEvent; @@ -884,10 +884,15 @@ PUBLIC void APP_vProcessIncomingSerialCommands ( uint8 u8RxByte ) u8SrcEp = au8LinkRxBuffer[ offset++ ]; u16Clusterid = ZNC_RTN_U16_OFFSET ( au8LinkRxBuffer , offset, offset ); u8DstAddrMode = au8LinkRxBuffer[ offset++ ]; - uDstAddress.u64Addr = ZNC_RTN_U64_OFFSET ( au8LinkRxBuffer , offset, offset ); + + if(u8DstAddrMode == 0x1) + { + uDstAddress.u16Addr = ZNC_RTN_U16_OFFSET( au8LinkRxBuffer , offset , offset); - if(u8DstAddrMode == 0x3) + }else + if(u8DstAddrMode == 0x3) { + uDstAddress.u64Addr = ZNC_RTN_U64_OFFSET ( au8LinkRxBuffer , offset, offset ); u8DstEp = au8LinkRxBuffer [ offset++ ] ; } diff --git a/Source/ZigbeeNodeControlBridge/app_general_events_handler.c b/Source/ZigbeeNodeControlBridge/app_general_events_handler.c index 73efd0e..5c73e3f 100644 --- a/Source/ZigbeeNodeControlBridge/app_general_events_handler.c +++ b/Source/ZigbeeNodeControlBridge/app_general_events_handler.c @@ -852,42 +852,38 @@ PUBLIC void APP_vHandleStackEvents ( ZPS_tsAfEvent* psStackEvent ) } break; + case ZPS_ZDP_BIND_RSP_CLUSTER_ID: + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], sApsZdpEvent.uZdpData.sUnbindRsp.u8Status, u16Length ); + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataIndEvent.u8SrcEndpoint, u16Length ); + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataIndEvent.u8SrcAddrMode, u16Length ); + ZNC_BUF_U16_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataIndEvent.uSrcAddress.u16Addr, u16Length ); + vSL_WriteMessage ( E_SL_MSG_BIND_RESPONSE, + u16Length, + au8LinkTxBuffer, + u8LinkQuality ); + break; + + case ZPS_ZDP_UNBIND_RSP_CLUSTER_ID: + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], sApsZdpEvent.uZdpData.sUnbindRsp.u8Status, u16Length ); + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataIndEvent.u8SrcEndpoint, u16Length ); + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataIndEvent.u8SrcAddrMode, u16Length ); + ZNC_BUF_U16_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataIndEvent.uSrcAddress.u16Addr, u16Length ); + vSL_WriteMessage ( E_SL_MSG_UNBIND_RESPONSE, + u16Length, + au8LinkTxBuffer, + u8LinkQuality ); + break; + + case ZPS_ZDP_MGMT_PERMIT_JOINING_RSP_CLUSTER_ID: + ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], sApsZdpEvent.uZdpData.sPermitJoiningRsp.u8Status, u16Length ); + vSL_WriteMessage ( E_SL_MSG_PERMIT_JOINING_RESPONSE, + u16Length, + au8LinkTxBuffer, + u8LinkQuality ); + break; + default: - { - ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length] , sApsZdpEvent.uZdpData.sUnbindRsp.u8Status, u16Length ); - switch ( sApsZdpEvent.u16ClusterId ) - { - case ZPS_ZDP_BIND_RSP_CLUSTER_ID: - vSL_WriteMessage ( E_SL_MSG_BIND_RESPONSE, - u16Length, - au8LinkTxBuffer, - u8LinkQuality ); - break; - - case ZPS_ZDP_UNBIND_RSP_CLUSTER_ID: - vSL_WriteMessage ( E_SL_MSG_UNBIND_RESPONSE, - u16Length, - au8LinkTxBuffer, - u8LinkQuality ); - break; - case ZPS_ZDP_MGMT_LEAVE_RSP_CLUSTER_ID: - vSL_WriteMessage ( E_SL_MSG_MANAGEMENT_LEAVE_RESPONSE, - u16Length, - au8LinkTxBuffer, - u8LinkQuality ); - break; - - case ZPS_ZDP_MGMT_PERMIT_JOINING_RSP_CLUSTER_ID: - vSL_WriteMessage ( E_SL_MSG_PERMIT_JOINING_RESPONSE, - u16Length, - au8LinkTxBuffer, - u8LinkQuality ); - break; - default: - break; - } - } - break; + break; } } } diff --git a/Source/ZigbeeNodeControlBridge/app_start.c b/Source/ZigbeeNodeControlBridge/app_start.c index 7face99..6077de1 100644 --- a/Source/ZigbeeNodeControlBridge/app_start.c +++ b/Source/ZigbeeNodeControlBridge/app_start.c @@ -160,8 +160,8 @@ uint8 u8GPZCLTimerEvent; #define MCPS_QUEUE_SIZE 20 #define ZPS_QUEUE_SIZE 2 #define APP_QUEUE_SIZE 8 -#define TX_QUEUE_SIZE 150 -#define RX_QUEUE_SIZE 150 +#define TX_QUEUE_SIZE MAX_PACKET_SIZE +#define RX_QUEUE_SIZE MAX_PACKET_SIZE #define BDB_QUEUE_SIZE 2 #define APP_NUM_STD_TMRS 4 diff --git a/Source/ZigbeeNodeControlBridge/app_zcl_event_handler.c b/Source/ZigbeeNodeControlBridge/app_zcl_event_handler.c index b23a7f6..be32b1b 100644 --- a/Source/ZigbeeNodeControlBridge/app_zcl_event_handler.c +++ b/Source/ZigbeeNodeControlBridge/app_zcl_event_handler.c @@ -259,7 +259,13 @@ void APP_vHandleZclEvents ( ZPS_tsAfEvent* psStackEvent ) ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.u8SrcEndpoint, u16Length ); ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.u8DstEndpoint, u16Length ); ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.u8DstAddrMode, u16Length ); - ZNC_BUF_U64_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.uDstAddr.u64Addr, u16Length ); + if (psStackEvent->uEvent.sApsDataConfirmEvent.u8DstAddrMode == 0x03) + { + ZNC_BUF_U64_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.uDstAddr.u64Addr, u16Length ); + }else + { + ZNC_BUF_U16_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.uDstAddr.u16Addr, u16Length ); + } ZNC_BUF_U8_UPD ( &au8LinkTxBuffer [u16Length], psStackEvent->uEvent.sApsDataConfirmEvent.u8SequenceNum, u16Length ); vSL_WriteMessage ( E_SL_MSG_APS_DATA_CONFIRM_FAILED, u16Length, @@ -382,6 +388,7 @@ PRIVATE void APP_ZCL_cbEndpointCallback ( tsZCL_CallBackEvent* psEvent ) } else { + vLog_Printf(TRACE_ZCL, LOG_DEBUG, "DROP EVT: status 0x%02x addr 0x%04x\r\n", psEvent->eZCL_Status , psEvent->pZPSevent->uEvent.sApsDataIndEvent.uSrcAddress.u16Addr); return; } } @@ -397,7 +404,7 @@ PRIVATE void APP_ZCL_cbEndpointCallback ( tsZCL_CallBackEvent* psEvent ) case E_ZCL_CBET_READ_ATTRIBUTES_RESPONSE: case E_ZCL_CBET_TIMER: case E_ZCL_CBET_ZIGBEE_EVENT: - vLog_Printf(TRACE_ZCL, LOG_DEBUG, "EP EVT:No action\r\n", psEvent->eZCL_Status ); + vLog_Printf(TRACE_ZCL, LOG_DEBUG, "EP EVT:No action 0x%02x\r\n", psEvent->eZCL_Status ); break; case E_ZCL_CBET_ERROR: