LoRaWAN demo.

Dependencies:   DebouncedInterrupt modem_ref_helper

Files at this revision

API Documentation at this revision

Comitter:
Jeej
Date:
Thu Oct 11 10:54:27 2018 +0000
Parent:
11:2c679f77af47
Child:
13:b9420183fbfc
Commit message:
v1.0.2 Updated API.

Changed in this revision

files.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
modem_ref_helper.lib Show annotated file Show diff for this revision Revisions of this file
--- a/files.cpp	Wed Sep 26 14:04:39 2018 +0000
+++ b/files.cpp	Thu Oct 11 10:54:27 2018 +0000
@@ -6,7 +6,7 @@
 #define __DEVICE_ID__               0x00000017
 
 alp_file_header_t h_rev = {
-    .perm = RW_R,
+    .perm = RWR_R_,
     .prop = FS_PERMANENT_NOTIF,
     .afid = FID_ACTP_RPT_FULL,
     .ifid = IFID_REPORT,
@@ -28,14 +28,14 @@
     .fw_version.id       = 0,
     .fw_version.major    = 1,
     .fw_version.minor    = 0,
-    .fw_version.patch    = 1,
+    .fw_version.patch    = 2,
     .fw_version.hash     = 0x00000000,
     /// Not used
     .cup_max_size        = 0x00000000
 };
 
 alp_file_header_t h_sensor_config = {
-    .perm = RW_RW,
+    .perm = RWRWRW,
     .prop = FS_VOLATILE,
     .afid = 0,
     .ifid = 0,
@@ -53,7 +53,7 @@
 };
 
 alp_file_header_t h_sensor_light = {
-    .perm = RW_R,
+    .perm = RWRWR_,
     .prop = FS_VOLATILE_NOTIF,
     .afid = FID_ACTP_RPT_FULL,
     .ifid = IFID_REPORT,
@@ -62,7 +62,7 @@
 };
 
 alp_file_header_t h_alarm = {
-    .perm = RW_R,
+    .perm = RWRWR_,
     .prop = FS_VOLATILE,
     .afid = 0,
     .ifid = 0,
--- a/main.cpp	Wed Sep 26 14:04:39 2018 +0000
+++ b/main.cpp	Thu Oct 11 10:54:27 2018 +0000
@@ -82,28 +82,18 @@
     }
 }
 
-void print_resp(uint8_t id, int status)
-{
-    switch (status)
-    {
-        case ALP_ERR_NONE:
-            PRINT("Resp[%d]: OK\n", id);
-            break;
-        default:
-            PRINT("Resp[%d]: error %d\n", id, status);
-            break;
-    }
-}
-
 // Callback for id User
 void my_main_callback(uint8_t terminal, int8_t err, uint8_t id)
 {
     (void)id;
     
-    print_resp(id, err);
+    if (ALP_ERR_NONE != err)
+    {
+        modem_print_error(ALP_ITF_TYPE_D7A, err);
+    }
     
     if (terminal)
-    {    
+    {
         modem_ready[id].release();
     }
 }
@@ -301,10 +291,6 @@
     uint8_t id = modem_get_id(my_main_callback);
     
     DPRINT("Register Files\n");
-    
-    // HOST Revision is a local file. Uses D7AActP Notification.
-    modem_update_file(FID_HOST_REV, (alp_file_header_t*)&h_rev, (uint8_t*)&f_rev);
-    
     // Create report file on modem.
     modem_update_file(FID_SENSOR_LIGHT, (alp_file_header_t*)&h_sensor_light, NULL);
 
@@ -325,7 +311,7 @@
     modem_activate_itf(ALP_ITF_TYPE_D7A, 24, 0, ALP_D7A_ISTAT_UNS|ALP_D7A_ISTAT_RESP, true, id);
     modem_ready[id].wait();
     
-    PRINT("Start LoRaWAN Stack\n");
+    PRINT("Start LoRaWAN Stack (Join)\n");
     modem_activate_itf(ALP_ITF_TYPE_LWAN, 1, FID_LWAN_ITF0, 0, true, id);
     modem_ready[id].wait();
     
@@ -334,8 +320,8 @@
     modem_ready[id].wait();
     
     PRINT("Notify FW Version\n");
-    modem_notify_file(FID_HOST_REV, 0, SIZE_HOST_REV, id);
-    modem_ready[id].wait();
+    uint8_t default_root_key[16] = DEFAULT_ROOT_KEY;
+    modem_notify_host_rev(&f_rev, &h_rev, default_root_key);
     
     modem_free_id(id);
     
--- a/modem_ref_helper.lib	Wed Sep 26 14:04:39 2018 +0000
+++ b/modem_ref_helper.lib	Thu Oct 11 10:54:27 2018 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/WizziLab/code/modem_ref_helper/#c6874105b3d6
+https://developer.mbed.org/teams/WizziLab/code/modem_ref_helper/#7563b8e53e1d