![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
Diff: xDotBridge/src/CommProtocolPeerBrute.cpp
- Revision:
- 89:edfe5d376e55
- Parent:
- 81:1eb0f16b2ab9
- Child:
- 91:8196900df6fe
--- a/xDotBridge/src/CommProtocolPeerBrute.cpp Thu Nov 16 18:10:53 2017 -0700 +++ b/xDotBridge/src/CommProtocolPeerBrute.cpp Sat Nov 18 15:50:10 2017 -0700 @@ -9,6 +9,7 @@ #include "dot_util.h" #include "util.h" #include "MyLog.h" +#include "ChannelPlan.h" // wireless bridge protocol const uint8_t TX_PWR = 20; // 20 dBm @@ -78,33 +79,36 @@ uint8_t tx_datarate; uint32_t tx_frequency; uint8_t frequency_band = dot->getFrequencyBand(); -// switch (frequency_band) { -// case mDot::FB_EU868: -// // 250kHz channels achieve higher throughput -// // DR6 : SF7 @ 250kHz -// // DR0 - DR5 (125kHz channels) available but much slower -// tx_frequency = 869850000; -// tx_datarate = mDot::DR6; -// // 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: -// // 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 -// tx_frequency = 915500000; -// tx_datarate = mDot::DR13; -// // 915 bands have no duty cycle restrictions, set tx power to max -// tx_power = 20; -// break; -// } + switch (frequency_band) { + 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 + tx_frequency = 869850000; + tx_datarate = mDot::DR6; + // 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 lora::ChannelPlan::US915_OLD: + case lora::ChannelPlan::US915: + case lora::ChannelPlan::AU915_OLD: + case lora::ChannelPlan::AU915: + default: + // 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 + tx_frequency = 915500000; + tx_datarate = mDot::DR13; + // 915 bands have no duty cycle restrictions, set tx power to max + tx_power = 20; + 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 @@ -145,33 +149,36 @@ uint8_t tx_datarate; uint32_t tx_frequency; uint8_t frequency_band = dot->getFrequencyBand(); -// switch (frequency_band) { -// case mDot::FB_EU868: -// // 250kHz channels achieve higher throughput -// // DR6 : SF7 @ 250kHz -// // DR0 - DR5 (125kHz channels) available but much slower -// tx_frequency = 869850000; -// tx_datarate = mDot::DR6; -// // 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: -// // 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 -// tx_frequency = 915500000; -// tx_datarate = mDot::DR13; -// // 915 bands have no duty cycle restrictions, set tx power to max -// tx_power = 20; -// break; -// } + switch (frequency_band) { + 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 + tx_frequency = 869850000; + tx_datarate = mDot::DR6; + // 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 lora::ChannelPlan::US915_OLD: + case lora::ChannelPlan::US915: + case lora::ChannelPlan::AU915_OLD: + case lora::ChannelPlan::AU915: + default: + // 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 + tx_frequency = 915500000; + tx_datarate = mDot::DR13; + // 915 bands have no duty cycle restrictions, set tx power to max + tx_power = 20; + break; + } update_peer_to_peer_config(pair_network_address, pair_network_session_key, pair_data_session_key, tx_frequency, tx_datarate, tx_power); dot->saveConfig(); // This is required for network settings to apply return cmdSuccess; @@ -537,9 +544,10 @@ myLogInfo("version ------------------ %s", dot->getId().c_str()); myLogInfo("device ID/EUI ------------ %s", mts::Text::bin2hexString(dot->getDeviceId()).c_str()); myLogInfo("frequency band ----------- %s", mDot::FrequencyBandStr(dot->getFrequencyBand()).c_str()); -// if (dot->getFrequencySubBand() != mDot::FB_EU868) { -// myLogInfo("frequency sub band ------- %u", dot->getFrequencySubBand()); -// } + if ((dot->getFrequencySubBand() != lora::ChannelPlan::EU868_OLD) + || (dot->getFrequencySubBand() != lora::ChannelPlan::EU868)) { + myLogInfo("frequency sub band ------- %u", dot->getFrequencySubBand()); + } myLogInfo("public network ----------- %s", dot->getPublicNetwork() ? "on" : "off"); myLogInfo("========================="); myLogInfo("credentials configuration");