Slave Implementation of WANOT Slave

Dependencies:   SX1276Lib mbed-src

SuperSlot.cpp

Committer:
semsem
Date:
2016-05-23
Revision:
0:80ebf9b1dd4f

File content as of revision 0:80ebf9b1dd4f:

#include "WANOT.h"

/*
 *  Global variables declarations
 */

volatile SuperSlotStates SuperSlotState = SetUp_Beacon_Phase;
Timeout SwitchState;

void SwitchState_Fn(void)
{
    switch(SuperSlotState) {
        case SetUp_Beacon_Phase:
            debug("Switching to SetUp Phase State !!\n\r");
            SuperSlotState = SetUp_Phase;
            SwitchState.attach(&SwitchState_Fn,SET_UP_INTERVAL);
            break;

        case SetUp_Phase:
            debug("Switching to TDMA Phase State !!\n\r");
            SuperSlotState = TDMA_Phase;
            SwitchState.attach(&SwitchState_Fn,TDMA_INTERVAL);
            break;

        case TDMA_Phase:
            debug("SuperSlot States finished\n\r\n\r\n\r");
            debug("Switching to SetUp Beacon State !! \n\r");
            SuperSlotState = SetUp_Beacon_Phase;
            SwitchState.attach(&SwitchState_Fn, BEACON_SET_UP_INTERVAL);
            break;

    }
}

void SuperSlotInit ()
{

    debug("Switching to SetUp Beacon State !! \n\r");
    SuperSlotState = SetUp_Beacon_Phase;
    SwitchState.attach(&SwitchState_Fn, BEACON_SET_UP_INTERVAL);
}