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.
Fork of LoRaWAN-lib by
Diff: LoRaMacClassB.cpp
- Branch:
- class_b
- Revision:
- 40:f7ce84dc9363
- Parent:
- 38:182ba91524e4
- Child:
- 48:81c0f4c4dd2c
--- a/LoRaMacClassB.cpp Tue Aug 15 17:09:12 2017 -0400
+++ b/LoRaMacClassB.cpp Tue Aug 15 17:10:25 2017 -0400
@@ -47,7 +47,7 @@
/*!
* Class B beacon context
*/
-static BeaconContext_t BeaconCtx;
+BeaconContext_t BeaconCtx;
/*!
* Timer for CLASS B beacon acquisition and tracking.
@@ -264,6 +264,13 @@
#endif // LORAMAC_CLASSB_ENABLED
}
+static TimerTime_t BeaconEventTime = 0;
+
+TimerTime_t LoRaMacClassBGetBeaconEventTime( )
+{
+ return BeaconEventTime;
+}
+
void LoRaMacClassBBeaconTimerEvent( void )
{
#ifdef LORAMAC_CLASSB_ENABLED
@@ -275,6 +282,7 @@
TimerTime_t currentTime = TimerGetCurrentTime( );
TimerStop( &BeaconTimer );
+ BeaconEventTime = 0;
// Beacon state machine
switch( BeaconState )
@@ -586,9 +594,14 @@
if( activateTimer == true )
{
+ BeaconEventTime = beaconEventTime;
+
TimerSetValue( &BeaconTimer, beaconEventTime );
TimerStart( &BeaconTimer );
}
+ else
+ BeaconEventTime = 0;
+
#endif // LORAMAC_CLASSB_ENABLED
}
@@ -873,6 +886,23 @@
LoRaMacClassBBeaconTimerEvent( );
}
+
+ if( ( crc0 != beaconCrc0 ) || ( crc1 != beaconCrc1 ) )
+ {
+ BeaconCtx.BeaconRxError.count++;
+ BeaconCtx.BeaconRxError.crc0 = beaconCrc0;
+ BeaconCtx.BeaconRxError.calcCrc0 = crc0;
+ BeaconCtx.BeaconRxError.crc1 = beaconCrc1;
+ BeaconCtx.BeaconRxError.calcCrc1 = crc1;
+ BeaconCtx.BeaconRxError.len = size;
+
+ uint8_t len = sizeof(BeaconCtx.BeaconRxError.payload);
+ if( size < len )
+ len = size;
+
+ memcpy1( BeaconCtx.BeaconRxError.payload, payload, len );
+ BeaconCtx.BeaconRxError.len = len;
+ }
}
if( BeaconState == BEACON_STATE_RX )
@@ -980,6 +1010,7 @@
// Halt ping slot state machine
TimerStop( &BeaconTimer );
+ BeaconEventTime = 0;
// Halt ping slot state machine
TimerStop( &PingSlotTimer );
@@ -1006,6 +1037,7 @@
}
TimerSetValue( &BeaconTimer, 1 );
TimerStart( &BeaconTimer );
+ BeaconEventTime = 1;
}
#endif // LORAMAC_CLASSB_ENABLED
}

