| Author |
Message |
|
|
Posted: Mar 19, 2012 - 03:48 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
Hello,
I have another question concerning a callback.
1. If a timer invokes a callback is it always invoked from the HAL Layer?
2. If a timer is invoked do I have to call Sys_PostTask() afterwards to get to
the next state?
Example:
Code:
case NWK_JOINED:
appState=NEW_STATE;
SYS_PostTask(APL_TASK_ID);
break;
Let's assume that before the BitCloud gets into the state NEW_STATE a Timer is invoked
because it has a higher priority.
Code:
void TimerCallback()
{
//some code
//do I have to call SYS_PostTask() again at this point to
// get to the NEW_STATE
}
|
|
|
| |
|
|
|
|
|
Posted: Mar 19, 2012 - 03:50 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
| No callbacks (including timers) will interrupt already running task. Higher priority means that if application posted a task and HAL posted a task then HAL's task will be executed first. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 19, 2012 - 04:06 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
Maybe my question wasn't that clear.
If a timer-callback is already waiting to be executed and the APL posts a task afterwards, then the timer will be first.
Do I have to make another SYS_PostTask() within the Timer-Callback in that case to get to the NEW_STATE? |
|
|
| |
|
|
|
|
|
Posted: Mar 19, 2012 - 04:07 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
| No, all pending tasks will remain pending until executed. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 19, 2012 - 04:17 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
|
|
|
|
|
Posted: Mar 26, 2012 - 04:20 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
I would like to request the temperature from a node in the network via a terminal command.
Request: PC --> Node 1 --> Node2
Answer: Node 2 --> Node1 --> PC
So far I use two Endpoints because I need one Indication Callback for the request to meausre the temperature (node 2)
and one Indicatin Callback for the answer in which I forward the message to the PC (node1).
Is it possible and reasonable to implement this on one endpoint? |
|
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 05:21 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
| It is possible, but does it really makes sense to invest your time into changing something that already works? |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 05:54 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
| Just wanted to hear your opinion. Maybe there is an easy solution for this problem. Would be lesser code in any case.If its not reasonable I leave it as it is. |
|
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 06:15 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
Another option (a bit more correct architecturally in this case) is to put "command type" field as a first byte of a frame and send frames using one endpoint and when frame is received decide what to do with it based on this field.
It you don't plan to extend your application then it is just easier to leave t as is. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 06:23 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
| Sounds like a good idea. At the moment I don't plan to extend the application. But thanks for your suggestion |
|
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 06:25 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
Few days ago I asked you about the Parent/Child relationship. There is another question now.
CS_MAX_CHILDREN_ROUTER_AMOUNT
Why is this macro needed. A Router can't have another Router as a child.
Is it only valid for the first 15 seconds? |
|
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 06:41 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
| Yes, this only defines how many routers can join a network through this router within 15 second interval. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 03:29 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
This is from the developer guide in section 'network parameters':
"But often it is required that the coordinator rejoin the same network as before to participate in data exchange"
I read that the coordinator can't rejoin a network. So the coordinator is forced to log in as a router in this case? |
|
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 03:59 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
| No, it means that C will start a "new" network with the same PAN ID, this goes against the specification, but might be useful in some application. |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 05:29 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
| Sorry, this went wrong! |
Last edited by guitero on Mar 29, 2012 - 05:43 PM; edited 1 time in total
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 05:40 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
The problem is that I want to let a router rejoin my network. But it always
rejoins as a coordinator to the network!
My software is the same for all devices. So the default device is a router. If joining
fails a number of times the INI_STATE is invoked again an the application changes the device
to coordinator. That works fine, see the code below:
Code:
static void initNetwork(void)
{
if(connectionFailed==0)
{
deviceType=DEVICE_TYPE_ROUTER;
}
else
{
deviceType=DEVICE_TYPE_COORDINATOR;
connectionFailed=0;
}
CS_WriteParameter(CS_NWK_UNIQUE_ADDR_ID, &(bool){false});
// Set the deviceType value to Config Server
CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);
}
To test the network leaving the following function is invoked if I push on a button.
Code:
void leaveNetwork(void)
{
ZDO_MgmtLeaveReq_t *zdpLeaveReq = &leaveReq.req.reqPayload.mgmtLeaveReq;
stopHeartbeatTimer();
//here I unregister my endpoints
unregisterHeartbeatEndpoint();
//....
leaveReq.ZDO_ZdpResp = zdpLeaveResp;
leaveReq.reqCluster = MGMT_LEAVE_CLID;
leaveReq.dstAddrMode = EXT_ADDR_MODE;
leaveReq.dstExtAddr = 0;
zdpLeaveReq->deviceAddr = 0;
zdpLeaveReq->rejoin = 0;
zdpLeaveReq->removeChildren = 1;
zdpLeaveReq->reserved = 0;
ZDO_ZdpReq(&leaveReq);
}
And the leave response. Although the default type is router
I wrote it to the CS just to be sure.
Code:
static void zdpLeaveResp(ZDO_ZdpResp_t *zdpResp)
{
// Try to rejoin the network
deviceType=DEVICE_TYPE_ROUTER;
CS_WriteParameter(CS_DEVICE_TYPE_ID, &deviceType);
connectionFailed=0;
appState = INI_STATE;
SYS_PostTask(APL_TASK_ID);
(void)zdpResp;
}
I use stochastic addressing and the PAN-ID is static
#define CS_NWK_UNIQUE_ADDR 0
#define CS_NWK_PREDEFINED_PANID true
As a first step I would like to rejoin the router to the network, but not
as a coordinator. I don't know if the code is okay to sovle the problem.
If not, let me know. |
|
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 05:41 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
Please use "code" tags to mark your code.
guitero wrote:
But it always rejoins as a coordinator to the network!
How do you know it? |
|
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 05:46 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
Sorry, I noticed it too late, you were too fast.
Quote:
How do you know it?
1.Requested the address via Usart. It's 0x00
2. My Routers send heartbeats to the C. This device doesn't |
|
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 05:48 PM |
|


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA
|
|
| Where this address comes from? |
_________________ The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
|
| |
|
|
|
|
|
Posted: Mar 29, 2012 - 05:53 PM |
|

Joined: Feb 03, 2012
Posts: 74
Location: Oldenburg
|
|
I sent the IEEE-Address of this device to a ZDP-function
Code:
void doNwkAddrReq(uint64_t ieeeAddr)
{
ZDO_NwkAddrReq_t *nwkAddrReq = &zdpReq.req.reqPayload.nwkAddrReq;
zdpReq.ZDO_ZdpResp = zdpNwkAddrResp;
zdpReq.reqCluster = NWK_ADDR_CLID;
zdpReq.dstAddrMode = SHORT_ADDR_MODE;
nwkAddrReq->ieeeAddrOfInterest = ieeeAddr;
nwkAddrReq->reqType = SINGLE_RESPONSE_REQUESTTYPE;
nwkAddrReq->startIndex = 0;
ZDO_ZdpReq(&zdpReq); //Request senden
}
|
|
|
| |
|
|
|
|
|