fp
Dependencies: libmDot-mbed5 ISL29011
Diff: examples/src/dot_util.cpp
- Revision:
- 31:b1d5811e3d5d
- Parent:
- 30:2f5ae37e6c47
- Child:
- 33:15ea8f985c54
--- a/examples/src/dot_util.cpp Mon Apr 30 14:46:28 2018 -0500 +++ b/examples/src/dot_util.cpp Thu Aug 23 15:40:00 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,9 @@ } } - 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) { + if (dot->setPublicNetwork(network_type) != mDot::MDOT_OK) { + logError("failed to set network type"); } } @@ -103,11 +112,11 @@ } } -void update_ota_config_id_key(uint8_t *network_id, uint8_t *network_key, uint8_t frequency_sub_band, bool public_network, uint8_t ack) { +void update_ota_config_id_key(uint8_t *network_id, uint8_t *network_key, uint8_t frequency_sub_band, lora::NetworkType network_type, uint8_t ack) { std::vector<uint8_t> current_network_id = dot->getNetworkId(); std::vector<uint8_t> current_network_key = dot->getNetworkKey(); 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(); std::vector<uint8_t> network_id_vector(network_id, network_id + 8); @@ -136,10 +145,9 @@ } } - 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) { + if (dot->setPublicNetwork(network_type) != mDot::MDOT_OK) { + logError("failed to set network type"); } } @@ -151,12 +159,12 @@ } } -void update_manual_config(uint8_t *network_address, uint8_t *network_session_key, uint8_t *data_session_key, uint8_t frequency_sub_band, bool public_network, uint8_t ack) { +void update_manual_config(uint8_t *network_address, uint8_t *network_session_key, uint8_t *data_session_key, uint8_t frequency_sub_band, lora::NetworkType network_type, uint8_t ack) { std::vector<uint8_t> current_network_address = dot->getNetworkAddress(); std::vector<uint8_t> current_network_session_key = dot->getNetworkSessionKey(); std::vector<uint8_t> current_data_session_key = dot->getDataSessionKey(); 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(); std::vector<uint8_t> network_address_vector(network_address, network_address + 4); @@ -191,10 +199,9 @@ } } - 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) { + if (dot->setPublicNetwork(network_type) != mDot::MDOT_OK) { + logError("failed to set network type"); } }