indented per coding standard using indent.sh
This commit is contained in:
@@ -488,7 +488,7 @@ bool bacapp_parse_application_data(BACNET_APPLICATION_TAG tag_number,
|
||||
value->type.Signed_Int = long_value;
|
||||
} else if (tag_number == BACNET_APPLICATION_TAG_REAL) {
|
||||
double_value = strtod(argv, NULL);
|
||||
value->type.Real = (float)double_value;
|
||||
value->type.Real = (float) double_value;
|
||||
} else if (tag_number == BACNET_APPLICATION_TAG_DOUBLE) {
|
||||
double_value = strtod(argv, NULL);
|
||||
value->type.Double = double_value;
|
||||
|
||||
@@ -644,13 +644,12 @@ typedef enum {
|
||||
/* procedures and constraints described in Clause 23. */
|
||||
} BACNET_LIFE_SAFETY_STATE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
SILENCED_STATE_UNSILENCED = 0,
|
||||
SILENCED_STATE_AUDIBLE_SILENCED = 1,
|
||||
SILENCED_STATE_VISIBLE_SILENCED = 2,
|
||||
SILENCED_STATE_ALL_SILENCED = 3,
|
||||
/* Enumerated values 0-63 are reserved for definition by ASHRAE.*/
|
||||
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */
|
||||
/* Enumerated values 64-65535 may be used by others subject to */
|
||||
/* procedures and constraints described in Clause 23. */
|
||||
} BACNET_SILENCED_STATE;
|
||||
|
||||
+2
-2
@@ -278,11 +278,11 @@ uint16_t bip_receive(BACNET_ADDRESS * src, /* source address */
|
||||
pdu_len = 0;
|
||||
}
|
||||
}
|
||||
#ifdef BBMD_ENABLED
|
||||
#ifdef BBMD_ENABLED
|
||||
if (buf[1] < MAX_BVLC_FUNCTION) {
|
||||
bbmd_handler(&buf[0], received_bytes, &sin);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
+123
-180
@@ -43,17 +43,18 @@
|
||||
BACnet Broadcast Management Device,
|
||||
Broadcast Distribution Table, and
|
||||
Foreign Device Registration */
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
|
||||
/* true if valid entry - false if not */
|
||||
bool valid;
|
||||
|
||||
/* BACnet/IP address */
|
||||
struct in_addr dest_address;
|
||||
|
||||
uint16_t dest_port;
|
||||
} BBMD_TABLE_ENTRY;
|
||||
|
||||
/* Broadcast Distribution Mask - stored in host byte order */
|
||||
struct in_addr broadcast_mask;
|
||||
|
||||
@@ -67,24 +68,23 @@ seconds remaining before the BBMD will purge the registrant's FDT
|
||||
/*Each device that registers as a foreign device shall be placed
|
||||
in an entry in the BBMD's Foreign Device Table (FDT). Each
|
||||
entry shall consist of the 6-octet B/IP address of the registrant;
|
||||
typedef struct
|
||||
{
|
||||
the 2-octet Time-to-Live value supplied at the time of
|
||||
registration; and a 2-octet value representing the number of
|
||||
seconds remaining before the BBMD will purge the registrant's FDT
|
||||
entry if no re-registration occurs. This value will be initialized
|
||||
to the 2-octet Time-to-Live value supplied at the time of
|
||||
registration.*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
bool valid;
|
||||
} FD_TABLE_ENTRY;
|
||||
|
||||
/* BACnet/IP address */
|
||||
struct in_addr dest_address;
|
||||
|
||||
|
||||
void bvlc_maintenance_timer(unsigned seconds)
|
||||
uint16_t dest_port;
|
||||
|
||||
/* seconds for valid entry lifetime */
|
||||
|
||||
uint16_t time_to_live;
|
||||
|
||||
time_t seconds_remaining; /* includes 30 second grace period */
|
||||
@@ -92,6 +92,7 @@ void bvlc_maintenance_timer(unsigned seconds)
|
||||
} FD_TABLE_ENTRY;
|
||||
|
||||
|
||||
#define MAX_FD_ENTRIES 128
|
||||
static FD_TABLE_ENTRY FD_Table[MAX_FD_ENTRIES];
|
||||
|
||||
|
||||
@@ -101,138 +102,108 @@ void bvlc_maintenance_timer(unsigned seconds)
|
||||
unsigned i = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_encode_bip_address(
|
||||
uint8_t *pdu,
|
||||
struct in_addr *address, /* in host format */
|
||||
for (i = 0; i < MAX_FD_ENTRIES; i++) {
|
||||
|
||||
if (FD_Table[i].valid)
|
||||
|
||||
{
|
||||
|
||||
|
||||
if (FD_Table[i].seconds_remaining)
|
||||
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_decode_bip_address(
|
||||
uint8_t *pdu,
|
||||
struct in_addr *address, /* in host format */
|
||||
uint16_t *port)
|
||||
if (FD_Table[i].seconds_remaining < seconds)
|
||||
|
||||
FD_Table[i].seconds_remaining = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
FD_Table[i].seconds_remaining -= seconds;
|
||||
|
||||
uint8_t *pdu,
|
||||
struct in_addr *address,
|
||||
uint16_t port,
|
||||
struct in_addr *mask)
|
||||
if (FD_Table[i].seconds_remaining == 0)
|
||||
|
||||
{
|
||||
|
||||
|
||||
FD_Table[i].valid = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int bvlc_encode_bvlc_result(
|
||||
uint8_t *pdu,
|
||||
BACNET_BVLC_RESULT result_code)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int bvlc_encode_bip_address(
|
||||
uint8_t * pdu,
|
||||
struct in_addr *address, /* in host format */
|
||||
uint16_t port)
|
||||
{
|
||||
|
||||
|
||||
int len = 0;
|
||||
}
|
||||
|
||||
int bvlc_encode_write_bdt_init(
|
||||
uint8_t *pdu,
|
||||
unsigned entries)
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
|
||||
len = encode_unsigned32(&pdu[0], address->s_addr);
|
||||
|
||||
len += encode_unsigned16(&pdu[len], port);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_encode_read_bdt(
|
||||
uint8_t *pdu)
|
||||
|
||||
int bvlc_decode_bip_address(
|
||||
uint8_t * pdu,
|
||||
struct in_addr *address, /* in host format */
|
||||
|
||||
uint16_t * port)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* used for both read and write entries */
|
||||
int bvlc_encode_address_entry(
|
||||
|
||||
uint8_t * pdu,
|
||||
}
|
||||
|
||||
int bvlc_encode_read_bdt_ack_init(
|
||||
uint8_t *pdu,
|
||||
unsigned entries)
|
||||
struct in_addr *address,
|
||||
uint16_t port,
|
||||
struct in_addr *mask)
|
||||
{
|
||||
|
||||
|
||||
int len = 0;
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
len = bvlc_encode_bip_address(pdu, address, port);
|
||||
|
||||
len += encode_unsigned32(&pdu[len], mask->s_addr);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int bvlc_encode_forwarded_npdu(
|
||||
uint8_t *pdu,
|
||||
BACNET_ADDRESS *src,
|
||||
uint8_t *npdu,
|
||||
unsigned npdu_length)
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int bvlc_encode_bvlc_result(
|
||||
uint8_t * pdu,
|
||||
BACNET_BVLC_RESULT result_code)
|
||||
{
|
||||
|
||||
if (pdu) {
|
||||
|
||||
encode_unsigned16(&pdu[2], 4+6+npdu_length);
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_RESULT;
|
||||
|
||||
@@ -243,19 +214,16 @@ int bvlc_encode_forwarded_npdu(
|
||||
|
||||
encode_unsigned16(&pdu[4], result_code);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int bvlc_encode_register_foreign_device(
|
||||
uint8_t *pdu,
|
||||
uint16_t time_to_live_seconds)
|
||||
|
||||
|
||||
return 6;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int bvlc_encode_write_bdt_init(
|
||||
uint8_t * pdu,
|
||||
unsigned entries)
|
||||
{
|
||||
|
||||
@@ -263,151 +231,127 @@ int bvlc_encode_register_foreign_device(
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_encode_read_fdt(
|
||||
uint8_t *pdu)
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_WRITE_BROADCAST_DISTRIBUTION_TABLE;
|
||||
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
encode_unsigned16(&pdu[2], 4 + entries * 10);
|
||||
|
||||
len = 4;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int bvlc_encode_read_fdt_ack_init(
|
||||
uint8_t *pdu,
|
||||
unsigned entries)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int bvlc_encode_read_bdt(
|
||||
uint8_t * pdu)
|
||||
{
|
||||
|
||||
int len = 0;
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_encode_delete_fdt_entry(
|
||||
uint8_t *pdu,
|
||||
struct in_addr *address,
|
||||
uint16_t port)
|
||||
pdu[1] = BVLC_READ_BROADCAST_DISTRIBUTION_TABLE;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
|
||||
encode_unsigned16(&pdu[2], 4);
|
||||
|
||||
len = 4;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int bvlc_encode_read_bdt_ack_init(
|
||||
uint8_t * pdu,
|
||||
|
||||
unsigned entries)
|
||||
}
|
||||
|
||||
int bvlc_encode_distribute_broadcast_to_network(
|
||||
uint8_t *pdu,
|
||||
uint8_t *npdu,
|
||||
unsigned npdu_length)
|
||||
{
|
||||
|
||||
int len = 0;
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_READ_BROADCAST_DISTRIBUTION_TABLE_ACK;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
len = encode_unsigned16(&pdu[2], 4+npdu_length) + 2;
|
||||
length field itself, most significant octet first. */
|
||||
encode_unsigned16(&pdu[2], 4 + entries * 10);
|
||||
|
||||
len = 4;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_encode_original_unicast_npdu(
|
||||
uint8_t * pdu,
|
||||
uint8_t * npdu,
|
||||
unsigned npdu_length)
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int bvlc_encode_forwarded_npdu(
|
||||
uint8_t * pdu,
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t * npdu,
|
||||
unsigned npdu_length)
|
||||
{
|
||||
|
||||
len = encode_unsigned16(&pdu[2], 4+npdu_length) + 2;
|
||||
int len = 0;
|
||||
|
||||
unsigned i; /* for loop counter */
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
int bvlc_encode_original_broadcast_npdu(
|
||||
uint8_t * pdu,
|
||||
uint8_t * npdu,
|
||||
unsigned npdu_length)
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_FORWARDED_NPDU;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
|
||||
length field itself, most significant octet first. */
|
||||
encode_unsigned16(&pdu[2], 4 + 6 + npdu_length);
|
||||
|
||||
len = 4;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
|
||||
len = encode_unsigned16(&pdu[2], 4+npdu_length) + 2;
|
||||
pdu[len] = src->adr[i];
|
||||
|
||||
len++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < npdu_length; i++) {
|
||||
}
|
||||
|
||||
pdu[len] = npdu[i];
|
||||
|
||||
len++;
|
||||
|
||||
}
|
||||
void bvlc_internet_to_bacnet_address(
|
||||
BACNET_ADDRESS * src, /* returns the BACnet source address */
|
||||
struct sockaddr_in * sin) /* source internet address */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
@@ -416,19 +360,17 @@ void bvlc_internet_to_bacnet_address(
|
||||
int bvlc_encode_register_foreign_device(
|
||||
uint8_t * pdu,
|
||||
uint16_t time_to_live_seconds)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
int len = 0;
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
void bvlc_bacnet_to_internet_address(
|
||||
struct sockaddr_in * sin, /* source internet address */
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_REGISTER_FOREIGN_DEVICE;
|
||||
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
@@ -437,16 +379,14 @@ void bvlc_bacnet_to_internet_address(
|
||||
encode_unsigned16(&pdu[2], time_to_live_seconds);
|
||||
|
||||
len = 6;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void bvlc_bdt_forward_npdu(
|
||||
struct sockaddr_in *sin, /* the source address */
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
uint8_t mtu[MAX_MPDU] = { 0 };
|
||||
}
|
||||
|
||||
|
||||
int bvlc_encode_read_fdt(
|
||||
uint8_t * pdu)
|
||||
@@ -455,53 +395,46 @@ void bvlc_bdt_forward_npdu(
|
||||
int len = 0;
|
||||
|
||||
|
||||
|
||||
mtu_len = bvlc_encode_forwarded_npdu(
|
||||
&mtu[0],
|
||||
sin,
|
||||
npdu,
|
||||
npdu_length);
|
||||
if (pdu) {
|
||||
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_READ_FOREIGN_DEVICE_TABLE;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
encode_unsigned16(&pdu[2], 4);
|
||||
|
||||
len = 4;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return len;
|
||||
htonl(((~BBMD_Table[i].broadcast_mask.s_addr) |
|
||||
BBMD_Table[i].dest_address.s_addr));
|
||||
|
||||
}
|
||||
|
||||
|
||||
int bvlc_encode_read_fdt_ack_init(
|
||||
bytes_sent = sendto(bip_socket(), (char *) mtu, mtu_len, 0,
|
||||
uint8_t * pdu,
|
||||
unsigned entries)
|
||||
{
|
||||
|
||||
|
||||
int len = 0;
|
||||
}
|
||||
|
||||
void bvlc_fdt_forward_npdu(
|
||||
struct sockaddr_in *sin, /* the source address */
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t bvlc_handler(
|
||||
BACNET_ADDRESS * src, /* returns the source address */
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_READ_FOREIGN_DEVICE_TABLE_ACK;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
{
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
uint8_t buf[MAX_MPDU] = { 0 }; /* data */
|
||||
encode_unsigned16(&pdu[2], 4 + entries * 10);
|
||||
|
||||
len = 4;
|
||||
|
||||
}
|
||||
@@ -528,11 +461,14 @@ uint16_t bvlc_handler(
|
||||
pdu[1] = BVLC_READ_FOREIGN_DEVICE_TABLE;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
if (select(max + 1, &read_fds, NULL, NULL, &select_timeout) > 0)
|
||||
received_bytes = recvfrom(BIP_Socket,
|
||||
(char *) &buf[0], MAX_MPDU, 0,
|
||||
encode_unsigned16(&pdu[2], 10);
|
||||
|
||||
/* FDT Entry */
|
||||
encode_unsigned32(&pdu[0], address->s_addr);
|
||||
|
||||
encode_unsigned16(&pdu[4], port);
|
||||
|
||||
len = 10;
|
||||
|
||||
@@ -549,8 +485,10 @@ uint16_t bvlc_handler(
|
||||
uint8_t * npdu,
|
||||
unsigned npdu_length)
|
||||
{
|
||||
|
||||
int len = 0; /* return value */
|
||||
(void)decode_unsigned16(&buf[2], &npdu_len);
|
||||
|
||||
unsigned i; /* for loop counter */
|
||||
|
||||
|
||||
if (pdu) {
|
||||
@@ -558,6 +496,7 @@ uint16_t bvlc_handler(
|
||||
pdu[0] = BVLL_TYPE_BACNET_IP;
|
||||
|
||||
pdu[1] = BVLC_DISTRIBUTE_BROADCAST_TO_NETWORK;
|
||||
|
||||
/* The 2-octet BVLC Length field is the length, in octets,
|
||||
of the entire BVLL message, including the two octets of the
|
||||
length field itself, most significant octet first. */
|
||||
@@ -572,6 +511,7 @@ uint16_t bvlc_handler(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
@@ -606,14 +546,18 @@ uint16_t bvlc_handler(
|
||||
|
||||
len++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
bvlc_internet_to_bacnet_address(src,&sin);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int bvlc_encode_original_broadcast_npdu(
|
||||
uint8_t * pdu,
|
||||
uint8_t * npdu,
|
||||
unsigned npdu_length)
|
||||
{
|
||||
@@ -621,6 +565,7 @@ uint16_t bvlc_handler(
|
||||
int len = 0; /* return value */
|
||||
|
||||
unsigned i = 0; /* loop counter */
|
||||
|
||||
|
||||
if (pdu) {
|
||||
|
||||
@@ -634,14 +579,17 @@ uint16_t bvlc_handler(
|
||||
len = encode_unsigned16(&pdu[2], 4 + npdu_length) + 2;
|
||||
|
||||
for (i = 0; i < npdu_length; i++) {
|
||||
bvlc_internet_to_bacnet_address(src,&sin);
|
||||
|
||||
pdu[len] = npdu[i];
|
||||
|
||||
len++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
@@ -649,27 +597,22 @@ uint16_t bvlc_handler(
|
||||
|
||||
/* copy the source internet address to the BACnet address */
|
||||
/* FIXME: IPv6? */
|
||||
|
||||
/* FIXME: is sockaddr_in host or network order? */
|
||||
}
|
||||
void bvlc_internet_to_bacnet_address(
|
||||
BACNET_ADDRESS * src, /* returns the BACnet source address */
|
||||
struct sockaddr_in *sin) /* source internet address */
|
||||
{
|
||||
|
||||
int len = 0;
|
||||
|
||||
void testBVLC(Test * pTest)
|
||||
{
|
||||
(void)pTest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (src && sin)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Test *pTest;
|
||||
{
|
||||
|
||||
len = encode_unsigned32(&src->mac[0], sin->sin_addr.s_addr);
|
||||
|
||||
|
||||
len += encode_unsigned16(&src->mac[4], sin->sin_port);
|
||||
|
||||
src->mac_len = len;
|
||||
|
||||
@@ -679,8 +622,8 @@ int main(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -40,13 +40,14 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* called from BACnet/IP handler */
|
||||
void bvlc_handler(uint8_t *buf, int len, struct sockaddr_in *sin);
|
||||
void bvlc_handler(uint8_t * buf, int len, struct sockaddr_in *sin);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ int dcc_decode_service_request(uint8_t * apdu,
|
||||
&len_value_type);
|
||||
len += decode_unsigned(&apdu[len], len_value_type, &value32);
|
||||
if (timeDuration)
|
||||
*timeDuration = (uint16_t)value32;
|
||||
*timeDuration = (uint16_t) value32;
|
||||
} else if (timeDuration)
|
||||
*timeDuration = 0;
|
||||
/* Tag 1: enable_disable */
|
||||
|
||||
@@ -104,7 +104,8 @@ unsigned Binary_Output_Instance_To_Index(uint32_t object_instance)
|
||||
return index;
|
||||
}
|
||||
|
||||
static BACNET_BINARY_PV Binary_Output_Present_Value(uint32_t object_instance)
|
||||
static BACNET_BINARY_PV Binary_Output_Present_Value(uint32_t
|
||||
object_instance)
|
||||
{
|
||||
BACNET_BINARY_PV value = RELINQUISH_DEFAULT;
|
||||
unsigned index = 0;
|
||||
|
||||
@@ -548,8 +548,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
Local_Time.min = 0;
|
||||
Local_Time.sec = 3;
|
||||
Local_Time.hundredths = 1;
|
||||
apdu_len =
|
||||
encode_tagged_time(&apdu[0], &Local_Time);
|
||||
apdu_len = encode_tagged_time(&apdu[0], &Local_Time);
|
||||
break;
|
||||
/* FIXME: if you support time */
|
||||
case PROP_UTC_OFFSET:
|
||||
@@ -563,10 +562,11 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
Local_Date.month = 4; /* 1=Jan */
|
||||
Local_Date.day = 1; /* 1..31 */
|
||||
Local_Date.wday = 6; /* 1=Monday */
|
||||
apdu_len = encode_tagged_date(&apdu[0],&Local_Date);
|
||||
apdu_len = encode_tagged_date(&apdu[0], &Local_Date);
|
||||
break;
|
||||
case PROP_DAYLIGHT_SAVINGS_STATUS:
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], Daylight_Savings_Status);
|
||||
apdu_len =
|
||||
encode_tagged_boolean(&apdu[0], Daylight_Savings_Status);
|
||||
break;
|
||||
case PROP_PROTOCOL_VERSION:
|
||||
apdu_len =
|
||||
@@ -681,8 +681,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
/* FIXME: encode the list here, if it exists */
|
||||
break;
|
||||
case PROP_DATABASE_REVISION:
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], Database_Revision);
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], Database_Revision);
|
||||
break;
|
||||
default:
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -61,7 +61,8 @@ void Life_Safety_Point_Init(void)
|
||||
for (i = 0; i < MAX_LIFE_SAFETY_POINTS; i++) {
|
||||
Life_Safety_Point_Mode[i] = LIFE_SAFETY_MODE_DEFAULT;
|
||||
Life_Safety_Point_State[i] = LIFE_SAFETY_STATE_QUIET;
|
||||
Life_Safety_Point_Silenced_State[i] = SILENCED_STATE_UNSILENCED;
|
||||
Life_Safety_Point_Silenced_State[i] =
|
||||
SILENCED_STATE_UNSILENCED;
|
||||
Life_Safety_Point_Operation[i] = LIFE_SAFETY_OPERATION_NONE;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,8 @@ unsigned Life_Safety_Point_Instance_To_Index(uint32_t object_instance)
|
||||
return index;
|
||||
}
|
||||
|
||||
static BACNET_LIFE_SAFETY_STATE Life_Safety_Point_Present_Value(uint32_t object_instance)
|
||||
static BACNET_LIFE_SAFETY_STATE Life_Safety_Point_Present_Value(uint32_t
|
||||
object_instance)
|
||||
{
|
||||
BACNET_LIFE_SAFETY_STATE present_value = LIFE_SAFETY_STATE_QUIET;
|
||||
unsigned index = 0;
|
||||
@@ -156,12 +158,12 @@ int Life_Safety_Point_Encode_Property_APDU(uint8_t * apdu,
|
||||
unsigned object_index = 0;
|
||||
bool state = false;
|
||||
BACNET_RELIABILITY reliability = RELIABILITY_NO_FAULT_DETECTED;
|
||||
|
||||
(void)array_index; /* currently not used */
|
||||
|
||||
(void) array_index; /* currently not used */
|
||||
Life_Safety_Point_Init();
|
||||
switch (property) {
|
||||
apdu_len = encode_tagged_object_id(&apdu[0], OBJECT_LIFE_SAFETY_POINT,
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
apdu_len =
|
||||
encode_tagged_object_id(&apdu[0], OBJECT_LIFE_SAFETY_POINT,
|
||||
object_instance);
|
||||
break;
|
||||
@@ -190,7 +192,8 @@ int Life_Safety_Point_Encode_Property_APDU(uint8_t * apdu,
|
||||
case PROP_EVENT_STATE:
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
object_index = Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
state = Life_Safety_Point_Out_Of_Service[object_index];
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], state);
|
||||
@@ -200,24 +203,27 @@ int Life_Safety_Point_Encode_Property_APDU(uint8_t * apdu,
|
||||
reliability = RELIABILITY_NO_FAULT_DETECTED;
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], reliability);
|
||||
break;
|
||||
object_index = Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
case PROP_MODE:
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
mode = Life_Safety_Point_Mode[object_index];
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], mode);
|
||||
break;
|
||||
for (mode = MIN_LIFE_SAFETY_MODE; mode < MAX_LIFE_SAFETY_MODE; mode++)
|
||||
{
|
||||
case PROP_ACCEPTED_MODES:
|
||||
for (mode = MIN_LIFE_SAFETY_MODE; mode < MAX_LIFE_SAFETY_MODE;
|
||||
mode++) {
|
||||
len = encode_tagged_enumerated(&apdu[apdu_len], mode);
|
||||
apdu_len += len;
|
||||
}
|
||||
break;
|
||||
object_index = Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
case PROP_SILENCED:
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
silenced_state = Life_Safety_Point_Silenced_State[object_index];
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], silenced_state);
|
||||
break;
|
||||
object_index = Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
case PROP_OPERATION_EXPECTED:
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(object_instance);
|
||||
operation = Life_Safety_Point_Operation[object_index];
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], operation);
|
||||
@@ -250,8 +256,11 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
case PROP_MODE:
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
|
||||
if ((wp_data->value.type.Enumerated >= MIN_LIFE_SAFETY_MODE) &&
|
||||
object_index = Life_Safety_Point_Instance_To_Index(wp_data->object_instance);
|
||||
Life_Safety_Point_Mode[object_index] = wp_data->value.type.Enumerated;
|
||||
(wp_data->value.type.Enumerated <= MIN_LIFE_SAFETY_MODE)) {
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Life_Safety_Point_Mode[object_index] =
|
||||
wp_data->value.type.Enumerated;
|
||||
status = true;
|
||||
} else {
|
||||
@@ -265,7 +274,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->object_instance);
|
||||
object_index =
|
||||
Life_Safety_Point_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
Life_Safety_Point_Out_Of_Service[object_index] =
|
||||
wp_data->value.type.Boolean;
|
||||
|
||||
@@ -46,8 +46,9 @@ extern "C" {
|
||||
int32_t array_index,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
|
||||
bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *
|
||||
wp_data, BACNET_ERROR_CLASS * error_class,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
|
||||
@@ -159,7 +159,7 @@ bool bip_init(void)
|
||||
bip_set_socket(-1);
|
||||
return false;
|
||||
}
|
||||
#if 0
|
||||
#if 0
|
||||
/* probably only for Apple... */
|
||||
/* rebind a port that is already in use.
|
||||
Note: all users of the port must specify this flag */
|
||||
@@ -171,7 +171,7 @@ bool bip_init(void)
|
||||
bip_set_socket(-1);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* bind the socket to the local port number and IP address */
|
||||
sin.sin_family = AF_INET;
|
||||
#if USE_INADDR
|
||||
|
||||
Reference in New Issue
Block a user