diff --git a/module/zigbee/cpc-zbgw/src/Z2M.c b/module/zigbee/cpc-zbgw/src/Z2M.c index 289bee9..52ec39f 100644 --- a/module/zigbee/cpc-zbgw/src/Z2M.c +++ b/module/zigbee/cpc-zbgw/src/Z2M.c @@ -95,20 +95,16 @@ static void Z2M_AEP(uint8_t *da, uint16_t len) if(ED[ED_Index].ShortAddress == Shor_Address) { ED[ED_Index].ep_counts = EP_Count; - - for(int i =0;i 0 && da[4 + i] < 10) - gw_cmd_simple_desc_req(Shor_Address, ED[ED_Index].ep_list[i]); + gw_cmd_simple_desc_req(Shor_Address, ED[ED_Index].ep_list[i].ep); } } } } - } - } static void Z2M_AN(uint8_t *da, uint16_t len) @@ -162,7 +158,7 @@ static void Z2M_AN(uint8_t *da, uint16_t len) void Z2M_SD(uint8_t *da, uint16_t len) { - unsigned short j; + unsigned short i, j; int ED_Index=ED_NO_INDEX; unsigned short Shor_Address; int updated = 0; @@ -178,14 +174,19 @@ void Z2M_SD(uint8_t *da, uint16_t len) { if(ED[ED_Index].ShortAddress == pt_idc->nwkAddr) { - ED[ED_Index].in_cluster_count = pt_idc->in_cluster_count; - ED[ED_Index].DeviceId = pt_idc->deviceID; - - for(j = 0; jin_cluster_count; j++ ) + for(i=0;iclusterID[j]; - } + if(ED[ED_Index].ep_list[i].ep != pt_idc->endpoint) + continue; + ED[ED_Index].ep_list[i].clusterCounts = pt_idc->in_cluster_count; + ED[ED_Index].ep_list[i].devidId = pt_idc->deviceID; + for(j = 0; jin_cluster_count; j++ ) + { + ED[ED_Index].ep_list[i].clusterID[j] = pt_idc->clusterID[j]; + } + + } Write_ED_Table_flag = 1; break; } diff --git a/module/zigbee/cpc-zbgw/src/common.h b/module/zigbee/cpc-zbgw/src/common.h index d696ae9..f37d68d 100644 --- a/module/zigbee/cpc-zbgw/src/common.h +++ b/module/zigbee/cpc-zbgw/src/common.h @@ -16,18 +16,27 @@ #define WHITE "\033[1;37m" //======================================================================== #define EndDeviceMax 250 +#define EndPointMax 10 +#define ClusterIDMax 30 + extern char Write_ED_Table_flag; +struct _EndPoint +{ + unsigned char ep; + unsigned short devidId; + unsigned short clusterCounts; + unsigned short clusterID[ClusterIDMax]; +}; + struct _EndDevice { unsigned char MacAddress[8]; //Mac Address(64bits) unsigned char Active; unsigned short ShortAddress; //Short Address(16bits) - unsigned short DeviceId; - unsigned short in_cluster_count; - unsigned short clusterID[30]; unsigned char ep_counts; - unsigned char ep_list[10]; + struct _EndPoint ep_list[EndPointMax]; + }; struct _Coordinator diff --git a/module/zigbee/cpc-zbgw/src/coordinator.c b/module/zigbee/cpc-zbgw/src/coordinator.c index 29667e3..02ea090 100644 --- a/module/zigbee/cpc-zbgw/src/coordinator.c +++ b/module/zigbee/cpc-zbgw/src/coordinator.c @@ -29,7 +29,7 @@ int FileExist(char *fname) void Clear_EndDevice_Information() { - int i; + int i,j; //--------------------------------- for(i=0;i