Added TimeSynchronization server example.
This commit is contained in:
@@ -87,8 +87,13 @@ static BACNET_DATE Local_Date; /* rely on OS, if there is one */
|
||||
BACnet UTC offset is expressed in minutes. */
|
||||
static int32_t UTC_Offset = 5 * 60;
|
||||
static bool Daylight_Savings_Status = false; /* rely on OS */
|
||||
/* List_Of_Session_Keys */
|
||||
#if defined(BACNET_TIME_MASTER)
|
||||
static bool Align_Intervals;
|
||||
static uint32_t Interval_Minutes;
|
||||
static uint32_t Interval_Offset_Minutes;
|
||||
/* Time_Synchronization_Recipients */
|
||||
#endif
|
||||
/* List_Of_Session_Keys */
|
||||
/* Max_Master - rely on MS/TP subsystem, if there is one */
|
||||
/* Max_Info_Frames - rely on MS/TP subsystem, if there is one */
|
||||
/* Device_Address_Binding - required, but relies on binding cache */
|
||||
@@ -720,6 +725,80 @@ bool Device_Daylight_Savings_Status(void)
|
||||
return Daylight_Savings_Status;
|
||||
}
|
||||
|
||||
#if defined(BACNET_TIME_MASTER)
|
||||
/**
|
||||
* Sets the time sync interval in minutes
|
||||
*
|
||||
* @param flag
|
||||
* This property, of type BOOLEAN, specifies whether (TRUE)
|
||||
* or not (FALSE) clock-aligned periodic time synchronization is
|
||||
* enabled. If periodic time synchronization is enabled and the
|
||||
* time synchronization interval is a factor of (divides without
|
||||
* remainder) an hour or day, then the beginning of the period
|
||||
* specified for time synchronization shall be aligned to the hour or
|
||||
* day, respectively. If this property is present, it shall be writable.
|
||||
*/
|
||||
bool Device_Align_Intervals_Set(bool flag)
|
||||
{
|
||||
Align_Intervals = flag;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Device_Align_Intervals(void)
|
||||
{
|
||||
return Align_Intervals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time sync interval in minutes
|
||||
*
|
||||
* @param minutes
|
||||
* This property, of type Unsigned, specifies the periodic
|
||||
* interval in minutes at which TimeSynchronization and
|
||||
* UTCTimeSynchronization requests shall be sent. If this
|
||||
* property has a value of zero, then periodic time synchronization is
|
||||
* disabled. If this property is present, it shall be writable.
|
||||
*/
|
||||
bool Device_Time_Sync_Interval_Set(uint32_t minutes)
|
||||
{
|
||||
Interval_Minutes = minutes;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t Device_Time_Sync_Interval(void)
|
||||
{
|
||||
return Interval_Minutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time sync interval offset value.
|
||||
*
|
||||
* @param minutes
|
||||
* This property, of type Unsigned, specifies the offset in
|
||||
* minutes from the beginning of the period specified for time
|
||||
* synchronization until the actual time synchronization requests
|
||||
* are sent. The offset used shall be the value of Interval_Offset
|
||||
* modulo the value of Time_Synchronization_Interval;
|
||||
* e.g., if Interval_Offset has the value 31 and
|
||||
* Time_Synchronization_Interval is 30, the offset used shall be 1.
|
||||
* Interval_Offset shall have no effect if Align_Intervals is
|
||||
* FALSE. If this property is present, it shall be writable.
|
||||
*/
|
||||
bool Device_Interval_Offset_Set(uint32_t minutes)
|
||||
{
|
||||
Interval_Offset_Minutes = minutes;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t Device_Interval_Offset(void)
|
||||
{
|
||||
return Interval_Offset_Minutes;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* return the length of the apdu encoded or BACNET_STATUS_ERROR for error or
|
||||
BACNET_STATUS_ABORT for abort message */
|
||||
int Device_Read_Property_Local(
|
||||
|
||||
Reference in New Issue
Block a user