AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
main.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 16:d5cf2af81a6d
Added ability to force the AT terminal to use the USB debug port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
9:ff62b20f7000 | 1 | #include "mbed.h" |
Mike Fiore |
9:ff62b20f7000 | 2 | #include "mDot.h" |
Mike Fiore |
9:ff62b20f7000 | 3 | #include "CommandTerminal.h" |
Mike Fiore |
9:ff62b20f7000 | 4 | #include "ATSerial.h" |
Mike Fiore |
9:ff62b20f7000 | 5 | #include "ATSerialFlowControl.h" |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 6 | #include "ChannelPlans.h" |
Mike Fiore |
9:ff62b20f7000 | 7 | |
Mike Fiore |
9:ff62b20f7000 | 8 | #define SERIAL_BUFFER_SIZE 512 |
pferland | 18:f5d28d621bb0 | 9 | #define USE_USB_SERIAL |
Mike Fiore |
9:ff62b20f7000 | 10 | |
Mike Fiore |
14:f9a77400b622 | 11 | Serial debug(USBTX, USBRX); |
Mike Fiore |
14:f9a77400b622 | 12 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 13 | #ifndef CHANNEL_PLAN |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 14 | #define CHANNEL_PLAN CP_US915 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 15 | #endif |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 16 | |
Mike Fiore |
14:f9a77400b622 | 17 | #ifndef UNIT_TEST |
Mike Fiore |
9:ff62b20f7000 | 18 | |
Mike Fiore |
9:ff62b20f7000 | 19 | int main() |
Mike Fiore |
9:ff62b20f7000 | 20 | { |
Mike Fiore |
9:ff62b20f7000 | 21 | debug.baud(115200); |
Mike Fiore |
9:ff62b20f7000 | 22 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 23 | #if CHANNEL_PLAN == CP_AS923 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 24 | lora::ChannelPlan* plan = new lora::ChannelPlan_AS923(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 25 | #elif CHANNEL_PLAN == CP_US915 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 26 | lora::ChannelPlan* plan = new lora::ChannelPlan_US915(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 27 | #elif CHANNEL_PLAN == CP_AU915 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 28 | lora::ChannelPlan* plan = new lora::ChannelPlan_AU915(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 29 | #elif CHANNEL_PLAN == CP_EU868 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 30 | lora::ChannelPlan* plan = new lora::ChannelPlan_EU868(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 31 | #elif CHANNEL_PLAN == CP_KR920 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 32 | lora::ChannelPlan* plan = new lora::ChannelPlan_KR920(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 33 | #elif CHANNEL_PLAN == CP_IN865 |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 34 | lora::ChannelPlan* plan = new lora::ChannelPlan_IN865(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 35 | #elif CHANNEL_PLAN == CP_AS923_JAPAN |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 36 | lora::ChannelPlan* plan = new lora::ChannelPlan_AS923_Japan(); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 37 | #endif |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 38 | assert(plan); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 39 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 40 | mDot* dot = mDot::getInstance(plan); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 41 | assert(dot); |
Mike Fiore |
9:ff62b20f7000 | 42 | |
Mike Fiore |
9:ff62b20f7000 | 43 | // Seed the RNG |
Mike Fiore |
9:ff62b20f7000 | 44 | srand(dot->getRadioRandom()); |
Mike Fiore |
9:ff62b20f7000 | 45 | |
Mike Fiore |
9:ff62b20f7000 | 46 | mts::ATSerial* serial; |
Mike Fiore |
9:ff62b20f7000 | 47 | |
pferland | 18:f5d28d621bb0 | 48 | if (dot->getFlowControl()){ |
pferland | 18:f5d28d621bb0 | 49 | #if defined(TARGET_MTS_MDOT_F411RE) && defined(USE_USB_SERIAL) |
pferland | 18:f5d28d621bb0 | 50 | //no flow control available on USB debug port |
pferland | 18:f5d28d621bb0 | 51 | dot->setFlowControl(false); |
pferland | 18:f5d28d621bb0 | 52 | serial = new mts::ATSerial(USBTX, USBRX, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
pferland | 18:f5d28d621bb0 | 53 | |
pferland | 18:f5d28d621bb0 | 54 | #elif defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
9:ff62b20f7000 | 55 | serial = new mts::ATSerialFlowControl(XBEE_DOUT, XBEE_DIN, XBEE_RTS, XBEE_CTS, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
Mike Fiore |
14:f9a77400b622 | 56 | #else |
Mike Fiore |
14:f9a77400b622 | 57 | serial = new mts::ATSerialFlowControl(UART1_TX, UART1_RX, UART1_RTS, UART1_CTS, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
Mike Fiore |
14:f9a77400b622 | 58 | #endif |
pferland | 18:f5d28d621bb0 | 59 | } else { |
pferland | 18:f5d28d621bb0 | 60 | #if defined(TARGET_MTS_MDOT_F411RE) && defined(USE_USB_SERIAL) |
pferland | 18:f5d28d621bb0 | 61 | serial = new mts::ATSerial(USBTX, USBRX, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
pferland | 18:f5d28d621bb0 | 62 | |
pferland | 18:f5d28d621bb0 | 63 | #elif defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
9:ff62b20f7000 | 64 | serial = new mts::ATSerial(XBEE_DOUT, XBEE_DIN, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
Mike Fiore |
14:f9a77400b622 | 65 | #else |
Mike Fiore |
14:f9a77400b622 | 66 | serial = new mts::ATSerial(UART1_TX, UART1_RX, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
Mike Fiore |
14:f9a77400b622 | 67 | #endif |
pferland | 18:f5d28d621bb0 | 68 | } |
pferland | 18:f5d28d621bb0 | 69 | |
Mike Fiore |
9:ff62b20f7000 | 70 | debug.baud(dot->getDebugBaud()); |
Mike Fiore |
9:ff62b20f7000 | 71 | serial->baud(dot->getBaud()); |
Mike Fiore |
9:ff62b20f7000 | 72 | |
Mike Fiore |
14:f9a77400b622 | 73 | CommandTerminal term(*serial); |
Mike Fiore |
14:f9a77400b622 | 74 | CommandTerminal::_dot = dot; |
Mike Fiore |
14:f9a77400b622 | 75 | |
Mike Fiore |
14:f9a77400b622 | 76 | term.init(); |
Mike Fiore |
9:ff62b20f7000 | 77 | |
Mike Fiore |
9:ff62b20f7000 | 78 | term.start(); |
Mike Fiore |
9:ff62b20f7000 | 79 | } |
Mike Fiore |
14:f9a77400b622 | 80 | |
Mike Fiore |
14:f9a77400b622 | 81 | #endif // UNIT_TEST |
Mike Fiore |
14:f9a77400b622 | 82 |