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-mbed5 ISL29011
Diff: examples/src/peer_to_peer_example.cpp
- Revision:
- 21:09d05faf0e13
- Parent:
- 17:d4f82e16de5f
- Child:
- 22:d9bc10bbc433
diff -r 9ea0f3385ab3 -r 09d05faf0e13 examples/src/peer_to_peer_example.cpp
--- a/examples/src/peer_to_peer_example.cpp Tue May 16 10:47:10 2017 -0500
+++ b/examples/src/peer_to_peer_example.cpp Fri Jun 09 08:31:21 2017 -0500
@@ -24,6 +24,7 @@
static uint8_t data_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
mDot* dot = NULL;
+lora::ChannelPlan* plan = NULL;
Serial pc(USBTX, USBRX);
@@ -46,7 +47,23 @@
mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
- dot = mDot::getInstance();
+#if CHANNEL_PLAN == CP_US915
+ plan = new lora::ChannelPlan_US915();
+#elif CHANNEL_PLAN == CP_AU915
+ plan = new lora::ChannelPlan_AU915();
+#elif CHANNEL_PLAN == CP_EU868
+ plan = new lora::ChannelPlan_EU868();
+#elif CHANNEL_PLAN == CP_KR920
+ plan = new lora::ChannelPlan_KR920();
+#elif CHANNEL_PLAN == CP_AS923
+ plan = new lora::ChannelPlan_AS923();
+#elif CHANNEL_PLAN == CP_AS923_JAPAN
+ plan = new lora::ChannelPlan_AS923_Japan();
+#endif
+ assert(plan);
+
+ dot = mDot::getInstance(plan);
+ assert(dot);
logInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION);
@@ -69,31 +86,58 @@
}
frequency_band = dot->getFrequencyBand();
switch (frequency_band) {
- case mDot::FB_EU868:
+ case lora::ChannelPlan::EU868_OLD:
+ case lora::ChannelPlan::EU868:
// 250kHz channels achieve higher throughput
- // DR6 : SF7 @ 250kHz
- // DR0 - DR5 (125kHz channels) available but much slower
+ // DR_6 : SF7 @ 250kHz
+ // DR_0 - DR_5 (125kHz channels) available but much slower
tx_frequency = 869850000;
- tx_datarate = mDot::DR6;
+ tx_datarate = lora::DR_6;
// the 869850000 frequency is 100% duty cycle if the total power is under 7 dBm - tx power 4 + antenna gain 3 = 7
tx_power = 4;
break;
- case mDot::FB_US915:
- case mDot::FB_AU915:
- default:
+
+ case lora::ChannelPlan::US915_OLD:
+ case lora::ChannelPlan::US915:
+ case lora::ChannelPlan::AU915_OLD:
+ case lora::ChannelPlan::AU915:
// 500kHz channels achieve highest throughput
- // DR8 : SF12 @ 500kHz
- // DR9 : SF11 @ 500kHz
- // DR10 : SF10 @ 500kHz
- // DR11 : SF9 @ 500kHz
- // DR12 : SF8 @ 500kHz
- // DR13 : SF7 @ 500kHz
- // DR0 - DR3 (125kHz channels) available but much slower
+ // DR_8 : SF12 @ 500kHz
+ // DR_9 : SF11 @ 500kHz
+ // DR_10 : SF10 @ 500kHz
+ // DR_11 : SF9 @ 500kHz
+ // DR_12 : SF8 @ 500kHz
+ // DR_13 : SF7 @ 500kHz
+ // DR_0 - DR_3 (125kHz channels) available but much slower
tx_frequency = 915500000;
- tx_datarate = mDot::DR13;
+ tx_datarate = lora::DR_13;
// 915 bands have no duty cycle restrictions, set tx power to max
tx_power = 20;
break;
+
+ case lora::ChannelPlan::AS923:
+ case lora::ChannelPlan::AS923_JAPAN:
+ // 250kHz channels achieve higher throughput
+ // DR_6 : SF7 @ 250kHz
+ // DR_0 - DR_5 (125kHz channels) available but much slower
+ tx_frequency = 924800000;
+ tx_datarate = lora::DR_6;
+ tx_power = 16;
+ break;
+
+ case lora::ChannelPlan::KR920:
+ // DR_5 : SF7 @ 125kHz
+ tx_frequency = 922700000;
+ tx_datarate = lora::DR_5;
+ tx_power = 14;
+ break;
+
+ default:
+ while (true) {
+ logFatal("no known channel plan in use - extra configuration is needed!");
+ wait(5);
+ }
+ break;
}
// in PEER_TO_PEER mode there is no join request/response transaction
// as long as both Dots are configured correctly, they should be able to communicate