Merged revision(s) 2969 from branches/releases/bacnet-stack-0-8-0:
Fix Send_TimeSyncUTC() to calculate the right length for datalink_send_pdu(). Added Send_TimeSyncUTC_Remote(). [bugs:#44] ........
This commit is contained in:
@@ -45,6 +45,13 @@
|
|||||||
|
|
||||||
/** @file s_ts.c Send TimeSync requests. */
|
/** @file s_ts.c Send TimeSync requests. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a TimeSync message to a specific destination
|
||||||
|
*
|
||||||
|
* @param dest - #BACNET_ADDRESS - the specific destination
|
||||||
|
* @param bdate - #BACNET_DATE
|
||||||
|
* @param btime - #BACNET_TIME
|
||||||
|
*/
|
||||||
void Send_TimeSync_Remote(
|
void Send_TimeSync_Remote(
|
||||||
BACNET_ADDRESS * dest,
|
BACNET_ADDRESS * dest,
|
||||||
BACNET_DATE * bdate,
|
BACNET_DATE * bdate,
|
||||||
@@ -80,6 +87,12 @@ void Send_TimeSync_Remote(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a TimeSync message as a broadcast
|
||||||
|
*
|
||||||
|
* @param bdate - #BACNET_DATE
|
||||||
|
* @param btime - #BACNET_TIME
|
||||||
|
*/
|
||||||
void Send_TimeSync(
|
void Send_TimeSync(
|
||||||
BACNET_DATE * bdate,
|
BACNET_DATE * bdate,
|
||||||
BACNET_TIME * btime)
|
BACNET_TIME * btime)
|
||||||
@@ -90,12 +103,20 @@ void Send_TimeSync(
|
|||||||
Send_TimeSync_Remote(&dest, bdate, btime);
|
Send_TimeSync_Remote(&dest, bdate, btime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Send_TimeSyncUTC(
|
/**
|
||||||
|
* Sends a UTC TimeSync message to a specific destination
|
||||||
|
*
|
||||||
|
* @param dest - #BACNET_ADDRESS - the specific destination
|
||||||
|
* @param bdate - #BACNET_DATE
|
||||||
|
* @param btime - #BACNET_TIME
|
||||||
|
*/
|
||||||
|
void Send_TimeSyncUTC_Remote(
|
||||||
|
BACNET_ADDRESS * dest,
|
||||||
BACNET_DATE * bdate,
|
BACNET_DATE * bdate,
|
||||||
BACNET_TIME * btime)
|
BACNET_TIME * btime)
|
||||||
{
|
{
|
||||||
|
int len = 0;
|
||||||
int pdu_len = 0;
|
int pdu_len = 0;
|
||||||
BACNET_ADDRESS dest;
|
|
||||||
int bytes_sent = 0;
|
int bytes_sent = 0;
|
||||||
BACNET_NPDU_DATA npdu_data;
|
BACNET_NPDU_DATA npdu_data;
|
||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
@@ -103,19 +124,19 @@ void Send_TimeSyncUTC(
|
|||||||
if (!dcc_communication_enabled())
|
if (!dcc_communication_enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* we could use unicast or broadcast */
|
|
||||||
datalink_get_broadcast_address(&dest);
|
|
||||||
datalink_get_my_address(&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
/* encode the NPDU portion of the packet */
|
/* encode the NPDU portion of the packet */
|
||||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||||
pdu_len =
|
pdu_len =
|
||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address,
|
||||||
&npdu_data);
|
&npdu_data);
|
||||||
/* encode the APDU portion of the packet */
|
/* encode the APDU portion of the packet */
|
||||||
pdu_len =
|
len =
|
||||||
timesync_utc_encode_apdu(&Handler_Transmit_Buffer[pdu_len], bdate, btime);
|
timesync_utc_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||||
|
bdate, btime);
|
||||||
|
pdu_len += len;
|
||||||
bytes_sent =
|
bytes_sent =
|
||||||
datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||||
pdu_len);
|
pdu_len);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (bytes_sent <= 0)
|
if (bytes_sent <= 0)
|
||||||
@@ -125,6 +146,22 @@ void Send_TimeSyncUTC(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a UTC TimeSync message as a broadcast
|
||||||
|
*
|
||||||
|
* @param bdate - #BACNET_DATE
|
||||||
|
* @param btime - #BACNET_TIME
|
||||||
|
*/
|
||||||
|
void Send_TimeSyncUTC(
|
||||||
|
BACNET_DATE * bdate,
|
||||||
|
BACNET_TIME * btime)
|
||||||
|
{
|
||||||
|
BACNET_ADDRESS dest;
|
||||||
|
|
||||||
|
datalink_get_broadcast_address(&dest);
|
||||||
|
Send_TimeSyncUTC_Remote(&dest, bdate, btime);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a UTC TimeSync message using the local time from the device.
|
* Sends a UTC TimeSync message using the local time from the device.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ extern "C" {
|
|||||||
void Send_TimeSyncUTC(
|
void Send_TimeSyncUTC(
|
||||||
BACNET_DATE * bdate,
|
BACNET_DATE * bdate,
|
||||||
BACNET_TIME * btime);
|
BACNET_TIME * btime);
|
||||||
|
void Send_TimeSyncUTC_Remote(
|
||||||
|
BACNET_ADDRESS * dest,
|
||||||
|
BACNET_DATE * bdate,
|
||||||
|
BACNET_TIME * btime);
|
||||||
void Send_TimeSyncUTC_Device(void);
|
void Send_TimeSyncUTC_Device(void);
|
||||||
void Send_TimeSync_Device(void);
|
void Send_TimeSync_Device(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user