Version del programa usado para la Expo IOT 2018 - Strada Hotel
Dependencies: DHT HX711 libmDot-mbed5 ISL29011
Fork of Dot-Examples by
Diff: examples/src/auto_ota_example.cpp
- Revision:
- 12:ec9768677cea
- Parent:
- 9:72d3203279b2
- Child:
- 14:19fae4509473
--- a/examples/src/auto_ota_example.cpp Tue Oct 11 11:49:56 2016 -0500 +++ b/examples/src/auto_ota_example.cpp Tue Oct 11 13:17:42 2016 -0500 @@ -41,32 +41,39 @@ dot = mDot::getInstance(); - // make sure library logging is turned on - dot->setLogLevel(mts::MTSLog::INFO_LEVEL); + if (!dot->getStandbyFlag()) { + // start from a well-known state + logInfo("defaulting Dot configuration"); + dot->resetConfig(); + dot->resetNetworkSession(); + + // make sure library logging is turned on + dot->setLogLevel(mts::MTSLog::INFO_LEVEL); - // update configuration if necessary - // in AUTO_OTA mode the session is automatically saved, so saveNetworkSession and restoreNetworkSession are not needed - if (dot->getJoinMode() != mDot::AUTO_OTA) { - logInfo("changing network join mode to AUTO_OTA"); - if (dot->setJoinMode(mDot::AUTO_OTA) != mDot::MDOT_OK) { - logError("failed to set network join mode to AUTO_OTA"); + // update configuration if necessary + // in AUTO_OTA mode the session is automatically saved, so saveNetworkSession and restoreNetworkSession are not needed + if (dot->getJoinMode() != mDot::AUTO_OTA) { + logInfo("changing network join mode to AUTO_OTA"); + if (dot->setJoinMode(mDot::AUTO_OTA) != mDot::MDOT_OK) { + logError("failed to set network join mode to AUTO_OTA"); + } } + // in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an ID and KEY + // only one method or the other should be used! + // network ID = crc64(network name) + // network KEY = cmac(network passphrase) + update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack); + //update_ota_config_id_key(network_id, network_key, frequency_sub_band, public_network, ack); + + // save changes to configuration + logInfo("saving configuration"); + if (!dot->saveConfig()) { + logError("failed to save configuration"); + } + + // display configuration + display_config(); } - // in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an EUI and KEY - // only one method or the other should be used! - // network ID = crc64(network name) - // network KEY = cmac(network passphrase) - update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack); - //update_ota_config_id_key(network_id, network_key, frequency_sub_band, public_network, ack); - - // save changes to configuration - logInfo("saving configuration"); - if (!dot->saveConfig()) { - logError("failed to save configuration"); - } - - // display configuration - display_config(); while (true) { uint16_t light;