
hello world
Dependencies: lib_gps lib_mpl3115a2 lmic_MOTE_L152RC mbed
Fork of lmic_NAmote_GPS by
Revision 6:0b2b2d196ddd, committed 2015-10-21
- Comitter:
- dudmuck
- Date:
- Wed Oct 21 01:09:19 2015 +0000
- Parent:
- 5:6244f45b15f2
- Child:
- 7:7de55330772d
- Commit message:
- prevent lost TX packet when OP_TXRXPEND is set. Testing reversed appeui & deveui.
Changed in this revision
--- a/config.h Mon Sep 21 18:04:06 2015 +0000 +++ b/config.h Wed Oct 21 01:09:19 2015 +0000 @@ -2,4 +2,4 @@ #define CFG_sx1272_radio -#define CHNL_HYBRID 0 /* 0-7 to select block of 8 channels used */ \ No newline at end of file +//#define CHNL_HYBRID 0 /* 0-7 to select block of 8 channels used */ \ No newline at end of file
--- a/lib_gps.lib Mon Sep 21 18:04:06 2015 +0000 +++ b/lib_gps.lib Wed Oct 21 01:09:19 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/dudmuck/code/lib_gps/#03d7275dc4fd +https://developer.mbed.org/users/dudmuck/code/lib_gps/#b8c049fa7db2
--- a/lmic_MOTE_L152RC.lib Mon Sep 21 18:04:06 2015 +0000 +++ b/lmic_MOTE_L152RC.lib Wed Oct 21 01:09:19 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/Semtech/code/lmic_MOTE_L152RC/#dfc048cda33f +https://developer.mbed.org/teams/Semtech/code/lmic_MOTE_L152RC/#0faa1bb768b5
--- a/main.cpp Mon Sep 21 18:04:06 2015 +0000 +++ b/main.cpp Wed Oct 21 01:09:19 2015 +0000 @@ -18,9 +18,8 @@ #include "gps.h" #include "debug.h" - -//#define SENET_F -#define SMTC +#define SENET_F +//#define SMTC typedef enum { MOTE_NONE = 0, @@ -69,10 +68,12 @@ ////////////////////////////////////////////////// #ifdef SENET_F // application router ID (LSBF) -static const u1_t APPEUI[8] = { 0x01, 0x00, 0x01, 0x00, 0x00, 0x0c, 0x25, 0x00 }; +//static const u1_t APPEUI[8] = { 0x01, 0x00, 0x01, 0x00, 0x00, 0x0c, 0x25, 0x00 }; +static const u1_t reverse_APPEUI[8] = { 0x00, 0x25, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x01 }; // unique device ID (LSBF) -static const u1_t DEVEUI[8] = { 0x0f, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 }; +//static const u1_t DEVEUI[8] = { 0x0f, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 }; +static const u1_t reverse_DEVEUI[8] = { 0x00, 0x25, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x0F }; // device-specific AES key (derived from device EUI) static const u1_t DEVKEY[16] = { 0xe4, 0x72, 0x71, 0xc5, 0xf5, 0x30, 0xa9, 0x9f, 0xcf, 0xc4, 0x0e, 0xab, 0xea, 0xd7, 0x19, 0x42, }; @@ -82,15 +83,20 @@ #ifdef SMTC // Semtech Activation (v1.x server) // application router ID (LSBF) -static const u1_t APPEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +static const u1_t reverse_APPEUI[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + //AA-AA-AA-AA-FF-FF-FF-FF +//static const u1_t APPEUI[8] = { 0xff, 0xff, 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0xaa }; +//static const u1_t reverse_APPEUI[8] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xff, 0xff, 0xff, 0xff }; // unique device ID (LSBF) -//static const u1_t DEVEUI[8] = { 0x20, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 }; -static const u1_t DEVEUI[8] = { 0x34, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 }; -//static const u1_t DEVEUI[8] = { 0x35, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 }; +//static const u1_t DEVEUI[8] = { 0x21, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 }; +static const u1_t reverse_DEVEUI[8] = { 0x00, 0x25, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x20 }; +//static const u1_t DEVEUI[8] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; +//static const u1_t reverse_DEVEUI[8] = { 0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x01 }; // device-specific AES key (derived from device EUI) static const u1_t DEVKEY[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; +//static const u1_t DEVKEY[16] = { 0xab, 0x89, 0xef, 0xcd, 0x23, 0x01, 0x67, 0x45, 0x54, 0x76, 0x10, 0x32, 0xdc, 0xfe, 0x98, 0xba }; /*static uint8_t NwkSKey[] = { @@ -112,12 +118,14 @@ // provide application router ID (8 bytes, LSBF) void os_getArtEui (u1_t* buf) { - memcpy(buf, APPEUI, 8); + //memcpy(buf, APPEUI, 8); + LMIC_reverse_memcpy(buf, reverse_APPEUI, 8); } // provide device ID (8 bytes, LSBF) void os_getDevEui (u1_t* buf) { - memcpy(buf, DEVEUI, 8); + //memcpy(buf, DEVEUI, 8); + LMIC_reverse_memcpy(buf, reverse_DEVEUI, 8); } // provide device key (16 bytes) @@ -131,9 +139,6 @@ void get_mote_version() { char first; - - /*DigitalOut pc_7(PC_7); - DigitalIn pc_1(PC_1);*/ pc_7 = 1; first = pc_1; @@ -231,15 +236,12 @@ static void PrepareDataFrame( void ) { uint16_t altitudeGps; - float volts; restore_hsi(); gps.service(); - printf("lat:%f long:%f\r\n", gps.Latitude, gps.Longitude); - // printf("lat:%d long:%d\r\n", gps.LatitudeBinary, gps.LongitudeBinary); + //printf("lat:%f long:%f\r\n", gps.Latitude, gps.Longitude); mpl3115a2.ReadTemperature(); - //printf("temp:%d\r\n", (int)mpl3115a2.Temperature); // immediately prepare next transmission //LMIC.frame[0] = LMIC.rxq.snr; @@ -259,26 +261,26 @@ LMIC.frame[9] = ( altitudeGps >> 8 ) & 0xFF; LMIC.frame[10] = altitudeGps & 0xFF; - volts = bat->read()*AIN_VREF*AIN_VBAT_DIV; - printf("bat:%.2f\r\n", volts); -#ifdef CHNL_HYBRID - LMIC.txpow_limit = 20; -#else + + //printf("bat:%.2f\r\n", volts); +#ifndef CHNL_HYBRID + float volts = bat->read()*AIN_VREF*AIN_VBAT_DIV; if (volts < LOW_BAT_THRESHOLD) LMIC.txpow_limit = 20; else LMIC.txpow_limit = 30; -#endif /* !CHNL_HYBRID */ - - // test forcing: - LMIC.datarate = DR_SF10; // force SF10 - +#endif /* !CHNL_HYBRID */ } -static void onSendFrame (osjob_t* j) { +static void onSendFrame (osjob_t* j) +{ + if (LMIC.opmode & OP_TXRXPEND) + return; + PrepareDataFrame( ); - // schedule transmission (port 1, data[], datalen 1, ACK requested) - // (will be sent as soon as duty cycle permits) + // schedule transmission (port 1, data[], datalen 1, ACK requested) + // (will be sent as soon as duty cycle permits) + LMIC_setTxData2(5, LMIC.frame, APP_DATA_SIZE, APP_ACK); }