static uint8_t App_StartRouter(void){ /* Message for the MLME will be allocated and attached to this pointer */ mlmeMessage_t *pMsg; UartUtil_Print("Sending the MLME-Start Request message to the MAC..."); /* Allocate a message for the MLME (We should check for NULL). */ pMsg = MSG_AllocType(mlmeMessage_t); if(pMsg != NULL) { /* Pointer which is used for easy access inside the allocated message */ mlmeStartReq_t *pStartReq; /* Return value from MSG_send - used for avoiding compiler warnings */ uint8_t ret; /* Boolean value that will be written to the MAC PIB */ uint8_t boolFlag; /* Set-up MAC PIB attributes. Please note that Set, Get, and Reset messages are not freed by the MLME. */ /* We must always set the short address to something else than 0xFFFF before starting a PAN. */ pMsg->msgType = gMlmeSetReq_c; pMsg->msgData.setReq.pibAttribute = gMPibShortAddress_c; pMsg->msgData.setReq.pibAttributeValue = (uint8_t *)maDeviceShortAddress; ret = MSG_Send(NWK_MLME, pMsg); /* We must set the Association Permit flag to TRUE in order to allow devices to associate to us. */ pMsg->msgType = gMlmeSetReq_c; pMsg->msgData.setReq.pibAttribute = gMPibAssociationPermit_c; boolFlag = TRUE; pMsg->msgData.setReq.pibAttributeValue = &boolFlag; ret = MSG_Send(NWK_MLME, pMsg); /*Set Beacon Order PIB*/ pMsg->msgType = gMlmeSetReq_c; pMsg->msgData.setReq.pibAttribute = gMPibBeaconOrder_c; pMsg->msgData.setReq.pibAttributeValue = (uint8_t *)mDefaultValueOfBeaconOrder_c; ret = MSG_Send(NWK_MLME, pMsg); /*Set SuperFrame Order PIB*/ pMsg->msgType = gMlmeSetReq_c; pMsg->msgData.setReq.pibAttribute = gMPibSuperFrameOrder_c; pMsg->msgData.setReq.pibAttributeValue = (uint8_t *)mDefaultValueOfSuperframeOrder_c; ret = MSG_Send(NWK_MLME, pMsg); /*Set macRxOnWhenIdle PIB*/ pMsg->msgType = gMlmeSetReq_c; pMsg->msgData.setReq.pibAttribute = gMPibRxOnWhenIdle_c; pMsg->msgData.setReq.pibAttributeValue = (uint8_t *)macRxOnWhenIdle_c; ret = MSG_Send(NWK_MLME, pMsg); macTreemodeStartTime = gOrder000s492ms_c; /*Set macTreemodeStartTime Order PIB*/ pMsg->msgType = gMlmeSetReq_c; pMsg->msgData.setReq.pibAttribute = gMPibTreemodeStartTime_c; pMsg->msgData.setReq.pibAttributeValue = (uint8_t *)macTreemodeStartTime; /* Send the Set request to the MLME. */ MSG_Send(NWK_MLME, pMsg); /* This is a MLME-START.req command */ pMsg->msgType = gMlmeStartReq_c; /* Create the Start request message data. */ pStartReq = &pMsg->msgData.startReq; /* PAN ID - LSB, MSB. The example shows a PAN ID of 0xBEEF. */ FLib_MemCpy(pStartReq->panId, &mCoordInfo.coordPanId, 2); /* Logical Channel - the default of 11 will be overridden */ pStartReq->logicalChannel = mLogicalChannel; /* Beacon Order: 0xF = turn off beacons, less than 0xF = turn on beacons */ pStartReq->beaconOrder = mDefaultValueOfBeaconOrder_c; /* Superframe Order: Must be equal or less than the beacon order */ pStartReq->superFrameOrder = mDefaultValueOfSuperframeOrder_c; /* Be a Router */ pStartReq->panCoordinator = FALSE; /* Dont use battery life extension */ pStartReq->batteryLifeExt = FALSE; /* This is not a Realignment command */ pStartReq->coordRealignment = FALSE; /* Dont use security */ pStartReq->securityEnable = FALSE; /* Send the Start request to the MLME. */ ret = MSG_Send(NWK_MLME, pMsg); if(ret == gSuccess_c) { UartUtil_Print("Done\n"); return errorNoError; } else { /* One or more parameters in the Start Request message were invalid. */ UartUtil_Print("Invalid parameter!\n"); return errorInvalidParameter; } } else { /* Allocation of a message buffer failed. */ UartUtil_Print("Message allocation failed!\n"); return errorAllocFailed; }}