MultiTech mDot Test Application for Loriot.io LoRaWAN Cloud service

Dependencies:   libmDot mbed-rtos mbed-src

Fork of mDot_test by Semtech

Files at this revision

API Documentation at this revision

Comitter:
jknapp_smtc
Date:
Fri Mar 04 00:59:45 2016 +0000
Parent:
6:b1afa2592e36
Child:
8:4b47a8973f91
Commit message:
Changed to Personalization as Default mode

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Nov 17 18:17:28 2015 +0000
+++ b/main.cpp	Fri Mar 04 00:59:45 2016 +0000
@@ -13,13 +13,27 @@
 
 static const uint8_t DEVKEY[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; // Normal
 static const uint8_t APPEUI[8]  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  }; // SMTC AppEUI - Most Significant Byte First
-static uint8_t       config_frequency_sub_band = 0; // 0 = Enable all channels, 1 = 1st eight channels
+
+//DevAddr  01DC266E 
+//NWKSKEY  C7 58 CB 09 BD F2 C7 0E 5F 4C FA 5B 7A 96 68 D8
+//APPSKEY  AC B3 B3 A1 B3 26 25 F7 24 3F B4 39 65 06 38 A7
+static const uint8_t DEV_ADDR[4] = { 0x01, 0xDC, 0x26, 0x6E };
+static const uint8_t NETSKEY[16] = { 0xC7, 0x58, 0xCB, 0x09, 0xBD, 0xF2, 0xC7, 0x0E, 0x5F, 0x4C, 0xFA, 0x5B, 0x7A, 0x96, 0x68, 0xD8 }; // Normal
+static const uint8_t APPSKEY[16] = { 0xAC, 0xB3, 0xB3, 0xA1, 0xB3, 0x26, 0x25, 0xF7, 0x24, 0x3F, 0xB4, 0x39, 0x65, 0x06, 0x38, 0xA7 }; // Normal
+
+static uint8_t       config_frequency_sub_band = 1; // 0 = Enable all channels, 1 = 1st eight channels
 
 /* ********************************************** */
 
 static std::vector<uint8_t> AppKey (DEVKEY, DEVKEY + sizeof(DEVKEY)/sizeof(uint8_t) );
 static std::vector<uint8_t> AppEUI (APPEUI, APPEUI + sizeof(APPEUI)/sizeof(uint8_t) ); 
 
+static std::vector<uint8_t> DevAddr (DEV_ADDR, DEV_ADDR + sizeof(DEV_ADDR)/sizeof(uint8_t) );
+static std::vector<uint8_t> NetSKey (NETSKEY, NETSKEY + sizeof(NETSKEY)/sizeof(uint8_t) ); 
+static std::vector<uint8_t> AppSKey (APPSKEY, APPSKEY + sizeof(APPSKEY)/sizeof(uint8_t) );
+
+
+
 InterruptIn button(PB_1);
 DigitalOut  drive_high(PB_0);
 DigitalIn   door_open(PA_7);
@@ -73,24 +87,34 @@
      * @param id a vector of 8 bytes
      * @returns MDOT_OK if success
      */
-    while ((ret = dot->setNetworkId(AppEUI)) != mDot::MDOT_OK) {
-        logError("failed to set AppEUI: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
+//    while ((ret = dot->setNetworkId(AppEUI)) != mDot::MDOT_OK) {
+//        logError("failed to set AppEUI: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
+//    }
+//    while ((ret = dot->setNetworkKey(AppKey)) != mDot::MDOT_OK) {
+//        logError("failed to set AppEUI: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
+//    }
+    while ((ret = dot->setNetworkAddress(DevAddr)) != mDot::MDOT_OK) {
+        logError("failed to set DevAddr: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
     }
-    while ((ret = dot->setNetworkKey(AppKey)) != mDot::MDOT_OK) {
-        logError("failed to set AppEUI: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
+    while ((ret = dot->setNetworkSessionKey(NetSKey)) != mDot::MDOT_OK) {
+        logError("failed to set NetworkSessionKey: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
+    }
+    while ((ret = dot->setDataSessionKey(AppSKey)) != mDot::MDOT_OK) {
+        logError("failed to set App Session Key: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
     }
 
     logInfo("enabling activity LED");
     dot->setActivityLedEnable(true);
 
     logInfo("joining network");
+    dot->setJoinMode( dot->MANUAL ); // 0 = Manual and 1 = OtAA
     while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
         logError("failed to join network: [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
         wait_ms(dot->getNextTxMs() + 1);
     }
     logInfo("joined");
 
-    dot->setAck(3); // Use Confirmed frames and try three times
+    //dot->setAck(3); // Use Confirmed frames and try three times
 
     while (1) {
 
--- a/mbed-rtos.lib	Tue Nov 17 18:17:28 2015 +0000
+++ b/mbed-rtos.lib	Fri Mar 04 00:59:45 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#d7bd06319118
+http://mbed.org/users/mbed_official/code/mbed-rtos/#dfc27975e193