you problem is that you free the msg, that contains the data before you are done transmitting.
here is an example on how to do it:
Add to top of BeeApp.c
uint8_t UartTxBuffer[20];
uint8_t UartTxLength = 0;
bool_t UartTxFlag = FALSE;
const uint8_t text[] = "Welcome \r\n";
Add to BeeAppInit():
UartX_SetBaud(gUARTBaudRate19200_c);
UartX_Transmit(text, sizeof(text), NULL);
Example of how your BeeAppIndication() function could look like:
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);
/*
Note: if multiple endpoints are supported by this app, insert
endpoint filtering here...
This app assumes only 1 active endpoint. APS layer has already
filtered by endpoint and profile.
Note: all multi-byte over-the-air fields are little endian.
That is 0x1101 would come in byte order 0x01 0x11.
*/
/* is the cluster for accelerometer? */
if(pIndication->aClusterId[1] != appDataCluster[1]) {
MSG_Free(pMsg); /* no, free it and we're done */
continue;
}
/* handle the command */
if(pIndication->aClusterId[0] == appDataCluster[0]) {
if (UartTxFlag == FALSE) // only transmit if we are not already transmitting...
{
UartTxFlag = TRUE;
FLib_MemCpy(UartTxBuffer, pIndication->pAsdu, pIndication->asduLength);
(void) UartX_Transmit(UartTxBuffer, pIndication->asduLength, UartTxCallBack);
}
}
/* Free memory allocated by data indication */
MSG_Free(pMsg);
}
}
This will transmit correctly over the uart.
Notice that tehe data from the Msg is copied so when the MSG_Free() is called we still got a copy of the data.
BR,
Mads Westergreen