Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot-Custom MTS-Serial
Fork of mDot_AT_firmware_CUSTOM by
To change channel plans replace AS923 with AU915, EU868, KR920 or US915 on line 15
#define CHANNEL_PLAN CP_AS923
main.cpp@24:739e3a700d34, 2017-01-06 (annotated)
- Committer:
- jreiss
- Date:
- Fri Jan 06 17:50:40 2017 +0000
- Revision:
- 24:739e3a700d34
- Parent:
- 22:89a1202125bc
- Child:
- 25:d53190a4ae96
update libmDot-Custom, ChannelPlans and mbed-os
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" |
jreiss | 18:4e02a7a01625 | 6 | #include "ChannelPlans.h" |
Mike Fiore |
9:ff62b20f7000 | 7 | |
Mike Fiore |
9:ff62b20f7000 | 8 | #define SERIAL_BUFFER_SIZE 512 |
Mike Fiore |
9:ff62b20f7000 | 9 | |
Mike Fiore |
9:ff62b20f7000 | 10 | mts::ATSerial debug(USBTX, USBRX); |
Mike Fiore |
9:ff62b20f7000 | 11 | |
jreiss | 12:98445fa50cd3 | 12 | #ifndef UNIT_TEST |
jreiss | 12:98445fa50cd3 | 13 | |
jreiss | 24:739e3a700d34 | 14 | #ifndef CHANNEL_PLAN |
jreiss | 24:739e3a700d34 | 15 | #define CHANNEL_PLAN CP_KR920 |
jreiss | 24:739e3a700d34 | 16 | #endif |
jreiss | 24:739e3a700d34 | 17 | |
Mike Fiore |
9:ff62b20f7000 | 18 | int main() |
Mike Fiore |
9:ff62b20f7000 | 19 | { |
Mike Fiore |
9:ff62b20f7000 | 20 | debug.baud(115200); |
jreiss | 24:739e3a700d34 | 21 | |
jreiss | 24:739e3a700d34 | 22 | // get a mDot handle |
Mike Fiore |
9:ff62b20f7000 | 23 | mDot* dot = mDot::getInstance(); |
jreiss | 24:739e3a700d34 | 24 | |
jreiss | 24:739e3a700d34 | 25 | #if CHANNEL_PLAN == CP_AS923 |
jreiss | 21:eba22baae4fd | 26 | lora::ChannelPlan* plan = new lora::CustomChannelPlan_AS923(*dot->getRadio(), *dot->getSettings()); |
jreiss | 24:739e3a700d34 | 27 | #elif CHANNEL_PLAN == CP_US915 |
jreiss | 24:739e3a700d34 | 28 | lora::ChannelPlan* plan = new lora::CustomChannelPlan_US915(*dot->getRadio(), *dot->getSettings()); |
jreiss | 24:739e3a700d34 | 29 | #elif CHANNEL_PLAN == CP_AU915 |
jreiss | 24:739e3a700d34 | 30 | lora::ChannelPlan* plan = new lora::CustomChannelPlan_AU915(*dot->getRadio(), *dot->getSettings()); |
jreiss | 24:739e3a700d34 | 31 | #elif CHANNEL_PLAN == CP_EU868 |
jreiss | 24:739e3a700d34 | 32 | lora::ChannelPlan* plan = new lora::CustomChannelPlan_EU868(*dot->getRadio(), *dot->getSettings()); |
jreiss | 24:739e3a700d34 | 33 | #elif CHANNEL_PLAN == CP_KR920 |
jreiss | 24:739e3a700d34 | 34 | lora::ChannelPlan* plan = new lora::CustomChannelPlan_KR920(*dot->getRadio(), *dot->getSettings()); |
jreiss | 24:739e3a700d34 | 35 | #endif |
jreiss | 22:89a1202125bc | 36 | |
jreiss | 12:98445fa50cd3 | 37 | dot->setChannelPlan(plan); |
jreiss | 12:98445fa50cd3 | 38 | |
Mike Fiore |
9:ff62b20f7000 | 39 | // Seed the RNG |
Mike Fiore |
9:ff62b20f7000 | 40 | srand(dot->getRadioRandom()); |
Mike Fiore |
9:ff62b20f7000 | 41 | |
Mike Fiore |
9:ff62b20f7000 | 42 | mts::ATSerial* serial; |
Mike Fiore |
9:ff62b20f7000 | 43 | |
Mike Fiore |
9:ff62b20f7000 | 44 | if (dot->getFlowControl()) |
jreiss | 17:17963e6bd07d | 45 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
9:ff62b20f7000 | 46 | serial = new mts::ATSerialFlowControl(XBEE_DOUT, XBEE_DIN, XBEE_RTS, XBEE_CTS, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
jreiss | 17:17963e6bd07d | 47 | #else |
jreiss | 12:98445fa50cd3 | 48 | serial = new mts::ATSerialFlowControl(UART1_TX, UART1_RX, UART1_RTS, UART1_CTS, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
jreiss | 17:17963e6bd07d | 49 | #endif |
Mike Fiore |
9:ff62b20f7000 | 50 | else |
jreiss | 17:17963e6bd07d | 51 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
9:ff62b20f7000 | 52 | serial = new mts::ATSerial(XBEE_DOUT, XBEE_DIN, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
jreiss | 17:17963e6bd07d | 53 | #else |
jreiss | 12:98445fa50cd3 | 54 | serial = new mts::ATSerial(UART1_TX, UART1_RX, SERIAL_BUFFER_SIZE, SERIAL_BUFFER_SIZE); |
jreiss | 17:17963e6bd07d | 55 | #endif |
Mike Fiore |
9:ff62b20f7000 | 56 | |
Mike Fiore |
9:ff62b20f7000 | 57 | debug.baud(dot->getDebugBaud()); |
Mike Fiore |
9:ff62b20f7000 | 58 | serial->baud(dot->getBaud()); |
Mike Fiore |
9:ff62b20f7000 | 59 | |
jreiss | 12:98445fa50cd3 | 60 | CommandTerminal term(*serial); |
jreiss | 12:98445fa50cd3 | 61 | CommandTerminal::_dot = dot; |
jreiss | 12:98445fa50cd3 | 62 | |
jreiss | 12:98445fa50cd3 | 63 | term.init(); |
jreiss | 12:98445fa50cd3 | 64 | |
jreiss | 12:98445fa50cd3 | 65 | |
Mike Fiore |
9:ff62b20f7000 | 66 | |
Mike Fiore |
9:ff62b20f7000 | 67 | term.start(); |
Mike Fiore |
9:ff62b20f7000 | 68 | } |
jreiss | 12:98445fa50cd3 | 69 | |
jreiss | 12:98445fa50cd3 | 70 | #endif // UNIT_TEST |
jreiss | 17:17963e6bd07d | 71 |