Added encode/decode for Time_Synchronization_Recipients.

Added Send_TimeSync_Remote() which can use specific destination address.
Added function prototypes for time sync master in the handlers.
This commit is contained in:
skarg
2013-02-20 23:54:11 +00:00
parent 209f9e82a2
commit 1c5d399a38
5 changed files with 350 additions and 7 deletions
+14 -6
View File
@@ -45,13 +45,13 @@
/** @file s_ts.c Send TimeSync requests. */
void Send_TimeSync(
void Send_TimeSync_Remote(
BACNET_ADDRESS * dest,
BACNET_DATE * bdate,
BACNET_TIME * btime)
{
int len = 0;
int pdu_len = 0;
BACNET_ADDRESS dest;
int bytes_sent = 0;
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -59,13 +59,11 @@ void Send_TimeSync(
if (!dcc_communication_enabled())
return;
/* we could use unicast or broadcast */
datalink_get_broadcast_address(&dest);
datalink_get_my_address(&my_address);
/* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */
@@ -74,7 +72,7 @@ void Send_TimeSync(
pdu_len += len;
/* send it out the datalink */
bytes_sent =
datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0],
datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
@@ -83,6 +81,16 @@ void Send_TimeSync(
#endif
}
void Send_TimeSync(
BACNET_DATE * bdate,
BACNET_TIME * btime)
{
BACNET_ADDRESS dest;
datalink_get_broadcast_address(&dest);
Send_TimeSync_Remote(&dest, bdate, btime);
}
void Send_TimeSyncUTC(
BACNET_DATE * bdate,
BACNET_TIME * btime)