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: mbed Chainable_RGB_LED DigitDisplay LoRaWAN-lib SX1276Lib
Fork of DSP_LoRaWAN by
Revision 2:66f94cef0765, committed 2016-04-21
- Comitter:
- spcores
- Date:
- Thu Apr 21 10:17:28 2016 +0000
- Parent:
- 1:c365eaf833bb
- Child:
- 3:042ccdf1dd92
- Commit message:
- With ABP & Smart LED Lamp
Changed in this revision
| app/Comissioning.h | Show annotated file Show diff for this revision Revisions of this file |
| app/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/app/Comissioning.h Tue Apr 12 05:21:37 2016 +0000
+++ b/app/Comissioning.h Thu Apr 21 10:17:28 2016 +0000
@@ -19,7 +19,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 1
+#define OVER_THE_AIR_ACTIVATION 0
/*!
* Indicates if the end-device is to be connected to a private or public network
@@ -31,7 +31,7 @@
/*!
* Mote device IEEE EUI (big endian)
*/
-#define LORAWAN_DEVICE_EUI { 0x82, 0x89, 0x9D, 0x68, 0xC9, 0xF4, 0xEC, 0xA6 } //{ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }
+#define LORAWAN_DEVICE_EUI { 0x82, 0x89, 0x9D, 0x68, 0xC9, 0xF4, 0xEC, 0xAA } //{ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }
/*!
* Application IEEE EUI (big endian)
--- a/app/main.cpp Tue Apr 12 05:21:37 2016 +0000
+++ b/app/main.cpp Thu Apr 21 10:17:28 2016 +0000
@@ -19,17 +19,23 @@
#include "LoRaMac.h"
#include "Comissioning.h"
#include "SerialDisplay.h"
-#include "DigitDisplay.h"
#include "ChainableLED.h"
+
+#define SEMTECH_BC_APP 0 //1 : Use Semtech Bootcamp Application
+
+#if defined( SEMTECH_BC_APP )
+ #include "DigitDisplay.h"
+#endif
+
/*!
* Join requests trials duty cycle.
*/
#define OVER_THE_AIR_ACTIVATION_DUTYCYCLE 10000000 // 10 [s] value in us
/*!
- * Defines the application data transmission duty cycle. 5s, value in [us].
+ * Defines the application data transmission duty cycle. 60s, value in [us].
*/
-#define APP_TX_DUTYCYCLE 5000000
+#define APP_TX_DUTYCYCLE 3000000
/*!
* Defines a random delay for application data transmission duty cycle. 1s,
@@ -159,7 +165,7 @@
*/
static bool NextTx = true;
-/*!
+#if defined( SEMTECH_BC_APP )/*!
* Hold the value returned from the Light Sensor
*/
//static float LightValue = 0.0;
@@ -183,28 +189,31 @@
DigitalOut buzzer(A3);
/*!
+ * Constructor for 4 Digit 7 semgent display
+ */
+DigitDisplay display(D8, D9);
+
+#endif
+
+/*!
+ * Constructor for Light Sensor
+*/
+AnalogIn LightSensor( A1 );
+
+/**
+Interrupt Event by SP
+**/
+InterruptIn buttonPressed(D8);
+
+/*!
* Constructor for the 3-color LED
*/
#define NUM_LED 3
ChainableLED color_led(D6, D7, NUM_LED);
-/*!
- * Constructor for Light Sensor
- */
-AnalogIn LightSensor( A1 );
+#define LIGHT_LEVEL 250 //0 : LED OFF | 250 : Bright White Light
-/*!
- * Constructor for 4 Digit 7 semgent display
- */
-DigitDisplay display(D8, D9);
-/* LED For Customer */
-DigitalOut myLed ( D8 );
-
-/**
-Interrupt Event by SP
-**/
-InterruptIn buttonPressed(D7);
uint8_t buttonCount = 0;
bool buttonStatus = false; //OFF = false & ON = true
bool ledStatus = false; //OFF = false & ON = true
@@ -216,15 +225,17 @@
buttonStatus=!buttonStatus;
if (buttonStatus == 1)
{
+ //Lights ON
ledStatus=1;
- myLed=1;
+ color_led.setColorRGB(0, LIGHT_LEVEL, LIGHT_LEVEL, LIGHT_LEVEL);
+
}
else
{
+ //Lights OFF
ledStatus = 0;
- myLed = 0;
+ color_led.setColorRGB(0, 0, 0, 0);
}
-
}
/*!
@@ -535,6 +546,7 @@
Led2StateChanged = true;
}
+#if defined( SEMTECH_BC_APP )
/*!
* \brief Function executed on Buzzer Timeout event
*/
@@ -543,7 +555,7 @@
buzzer = 0;
BuzTimer.detach( );
}
-
+#endif
/*!
* \brief MCPS-Confirm event function
*
@@ -665,14 +677,34 @@
Led3StateChanged = true;
}
break;
-
+ case 5:
+ //printf("****************************Msg Received from Server ********************");
+ break;
case 10:
- display.write( 0, McpsIndication->Buffer[0] );
- display.write( 1, McpsIndication->Buffer[1] );
- display.write( 2, McpsIndication->Buffer[2] );
- display.write( 3, McpsIndication->Buffer[3] );
+ /*
+ display.write( 0, McpsIndication->Buffer[0] );
+ display.write( 1, McpsIndication->Buffer[1] );
+ display.write( 2, McpsIndication->Buffer[2] );
+ display.write( 3, McpsIndication->Buffer[3] );
+ */
+ buttonStatus=McpsIndication->Buffer[0];
+
+ if (buttonStatus == 1)
+ {
+ //Lights ON
+ ledStatus=1;
+ color_led.setColorRGB(0, LIGHT_LEVEL, LIGHT_LEVEL, LIGHT_LEVEL);
+
+ }
+ else
+ {
+ //Lights OFF
+ ledStatus = 0;
+ color_led.setColorRGB(0, 0, 0, 0);
+ }
break;
+#if defined( SEMTECH_BC_APP )
case 20:
LightMode = McpsIndication->Buffer[0];
if( LightMode )
@@ -685,7 +717,7 @@
BuzTimer.attach_us( &OnBuzTimerEvent, 200000 );
buzzer = 1;
break;
-
+#endif
case 224:
if( ComplianceTest.Running == false )
{
@@ -824,10 +856,11 @@
int main( void )
{
//float tempLightValue = 0.0;
-
+#if defined( SEMTECH_BC_APP )
LightMode = 0; // 0: manual, 1: automatic
buzzer = 0; // 0: OFF, 1: ON
- myLed = 0;
+#endif
+
LoRaMacPrimitives_t LoRaMacPrimitives;
LoRaMacCallback_t LoRaMacCallbacks;
@@ -1019,18 +1052,5 @@
}
}
-
- /*
- // Read light sensor
- tempLightValue = LightSens.read( ) * 1.65;
-
- LightValue = ( 1 - tempLightValue );
-
- // Set automatic RGB from light sensor
- if( LightMode == 0 )
- {
- color_led.setColorRGB( 0, ( uint8_t )( 255 * LightValue ), ( uint8_t )( 255 * LightValue ), ( uint8_t )( 255 * LightValue ) );
- }
- */
}
}
