text: #include <zephyr.h>
  #include <misc/printk.h>
  
  #include <unistd.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  
  #include <device.h>
  #include <soc.h>
  
  #include <stdint.h>
  #include "upm.h"
  #include "mraa.h"
  #include "sx127x.h"
  #include "upm_utilities.h"
  #include "sx127x_mac.h"
  
  
  #define PINGTIME 1000
  #define STACKSIZE 2000
  
  #define TX_OUTPUT_POWER                             20        // dBm
  
  #define LORA_BANDWIDTH                              0         // [0: 125 kHz,
                                                                //  1: 250 kHz,
                                                                //  2: 500 kHz,
                                                                //  3: Reserved]
  #define LORA_SPREADING_FACTOR                       7         // [SF7..SF12]
  #define LORA_CODINGRATE                             1         // [1: 4/5,
                                                                //  2: 4/6,
                                                                //  3: 4/7,
                                                                //  4: 4/8]
  #define LORA_PREAMBLE_LENGTH                        8         // Same for Tx and Rx
  #define LORA_SYMBOL_TIMEOUT                         5         // Symbols
  #define LORA_FIX_LENGTH_PAYLOAD_ON                  false
  #define LORA_IQ_INVERSION_ON                        false
  
  
  // THE FOLLOWING VALUES ARE EXPECTED TO BE MODIFIED BY THE USER BECAUSE THESE ARE ED AND GW AND NW SPECIFIC
  /*!
   * Mote device EUI (big endian)
   *
   * \remark In this application the value is automatically generated by calling
   *         BoardGetUniqueId function
   */
  uint8_t LORAWAN_DEVICE_EUI[8] =                         { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
  
  /*!
   * Application IEEE EUI (big endian)
   */
  uint8_t LORAWAN_APPLICATION_EUI[8] =                     { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 };
  
  /*!
   * AES encryption/decryption cipher application key
   */
  uint8_t LORAWAN_APPLICATION_KEY[16] =                     { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16 };
  
  int counter = 0;
  
  uint8_t buffer[25] = {0};
  
  volatile int req_ready;
  volatile uint32_t value[3];
  
  #define STACKSIZE 2000
  
  #define REQ_FIBER_PRE 4
  char thread_stacks[2][STACKSIZE];
  
  /*
   * Example ordered list to store devices on which
   * device power policies would be executed.
   */
  struct device *device_list;
  int device_count;
  int count;
  
  
  void main() {
  	printf("LoRa Sender\n");
  
  	loRaWAN_context dev = lorawan_init();
  	lorawan_set_dev_eui(dev, LORAWAN_DEVICE_EUI);
  	lorawan_set_app_eui(dev, LORAWAN_APPLICATION_EUI);
  	lorawan_set_app_key(dev, LORAWAN_APPLICATION_KEY);
  
  	printf("prior to lora wan join\n");
  	lorawan_otaa_join(dev);
  	upm_delay_us(4000000);
  
  	while(1) {
                  // replace data here with something meaningful
  		snprintf(buffer, 25, "Ping: %d, Data: %d", counter++, 22);
  		lorawan_transmit_packet(dev, buffer, 25);
  		counter++;
  		upm_delay_us(10000000);
  	}
  }
  