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-10secs SX1276Lib X_NUCLEO_IKS01A1 cantcoap lwip mbed-rtos mbed
Fork of LoRaWAN-lmic-app by
Revision 8:8d9a49aaa323, committed 2015-12-21
- Comitter:
- pnysten
- Date:
- Mon Dec 21 14:19:42 2015 +0000
- Parent:
- 7:f1521b0ecf08
- Child:
- 9:84a69ca4d35a
- Commit message:
- "LoRa" payload
Changed in this revision
| LMiC.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LMiC.lib Mon Dec 14 10:51:40 2015 +0000 +++ b/LMiC.lib Mon Dec 21 14:19:42 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/Alcatel-Lucent-IoT-Development/code/LMiC/#663db54d46eb +https://developer.mbed.org/teams/Alcatel-Lucent-IoT-Development/code/LMiC/#74acff269a3d
--- a/main.cpp Mon Dec 14 10:51:40 2015 +0000
+++ b/main.cpp Mon Dec 21 14:19:42 2015 +0000
@@ -218,6 +218,7 @@
0x30, 0x74, 0x73, 0x65, 0x74, 0x2D, 0x52, 0x4C // 4c522d7465737430 = "LR-test0"
// 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x99, 0xF7
+// 0x32, 0x74, 0x73, 0x65, 0x74, 0x2D, 0x52, 0x4C // 4c522d7465737430 = "LR-test2"
// 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
@@ -345,6 +346,25 @@
LoRaWAN_data_size = PDUlength + 5;
}
+static void prepareTxLoraFrame( void )
+{
+ const char *frame = "LoRa";
+
+ strncpy((char*) LMIC.frame, frame, strlen(frame));
+
+#if ( LORAWAN_CONFIRMED_MSG_ON == 1 )
+ LMIC.frame[strlen(frame)] = LMIC.seqnoDn >> 8;
+ LMIC.frame[strlen(frame)+1] = LMIC.seqnoDn;
+ LMIC.frame[strlen(frame)+2] = LMIC.rssi >> 8;
+ LMIC.frame[strlen(frame)+3] = LMIC.rssi;
+ LMIC.frame[strlen(frame)+4] = LMIC.snr;
+#endif
+ debug_str("Frame to be sent: ");
+ debug_buf(LMIC.frame, strlen(frame) + 5);
+
+ LoRaWAN_data_size = strlen(frame) + 5;
+}
+
static void prepareTxFrame( void )
{
LMIC.frame[0] = AppLedStateOn;
@@ -363,8 +383,9 @@
void processRxFrame( void )
{
- debug_str("Data: ");
- debug_buf( LMIC.frame + LMIC.dataBeg, LMIC.dataLen );
+
+ char* frameToDisplay = (char*) (LMIC.frame + LMIC.dataBeg);
+ frameToDisplay[LMIC.dataLen] = '\0';
switch( LMIC.frame[LMIC.dataBeg - 1] ) // Check Rx port number
{
@@ -373,7 +394,24 @@
// debug_val("Data Len: ", LMIC.dataLen);
case 1: // The application LED can be controlled on port 1 or 2
+ debug_str("Data received on port 1: ");
+ debug_str("Data in hexa: ");
+ debug_buf( LMIC.frame + LMIC.dataBeg, LMIC.dataLen );
+ debug_str("Data in string: ");
+
+ debug_str( frameToDisplay );
+ debug_str("\r\n");
+
+ break;
case 2:
+ debug_str("Data received on port 2: ");
+ debug_str("Data in hexa: ");
+ debug_buf( LMIC.frame + LMIC.dataBeg, LMIC.dataLen );
+ debug_str("Data in string: ");
+
+ debug_str( frameToDisplay );
+ debug_str("\r\n");
+
if( LMIC.dataLen == 1 )
{
debug_str("Data received on port 2: ");
@@ -391,7 +429,8 @@
static void onSendFrame( osjob_t* j )
{
//prepareTxFrame( );
- prepareTxCoapFrame();
+ //prepareTxCoapFrame();
+ prepareTxLoraFrame();
LMIC_setTxData2( LORAWAN_APP_PORT, LMIC.frame, LoRaWAN_data_size, LORAWAN_CONFIRMED_MSG_ON );
