File tree Expand file tree Collapse file tree 14 files changed +135
-0
lines changed Expand file tree Collapse file tree 14 files changed +135
-0
lines changed Original file line number Diff line number Diff line change @@ -728,7 +728,12 @@ static void McpsIndication( McpsIndication_t *mcpsIndication )
728728
729729 if ( mcpsIndication -> DeviceTimeAnsReceived == true )
730730 {
731+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
732+ // Provide fix values. DeviceTimeAns is accurate
733+ LmHandlerCallbacks -> OnSysTimeUpdate ( true, 0 );
734+ #else
731735 LmHandlerCallbacks -> OnSysTimeUpdate ( );
736+ #endif
732737 }
733738 // Call packages RxProcess function
734739 LmHandlerPackagesNotify ( PACKAGE_MCPS_INDICATION , mcpsIndication );
Original file line number Diff line number Diff line change @@ -199,10 +199,20 @@ typedef struct LmHandlerCallbacks_s
199199 * \param [IN] params notification parameters
200200 */
201201 void ( * OnBeaconStatusChange )( LoRaMAcHandlerBeaconParams_t * params );
202+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
203+ /*!
204+ * Notifies the upper layer that the system time has been updated.
205+ *
206+ * \param [in] isSynchronized Indicates if the system time is synchronized in the range +/-1 second
207+ * \param [in] timeCorrection Received time correction value
208+ */
209+ void ( * OnSysTimeUpdate )( bool isSynchronized , int32_t timeCorrection );
210+ #else
202211 /*!
203212 * Notifies the upper layer that the system time has been updated.
204213 */
205214 void ( * OnSysTimeUpdate )( void );
215+ #endif
206216}LmHandlerCallbacks_t ;
207217
208218/*!
Original file line number Diff line number Diff line change 2323
2424#include "LoRaMac.h"
2525
26+ /*!
27+ * If set to 1 the new API defining \ref OnSysTimeUpdate callback is used.
28+ */
29+ #define LMH_SYS_TIME_UPDATE_NEW_API 1
30+
2631/*!
2732 *
2833 */
Original file line number Diff line number Diff line change @@ -135,10 +135,20 @@ typedef struct LmhPackage_s
135135 * \retval status Returns \ref LORAMAC_HANDLER_SET if joined else \ref LORAMAC_HANDLER_RESET
136136 */
137137 LmHandlerErrorStatus_t ( * OnDeviceTimeRequest )( void );
138+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
139+ /*!
140+ * Notifies the upper layer that the system time has been updated.
141+ *
142+ * \param [in] isSynchronized Indicates if the system time is synchronized in the range +/-1 second
143+ * \param [in] timeCorrection Received time correction value
144+ */
145+ void ( * OnSysTimeUpdate )( bool isSynchronized , int32_t timeCorrection );
146+ #else
138147 /*!
139148 * Notifies the upper layer that the system time has been updated.
140149 */
141150 void ( * OnSysTimeUpdate )( void );
151+ #endif
142152}LmhPackage_t ;
143153
144154#endif // __LMH_PACKAGE_H__
Original file line number Diff line number Diff line change @@ -250,10 +250,16 @@ static void LmhpClockSyncOnMcpsIndication( McpsIndication_t *mcpsIndication )
250250 LmhpClockSyncState .TimeReqParam .Fields .TokenReq = ( LmhpClockSyncState .TimeReqParam .Fields .TokenReq + 1 ) & 0x0F ;
251251 if ( LmhpClockSyncPackage .OnSysTimeUpdate != NULL )
252252 {
253+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
254+ LmhpClockSyncPackage .OnSysTimeUpdate (
255+ ( timeCorrection >= -1 ) && ( timeCorrection <= 1 ),
256+ timeCorrection );
257+ #else
253258 if ( ( timeCorrection >= -1 ) && ( timeCorrection <= 1 ) )
254259 {
255260 LmhpClockSyncPackage .OnSysTimeUpdate ( );
256261 }
262+ #endif
257263 }
258264 }
259265 break ;
Original file line number Diff line number Diff line change @@ -138,7 +138,11 @@ static void OnTxData( LmHandlerTxParams_t* params );
138138static void OnRxData ( LmHandlerAppData_t * appData , LmHandlerRxParams_t * params );
139139static void OnClassChange ( DeviceClass_t deviceClass );
140140static void OnBeaconStatusChange ( LoRaMAcHandlerBeaconParams_t * params );
141+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
142+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection );
143+ #else
141144static void OnSysTimeUpdate ( void );
145+ #endif
142146#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
143147static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size );
144148static uint8_t FragDecoderRead ( uint32_t addr , uint8_t * data , uint32_t size );
@@ -476,10 +480,17 @@ static void OnBeaconStatusChange( LoRaMAcHandlerBeaconParams_t* params )
476480 DisplayBeaconUpdate ( params );
477481}
478482
483+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
484+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection )
485+ {
486+ IsClockSynched = isSynchronized ;
487+ }
488+ #else
479489static void OnSysTimeUpdate ( void )
480490{
481491 IsClockSynched = true;
482492}
493+ #endif
483494
484495#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
485496static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size )
Original file line number Diff line number Diff line change @@ -136,7 +136,11 @@ static void OnTxData( LmHandlerTxParams_t* params );
136136static void OnRxData ( LmHandlerAppData_t * appData , LmHandlerRxParams_t * params );
137137static void OnClassChange ( DeviceClass_t deviceClass );
138138static void OnBeaconStatusChange ( LoRaMAcHandlerBeaconParams_t * params );
139+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
140+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection );
141+ #else
139142static void OnSysTimeUpdate ( void );
143+ #endif
140144#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
141145static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size );
142146static uint8_t FragDecoderRead ( uint32_t addr , uint8_t * data , uint32_t size );
@@ -465,10 +469,17 @@ static void OnBeaconStatusChange( LoRaMAcHandlerBeaconParams_t* params )
465469 DisplayBeaconUpdate ( params );
466470}
467471
472+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
473+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection )
474+ {
475+ IsClockSynched = isSynchronized ;
476+ }
477+ #else
468478static void OnSysTimeUpdate ( void )
469479{
470480 IsClockSynched = true;
471481}
482+ #endif
472483
473484#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
474485static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size )
Original file line number Diff line number Diff line change @@ -133,7 +133,11 @@ static void OnTxData( LmHandlerTxParams_t* params );
133133static void OnRxData ( LmHandlerAppData_t * appData , LmHandlerRxParams_t * params );
134134static void OnClassChange ( DeviceClass_t deviceClass );
135135static void OnBeaconStatusChange ( LoRaMAcHandlerBeaconParams_t * params );
136+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
137+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection );
138+ #else
136139static void OnSysTimeUpdate ( void );
140+ #endif
137141#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
138142static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size );
139143static uint8_t FragDecoderRead ( uint32_t addr , uint8_t * data , uint32_t size );
@@ -461,10 +465,17 @@ static void OnBeaconStatusChange( LoRaMAcHandlerBeaconParams_t* params )
461465 DisplayBeaconUpdate ( params );
462466}
463467
468+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
469+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection )
470+ {
471+ IsClockSynched = isSynchronized ;
472+ }
473+ #else
464474static void OnSysTimeUpdate ( void )
465475{
466476 IsClockSynched = true;
467477}
478+ #endif
468479
469480#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
470481static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size )
Original file line number Diff line number Diff line change @@ -133,7 +133,11 @@ static void OnTxData( LmHandlerTxParams_t* params );
133133static void OnRxData ( LmHandlerAppData_t * appData , LmHandlerRxParams_t * params );
134134static void OnClassChange ( DeviceClass_t deviceClass );
135135static void OnBeaconStatusChange ( LoRaMAcHandlerBeaconParams_t * params );
136+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
137+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection );
138+ #else
136139static void OnSysTimeUpdate ( void );
140+ #endif
137141#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
138142static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size );
139143static uint8_t FragDecoderRead ( uint32_t addr , uint8_t * data , uint32_t size );
@@ -461,10 +465,17 @@ static void OnBeaconStatusChange( LoRaMAcHandlerBeaconParams_t* params )
461465 DisplayBeaconUpdate ( params );
462466}
463467
468+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
469+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection )
470+ {
471+ IsClockSynched = isSynchronized ;
472+ }
473+ #else
464474static void OnSysTimeUpdate ( void )
465475{
466476 IsClockSynched = true;
467477}
478+ #endif
468479
469480#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
470481static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size )
Original file line number Diff line number Diff line change @@ -133,7 +133,11 @@ static void OnTxData( LmHandlerTxParams_t* params );
133133static void OnRxData ( LmHandlerAppData_t * appData , LmHandlerRxParams_t * params );
134134static void OnClassChange ( DeviceClass_t deviceClass );
135135static void OnBeaconStatusChange ( LoRaMAcHandlerBeaconParams_t * params );
136+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
137+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection );
138+ #else
136139static void OnSysTimeUpdate ( void );
140+ #endif
137141#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
138142static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size );
139143static uint8_t FragDecoderRead ( uint32_t addr , uint8_t * data , uint32_t size );
@@ -461,10 +465,17 @@ static void OnBeaconStatusChange( LoRaMAcHandlerBeaconParams_t* params )
461465 DisplayBeaconUpdate ( params );
462466}
463467
468+ #if ( LMH_SYS_TIME_UPDATE_NEW_API == 1 )
469+ static void OnSysTimeUpdate ( bool isSynchronized , int32_t timeCorrection )
470+ {
471+ IsClockSynched = isSynchronized ;
472+ }
473+ #else
464474static void OnSysTimeUpdate ( void )
465475{
466476 IsClockSynched = true;
467477}
478+ #endif
468479
469480#if ( FRAG_DECODER_FILE_HANDLING_NEW_API == 1 )
470481static uint8_t FragDecoderWrite ( uint32_t addr , uint8_t * data , uint32_t size )
You can’t perform that action at this time.
0 commit comments