Jason Reiss / Mbed OS Dot-AT-Firmware-XDOT

Dependencies:   MTS-Serial libxDot-mbed5

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "mDot.h"
00003 #include "CommandTerminal.h"
00004 #include "ATSerial.h"
00005 #include "ATSerialFlowControl.h"
00006 #include "ChannelPlans.h"
00007 
00008 #define SERIAL_BUFFER_SIZE 512
00009 
00010 Serial pc(USBTX, USBRX);
00011 
00012 #ifndef CHANNEL_PLAN
00013 #define CHANNEL_PLAN CP_US915
00014 #endif
00015 
00016 #ifndef UNIT_TEST
00017 
00018 int main()
00019 {
00020     pc.baud(115200);
00021 
00022 #if CHANNEL_PLAN == CP_AS923
00023     lora::ChannelPlan* plan = new lora::ChannelPlan_AS923();
00024 #elif CHANNEL_PLAN == CP_US915
00025     lora::ChannelPlan* plan = new lora::ChannelPlan_US915();
00026 #elif CHANNEL_PLAN == CP_AU915
00027     lora::ChannelPlan* plan = new lora::ChannelPlan_AU915();
00028 #elif CHANNEL_PLAN == CP_EU868
00029     lora::ChannelPlan* plan = new lora::ChannelPlan_EU868();
00030 #elif CHANNEL_PLAN == CP_KR920
00031     lora::ChannelPlan* plan = new lora::ChannelPlan_KR920();
00032 #elif CHANNEL_PLAN == CP_IN865
00033     lora::ChannelPlan* plan = new lora::ChannelPlan_IN865();
00034 #elif CHANNEL_PLAN == CP_AS923_JAPAN
00035     lora::ChannelPlan* plan = new lora::ChannelPlan_AS923_Japan();
00036 #endif
00037     assert(plan);
00038 
00039     mDot* dot = mDot::getInstance(plan);
00040     assert(dot);
00041 
00042     // Seed the RNG
00043     srand(dot->getRadioRandom());
00044 
00045     mts::ATSerial* serial;
00046 
00047     if (dot->getFlowControl())
00048 #if defined(TARGET_MTS_MDOT_F411RE)
00049         serial = new mts::ATSerialFlowControl(XBEE_DOUT, XBEE_DIN, XBEE_RTS, XBEE_CTS, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE);
00050 #else
00051         serial = new mts::ATSerialFlowControl(UART1_TX, UART1_RX, UART1_RTS, UART1_CTS, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE);
00052 #endif
00053     else
00054 #if defined(TARGET_MTS_MDOT_F411RE)
00055         serial = new mts::ATSerial(XBEE_DOUT, XBEE_DIN, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE);
00056 #else
00057         serial = new mts::ATSerial(UART1_TX, UART1_RX, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE);
00058 #endif
00059 
00060     pc.baud(dot->getDebugBaud());
00061     serial->baud(dot->getBaud());
00062 
00063     CommandTerminal term(*serial);
00064     CommandTerminal::_dot = dot;
00065 
00066     term.init();
00067 
00068     term.start();
00069 }
00070 
00071 #endif // UNIT_TEST
00072