LWmesh Sending data in Two times - Page 1
Forum section: electronics / beginners

author: vishal
author_rank: Regular Contributor
timestamp: January 04, 2018, 05:46:03 am
content: HiI have modified Lwmesh Atmel's stack of WSNDemo application to send data two times as follows {one example}Code:appMsg1.parentShortAddr=NWK_RouteNextHop(0,0);appNwkDataReq.dstAddr=0x0000;appNwkDataReq.dstEndpoint=APP_ENDPOINT;appNwkDataReq.srcEndPoint=APP_ENDPOINT;appNwkDataReq.options=NWK_OPT_ENABLE_SECURITY;appNwkDataReq.data=(uint8_t*)&appMsg;appNwkDataReq.size=sizeof(appMsg1);appNwkDataReq.confirm=appDataConf;NWK_DataReq(&appNwkDataReq);/*********Send Second packet**********/appMsg2.parentShortAddr=NWK_RouteNextHop(0,0);appNwkDataReq1.dstAddr=0x0000;appNwkDataReq1.dstEndpoint=APP_ENDPOINT;appNwkDataReq1.srcEndPoint=APP_ENDPOINT;appNwkDataReq1.options=NWK_OPT_ENABLE_SECURITY;appNwkDataReq1.data=(uint8_t*)&appMsg;appNwkDataReq1.size=sizeof(appMsg2);appNwkDataReq1.confirm=appDataConf;NWK_DataReq(&appNwkDataReq1);Here am getting the same parent address in both packets. I expect to have 0xFFFF in the first packet and 0x0000(or some other address) in the second packet.I tried the same scenario for 5 packets.In all the five packet am getting the same result of five times same parent.Do I reset anything after sending one packet?please help

author: ataradov
author_rank: Super Contributor
timestamp: January 04, 2018, 06:17:14 am
content: You are sending "appMsg" in both cases, not "appMsg1" and "appMsg2". Copy-paste error.And also, why do you expect different values, when you fill the payload with the same value?NWK_RouteNextHop() will return a different value only after appDataConf() is called for the first transfer and routing tables actually updated.NWK_DataReq() is not sending anything, it just puts a message into a queue and exits. The actual sending happens much later in NWK_TaskHandler() and all dependent functions.

author: vishal
author_rank: Regular Contributor
timestamp: January 04, 2018, 06:53:35 am
content: Quote from: ataradov on January 04, 2018, 06:17:14 amSendind appMsg1 and appMsg2. Error in posted question not in code.SorryQuoteI want to monitor the change of parent address while sending the packet .QuoteI think am calling appDataConf after sending each packet.is .or else how can I send data with updated parent address value in this flow .

author: ataradov
author_rank: Super Contributor
timestamp: January 04, 2018, 06:59:27 am
content: Quote from: vishal on January 04, 2018, 06:53:35 amBut in this code you are not sending the packets, you just lining them up to be sent much later. After encryption, route discovery, retries, etc.Quote from: vishal on January 04, 2018, 06:53:35 amStack must call it. You calling it does absolutely noting.You are missing the point of cooperative multitasking. This task just lets other.Look at the code and see that NWK_DataReq() does not talk to the radio in any way.Quote from: vishal on January 04, 2018, 06:53:35 amYou send one and exit while waiting for appDataConf() to be called. Then you fill the next request right in appDataConf() or use it to schedule a task (change of application state) that actually sends a message.You will have to work with stack machines, just like sample applications do.

author: vishal
author_rank: Regular Contributor
timestamp: January 04, 2018, 07:09:08 am
content: QuoteIs the flow is same as real WSNDemo?c code.Here it handles application state change

author: ataradov
author_rank: Super Contributor
timestamp: January 04, 2018, 07:10:10 am
content: I don't understand the question. Can you post full source code?

author: vishal
author_rank: Regular Contributor
timestamp: January 05, 2018, 03:00:21 am
content: Is the flow is same as in original WSNDemo.c code in the lwmesh stack.In this application it handles APP state change

author: ataradov
author_rank: Super Contributor
timestamp: January 05, 2018, 03:02:19 am
content: I still don't understand. Post more complete code, otherwise I can't help you.