Master Implementation of WANOT

Dependencies:   SX1276Lib mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include"WANOT.h"
00002 
00003 /*
00004  *  Global variables declarations
00005  */
00006 
00007 /*!
00008  * Radio events function pointer
00009  */
00010 RadioEvents_t RadioEvents;
00011 SX1276MB1xAS Radio(NULL);
00012 
00013 extern SuperSlotStates SuperSlotState;
00014 
00015 Timer timer;
00016 int begin, end;
00017 
00018 int main()
00019 {
00020 
00021     // verify the connection with the board
00022     while (Radio.Read(REG_VERSION) == 0x00) {
00023         debug("Radio could not be detected!\n\r\r", NULL);
00024         wait(1);
00025     }
00026     debug("WANOT Master Started...\n\r");
00027 
00028     char StoreRead[50];
00029     GPS_Read(StoreRead);
00030 
00031     SuperSlotInit();
00032     
00033     uint8_t SlaveLocalID = 1;
00034 
00035     while(1)    {
00036 
00037         switch(SuperSlotState) {
00038             case SetUp_Beacon_Phase:
00039                 SetUp_Beacon();
00040                 break;
00041 
00042             case SetUp_Phase:
00043                 MasterSetUp();
00044                 break;
00045 
00046             case TDMA_Phase:
00047                 MasterTDMA(SlaveLocalID);
00048                 SlaveLocalID++;
00049                 break;
00050 
00051         }
00052     }
00053 
00054 }