[MC13213 - Zigbee] Loop of AF_DataRequest

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

[MC13213 - Zigbee] Loop of AF_DataRequest

3,022件の閲覧回数
CecchiSandrone
Contributor II
I want to make cyclic AF_DataRequest, for example:

for(i=0;i<100;i++) {
    AF_DataRequest(....);
}

But as I read AF_DataRequest is async so I must wait for a confirm for every packet. Can you suggest me a way to do this easy?
ラベル(1)
0 件の賞賛
6 返答(返信)

630件の閲覧回数
Mads
Contributor V
cecchi,
 
the code you write as an example is not possible, if you do not make the scheduler run then no packets will be send.
 
so what you can do is capture the confirm in the :BeeAppDataConfirm() function
then start a timer to trigger the next transmission.
 
here is a bit of pseudo code :
 
Add something like this to the confirm function :
TMR_StartSingleShotTimer(SendpacketTimerId, 100, SendPacketCallback());
 
SendPacketCallback( tmrTimerID_t timerId )
{
(void) timerId;
call AF_dataRequest to send a packet)
}
 
 
BR,
Mads
0 件の賞賛

630件の閲覧回数
CecchiSandrone
Contributor II
Thanks Mads, I also solved this using confirmId parameter in AF_DataRequest. But so I can send 1 packet every 3 seconds average. It's the max "packet rate" that can I reach?
Code:
#define MAX_ATTEMPTS 100uint8_t requestor[2];index_t txAttempt;zbApsCounter_t confirmId = 0x6;void BeeAppDataIndication  (  void  ){  apsdeToAfMessage_t *pMsg;  zbApsdeDataIndication_t *pIndication;    while(MSG_Pending(&gAppDataIndicationQueue))  {    /* Get a message from a queue */    pMsg = MSG_DeQueue( &gAppDataIndicationQueue );    /* ask ZCL to handle the frame */    pIndication = &(pMsg->msgData.dataIndication);    /* handle the command */    if(pIndication->aClusterId[0] == appDataCluster[0]) {       Copy2Bytes(requestor,pIndication->aSrcAddr);       txAttempt = 0;       SendPacket();                             }                                                                                      /* Free memory allocated by data indication */    MSG_Free(pMsg);  }}void BeeAppDataConfirm  (  void  ){  apsdeToAfMessage_t *pMsg;  zbApsdeDataConfirm_t *pConfirm;  while(MSG_Pending(&gAppDataConfirmQueue))  {    /* Get a message from a queue */    pMsg = MSG_DeQueue( &gAppDataConfirmQueue );    pConfirm = &(pMsg->msgData.dataConfirm);    /* Action taken when confirmation is received. */    if( pConfirm->status == gSuccess_c )    {      /* successful confirm */      if(pConfirm->confirmId == confirmId)        SendLQI();          }        /* Free memory allocated in Call Back function */    MSG_Free(pMsg);  }}void SendPacket  (  void  ) {  if(txAttempt != MAX_ATTEMPTS) {       afAddrInfo_t addrInfo;    addrInfo.dstAddrMode = gZbAddrMode16Bit_c;    Copy2Bytes(addrInfo.dstAddr.aNwkAddr,requestor);     addrInfo.dstEndPoint = 0x01;    addrInfo.srcEndPoint = 0x01;    addrInfo.txOptions = gApsTxOptionNone_c;    addrInfo.radiusCounter = afDefaultRadius_c;    /* set up cluster */    Copy2Bytes(addrInfo.aClusterId, appDataCluster);    /* send the data request */    (void)AF_DataRequest(&addrInfo,10,"Message",&confirmId);    txAttempt++;  }   }          

 

0 件の賞賛

630件の閲覧回数
Mads
Contributor V
I can not tell you what the exact data rate is,
You should be able to send the next packet right after recieving the confirm.
 
Try adding timer as i suggested to the confirm code.
 
also please note that the confirmID is NOT set by you, it is set by the lower layer and you can provide a pointer so you can receive the id used. but it is not needed to track this ID as you are the one initiating the send packet and you only receive confirms on the packets the application send.
 
BR,
Mads
0 件の賞賛

630件の閲覧回数
CecchiSandrone
Contributor II
I did as you suggested but in fact I can send a message every 3 seconds. How can I increase this packet rate?
0 件の賞賛

630件の閲覧回数
Mads
Contributor V
Please note that when you send data to end devices you can not send data faster than their poll rate.
your option is to increase the poll rate - but this is not recommend, else enable the RxOnWhenIdle property on the Freescale Beeapps component.
 
I can only recommend buying an ZigBee protocol analyzer so you can see what happens over the air.
 
Br,
Mads
0 件の賞賛

630件の閲覧回数
CecchiSandrone
Contributor II
In ApplicationConf.h I found this:

Code:
#define mDefaultValueOfPollTimeOut_c 3000

 Modifying this I can get higher "packet rate" with obviously more power consumption.
0 件の賞賛