Hello everybody,
I return on an Old project which present some problem.
This Project is based on MC13213 with the Beekit 3.0.2 : HCS08 MAC Codebase 2.6.1.
On this project we have some End Device and One coordinator. Device send sometime information over air.
But regulary, we have some difficult to transmit message.
My code follow the given exemple of "UART wireless"
I have the following code to send data:
mpPacket->msgData.dataReq.msduLength = index; //****
// Data was available in the UART receive buffer. Now create an
// MCPS-Data Request message containing the UART data.
mpPacket->msgType = gMcpsDataReq_c;
// Create the header using coordinator information gained during
// the scan procedure. Also use the short address we were assigned
// by the coordinator during association.
FLib_MemCpy(mpPacket->msgData.dataReq.dstAddr, mCoordInfo.coordAddress, 2);
FLib_MemCpy(mpPacket->msgData.dataReq.srcAddr, maMyAddress, 2);
FLib_MemCpy(mpPacket->msgData.dataReq.dstPanId, mCoordInfo.coordPanId, 2);
FLib_MemCpy(mpPacket->msgData.dataReq.srcPanId, mCoordInfo.coordPanId, 2);
mpPacket->msgData.dataReq.dstAddrMode = mCoordInfo.coordAddrMode;
mpPacket->msgData.dataReq.srcAddrMode = mAddrMode;
// Request MAC level acknowledgement of the data packet
mpPacket->msgData.dataReq.txOptions = gTxOptsAck_c;
// Give the data packet a handle. The handle is
// returned in the MCPS-Data Confirm message.
mpPacket->msgData.dataReq.msduHandle = (uint8_t)Evt + 0x11;
//UartUtil_Print("Sending ...\n\r", gNoBlock_d);
// Send the Data Request to the MCPS
res = MSG_Send(NWK_MCPS, mpPacket);
// Prepare for another data buffer
mpPacket = NULL;
mcPendingPackets++;
MSG_Send return always 0x00.
Then we have the HandleMcpsInput function wichin is call on each MCPS indication:
static void App_HandleMcpsInput(mcpsToNwkMessage_t* pMsgIn)
{
...
switch(pMsgIn->msgType)
{
/* The MCPS-Data confirm is sent by the MAC to the network
or application layer when data has been sent. */
case gMcpsDataCnf_c:
if(mcPendingPackets)
{
mcPendingPackets--;
}
IF_Print_String("--0x", gAllowToBlock_d);
IF_Print_Hex(&pMsgIn->msgData.dataCnf.status, 1, 0);....
Thank to My function to print data to the UART, I can see something:
After MSG_Send called, we are notified with HandleMcpsInput with msgType = McpsDataCnf.
On the first transmission, the pMsgIn->msgData.dataCnf.status is well "0x00" and data are well transmitted and received by the coordinator.
On the second, MSG_Send, the Status is 0xE8 (??? not found this value in documentation), then I must recall the MSG_Send a second time...
After that, all MSG_Send must be done 4 time to have a Status of 0x00 instead of 0xE8 to transmit correctly the Data. :smileyconfused:
And sometime, I transmit it many time (A retry during 3s = about 30 try) I always a confirmation with status of 0xE8... After that, I restart an association.
Sometime this association finish Ok, sometime association fail... (I don't know yet where)
- Why many Time the Confirmation status is 0xE8 (Which mean this returned code?) THis will help me to understand why we need 4 try to transmit and maybe why sometime th transmission failed...
- Like this codebase is old, is the source code is free available for editing?
Thank:smileyhappy:
Solved! Go to Solution.
Ok
I missed the following line when I port my application (to be called just before the MSG_Send:
mpPacket->msgData.dataReq.securityLevel = 0
Thank for your help
Hello Arnaud,
When is MSG_Send() called?
What are you filling the pMsdu with?
In your implementation, is there a reason to have the "pending packets" variable? (mcPendingPackets++; )
What's the frequency of each MSG_Send call?
I see your Printing function is blocking, can you try using another function or incrementing a variable and check later instead of real-time printing?
-JC
Hello
-The MSG_Send is called on a specific event in my application (not under interrupt but from a basic task of 25ms periodic)
- The pMsdu is set to a static buffer just before the line exposed above.
-mcPendingPackets from the original demonstration file generated with the "Freescal Beekit" I not need it in my application
- Msg_Send is called one time and not called before have a positive return. So I never calle MSG_Send many time without receive a Coordinator response or many second later.
-IF_Print_Hex is only my adaptation of com_util library provided with the demonstration. This is a macro that I can disable. When disabled, problem is still present.
Have you access to the stack to know the means of error code 0xE8? I not found in documentions information about this code!
Hello Arnaud,
Result types are listed in PublicConst.h
#define gInvalidParameter_c 0xE8
Ok
I missed the following line when I port my application (to be called just before the MSG_Send:
mpPacket->msgData.dataReq.securityLevel = 0
Thank for your help