
FF1705 support added
Dependencies: libxDot-dev-mbed5-deprecated ISL29011
Fork of Dot-Examples by
Dot-Examples rev. 31:7ec180e84cb6 have been tested with xdot-library 3.0.0-19-gb6c0ba2 and mbed-os-5.6.2
Revision 12:ec9768677cea, committed 2016-10-11
- Comitter:
- Mike Fiore
- Date:
- Tue Oct 11 13:17:42 2016 -0500
- Parent:
- 11:d2e31743433a
- Child:
- 13:f1d1ef71b3c4
- Commit message:
- default configuration and session in each example when starting for the first time
Changed in this revision
--- a/examples/inc/dot_util.h Tue Oct 11 11:49:56 2016 -0500 +++ b/examples/inc/dot_util.h Tue Oct 11 13:17:42 2016 -0500 @@ -18,6 +18,8 @@ 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_peer_to_peer_config(uint8_t *network_address, uint8_t *network_session_key, uint8_t *data_session_key, uint32_t tx_frequency, uint8_t tx_datarate, uint8_t tx_power); + void join_network(); void sleep_wake_rtc_only(bool deepsleep);
--- 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;
--- a/examples/src/class_c_example.cpp Tue Oct 11 11:49:56 2016 -0500 +++ b/examples/src/class_c_example.cpp Tue Oct 11 13:17:42 2016 -0500 @@ -112,7 +112,12 @@ dot = mDot::getInstance(); - // make sure library logging is turned on + // 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); // attach the custom events handler @@ -125,7 +130,7 @@ logError("failed to set network join mode to OTA"); } } - // 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 + // 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) @@ -150,10 +155,12 @@ // display configuration display_config(); +#if defined(TARGET_XDOT_L151CC) // configure the ISL29011 sensor on the xDot-DK for continuous ambient light sampling, 16 bit conversion, and maximum range lux.setMode(ISL29011::ALS_CONT); lux.setResolution(ISL29011::ADC_16BIT); lux.setRange(ISL29011::RNG_64000); +#endif while (true) { uint16_t light;
--- a/examples/src/manual_example.cpp Tue Oct 11 11:49:56 2016 -0500 +++ b/examples/src/manual_example.cpp Tue Oct 11 13:17:42 2016 -0500 @@ -38,44 +38,50 @@ 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(); - // update configuration if necessary - if (dot->getJoinMode() != mDot::MANUAL) { - logInfo("changing network join mode to MANUAL"); - if (dot->setJoinMode(mDot::MANUAL) != mDot::MDOT_OK) { - logError("failed to set network join mode to MANUAL"); + // make sure library logging is turned on + dot->setLogLevel(mts::MTSLog::INFO_LEVEL); + + // update configuration if necessary + if (dot->getJoinMode() != mDot::MANUAL) { + logInfo("changing network join mode to MANUAL"); + if (dot->setJoinMode(mDot::MANUAL) != mDot::MDOT_OK) { + logError("failed to set network join mode to MANUAL"); + } } - } - // in MANUAL join mode there is no join request/response transaction - // as long as the Dot is configured correctly and provisioned correctly on the gateway, it should be able to communicate - // network address - 4 bytes (00000001 - FFFFFFFE) - // network session key - 16 bytes - // data session key - 16 bytes - // to provision your Dot with a Conduit gateway, follow the following steps - // * ssh into the Conduit - // * provision the Dot using the lora-query application: http://www.multitech.net/developer/software/lora/lora-network-server/ - // lora-query -a 01020304 A 0102030401020304 <your Dot's device ID> 01020304010203040102030401020304 01020304010203040102030401020304 - // * if you change the network address, network session key, or data session key, make sure you update them on the gateway - // to provision your Dot with a 3rd party gateway, see the gateway or network provider documentation - update_manual_config(network_address, network_session_key, data_session_key, frequency_sub_band, public_network, ack); + // in MANUAL join mode there is no join request/response transaction + // as long as the Dot is configured correctly and provisioned correctly on the gateway, it should be able to communicate + // network address - 4 bytes (00000001 - FFFFFFFE) + // network session key - 16 bytes + // data session key - 16 bytes + // to provision your Dot with a Conduit gateway, follow the following steps + // * ssh into the Conduit + // * provision the Dot using the lora-query application: http://www.multitech.net/developer/software/lora/lora-network-server/ + // lora-query -a 01020304 A 0102030401020304 <your Dot's device ID> 01020304010203040102030401020304 01020304010203040102030401020304 + // * if you change the network address, network session key, or data session key, make sure you update them on the gateway + // to provision your Dot with a 3rd party gateway, see the gateway or network provider documentation + update_manual_config(network_address, network_session_key, data_session_key, frequency_sub_band, public_network, ack); - // save changes to configuration - logInfo("saving configuration"); - if (!dot->saveConfig()) { - logError("failed to save configuration"); - } + // save changes to configuration + logInfo("saving configuration"); + if (!dot->saveConfig()) { + logError("failed to save configuration"); + } - // restore the saved session if the dot woke from deepsleep mode - // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep - if (dot->getStandbyFlag()) { + // display configuration + display_config(); + } else { + // restore the saved session if the dot woke from deepsleep mode + // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep logInfo("restoring network session from NVM"); dot->restoreNetworkSession(); } - // display configuration - display_config(); while (true) { uint16_t light;
--- a/examples/src/ota_example.cpp Tue Oct 11 11:49:56 2016 -0500 +++ b/examples/src/ota_example.cpp Tue Oct 11 13:17:42 2016 -0500 @@ -41,39 +41,44 @@ 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(); - // update configuration if necessary - if (dot->getJoinMode() != mDot::OTA) { - logInfo("changing network join mode to OTA"); - if (dot->setJoinMode(mDot::OTA) != mDot::MDOT_OK) { - logError("failed to set network join mode to OTA"); + // make sure library logging is turned on + dot->setLogLevel(mts::MTSLog::INFO_LEVEL); + + // update configuration if necessary + if (dot->getJoinMode() != mDot::OTA) { + logInfo("changing network join mode to OTA"); + if (dot->setJoinMode(mDot::OTA) != mDot::MDOT_OK) { + logError("failed to set network join mode to OTA"); + } } - } - // 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); + // 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"); - } + // save changes to configuration + logInfo("saving configuration"); + if (!dot->saveConfig()) { + logError("failed to save configuration"); + } - // restore the saved session if the dot woke from deepsleep mode - // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep - if (dot->getStandbyFlag()) { + // display configuration + display_config(); + } else { + // restore the saved session if the dot woke from deepsleep mode + // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep logInfo("restoring network session from NVM"); dot->restoreNetworkSession(); } - // display configuration - display_config(); - while (true) { uint16_t light; std::vector<uint8_t> tx_data;
--- a/examples/src/peer_to_peer_example.cpp Tue Oct 11 11:49:56 2016 -0500 +++ b/examples/src/peer_to_peer_example.cpp Tue Oct 11 13:17:42 2016 -0500 @@ -111,6 +111,10 @@ dot = mDot::getInstance(); + // start from a well-known state + logInfo("defaulting Dot configuration"); + dot->resetConfig(); + // make sure library logging is turned on dot->setLogLevel(mts::MTSLog::INFO_LEVEL);