Skip to content

Commit

Permalink
Modify ed struct
Browse files Browse the repository at this point in the history
  • Loading branch information
rex authored and rex committed Jan 4, 2024
1 parent aa98e79 commit 53926de
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 36 deletions.
27 changes: 14 additions & 13 deletions module/zigbee/cpc-zbgw/src/Z2M.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<EP_Count;i++)
{
ED[ED_Index].ep_list[i] = da[4 + i];
ED[ED_Index].ep_list[i].ep = da[4 + i];
if( da[4 + 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)
Expand Down Expand Up @@ -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;
Expand All @@ -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; j<pt_idc->in_cluster_count; j++ )
for(i=0;i<ED[ED_Index].ep_counts;i++)
{
ED[ED_Index].clusterID[j] = pt_idc->clusterID[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; j<pt_idc->in_cluster_count; j++ )
{
ED[ED_Index].ep_list[i].clusterID[j] = pt_idc->clusterID[j];
}

}
Write_ED_Table_flag = 1;
break;
}
Expand Down
17 changes: 13 additions & 4 deletions module/zigbee/cpc-zbgw/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 19 additions & 19 deletions module/zigbee/cpc-zbgw/src/coordinator.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ int FileExist(char *fname)

void Clear_EndDevice_Information()
{
int i;
int i,j;
//---------------------------------
for(i=0;i<EndDeviceMax;i++)
{
//----------------------------
memset(ED[i].MacAddress,0x00,8);
//----------------------------
ED[i].ShortAddress=0;
ED[i].DeviceId=0;
ED[i].in_cluster_count=0;
ED[i].Active=0;
ED[i].ep_counts=0;

memset(ED[i].clusterID,0x00,sizeof(ED[i].clusterID));
memset(ED[i].ep_list,0x00,sizeof(ED[i].ep_list));
for(j=0;j<EndPointMax;j++)
memset(&ED[i].ep_list[j], 0x00, sizeof(struct _EndPoint));
}

}
Expand Down Expand Up @@ -216,30 +216,30 @@ char* Transfer_End_Device_Mac(unsigned char* src_mac)

void show_dev_info()
{
int i, j;
printf("| ExtAddr | Short Addr | Device ID | EP List | Cluster (In) | \r\n");
int i, j, k;
// printf("| ExtAddr | Short Addr | Device ID | EP List | Cluster (In) | \r\n");

for(i=0;i<EndDeviceMax;i++)
{
if(ED[i].Active == 0)
continue;
printf("| %02X%02X%02X%02X%02X%02X%02X%02X | ", ED[i].MacAddress[0], ED[i].MacAddress[1], ED[i].MacAddress[2], ED[i].MacAddress[3],
printf("Device %d \r\n", i);

printf("\t MAC Address :%02X%02X%02X%02X%02X%02X%02X%02X \r\n", ED[i].MacAddress[0], ED[i].MacAddress[1], ED[i].MacAddress[2], ED[i].MacAddress[3],
ED[i].MacAddress[4], ED[i].MacAddress[5], ED[i].MacAddress[6], ED[i].MacAddress[7]);
printf(" 0x%04X |", ED[i].ShortAddress);
printf(" %04X | ", ED[i].DeviceId);
printf("\t Short Addr : 0x%04X\r\n", ED[i].ShortAddress);
for (j = 0; j < ED[i].ep_counts; j++)
{
printf(" %X", ED[i].ep_list[j]);
}
printf(" | ");
for (j = 0; j < ED[i].in_cluster_count; j++)
{
printf("%X ", ED[i].clusterID[j]);
printf("\tEP-%d \r\n",j);
printf("\t\t endpoint : %d\r\n", ED[i].ep_list[j].ep);
printf("\t\t Device ID : %d\r\n", ED[i].ep_list[j].devidId);
printf("\t\t Cluster ID : ");
for (k = 0; k < ED[i].ep_list[j].clusterCounts; k++)
printf("0x%04X ", ED[i].ep_list[j].clusterID[k]);
printf("\r\n");
}
printf("\r\n");


printf("\r\n");
}

printf("\r\n");
}

0 comments on commit 53926de

Please sign in to comment.