Shoalhaven Water / Mbed OS Cloudtracker

Dependencies:   libmDot-mbed5 ISL29011

Files at this revision

API Documentation at this revision

Comitter:
Evan Hosseini
Date:
Thu Aug 23 15:40:00 2018 -0500
Parent:
30:2f5ae37e6c47
Child:
32:febff0fd3195
Commit message:
Updates for version 3.1 of the dot library

Changed in this revision

examples/inc/dot_util.h Show annotated file Show diff for this revision Revisions of this file
examples/src/auto_ota_example.cpp Show annotated file Show diff for this revision Revisions of this file
examples/src/class_c_example.cpp Show annotated file Show diff for this revision Revisions of this file
examples/src/dot_util.cpp Show annotated file Show diff for this revision Revisions of this file
examples/src/manual_example.cpp Show annotated file Show diff for this revision Revisions of this file
examples/src/ota_example.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- a/examples/inc/dot_util.h	Mon Apr 30 14:46:28 2018 -0500
+++ b/examples/inc/dot_util.h	Thu Aug 23 15:40:00 2018 -0500
@@ -13,11 +13,11 @@
 
 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);
 
-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 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);
 
--- a/examples/src/auto_ota_example.cpp	Mon Apr 30 14:46:28 2018 -0500
+++ b/examples/src/auto_ota_example.cpp	Thu Aug 23 15:40:00 2018 -0500
@@ -27,7 +27,7 @@
 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 = true;
+static lora::NetworkType network_type = lora::PUBLIC_LORAWAN;
 static uint8_t join_delay = 5;
 static uint8_t ack = 0;
 static bool adr = true;
@@ -108,8 +108,8 @@
         // 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);
+        update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, network_type, ack);
+        //update_ota_config_id_key(network_id, network_key, frequency_sub_band, network_type, ack);
     
         // configure network link checks
         // network link checks are a good alternative to requiring the gateway to ACK every packet and should allow a single gateway to handle more Dots
--- a/examples/src/class_c_example.cpp	Mon Apr 30 14:46:28 2018 -0500
+++ b/examples/src/class_c_example.cpp	Thu Aug 23 15:40:00 2018 -0500
@@ -27,7 +27,7 @@
 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 = true;
+static lora::NetworkType network_type = lora::PUBLIC_LORAWAN;
 static uint8_t join_delay = 5;
 static uint8_t ack = 1;
 static bool adr = true;
@@ -100,8 +100,8 @@
     // 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);
+    update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, network_type, ack);
+    //update_ota_config_id_key(network_id, network_key, frequency_sub_band, network_type, ack);
 
     // configure the Dot for class C operation
     // the Dot must also be configured on the gateway for class C
--- 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");
         }
     }
     
--- a/examples/src/manual_example.cpp	Mon Apr 30 14:46:28 2018 -0500
+++ b/examples/src/manual_example.cpp	Thu Aug 23 15:40:00 2018 -0500
@@ -24,7 +24,7 @@
 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 = true;
+static lora::NetworkType network_type = lora::PUBLIC_LORAWAN;
 static uint8_t join_delay = 5;
 static uint8_t ack = 1;
 static bool adr = true;
@@ -111,7 +111,7 @@
         //      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);
+        update_manual_config(network_address, network_session_key, data_session_key, frequency_sub_band, network_type, ack);
 
         // enable or disable Adaptive Data Rate
         dot->setAdr(adr);
--- a/examples/src/ota_example.cpp	Mon Apr 30 14:46:28 2018 -0500
+++ b/examples/src/ota_example.cpp	Thu Aug 23 15:40:00 2018 -0500
@@ -27,7 +27,7 @@
 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 = true;
+static lora::NetworkType network_type = lora::PUBLIC_LORAWAN;
 static uint8_t join_delay = 5;
 static uint8_t ack = 0;
 static bool adr = true;
@@ -107,8 +107,8 @@
         // 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);
+        update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, network_type, ack);
+        //update_ota_config_id_key(network_id, network_key, frequency_sub_band, network_type, ack);
 
         // configure network link checks
         // network link checks are a good alternative to requiring the gateway to ACK every packet and should allow a single gateway to handle more Dots
--- a/mbed-os.lib	Mon Apr 30 14:46:28 2018 -0500
+++ b/mbed-os.lib	Thu Aug 23 15:40:00 2018 -0500
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#fc1836545dcc2fc86f03b01292b62bf2089f67c3
+https://github.com/ARMmbed/mbed-os/#16bac101a6b7b4724023dcf86ece1548e3a23cbf