Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot-mbed5 picojson ISL29011
Revision 25:56f7775c702f, committed 2018-03-14
- Comitter:
- Evan Hosseini
- Date:
- Wed Mar 14 14:38:08 2018 -0500
- Parent:
- 24:d80afce304c6
- Child:
- 26:8bdfb39a5743
- Commit message:
- Updates for the dot 3.1 release
Changed in this revision
--- a/.hgignore Tue Jul 11 10:46:17 2017 -0500 +++ b/.hgignore Wed Mar 14 14:38:08 2018 -0500 @@ -2,3 +2,5 @@ .build /mdot/ /mdot-library/ +/BUILD/ +/.git/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Wed Mar 14 14:38:08 2018 -0500 @@ -0,0 +1,22 @@ +Instructions for building Dot-Examples + +1. Import dot-examples +$ mbed import http://os.mbed.com/teams/MultiTech/code/Dot-Examples/ + +2. cd to the Dot-Examples/examples and import the dot library stack +Choose either the stable or dev library for your dot device +e.g. to get the latest development library for the xDot +$ mbed add http://os.mbed.com/teams/MultiTech/code/libxDot-dev-mbed5/ + +3. Update mbed-os revision to match that of the dot library you just imported. +This information can be found in the library's commit history. +e.g. +$ cd Dot-Examples/examples/mbed-os +$ mbed update mbed-os-5.7.6 + +4. Modify the Dot-Examples/examples/example_config.h to select which example to build +By default, the OTA example is selected + +5. Once the example is selected, modify the example source file to match the configuration of your gateway. +Make sure the network_name, network_passphrase, frequency_sub_band (US), public_network, and join_delay settings match that of your gateway +
--- a/examples/inc/dot_util.h Tue Jul 11 10:46:17 2017 -0500 +++ b/examples/inc/dot_util.h Wed Mar 14 14:38:08 2018 -0500 @@ -6,14 +6,13 @@ #include "ChannelPlans.h" #include "MTSLog.h" #include "MTSText.h" -#include "ISL29011.h" #include "example_config.h" extern mDot* dot; void display_config(); -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); 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);
--- a/examples/lib/ISL29011.lib Tue Jul 11 10:46:17 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/Multi-Hackers/code/ISL29011/#c1d5f4999b9e
--- a/examples/src/auto_ota_example.cpp Tue Jul 11 10:46:17 2017 -0500
+++ b/examples/src/auto_ota_example.cpp Wed Mar 14 14:38:08 2018 -0500
@@ -27,7 +27,8 @@
static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
static uint8_t frequency_sub_band = 0;
-static bool public_network = false;
+static lora::NetworkType public_network = lora::PUBLIC_LORAWAN;
+static uint8_t join_delay = 5;
static uint8_t ack = 0;
static bool adr = true;
@@ -42,13 +43,6 @@
Serial pc(USBTX, USBRX);
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
int main() {
// Custom event handler for automatically displaying RX data
RadioEvent events;
@@ -115,6 +109,9 @@
// enable or disable Adaptive Data Rate
dot->setAdr(adr);
+
+ // Configure the join delay
+ dot->setJoinDelay(join_delay);
// save changes to configuration
logInfo("saving configuration");
@@ -126,8 +123,8 @@
display_config();
}
+ uint8_t counter = 0;
while (true) {
- uint16_t light;
std::vector<uint8_t> tx_data;
// join network if not joined
@@ -135,30 +132,10 @@
join_network();
}
-#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);
-
- // get the latest light sample and send it to the gateway
- light = lux.getData();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
+ tx_data.push_back(++counter);
+ logInfo("sending uplink with data = %d", counter);
send_data(tx_data);
- // put the LSL29011 ambient light sensor into a low power state
- lux.setMode(ISL29011::PWR_DOWN);
-#else
- // get some dummy data and send it to the gateway
- light = lux.read_u16();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
-#endif
-
// ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method
//sleep_wake_rtc_only(deep_sleep);
//sleep_wake_interrupt_only(deep_sleep);
--- a/examples/src/class_c_example.cpp Tue Jul 11 10:46:17 2017 -0500
+++ b/examples/src/class_c_example.cpp Wed Mar 14 14:38:08 2018 -0500
@@ -27,7 +27,8 @@
static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
static uint8_t frequency_sub_band = 0;
-static bool public_network = false;
+static lora::NetworkType public_network = lora::PUBLIC_LORAWAN;
+static uint8_t join_delay = 5;
static uint8_t ack = 1;
static bool adr = true;
@@ -36,13 +37,6 @@
Serial pc(USBTX, USBRX);
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
int main() {
// Custom event handler for automatically displaying RX data
RadioEvent events;
@@ -109,7 +103,10 @@
// enable or disable Adaptive Data Rate
dot->setAdr(adr);
-
+
+ // Configure the join delay
+ dot->setJoinDelay(join_delay);
+
// save changes to configuration
logInfo("saving configuration");
if (!dot->saveConfig()) {
@@ -119,15 +116,8 @@
// 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
-
+ uint8_t counter = 0;
while (true) {
- uint16_t light;
std::vector<uint8_t> tx_data;
// join network if not joined
@@ -135,21 +125,9 @@
join_network();
}
-#if defined(TARGET_XDOT_L151CC)
- // get the latest light sample and send it to the gateway
- light = lux.getData();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
+ tx_data.push_back(++counter);
+ logInfo("sending uplink with data = %d", counter);
send_data(tx_data);
-#else
- // get some dummy data and send it to the gateway
- light = lux.read_u16();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
-#endif
// the Dot can't sleep in class C mode
// it must be waiting for data from the gateway
--- 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 {
--- a/examples/src/manual_example.cpp Tue Jul 11 10:46:17 2017 -0500
+++ b/examples/src/manual_example.cpp Wed Mar 14 14:38:08 2018 -0500
@@ -24,7 +24,8 @@
static uint8_t network_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
static uint8_t data_session_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
static uint8_t frequency_sub_band = 6;
-static bool public_network = false;
+static lora::NetworkType public_network = lora::PUBLIC_LORAWAN;
+static uint8_t join_delay = 5;
static uint8_t ack = 1;
static bool adr = true;
@@ -39,13 +40,6 @@
Serial pc(USBTX, USBRX);
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
int main() {
// Custom event handler for automatically displaying RX data
RadioEvent events;
@@ -111,6 +105,9 @@
// enable or disable Adaptive Data Rate
dot->setAdr(adr);
+ // Configure the join delay
+ dot->setJoinDelay(join_delay);
+
// save changes to configuration
logInfo("saving configuration");
if (!dot->saveConfig()) {
@@ -127,34 +124,14 @@
}
+ uint8_t counter = 0;
while (true) {
- uint16_t light;
std::vector<uint8_t> tx_data;
-#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);
-
- // get the latest light sample and send it to the gateway
- light = lux.getData();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
+ tx_data.push_back(++counter);
+ logInfo("sending uplink with data = %d", counter);
send_data(tx_data);
- // put the LSL29011 ambient light sensor into a low power state
- lux.setMode(ISL29011::PWR_DOWN);
-#else
- // get some dummy data and send it to the gateway
- light = lux.read_u16();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
-#endif
-
// if going into deepsleep mode, save the session so we don't need to join again after waking up
// not necessary if going into sleep mode since RAM is retained
if (deep_sleep) {
--- a/examples/src/ota_example.cpp Tue Jul 11 10:46:17 2017 -0500
+++ b/examples/src/ota_example.cpp Wed Mar 14 14:38:08 2018 -0500
@@ -22,12 +22,13 @@
// * either the network name and passphrase can be used or //
// the network ID (8 bytes) and KEY (16 bytes) //
/////////////////////////////////////////////////////////////
-static std::string network_name = "MultiTech";
+static std::string network_name = "Packers-aep14x";
static std::string network_passphrase = "MultiTech";
static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 };
static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B };
static uint8_t frequency_sub_band = 0;
-static bool public_network = false;
+static lora::NetworkType public_network = lora::PUBLIC_LORAWAN;
+static uint8_t join_delay = 5;
static uint8_t ack = 0;
static bool adr = true;
@@ -42,13 +43,6 @@
Serial pc(USBTX, USBRX);
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
int main() {
// Custom event handler for automatically displaying RX data
RadioEvent events;
@@ -114,7 +108,10 @@
// enable or disable Adaptive Data Rate
dot->setAdr(adr);
-
+
+ // Configure the join delay
+ dot->setJoinDelay(join_delay);
+
// save changes to configuration
logInfo("saving configuration");
if (!dot->saveConfig()) {
@@ -130,8 +127,8 @@
dot->restoreNetworkSession();
}
+ uint8_t counter = 0;
while (true) {
- uint16_t light;
std::vector<uint8_t> tx_data;
// join network if not joined
@@ -139,30 +136,10 @@
join_network();
}
-#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);
-
- // get the latest light sample and send it to the gateway
- light = lux.getData();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
+ tx_data.push_back(++counter);
+ logInfo("sending uplink with data = %d", counter);
send_data(tx_data);
- // put the LSL29011 ambient light sensor into a low power state
- lux.setMode(ISL29011::PWR_DOWN);
-#else
- // get some dummy data and send it to the gateway
- light = lux.read_u16();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
-#endif
-
// if going into deepsleep mode, save the session so we don't need to join again after waking up
// not necessary if going into sleep mode since RAM is retained
if (deep_sleep) {
@@ -174,6 +151,8 @@
//sleep_wake_rtc_only(deep_sleep);
//sleep_wake_interrupt_only(deep_sleep);
sleep_wake_rtc_or_interrupt(deep_sleep);
+
+ logInfo("Did we ever return from our slumber???");
}
return 0;
--- a/examples/src/peer_to_peer_example.cpp Tue Jul 11 10:46:17 2017 -0500
+++ b/examples/src/peer_to_peer_example.cpp Wed Mar 14 14:38:08 2018 -0500
@@ -28,13 +28,6 @@
Serial pc(USBTX, USBRX);
-#if defined(TARGET_XDOT_L151CC)
-I2C i2c(I2C_SDA, I2C_SCL);
-ISL29011 lux(i2c);
-#else
-AnalogIn lux(XBEE_AD0);
-#endif
-
int main() {
// Custom event handler for automatically displaying RX data
RadioEvent events;
@@ -154,15 +147,8 @@
// 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
-
+ uint8_t counter = 0;
while (true) {
- uint16_t light;
std::vector<uint8_t> tx_data;
// join network if not joined
@@ -170,21 +156,9 @@
join_network();
}
-#if defined(TARGET_XDOT_L151CC)
- // get the latest light sample and send it to the gateway
- light = lux.getData();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
+ tx_data.push_back(++counter);
+ logInfo("sending uplink with data = %d", counter);
send_data(tx_data);
-#else
- // get some dummy data and send it to the gateway
- light = lux.read_u16();
- tx_data.push_back((light >> 8) & 0xFF);
- tx_data.push_back(light & 0xFF);
- logInfo("light: %lu [0x%04X]", light, light);
- send_data(tx_data);
-#endif
// the Dot can't sleep in PEER_TO_PEER mode
// it must be waiting for data from the other Dot
@@ -197,4 +171,3 @@
}
#endif
-
--- a/setup.sh Tue Jul 11 10:46:17 2017 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -if [ ! -d ISL29011 ]; then - hg clone https://developer.mbed.org/teams/Multi-Hackers/code/ISL29011/ -fi