Fork for Get Started Demo

Dependencies:   DebouncedInterrupt dash7-alp mbed-rtos mbed wizzi-utils

Fork of D7A_Demo_full by WizziLab

Revision:
11:1a5a4f7cc5d3
Parent:
10:e16d5cfd4198
Child:
12:d17ef6ce50c8
--- a/main.cpp	Mon Nov 30 15:18:13 2015 +0000
+++ b/main.cpp	Mon Nov 30 18:02:07 2015 +0000
@@ -3,43 +3,12 @@
 #include "dbg.h"
 #include "DebouncedInterrupt.h"
 #include "system.h"
-#include "file_sys.h"
+#include "files.h"
 #include "alp.h"
 
 // Semaphore for notifiying button presses
 Semaphore button_user(1);
 
-revision_t revision = {
-    .nw_stat = 0,
-    .nw_seq = 255,
-    // These data are parsed to identify the device
-    .manufacturer_id    = __MANUFACTURER_ID__,
-    .device_id          = __DEVICE_ID__,
-    .fw_version.fw_id   = __FW_ID__,
-    .fw_version.major   = __FW_MAJOR__,
-    .fw_version.minor   = __FW_MINOR__,
-    .fw_version.patch   = __FW_PATCH__,
-    .fw_version.hash    = __FW_HASH__,
-    .hw_version         = __HW_ID__,
-    .fs_crc             = 0,
-};
-
-alarm_data_t alarm_data = {
-    .nw_stat = 0,
-    .nw_seq = 255,
-    .status = true,
-};
-
-alarm_cmd_t alarm_cmd = {
-    .cmd = 0,
-};
-
-temp_data_t temp_data = {
-    .nw_stat = 0,
-    .nw_seq = 255,
-    .value = 0,
-};
-
 alp_err_t d7_write_file(const uint8_t file_id,
                         const uint16_t offset,
                         const uint16_t file_size,
@@ -133,34 +102,6 @@
 };
 
 
-const d7_file_header_t revision_device_fh = {
-    .access_class = ACCESS_CLASS_GW,
-    .notify = true,
-    .file_size = REVISION_DEVICE_FILE_SIZE,
-    .file_id = REVISION_DEVICE_FILE_ID,
-};
-
-const d7_file_header_t alarm_data_fh = {
-    .access_class = ACCESS_CLASS_GW,
-    .notify = true,
-    .file_size = ALARM_DATA_FILE_SIZE,
-    .file_id = ALARM_DATA_FILE_ID,
-};
-
-const d7_file_header_t alarm_cmd_fh = {
-    .access_class = ACCESS_CLASS_GW,
-    .notify = false,
-    .file_size = ALARM_CMD_FILE_SIZE,
-    .file_id = ALARM_CMD_FILE_ID,
-};
-
-const d7_file_header_t temp_data_fh = {
-    .access_class = ACCESS_CLASS_GW,
-    .notify = true,
-    .file_size = TEMP_DATA_FILE_SIZE,
-    .file_id = TEMP_DATA_FILE_ID,
-};
-
 // Checks the status of the report send.
 void check_status( uint8_t status, char* message )
 {
@@ -187,11 +128,14 @@
 {    
     // Get modem
     D7_modem* wm1001 = (D7_modem*)args;
-    
+    uint8_t target_uid[8] = { 0x00, 0x1B, 0xC5, 0x0C, 0x70, 0x00, 0x06, 0x9B };
+
     // Enable interrupt on User button
     DebouncedInterrupt button(USER_BUTTON);
     button.attach(&button_push_isr, IRQ_FALL, 500, true);
     
+    wm1001->io_output(target_uid, ACCESS_CLASS_SC, 9, 0, 500, 128, 30);
+        
     while(true)
     {
         // Wait for button press
@@ -205,6 +149,15 @@
         
         // Notify alarm status
         check_status(wm1001->notify_filechange(ALARM_DATA_FILE_ID), "ALARM REPORT");
+        
+        if (alarm_data.status)
+        {
+            wm1001->io_set(target_uid, ACCESS_CLASS_SC, 9);
+        }
+        else
+        {
+            wm1001->io_clear(target_uid, ACCESS_CLASS_SC, 9);
+        }
     }
 }