Fork for Get Started Demo

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

Fork of D7A_Demo_full by WizziLab

Revision:
2:c3cfaa7d5bb8
Parent:
1:49da0144dd4c
Child:
3:b77b01171cc0
--- a/main.cpp	Thu Nov 19 17:26:13 2015 +0000
+++ b/main.cpp	Thu Nov 19 17:27:32 2015 +0000
@@ -4,6 +4,72 @@
 #include "shield.h"
 #include "alp_serial.h"
 #include "alp_device.h"
+#include "alp_file.h"
+#include "alp_report.h"
+
+/*
+These data are user defined and will be used by the dash7board
+to identify the device
+*/
+
+#define __MANUFACTURER_ID__         0x01234567 // Identify the manufacturer
+#define __DEVICE_ID__               0x89ABCDEF // Identify the device type
+
+#define __FW_ID__                   0x01 // Device type option
+
+// Software version
+#define __FW_MAJOR__                0x02
+#define __FW_MINOR__                0x03
+#define __FW_PATCH__                0x0005
+#define __FW_HASH__                 0x86605dba
+
+#define __HW_ID__                   0x01520C02 // Hardware ID
+
+
+revision_t revision = {
+    // The two first bytes must be present in all reported files
+    // They are parsed by the dash7board
+    .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
+};
+
+// Checks the status of the report send.
+void check_status( AlpReport* report, void* param )
+{
+    char* message = (char*)param;
+    uint8_t status = report->get_status();
+    switch (status)
+    {
+        case ALP_CMD_OK: // message is send and acknowleged
+            DPRINT("%s OK\r\n", message);
+        break;
+        case ALP_CMD_TIMEOUT: // message has not been acknowleged by modem
+            DPRINT("%s CMD TIMEOUT\r\n", message);
+        break;
+        case ALP_CMD_ERROR: // message has been acknowleged by modem but returned an error
+            DPRINT("%s CMD ERROR\r\n", message);
+        break;
+        case ALP_D7_TIMEOUT: // message has not been acknowleged by gateway
+            DPRINT("%s D7 TIMEOUT\r\n", message);
+        break;
+        case ALP_D7_ERROR: // message has been acknowleged by gateway but returned an error
+            DPRINT("%s D7 ERROR\r\n", message);
+        break;
+        default:
+            DPRINT("%s UNKNOWN ERROR %d\r\n", message, status);
+        break;
+    }
+}
 
 int main()
 {
@@ -37,6 +103,19 @@
     // Wait for Shield to notify its files if there is any
     Thread::wait(1000);
     
+    // Add the Report file to the file system
+    alp_file_add(REVISION_DEVICE_FILE_ID, REVISION_DEVICE_FILE_SIZE, (uint8_t*)&revision);
+    
+    // Create the Revision report
+    AlpReport report_revision(&shield, REVISION_DEVICE_FILE_ID);
+    
+    // Attach callback after report is send
+    report_revision.attach_after(check_status, (void*)"REPORT REVISION");
+    
+    // Send the Revision report
+    DPRINT("SENDING REPORT REVISION\r\n");
+    report_revision.send();
+    
     // Set main task to lowest priority
     osThreadSetPriority(osThreadGetId(), osPriorityIdle);
     while(true)