SmartMesh QSL for STM32F4 version

Fork of COG-AD4050_QSL by APS Lab

Revision:
1:b909b8399252
Parent:
0:8ca1e814a851
--- a/main.cpp	Wed May 02 09:26:10 2018 +0000
+++ b/main.cpp	Thu Jul 12 09:19:12 2018 +0000
@@ -13,7 +13,7 @@
 #include "dn_debug.h"       // Included to borrow debug macros
 #include "dn_endianness.h"  // Included to borrow array copying
 #include "dn_time.h"        // Included to borrow sleep function
-#include "ADXL362.h"
+//#include "ADXL362.h"
 
 #define NETID           0       // Factory default value used if zero (1229)
 #define JOINKEY         NULL    // Factory default value used if NULL (44 55 53 54 4E 45 54 57 4F 52 4B 53 52 4F 43 4B)
@@ -23,22 +23,22 @@
 #define DATA_PERIOD_MS  500    // Should be longer than (or equal to) bandwidth
 
 // We can use debug macros from dn_debug, as stdio defaults to this serial
-//Serial serialDebug(USBTX1, USBRX1);
+Serial serialDebug(USBTX, USBRX);
 #define log_info serialDebug.printf
  
 // LED2 is the green LED on the NUCLEO-L053R8; might change for other boards
 DigitalOut myled(LED1);
 DigitalOut status(LED2);
-ADXL362 Acc(P1_07, P1_08, P1_06, P1_10);
+//ADXL362 Acc(P1_07, P1_08, P1_06, P1_10);
 
 static uint16_t randomWalk(void);
 static void parsePayload(const uint8_t *payload, uint8_t size);
 
-void init_acc(void)
-{    
-    Acc.init_spi();
-    Acc.init_adxl362();
-}
+//void init_acc(void)
+//{    
+//    Acc.init_spi();
+//    Acc.init_adxl362();
+//}
  
 int main()
 {
@@ -46,7 +46,7 @@
     uint8_t inboxBuf[DN_DEFAULT_PAYLOAD_SIZE_LIMIT];
     uint8_t bytesRead;
     uint8_t i,e;
-    int8_t x0, y0, z0;
+    //int8_t x0, y0, z0;
     
     myled=1;
     status=1;     
@@ -61,14 +61,15 @@
     myled=1;
     status=1;     
 
-    init_acc();
+    //init_acc();
     // Configure SysTick for timing
     millisStart();
     
     // Set PC debug serial baudrate
-    //serialDebug.baud(115200);
+    serialDebug.baud(115200);
+    serialDebug.printf("STM32F4 SmartMesh Demo\n");
     
-    //log_info("Initializing...");
+    log_info("Initializing...");
     dn_qsl_init();
     
     // Flash LED to indicate start-up complete
@@ -82,25 +83,25 @@
     while(TRUE) {
         if (dn_qsl_isConnected())
         {
-            Acc.ACC_GetXYZ8(&x0, &y0, &z0);
-            payload[0]=x0;
-            payload[1]=y0;
-            payload[2]=z0;
-            //uint16_t val = randomWalk();
+            //Acc.ACC_GetXYZ8(&x0, &y0, &z0);
+            //payload[0]=x0;
+            //payload[1]=y0;
+            //payload[2]=z0;
+            uint16_t val = randomWalk();
             static uint8_t count = 0;
             myled = 1; // Turn off LED during send/read
             status = 0;
-            //dn_write_uint16_t(payload, val);
-            payload[3] = count;
+            dn_write_uint16_t(payload, val);
+            payload[0] = count;
             
             if (dn_qsl_send(payload, sizeof (payload), DEST_PORT))
             {
-                //log_info("Sent message nr %u: %u", count, val);
+                log_info("Sent message nr %u: %u", count, val);
                 count++;
                 status=1;
             } else
             {
-                //log_info("Send failed");
+                log_info("Send failed");
                 status=0;
             }
 
@@ -114,7 +115,7 @@
             dn_sleep_ms(DATA_PERIOD_MS);
         } else
         {
-            //log_info("Connecting...");
+            log_info("Connecting...");
             myled = 1; // Not connected; turn off LED
             if (dn_qsl_connect(NETID, JOINKEY, SRC_PORT, BANDWIDTH_MS))
             {
@@ -122,7 +123,7 @@
                 status=1;//log_info("Connected to network");
             } else
             {
-                //log_info("Failed to connect");
+                log_info("Failed to connect");
             }
         }
     status=0;
@@ -165,8 +166,8 @@
     for (i = 0; i < size; i++)
     {
         msg[i] = payload[i];
-        //log_info("\tByte# %03u: %#.2x (%u)", i, payload[i], payload[i]);
+        log_info("\tByte# %03u: %#.2x (%u)", i, payload[i], payload[i]);
     }
     msg[size] = '\0';
-    //log_info("\tMessage: %s", msg);
+    log_info("\tMessage: %s", msg);
 }