Example of using the mDot UDK with the X-NUCLEO-IKS01A2 board
Dependencies: MTS_X_NUCLEO_IKS01A2 libmDot-mbed5
Fork of mDot-IKS01A1 by
Diff: dot_util.cpp
- Revision:
- 13:e165a137c3af
- Parent:
- 12:63e90d375afd
--- a/dot_util.cpp Fri Jan 26 17:39:50 2018 +0000 +++ b/dot_util.cpp Fri Jan 26 17:53:23 2018 +0000 @@ -19,8 +19,9 @@ logInfo("====================="); logInfo("version ------------------ %s", dot->getId().c_str()); logInfo("device ID/EUI ------------ %s", mts::Text::bin2hexString(dot->getDeviceId()).c_str()); - logInfo("frequency band ----------- %s", mDot::FrequencyBandStr(dot->getFrequencyBand()).c_str()); - if (dot->getFrequencySubBand() != mDot::FB_EU868) { + logInfo("default channel plan ----- %s", mDot::FrequencyBandStr(dot->getDefaultFrequencyBand()).c_str()); + logInfo("current channel plan ----- %s", mDot::FrequencyBandStr(dot->getFrequencyBand()).c_str()); + if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) { logInfo("frequency sub band ------- %u", dot->getFrequencySubBand()); } logInfo("public network ----------- %s", dot->getPublicNetwork() ? "on" : "off"); @@ -49,7 +50,12 @@ } logInfo("TX datarate -------------- %s", mDot::DataRateStr(dot->getTxDataRate()).c_str()); logInfo("TX power ----------------- %lu dBm", dot->getTxPower()); - logInfo("atnenna gain ------------- %u dBm", dot->getAntennaGain()); + logInfo("antenna gain ------------- %u dBm", dot->getAntennaGain()); + logInfo("LBT ---------------------- %s", dot->getLbtTimeUs() ? "on" : "off"); + if (dot->getLbtTimeUs()) { + logInfo("LBT time ----------------- %lu us", dot->getLbtTimeUs()); + logInfo("LBT threshold ------------ %d dBm", dot->getLbtThreshold()); + } } 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) { @@ -73,11 +79,13 @@ } } - if (current_frequency_sub_band != frequency_sub_band) { - logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band); - if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) { - logError("failed to set frequency sub band to %u", frequency_sub_band); - } + if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) { + if (current_frequency_sub_band != frequency_sub_band) { + logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band); + if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) { + logError("failed to set frequency sub band to %u", frequency_sub_band); + } + } } if (current_public_network != public_network) { @@ -119,11 +127,13 @@ } } - if (current_frequency_sub_band != frequency_sub_band) { - logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band); - if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) { - logError("failed to set frequency sub band to %u", frequency_sub_band); - } + if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) { + if (current_frequency_sub_band != frequency_sub_band) { + logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band); + if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) { + logError("failed to set frequency sub band to %u", frequency_sub_band); + } + } } if (current_public_network != public_network) { @@ -692,7 +702,7 @@ } void send_data(std::vector<uint8_t> data) { - uint32_t ret; + int32_t ret; ret = dot->send(data); if (ret != mDot::MDOT_OK) { @@ -701,3 +711,4 @@ logInfo("successfully sent data to %s", dot->getJoinMode() == mDot::PEER_TO_PEER ? "peer" : "gateway"); } } +