light sensor

Dependencies:   X_NUCLEO_IKS01A1 LoRaWAN-lib SX1276Lib mbed

Fork of LoRaWAN-SX1276-Application-Demo by Uttam Bhat

Files at this revision

API Documentation at this revision

Comitter:
terence304
Date:
Fri Sep 08 20:42:14 2017 +0000
Parent:
3:4bca7f8f731a
Child:
5:f04a6f68e159
Commit message:
add light sensor

Changed in this revision

app/Comissioning.h Show annotated file Show diff for this revision Revisions of this file
app/Config.h Show annotated file Show diff for this revision Revisions of this file
app/LoRaApp.cpp Show annotated file Show diff for this revision Revisions of this file
app/LoRaApp.h Show annotated file Show diff for this revision Revisions of this file
app/LoRaEventProc.cpp Show annotated file Show diff for this revision Revisions of this file
board/board.cpp Show annotated file Show diff for this revision Revisions of this file
board/board.h Show annotated file Show diff for this revision Revisions of this file
--- a/app/Comissioning.h	Thu Apr 06 16:35:17 2017 +0000
+++ b/app/Comissioning.h	Fri Sep 08 20:42:14 2017 +0000
@@ -40,17 +40,17 @@
  * \remark In this application, if the last 4 bytes are all 0, then the 32 bit address is automatically generated using a pseudo random generator seeded with a value derived from BoardUniqueId value
  * If provided by user, e.g. { IEEE_OUI, 0x00, 0x00, 0x00, 0xFF, 0x01 }, then this value is used by the application
  */
-#define LORAWAN_DEVICE_EUI                          { IEEE_OUI, 0x00, 0x00, 0x00, 0x00, 0x00 }
+#define LORAWAN_DEVICE_EUI                          { 0x00, 0x00, 0x00, 0x00, 0x78, 0x56, 0x34, 0x12 }
 
 /*!
  * Application IEEE EUI (big endian)
  */
-#define LORAWAN_APPLICATION_EUI                     { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+#define LORAWAN_APPLICATION_EUI                     { 0x70, 0xB3, 0xD5, 0x7E, 0xF0, 0x00, 0x63, 0xA6 }
 
 /*!
  * AES encryption/decryption cipher application key
  */
-#define LORAWAN_APPLICATION_KEY                     { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }
+#define LORAWAN_APPLICATION_KEY                     { 0x24, 0x11, 0x00, 0x61, 0x98, 0xD1, 0xDB, 0x8C, 0x6E, 0x8B, 0x8C, 0x24, 0xB2, 0x8A, 0xFB, 0x82 }
 
 #else
 
--- a/app/Config.h	Thu Apr 06 16:35:17 2017 +0000
+++ b/app/Config.h	Fri Sep 08 20:42:14 2017 +0000
@@ -63,7 +63,7 @@
 /*!
  * LoRaWAN application port
  */
-#define LORAWAN_APP_PORT                            9
+#define LORAWAN_APP_PORT                            13
 
 /*!
  * LoRaWAN User defined Tx Power
@@ -122,6 +122,16 @@
  */
 #define LORAWAN_APP_DATA_SIZE                       2
 
+#elif ( LORAWAN_APP_PORT == 13 )
+/*====================================================
+    Light Sensor DEMO + CAYENNE LPP (PORT 13)
+====================================================*/
+
+/*!
+ * User application data buffer size
+ */
+#define LORAWAN_APP_DATA_SIZE                       4
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #endif
--- a/app/LoRaApp.cpp	Thu Apr 06 16:35:17 2017 +0000
+++ b/app/LoRaApp.cpp	Fri Sep 08 20:42:14 2017 +0000
@@ -189,6 +189,21 @@
             
             break;
         }
+        
+        case AppExtLight:
+        {
+        uint16_t lux = (uint16_t)(ext_light.read_u16());
+        
+        //ext_LED = 1;
+
+        printf("light raw data: %d\r\n", lux);
+        //printf("button raw data: %d\r\n", ext_button.read_u16());
+
+            BuffAddr[BuffPtr++] = ((lux) >> 8) & 0xff;
+            BuffAddr[BuffPtr++] = (lux)        & 0xff;
+        
+        break;
+        }
 
         default:
         {            
--- a/app/LoRaApp.h	Thu Apr 06 16:35:17 2017 +0000
+++ b/app/LoRaApp.h	Fri Sep 08 20:42:14 2017 +0000
@@ -50,6 +50,7 @@
     AppRamp, // Generate Ramp bytes
     AppAccl, // Accelerometer application    
     AppPushButton, // Push button application example
+    AppExtLight, // external light sensor
 };
 
 /*!
--- a/app/LoRaEventProc.cpp	Thu Apr 06 16:35:17 2017 +0000
+++ b/app/LoRaEventProc.cpp	Fri Sep 08 20:42:14 2017 +0000
@@ -206,6 +206,22 @@
             
             break;
         }
+        
+    case 13: 
+    {
+        uint8_t ptrIndex       =  0;
+        uint8_t data_header[2] = {0};
+
+            //Point the pointer to position index of Tx Buffer
+            LoRaApp.ApplicationPtrPos( ptrIndex );
+
+        data_header[0] = 0;
+        data_header[1] = 0;
+            
+            LoRaApp.ApplicationAppendData( data_header, 2 ); 
+            LoRaApp.ApplicationCall( AppExtLight ); // Transmit uplink counter   
+        break;
+    }
     
     default:
         break;
--- a/board/board.cpp	Thu Apr 06 16:35:17 2017 +0000
+++ b/board/board.cpp	Fri Sep 08 20:42:14 2017 +0000
@@ -23,6 +23,12 @@
 
 DigitalIn UsrButton( PC_13 );
 
+AnalogIn   ext_light(A2);
+
+DigitalOut ext_LED(D6);
+
+AnalogIn   ext_button(A3);
+
 #ifdef USE_IKS01A1_SENSOR
 X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance();
 MotionSensor *accelerometer = mems_expansion_board->GetAccelerometer();
--- a/board/board.h	Thu Apr 06 16:35:17 2017 +0000
+++ b/board/board.h	Fri Sep 08 20:42:14 2017 +0000
@@ -43,6 +43,12 @@
 
 extern AnalogOut UsrLED;
 
+extern AnalogIn  ext_light;
+
+extern DigitalOut ext_LED;
+
+extern AnalogIn  ext_button;
+
 #ifdef USE_IKS01A1_SENSOR
 extern X_NUCLEO_IKS01A1 *mems_expansion_board;
 extern MotionSensor *accelerometer;