Hi,
I am trying to do the same but I don't get that far - I can't get MLME-SYNC to succeed. According to the steps in the user guide I need to synchronise to the incoming beacon. I am using an MC9S08GT60 coupled to an MC13193. There is a working PAN coordinator present. I have tried Beacon orders of 1, 3, 4 and 7.
Here is my source:
uint8_t App_TrackParentBeacon(void) {
uint8_t ret;
uint8_t b_order;
uint8_t s_order;
mlmeMessage_t *pMsg;
mlmeSyncReq_t *pSyncReq;
b_order = BEACON_ORDER;
s_order = SUPERFRAME_ORDER;
pMsg = MSG_AllocType(mlmeMessage_t);
/* Set Beacon Order */
pMsg->msgType = gMlmeSetReq_c;
pMsg->msgData.setReq.pibAttribute = gMPibBeaconOrder_c;
pMsg->msgData.setReq.pibAttributeValue = &b_order
ret = MSG_Send(NWK_MLME, pMsg);
if (ret != gSuccess_c) {
Uart_Print("set beacon order failed.\n");
}
/* Set Super frame Order */
pMsg->msgType = gMlmeSetReq_c;
pMsg->msgData.setReq.pibAttribute = gMPibSuperFrameOrder_c;
pMsg->msgData.setReq.pibAttributeValue = &s_order
ret = MSG_Send(NWK_MLME, pMsg);
if (ret != gSuccess_c) {
Uart_Print("set superframe order failed.\n");
}
MSG_Free(pMsg);
pMsg = MSG_AllocType(mlmeMessage_t);
pSyncReq = &pMsg->msgData.syncReq;
if (pMsg != NULL) {
pMsg->msgType = gMlmeSyncReq_c;
pSyncReq->trackBeacon = TRUE;
pSyncReq->logicalChannel = logicalChannel;
if (MSG_Send(NWK_MLME, pMsg) == gSuccess_c)
{
Uart_Print("App_TrackParentBeacon succeeded.\n");
return errorNoError;
}
else
{
Uart_Print("App_TrackParentBeacon failed.\n");
return errorNotSuccessful;
}
}
}
Before this code executes my node associates with the PAN coordinator successfully and can send/receive ok. I receive the "App_TrackParentBeacon failed" message through the UART, indicating that MLME-SYNC does not succeed. Is there something wrong with my source code that I can't see (apart from freeing the message)?
Thanks in advance.