example-ttn-workshop

Dependencies:   X_NUCLEO_IKS01A2

Files at this revision

API Documentation at this revision

Comitter:
LithiumSR
Date:
Thu Mar 14 17:27:26 2019 +0000
Parent:
50:6e615eea1e6f
Commit message:
Add support for X-NUCLEO-IKS01A2

Changed in this revision

X_NUCLEO_IKS01A2.lib 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
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A2.lib	Thu Mar 14 17:27:26 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/X_NUCLEO_IKS01A2/#138a7a28bd21
--- a/main.cpp	Wed Mar 13 17:30:20 2019 +0000
+++ b/main.cpp	Thu Mar 14 17:27:26 2019 +0000
@@ -19,7 +19,7 @@
 #include "lorawan/LoRaWANInterface.h"
 #include "lorawan/system/lorawan_data_structures.h"
 #include "events/EventQueue.h"
-
+#include "XNucleoIKS01A2.h"
 // Application helpers
 #include "trace_helper.h"
 #include "lora_radio_helper.h"
@@ -29,8 +29,8 @@
 // Max payload size can be LORAMAC_PHY_MAXPAYLOAD.
 // This example only communicates with much shorter messages (<30 bytes).
 // If longer messages are used, these buffers must be changed accordingly.
-uint8_t tx_buffer[30];
-uint8_t rx_buffer[30];
+uint8_t tx_buffer[256];
+uint8_t rx_buffer[256];
 
 /*
  * Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing
@@ -77,11 +77,18 @@
  */
 static lorawan_app_callbacks_t callbacks;
 
+
+static XNucleoIKS01A2 *mems_expansion_board = XNucleoIKS01A2::instance();
+static LSM6DSLSensor *acc_gyro = mems_expansion_board->acc_gyro;
+static HTS221Sensor *hum_temp = mems_expansion_board->ht_sensor;
 /**
  * Entry point for application
  */
 int main(void)
 {
+    acc_gyro->enable_x();
+    acc_gyro->enable_g();
+    
     // setup tracing
     setup_trace();
 
@@ -142,9 +149,15 @@
 {
     uint16_t packet_len;
     int16_t retcode;
-    printf("\n\rHello world");    
+    float value;
+    int32_t axes[3];
+    acc_gyro->get_x_axes(axes);
+    printf("\n\rgyro:%d %d %d\n\r",axes[0],axes[1], axes[2]); 
+    hum_temp->get_temperature(&value);
+    printf("\n\rtemp:%f\n\r",value);    
+        
 
-    packet_len = sprintf((char *) tx_buffer, "Hello world");
+    packet_len = sprintf((char *) tx_buffer, "\n\rgyro:%d %d %d\n\rn\rtemp:%f\n\r",axes[0],axes[1], axes[2], value);
 
     retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
                            MSG_UNCONFIRMED_FLAG);
--- a/mbed_app.json	Wed Mar 13 17:30:20 2019 +0000
+++ b/mbed_app.json	Thu Mar 14 17:27:26 2019 +0000
@@ -5,7 +5,6 @@
             "value": "SX1276"
         },
         "main_stack_size":     { "value": 4096 },
-
         "lora-spi-mosi":       { "value": "NC" },
         "lora-spi-miso":       { "value": "NC" },
         "lora-spi-sclk":       { "value": "NC" },
@@ -33,9 +32,9 @@
             "lora.over-the-air-activation": false,
             "lora.duty-cycle-on": false,
             "lora.phy": "EU868",
-            "lora.appskey": "{ 0xCD, 0xA9, 0x0D, 0x58, 0x4A, 0x45, 0x47, 0xE7, 0x77, 0x06, 0x63, 0x7E, 0x7B, 0x0D, 0x88, 0xC1 }",
-            "lora.nwkskey": "{ 0x30, 0xFD, 0x2C, 0xD2, 0x46, 0x06, 0xE5, 0xAE, 0x21, 0x8E, 0xCF, 0x29, 0xCE, 0xFB, 0xC1, 0xA1 }",
-            "lora.device-address": "0x26011BF1" 
+            "lora.appskey": "{ 0xEB, 0x8D, 0x7B, 0xB4, 0x2C, 0x70, 0x5D, 0xD5, 0x66, 0xAE, 0xC6, 0x37, 0x1B, 0x5F, 0xAE, 0xE6 }",
+            "lora.nwkskey": "{ 0x68, 0x6A, 0xC0, 0xED, 0x25, 0x97, 0x7C, 0x7F, 0x97, 0x8C, 0x7A, 0xB7, 0x77, 0x4A, 0x91, 0xA9}",
+            "lora.device-address": "0x26011E0E" 
         },
 
         "K64F": {