for India band 30dBm LoRa Module, DSPLoRa based on code from Semtech and as modified by Sachin Pukale/ TCL/
Dependencies: mbed Chainable_RGB_LED DigitDisplay LoRaWAN-lib SX1276Lib
Fork of DSP_LoRaWAN by
Diff: app/main.cpp
- Revision:
- 2:66f94cef0765
- Parent:
- 1:c365eaf833bb
- Child:
- 3:042ccdf1dd92
--- 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 ) ); - } - */ } }