Basic xdot code to check how many memory is available for user APP after initializing libxdot lorawan stack
Diff: examples/src/dot_util.cpp
- Revision:
- 25:56f7775c702f
- Parent:
- 24:d80afce304c6
- Child:
- 29:9e2c0d990ace
diff -r d80afce304c6 -r 56f7775c702f examples/src/dot_util.cpp --- a/examples/src/dot_util.cpp Tue Jul 11 10:46:17 2017 -0500 +++ b/examples/src/dot_util.cpp Wed Mar 14 14:38:08 2018 -0500 @@ -24,7 +24,17 @@ if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) { logInfo("frequency sub band ------- %u", dot->getFrequencySubBand()); } - logInfo("public network ----------- %s", dot->getPublicNetwork() ? "on" : "off"); + + std::string network_mode_str("Undefined"); + uint8_t network_mode = dot->getPublicNetwork(); + if (network_mode == lora::PRIVATE_MTS) + network_mode_str = "Private MTS"; + else if (network_mode == lora::PUBLIC_LORAWAN) + network_mode_str = "Public LoRaWAN"; + else if (network_mode == lora::PRIVATE_LORAWAN) + network_mode_str = "Private LoRaWAN"; + logInfo("public network ----------- %s", network_mode_str.c_str()); + logInfo("========================="); logInfo("credentials configuration"); logInfo("========================="); @@ -58,11 +68,11 @@ } } -void update_ota_config_name_phrase(std::string network_name, std::string network_passphrase, uint8_t frequency_sub_band, bool public_network, uint8_t ack) { +void update_ota_config_name_phrase(std::string network_name, std::string network_passphrase, uint8_t frequency_sub_band, lora::NetworkType network_type, uint8_t ack) { std::string current_network_name = dot->getNetworkName(); std::string current_network_passphrase = dot->getNetworkPassphrase(); uint8_t current_frequency_sub_band = dot->getFrequencySubBand(); - bool current_public_network = dot->getPublicNetwork(); + uint8_t current_network_type = dot->getPublicNetwork(); uint8_t current_ack = dot->getAck(); if (current_network_name != network_name) { @@ -88,10 +98,10 @@ } } - if (current_public_network != public_network) { - logInfo("changing public network from %s to %s", current_public_network ? "on" : "off", public_network ? "on" : "off"); - if (dot->setPublicNetwork(public_network) != mDot::MDOT_OK) { - logError("failed to set public network to %s", public_network ? "on" : "off"); + if (current_network_type != network_type) { + logInfo("changing public network from %d to %d", current_network_type, network_type); + if (dot->setPublicNetwork(network_type) != mDot::MDOT_OK) { + logError("failed to set public network to %d", network_type); } } @@ -292,7 +302,7 @@ logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); // in some frequency bands we need to wait until another channel is available before transmitting again uint32_t delay_s = (dot->getNextTxMs() / 1000) + 1; - if (delay_s < 2) { + if (delay_s < 5) { logInfo("waiting %lu s until next free channel", delay_s); wait(delay_s); } else {