first draft
Dependencies: LMiC SX1272Libx mbed
Fork of LoRaWAN-lmic-app by
Diff: main.cpp
- Revision:
- 6:fc465060b63e
- Parent:
- 5:1b2fcc2582e8
- Child:
- 8:0137acc9a6cd
--- a/main.cpp Thu Nov 26 17:20:53 2015 +0000 +++ b/main.cpp Tue Feb 23 15:42:41 2016 +0000 @@ -21,7 +21,7 @@ * 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 1 #if( OVER_THE_AIR_ACTIVATION == 0 ) @@ -68,30 +68,20 @@ #define LORAWAN_APP_DATA_SIZE 1 #endif +Serial pc(PTE0, PTE1); ////////////////////////////////////////////////// // CONFIGURATION (FOR APPLICATION CALLBACKS BELOW) ////////////////////////////////////////////////// - // application router ID (LSBF) -static const uint8_t AppEui[8] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; +static const u1_t AppEui[8] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 }; // unique device ID (LSBF) -static const u1_t DevEui[8] = -{ - 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF -}; +static const u1_t DevEui[8] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0xee, 0xff, 0xc0 }; // device-specific AES key (derived from device EUI) -static const uint8_t DevKey[16] = -{ - 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C -}; - +static const u1_t DevKey[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, }; + // E4 -72 -71 -C5 -F5 -30 -A9 -9F -CF -C4 -0E -AB -EA -D7 -19 -42 #if( OVER_THE_AIR_ACTIVATION == 0 ) // network session key static uint8_t NwkSKey[] = @@ -140,18 +130,30 @@ void os_getArtEui( uint8_t *buf ) { memcpy( buf, AppEui, 8 ); + debug("os_getArtEui enter"); + for(int i=0;i<8;i++) + debug(" %02X",buf[i]); + debug("\r\n"); } // provide device ID (8 bytes, LSBF) void os_getDevEui( uint8_t *buf ) { memcpy( buf, DevEui, 8 ); + debug("os_getDevEui enter"); + for(int i=0;i<8;i++) + debug(" %02X",buf[i]); + debug("\r\n"); } // provide device key (16 bytes) void os_getDevKey( uint8_t *buf ) { memcpy( buf, DevKey, 16 ); + debug("os_getDevKey enter"); + for(int i=0;i<16;i++) + debug(" %02X",buf[i]); + debug("\r\n"); } ////////////////////////////////////////////////// @@ -182,7 +184,8 @@ void processRxFrame( void ) { - switch( LMIC.frame[LMIC.dataBeg - 1] ) // Check Rx port number + debug("processRxFrame enter\r\n"); + switch( LMIC.frame[LMIC.dataBeg - 1] ) // Check Rx port number { case 1: // The application LED can be controlled on port 1 or 2 case 2: @@ -199,6 +202,7 @@ static void onSendFrame( osjob_t* j ) { + debug("onSendFrame enter\r\n"); prepareTxFrame( ); LMIC_setTxData2( LORAWAN_APP_PORT, LMIC.frame, LORAWAN_APP_DATA_SIZE, LORAWAN_CONFIRMED_MSG_ON ); @@ -210,6 +214,7 @@ // Initialization job static void onInit( osjob_t* j ) { + debug("onInit enter\r\n"); // reset MAC state LMIC_reset( ); LMIC_setAdrMode( LORAWAN_ADR_ON ); @@ -232,7 +237,9 @@ int main( void ) { osjob_t initjob; - + + pc.baud(115200); + printf( "\r\nLoRaWan Demo Application TJM\r\n" ); // initialize runtime env os_init( ); // setup initial job @@ -247,6 +254,7 @@ ////////////////////////////////////////////////// void onEvent( ev_t ev ) { + debug("onEvent enter %d\r\n",ev); bool txOn = false; debug_event( ev );