Temperature reading using NUCLEO-L152RE microcontroller and Grove – Temperature&Humidity Sensor Pro.
Dependencies: DHT LMiC SX1276Lib mbed
Fork of LoRaWAN_send_text by
Diff: main.cpp
- Revision:
- 11:0cc0f7b84c72
- Parent:
- 10:576f275cfc14
- Child:
- 12:020ffc39a19e
diff -r 576f275cfc14 -r 0cc0f7b84c72 main.cpp --- a/main.cpp Wed Sep 16 23:28:25 2015 +0000 +++ b/main.cpp Sun Sep 27 15:52:00 2015 +0000 @@ -1,24 +1,27 @@ -// License: Revised BSD License, see LICENSE.TXT, (c)2015 tamberg.org, (c)2015 Semtech +// License: Revised BSD License, see LICENSE.TXT, (c)2015 Semtech #include "mbed.h" #include "lmic.h" #include "debug.h" #define LORAWAN_NET_ID (uint32_t) 0x00000000 -#define LORAWAN_DEV_ADDR (uint32_t) 0x00001056 +#define LORAWAN_DEV_ADDR (uint32_t) 0x00001056 // 0xA81F657A #define LORAWAN_ADR_ON 1 #define LORAWAN_CONFIRMED_MSG_ON 1 #define LORAWAN_APP_PORT 15 -#define LORAWAN_APP_DATA_SIZE 32 // max 51 static uint8_t NwkSKey[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF +// 0x6D, 0x0D, 0x54, 0x96, 0x79, 0xE7, 0x3D, 0x14, +// 0x46, 0xA2, 0x88, 0x28, 0xC8, 0x7A, 0x85, 0x10 }; static uint8_t ArtSKey[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF +// 0xE9, 0x4D, 0x61, 0x65, 0x7D, 0x9C, 0xF7, 0xB2, +// 0x6F, 0xB6, 0xED, 0x68, 0xF1, 0xD5, 0xD7, 0xA9 }; osjob_t initjob; @@ -30,11 +33,17 @@ void os_getDevKey (uint8_t *buf) {} // ignore void onSendFrame (osjob_t* j) { - for (int i = 0; i < LORAWAN_APP_DATA_SIZE; i++) { + int frameLength = 32; // max 51? + for (int i = 0; i < frameLength; i++) { LMIC.frame[i] = n++; // or any other payload } +// LMIC.frame[0] = 'H'; +// LMIC.frame[1] = 'e'; +// LMIC.frame[2] = 'l'; +// LMIC.frame[3] = 'l'; +// LMIC.frame[4] = 'o'; int result = LMIC_setTxData2(LORAWAN_APP_PORT, LMIC.frame, - LORAWAN_APP_DATA_SIZE, LORAWAN_CONFIRMED_MSG_ON); // calls onEvent() + frameLength, LORAWAN_CONFIRMED_MSG_ON); // calls onEvent() } void onInit (osjob_t* j) { @@ -46,7 +55,7 @@ } void onEvent (ev_t ev) { // called by lmic.cpp, see also oslmic.h - //debug_event(ev); + debug_event(ev); if (ev == EV_TXCOMPLETE) { os_setCallback(&sendFrameJob, onSendFrame); }