Hello,
I set NUM_CONNECTIONS = 10 on AP side and using it as HUB in star network. When I join ED's in networks,
it's linkID is given obtained in sLID[10] arrays.
My question is how I can get adress of ED's from sLID[] array's LinkID?
what I found is to map linkID(sLID[]) with index in sPersistInfo.connStruct[X], but what I observed is I am getting this array element as zero in debugger every time?
Regards,
khodidas
Hi,
i haven't tested it yet, but i think this should be possible by doing this:
add the following function in nwk.c file:
void nwkGetPeerAddr(linkID_t sLinkId, addr_t *peerAddr){ uint8_t index; if(map_lid2idx(sLinkId, &index)) { memcpy(peerAddr->addr, sPersistInfo.connStruct[index].peerAddr, NET_ADDR_SIZE); } }
and add the following declaration if necessary:
extern void nwkGetPeerAddr(linkID_t sLinkId, addr_t *peerAddr);
please notice however that the the link ID given in the function above should be a valid one (retrieved from either SMPL_Link() or SMPL_LinkListen() function).
Let me know if this works for you.
Leo Hendrawan
I have some issues. Actually I used your code in my project, I can read out the MAC address related to the LinkID. However the result is not stable, at least print out string shows unstable result. For example, if peer Address is 7A3F3940, sometimes it prints out correctly, sometimes it only prints 940. The low-level UART print hex routine should be all right, since all other hex content like appload is printed correctly.
The source file is here with small modification from TI demo. BTW, I think peer addr information, including other information should be available from API level. It is very important to understand who is talking to the application.
2742.ez430-RF2500-2009-MacAddr-Unstable.zip
Log:
AP->ED:414C4BNode:HUB0,Temp: 91.2F,Battery:3.6V,Strength:000%,RE:no ED->AP:F0001EMAC:7A3F3940$0002, 75.2F,3.0,029,N#
AP->ED:414C4BNode:HUB0,Temp: 91.2F,Battery:3.6V,Strength:000%,RE:no
ED->AP:F0001EMAC:940$0002, 75.2F,3.0,029,N#AP->ED:414C4B
maybe you can try to put your breakpoint after the function to see whether the peerAddress is correct or not.
Could it be a problem with the transmit function? Because according to your description, if the log shows wrong data, it basically shows only part of the data.
Hi, lhend
Actually I find that it is a bug for print() statement prior to hex print() statement due to mismatch string length parameter. So the print is weried. All transmission drivers and MAC addr are correct. Now this issue is closed.
Thank you for the information.
Allan K Liu
Hi Allan,
glad to hear the good news, and thank you for testing it. So i think my code should really works in this case.
leo,
you solution has worked for me.