student-devel / Mbed OS ASIA_AT

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

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 debug(USBTX, USBRX);
00011 #define CHANNEL_PLAN CP_AS923
00012 
00013 #ifndef CHANNEL_PLAN
00014 #define CHANNEL_PLAN CP_US915
00015 #endif
00016 
00017 #ifndef UNIT_TEST
00018 
00019 int main()
00020 {
00021     debug.baud(115200);
00022 
00023 #if CHANNEL_PLAN == CP_AS923
00024     lora::ChannelPlan* plan = new lora::ChannelPlan_AS923();
00025 #elif CHANNEL_PLAN == CP_US915
00026     lora::ChannelPlan* plan = new lora::ChannelPlan_US915();
00027 #elif CHANNEL_PLAN == CP_AU915
00028     lora::ChannelPlan* plan = new lora::ChannelPlan_AU915();
00029 #elif CHANNEL_PLAN == CP_EU868
00030     lora::ChannelPlan* plan = new lora::ChannelPlan_EU868();
00031 #elif CHANNEL_PLAN == CP_KR920
00032     lora::ChannelPlan* plan = new lora::ChannelPlan_KR920();
00033 #elif CHANNEL_PLAN == CP_IN865
00034     lora::ChannelPlan* plan = new lora::ChannelPlan_IN865();
00035 #elif CHANNEL_PLAN == CP_AS923_JAPAN
00036     lora::ChannelPlan* plan = new lora::ChannelPlan_AS923_Japan();
00037 #endif
00038     assert(plan);
00039 
00040     mDot* dot = mDot::getInstance(plan);
00041     assert(dot);
00042     // Seed the RNG
00043     srand(dot->getRadioRandom());
00044 
00045     mts::ATSerial* serial;
00046     serial = new mts::ATSerial(XBEE_DOUT, XBEE_DIN, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE);
00047     debug.baud(dot->getDebugBaud());
00048     serial->baud(dot->getBaud());
00049 
00050     CommandTerminal term(*serial);
00051     CommandTerminal::_dot = dot;
00052 
00053     term.init();
00054 
00055     term.start();
00056 }
00057 
00058 #endif // UNIT_TEST
00059