Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LMiC SX1276Lib mbed
Fork of LoRaWAN-lmic-app by
Revision 4:2ab955d77be2, committed 2016-04-24
- Comitter:
- KarlNL
- Date:
- Sun Apr 24 08:10:41 2016 +0000
- Parent:
- 3:ce28e3313a88
- Commit message:
- The Things Network based example
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 16 20:00:01 2015 +0000
+++ b/main.cpp Sun Apr 24 08:10:41 2016 +0000
@@ -17,11 +17,13 @@
#include "lmic.h"
#include "debug.h"
+AnalogIn analog_value(A1); //A0 is also the reset line
+
/*!
* When set to 1 the application uses the Over-the-Air activation procedure
* When set to 0 the application uses the Personalization activation procedure
*/
-#define OVER_THE_AIR_ACTIVATION 0
+#define OVER_THE_AIR_ACTIVATION 0
#if( OVER_THE_AIR_ACTIVATION == 0 )
@@ -33,7 +35,7 @@
/*!
* Defines the device address when using personalization activation procedure
*/
-#define LORAWAN_DEV_ADDR ( uint32_t )0x12345678
+#define LORAWAN_DEV_ADDR ( uint32_t )0x07091970
#endif
@@ -76,13 +78,13 @@
// application router ID (LSBF)
static const uint8_t AppEui[8] =
{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x07, 0x09, 0x19, 0x70, 0x07, 0x09, 0x19, 0x70
};
// unique device ID (LSBF)
static const u1_t DevEui[8] =
{
- 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
+ 0x07, 0x09, 0x19, 0x70, 0x07, 0x09, 0x19, 0x70
};
// device-specific AES key (derived from device EUI)
@@ -166,18 +168,38 @@
static void onTxLed( osjob_t* j )
{
debug_val("LED1 = ", 0 );
+
}
static void prepareTxFrame( void )
{
- LMIC.frame[0] = AppLedStateOn;
-#if ( LORAWAN_CONFIRMED_MSG_ON == 1 )
- LMIC.frame[1] = LMIC.seqnoDn >> 8;
- LMIC.frame[2] = LMIC.seqnoDn;
- LMIC.frame[3] = LMIC.rssi >> 8;
- LMIC.frame[4] = LMIC.rssi;
- LMIC.frame[5] = LMIC.snr;
-#endif
+ float meas;
+ meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+ meas = meas * 18100; // Change the value to be roughly in the 0 to 15V range using a 4.7k/1k divider
+ printf("measure = %.0f mV\n\r", meas);
+ printf("measure fixed point = %u mV\n\r", (short) meas);
+
+ snprintf((char *)LMIC.frame, 7, "%.1f Volt", meas/1000.0);
+
+ // LMIC.frame[0] = (int) meas; //This is were the data of the measures value should go KB
+ // LMIC.frame[1] = (int) meas >> 8;
+//#if ( LORAWAN_CONFIRMED_MSG_ON == 1 )
+ // LMIC.frame[2] = LMIC.seqnoDn >> 8;
+ // LMIC.frame[3] = LMIC.seqnoDn;
+ // LMIC.frame[4] = LMIC.rssi >> 8;
+ // LMIC.frame[5] = LMIC.rssi;
+ // LMIC.frame[6] = LMIC.snr;
+ //LMIC.frame[0] = 0;
+ //LMIC.frame[1] = 0;
+// LMIC.frame[2] = 0;
+// LMIC.frame[3] = 0;
+// LMIC.frame[4] = 0;
+// LMIC.frame[5] = 0;
+ LMIC.frame[6] = 0;
+
+ printf("prepareTxFrame %02x %02x\r\n", LMIC.frame[0], LMIC.frame[1]);
+
+//#endif
}
void processRxFrame( void )
