Modified Connect Example showing how to set the APP-EUI and APP-KEY

Dependencies:   libmDot mbed-rtos mbed

Fork of mDot_LoRa_Connect_Example_ABPA by MultiTech

Revision:
6:ac306e26e4cc
Parent:
5:6b988a804fcb
--- a/main.cpp	Tue Mar 29 13:41:12 2016 +0000
+++ b/main.cpp	Wed Mar 30 13:16:09 2016 +0000
@@ -7,9 +7,9 @@
 
 // these options must match the settings on your Conduit
 // uncomment the following lines and edit their values to match your configuration
-static uint8_t config_network_addr[] = { 0x01, 0x02, 0x03, 0x04 };
-static uint8_t config_network_nskey[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
-static uint8_t config_network_dskey[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
+static uint8_t config_app_eui[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
+static uint8_t config_app_key[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 };
+
 static uint8_t config_frequency_sub_band = 1;
 
 int main() {
@@ -45,33 +45,23 @@
     
     std::vector<uint8_t> temp;
     
-    for (int i = 0; i < 4; i++) {
-        temp.push_back(config_network_addr[i]);    
+    for (int i = 0; i < 16; i++) {
+        temp.push_back(config_app_eui[i]);    
     }
     
-    logInfo("setting network addr");
-    if ((ret = dot->setNetworkAddress(temp)) != mDot::MDOT_OK) {
-        logError("failed to set network name %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
+    logInfo("setting app eui");
+    if ((ret = dot->setNetworkId(temp)) != mDot::MDOT_OK) {
+        logError("failed to set app eui %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
     }
     
     temp.clear();
     for (int i = 0; i < 16; i++) {
-        temp.push_back(config_network_nskey[i]);    
-    }
-    
-    logInfo("setting network password");
-    if ((ret = dot->setNetworkSessionKey(temp)) != mDot::MDOT_OK) {
-        logError("failed to set network password %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
+        temp.push_back(config_app_key[i]);    
     }
     
-    temp.clear();
-    for (int i = 0; i < 16; i++) {
-        temp.push_back(config_network_dskey[i]);    
-    }
-    
-    logInfo("setting network password");
-    if ((ret = dot->setDataSessionKey(temp)) != mDot::MDOT_OK) {
-        logError("failed to set network password %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
+    logInfo("setting app key");
+    if ((ret = dot->setNetworkKey(temp)) != mDot::MDOT_OK) {
+        logError("failed to set app key %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
     }
     
     // a higher spreading factor allows for longer range but lower throughput