Fork of Semtech LoRaWAN stack
Fork of LoRaWAN-lib by
Revision 40:f7ce84dc9363, committed 2017-08-15
- Comitter:
- Shaun Nelson
- Date:
- Tue Aug 15 17:10:25 2017 -0400
- Branch:
- class_b
- Parent:
- 39:ca51084123b8
- Child:
- 41:b0d67ca11bdf
- Commit message:
- Add debug state
Changed in this revision
| LoRaMacClassB.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LoRaMacClassB.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
}
--- a/LoRaMacClassB.h Tue Aug 15 17:09:12 2017 -0400
+++ b/LoRaMacClassB.h Tue Aug 15 17:10:25 2017 -0400
@@ -297,6 +297,20 @@
* Delay for next beacon in ms
*/
TimerTime_t BeaconTimingDelay;
+
+ struct sBeaconRxError
+ {
+ uint16_t count;
+ uint16_t crc0;
+ uint16_t calcCrc0;
+ uint16_t crc1;
+ uint16_t calcCrc1;
+ uint8_t len;
+ uint8_t payload[32];
+
+ sBeaconRxError() : count(0), crc0(0), crc1(0), len(0) {}
+ } BeaconRxError;
+
}BeaconContext_t;
/*!
@@ -443,6 +457,8 @@
*/
bool LoRaMacClassBIsAcquisitionTimerSet( void );
+TimerTime_t LoRaMacClassBGetBeaconEventTime( void );
+
/*!
* \brief Verifies if the beacon mode active bit is set
*
