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 LoRaWAN-lib
Diff: app/main.cpp
- Revision:
- 10:4e528716aa7a
- Parent:
- 9:ee9dcbb9708d
- Child:
- 11:876331d64e0e
--- a/app/main.cpp Mon Apr 24 13:38:31 2017 +0000
+++ b/app/main.cpp Thu Dec 27 18:37:04 2018 +0000
@@ -143,24 +143,6 @@
static TimerEvent_t TxNextPacketTimer;
/*!
- * Specifies the state of the application LED
- */
-static bool AppLedStateOn = false;
-volatile bool Led3StateChanged = false;
-/*!
- * Timer to handle the state of LED1
- */
-static TimerEvent_t Led1Timer;
-volatile bool Led1State = false;
-volatile bool Led1StateChanged = false;
-/*!
- * Timer to handle the state of LED2
- */
-static TimerEvent_t Led2Timer;
-volatile bool Led2State = false;
-volatile bool Led2StateChanged = false;
-
-/*!
* Indicates if a new packet can be sent
*/
static bool NextTx = true;
@@ -232,6 +214,12 @@
}LoRaMacDownlinkStatus;
volatile bool DownlinkStatusUpdated = false;
+
+// Application Globals
+DigitalOut myled(D6);
+
+
+
void SerialDisplayRefresh( void )
{
MibRequestConfirm_t mibReq;
@@ -260,8 +248,6 @@
SerialDisplayUpdateDutyCycle( false );
#endif
SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
-
- SerialDisplayUpdateLedState( 3, AppLedStateOn );
}
void SerialRxProcess( void )
@@ -290,7 +276,7 @@
{
case 15:
{
- AppData[0] = AppLedStateOn;
+ AppData[0] = 0;
if( IsTxConfirmed == true )
{
AppData[1] = LoRaMacDownlinkStatus.DownlinkCounter >> 8;
@@ -416,27 +402,6 @@
}
}
-/*!
- * \brief Function executed on Led 1 Timeout event
- */
-static void OnLed1TimerEvent( void )
-{
- TimerStop( &Led1Timer );
- // Switch LED 1 OFF
- Led1State = false;
- Led1StateChanged = true;
-}
-
-/*!
- * \brief Function executed on Led 2 Timeout event
- */
-static void OnLed2TimerEvent( void )
-{
- TimerStop( &Led2Timer );
- // Switch LED 2 OFF
- Led2State = false;
- Led2StateChanged = true;
-}
/*!
* \brief MCPS-Confirm event function
@@ -475,11 +440,6 @@
LoRaMacUplinkStatus.Datarate = mcpsConfirm->Datarate;
LoRaMacUplinkStatus.UplinkCounter = mcpsConfirm->UpLinkCounter;
- // Switch LED 1 ON
- Led1State = true;
- Led1StateChanged = true;
- TimerStart( &Led1Timer );
-
UplinkStatusUpdated = true;
}
NextTx = true;
@@ -558,11 +518,6 @@
{
case 1: // The application LED can be controlled on port 1 or 2
case 2:
- if( mcpsIndication->BufferSize == 1 )
- {
- AppLedStateOn = mcpsIndication->Buffer[0] & 0x01;
- Led3StateChanged = true;
- }
break;
case 224:
if( ComplianceTest.Running == false )
@@ -702,10 +657,6 @@
}
}
- // Switch LED 2 ON for each received downlink
- Led2State = true;
- Led2StateChanged = true;
- TimerStart( &Led2Timer );
DownlinkStatusUpdated = true;
}
@@ -756,11 +707,23 @@
UplinkStatusUpdated = true;
}
+void flash_builtin() {
+ myled = 1; // turn the LED on (HIGH is the voltage level)
+ wait(2); // wait for a second
+ myled = 0; // turn the LED off by making the voltage LOW
+ wait(1);
+}
+
/**
* Main application entry point.
*/
int main( void )
{
+ flash_builtin();
+ flash_builtin();
+ flash_builtin();
+ flash_builtin();
+
LoRaMacPrimitives_t LoRaMacPrimitives;
LoRaMacCallback_t LoRaMacCallbacks;
MibRequestConfirm_t mibReq;
@@ -784,6 +747,7 @@
while( 1 )
{
SerialRxProcess( );
+ flash_builtin();
if( IsNetworkJoinedStatusUpdate == true )
{
IsNetworkJoinedStatusUpdate = false;
@@ -791,21 +755,6 @@
LoRaMacMibGetRequestConfirm( &mibReq );
SerialDisplayUpdateNetworkIsJoined( mibReq.Param.IsNetworkJoined );
}
- if( Led1StateChanged == true )
- {
- Led1StateChanged = false;
- SerialDisplayUpdateLedState( 1, Led1State );
- }
- if( Led2StateChanged == true )
- {
- Led2StateChanged = false;
- SerialDisplayUpdateLedState( 2, Led2State );
- }
- if( Led3StateChanged == true )
- {
- Led3StateChanged = false;
- SerialDisplayUpdateLedState( 3, AppLedStateOn );
- }
if( UplinkStatusUpdated == true )
{
UplinkStatusUpdated = false;
@@ -814,7 +763,6 @@
if( DownlinkStatusUpdated == true )
{
DownlinkStatusUpdated = false;
- SerialDisplayUpdateLedState( 2, Led2State );
SerialDisplayUpdateDownlink( LoRaMacDownlinkStatus.RxData, LoRaMacDownlinkStatus.Rssi, LoRaMacDownlinkStatus.Snr, LoRaMacDownlinkStatus.DownlinkCounter, LoRaMacDownlinkStatus.Port, LoRaMacDownlinkStatus.Buffer, LoRaMacDownlinkStatus.BufferSize );
}
@@ -830,12 +778,6 @@
TimerInit( &TxNextPacketTimer, OnTxNextPacketTimerEvent );
- TimerInit( &Led1Timer, OnLed1TimerEvent );
- TimerSetValue( &Led1Timer, 25 );
-
- TimerInit( &Led2Timer, OnLed2TimerEvent );
- TimerSetValue( &Led2Timer, 25 );
-
mibReq.Type = MIB_ADR;
mibReq.Param.AdrEnable = LORAWAN_ADR_ON;
LoRaMacMibSetRequestConfirm( &mibReq );