example-ttn-workshop
Dependencies: X_NUCLEO_IKS01A2
Diff: main.cpp
- Revision:
- 51:66ecf886daca
- Parent:
- 50:6e615eea1e6f
--- 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);