Added a Binary Input object to the demo objects and updated the demo applications and device object to support the new object.
This commit is contained in:
@@ -73,8 +73,8 @@ extern "C" {
|
||||
uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t timeDuration, /* 0=optional */
|
||||
BACNET_COMMUNICATION_ENABLE_DISABLE state, char *password); /* NULL=optional */
|
||||
|
||||
void Send_TimeSync(BACNET_DATE *bdate, BACNET_TIME *btime);
|
||||
void Send_TimeSyncUTC(BACNET_DATE *bdate, BACNET_TIME *btime);
|
||||
void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime);
|
||||
void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
/* demo objects */
|
||||
#include "device.h"
|
||||
#include "ai.h"
|
||||
#include "bi.h"
|
||||
#include "ao.h"
|
||||
#if BACFILE
|
||||
#include "bacfile.h"
|
||||
@@ -123,6 +124,27 @@ void handler_read_property(uint8_t * service_request,
|
||||
} else
|
||||
error = true;
|
||||
break;
|
||||
case OBJECT_BINARY_INPUT:
|
||||
if (Binary_Input_Valid_Instance(data.object_instance)) {
|
||||
len = Binary_Input_Encode_Property_APDU(&Temp_Buf[0],
|
||||
data.object_instance,
|
||||
data.object_property,
|
||||
data.array_index, &error_class, &error_code);
|
||||
if (len >= 0) {
|
||||
/* encode the APDU portion of the packet */
|
||||
data.application_data = &Temp_Buf[0];
|
||||
data.application_data_len = len;
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
pdu_len +=
|
||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
||||
[pdu_len], service_data->invoke_id, &data);
|
||||
fprintf(stderr, "Sending Read Property Ack!\n");
|
||||
send = true;
|
||||
} else
|
||||
error = true;
|
||||
} else
|
||||
error = true;
|
||||
break;
|
||||
case OBJECT_ANALOG_OUTPUT:
|
||||
if (Analog_Output_Valid_Instance(data.object_instance)) {
|
||||
len = Analog_Output_Encode_Property_APDU(&Temp_Buf[0],
|
||||
|
||||
@@ -31,19 +31,17 @@
|
||||
#include "bacdcode.h"
|
||||
#include "timesync.h"
|
||||
|
||||
static void show_bacnet_date_time(
|
||||
BACNET_DATE *bdate,
|
||||
BACNET_TIME *btime)
|
||||
static void show_bacnet_date_time(BACNET_DATE * bdate, BACNET_TIME * btime)
|
||||
{
|
||||
/* show the date received */
|
||||
fprintf(stderr, "%u", (unsigned)bdate->year);
|
||||
fprintf(stderr, "/%u", (unsigned)bdate->month);
|
||||
fprintf(stderr, "/%u", (unsigned)bdate->day);
|
||||
fprintf(stderr, "%u", (unsigned) bdate->year);
|
||||
fprintf(stderr, "/%u", (unsigned) bdate->month);
|
||||
fprintf(stderr, "/%u", (unsigned) bdate->day);
|
||||
/* show the time received */
|
||||
fprintf(stderr, " %02u", (unsigned)btime->hour);
|
||||
fprintf(stderr, ":%02u", (unsigned)btime->min);
|
||||
fprintf(stderr, ":%02u", (unsigned)btime->sec);
|
||||
fprintf(stderr, ".%02u", (unsigned)btime->hundredths);
|
||||
fprintf(stderr, " %02u", (unsigned) btime->hour);
|
||||
fprintf(stderr, ":%02u", (unsigned) btime->min);
|
||||
fprintf(stderr, ":%02u", (unsigned) btime->sec);
|
||||
fprintf(stderr, ".%02u", (unsigned) btime->hundredths);
|
||||
fprintf(stderr, "\r\n");
|
||||
}
|
||||
|
||||
@@ -57,9 +55,7 @@ void handler_timesync(uint8_t * service_request,
|
||||
(void) src;
|
||||
(void) service_len;
|
||||
len = timesync_decode_service_request(service_request,
|
||||
service_len,
|
||||
&bdate,
|
||||
&btime);
|
||||
service_len, &bdate, &btime);
|
||||
fprintf(stderr, "Received TimeSyncronization Request\r\n");
|
||||
show_bacnet_date_time(&bdate, &btime);
|
||||
/* FIXME: set the time? */
|
||||
@@ -77,9 +73,7 @@ void handler_timesync_utc(uint8_t * service_request,
|
||||
(void) src;
|
||||
(void) service_len;
|
||||
len = timesync_decode_service_request(service_request,
|
||||
service_len,
|
||||
&bdate,
|
||||
&btime);
|
||||
service_len, &bdate, &btime);
|
||||
fprintf(stderr, "Received TimeSyncronization Request\r\n");
|
||||
show_bacnet_date_time(&bdate, &btime);
|
||||
/* FIXME: set the time? */
|
||||
|
||||
@@ -54,10 +54,11 @@ void handler_who_is(uint8_t * service_request,
|
||||
else if (len != -1) {
|
||||
/* is my device id within the limits? */
|
||||
if (((Device_Object_Instance_Number() >= (uint32_t) low_limit) &&
|
||||
(Device_Object_Instance_Number() <= (uint32_t) high_limit)) ||
|
||||
(Device_Object_Instance_Number() <= (uint32_t) high_limit))
|
||||
||
|
||||
/* BACnet wildcard is the max instance number - everyone responds */
|
||||
((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) &&
|
||||
(BACNET_MAX_INSTANCE <= (uint32_t) high_limit)))
|
||||
(BACNET_MAX_INSTANCE <= (uint32_t) high_limit)))
|
||||
iam_send(&Handler_Transmit_Buffer[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ extern "C" {
|
||||
|
||||
void handler_i_have(uint8_t * service_request,
|
||||
uint16_t service_len, BACNET_ADDRESS * src);
|
||||
|
||||
|
||||
void handler_timesync(uint8_t * service_request,
|
||||
uint16_t service_len, BACNET_ADDRESS * src);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "handlers.h"
|
||||
#include "txbuf.h"
|
||||
|
||||
void Send_TimeSync(BACNET_DATE *bdate, BACNET_TIME *btime)
|
||||
void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest;
|
||||
@@ -60,14 +60,15 @@ void Send_TimeSync(BACNET_DATE *bdate, BACNET_TIME *btime)
|
||||
pdu_len += timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
bdate, btime);
|
||||
/* send it out the datalink */
|
||||
bytes_sent = datalink_send_pdu(&dest,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Time-Synchronization Request (%s)!\n",
|
||||
fprintf(stderr,
|
||||
"Failed to Send Time-Synchronization Request (%s)!\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
void Send_TimeSyncUTC(BACNET_DATE *bdate, BACNET_TIME *btime)
|
||||
void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest;
|
||||
@@ -85,9 +86,10 @@ void Send_TimeSyncUTC(BACNET_DATE *bdate, BACNET_TIME *btime)
|
||||
pdu_len += timesync_utc_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
bdate, btime);
|
||||
/* send it out the datalink */
|
||||
bytes_sent = datalink_send_pdu(&dest,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send UTC-Time-Synchronization Request (%s)!\n",
|
||||
fprintf(stderr,
|
||||
"Failed to Send UTC-Time-Synchronization Request (%s)!\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user