make pretty

This commit is contained in:
Steve Karg
2022-09-10 10:32:50 -05:00
parent 7cdab61d72
commit cc4911a185
123 changed files with 1387 additions and 1604 deletions
+8 -12
View File
@@ -784,9 +784,8 @@ int bvlc_bbmd_disabled_handler(BACNET_IP_ADDRESS *addr,
npdu = &mtu[offset];
if (npdu_confirmed_service(npdu, npdu_len)) {
offset = 0;
debug_print_string(
"Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
debug_print_string("Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
} else {
debug_print_npdu(
"Original-Broadcast-NPDU", offset, npdu_len);
@@ -1105,14 +1104,13 @@ int bvlc_bbmd_enabled_handler(BACNET_IP_ADDRESS *addr,
network layer. */
if (npdu_confirmed_service(npdu, npdu_len)) {
offset = 0;
debug_print_string(
"Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
debug_print_string("Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
} else {
(void)bbmd_fdt_forward_npdu(addr, npdu, npdu_len, true);
(void)bbmd_bdt_forward_npdu(addr, npdu, npdu_len, true);
debug_print_npdu("Original-Broadcast-NPDU",
offset, npdu_len);
debug_print_npdu(
"Original-Broadcast-NPDU", offset, npdu_len);
}
} else {
debug_print_string(
@@ -1211,8 +1209,7 @@ int bvlc_register_with_bbmd(BACNET_IP_ADDRESS *bbmd_addr, uint16_t ttl_seconds)
* 0 if no registration request is sent, or
* -1 if registration fails.
*/
void bvlc_remote_bbmd_address(
BACNET_IP_ADDRESS *bbmd_addr)
void bvlc_remote_bbmd_address(BACNET_IP_ADDRESS *bbmd_addr)
{
bvlc_address_copy(bbmd_addr, &Remote_BBMD);
}
@@ -1222,8 +1219,7 @@ void bvlc_remote_bbmd_address(
* Register Foreign Device
* @return Lease time in seconds to use when registering.
*/
uint16_t bvlc_remote_bbmd_lifetime(
void)
uint16_t bvlc_remote_bbmd_lifetime(void)
{
return Remote_BBMD_TTL_Seconds;
}
+11 -15
View File
@@ -44,15 +44,14 @@
#include "bacnet/basic/bbmd6/vmac.h"
#include "bacnet/basic/bbmd6/h_bbmd6.h"
static bool BVLC6_Debug;
#if PRINT_ENABLED
#include <stdarg.h>
#include <stdio.h>
#define PRINTF(...) \
if (BVLC6_Debug) { \
fprintf(stderr,__VA_ARGS__); \
fflush(stderr); \
#define PRINTF(...) \
if (BVLC6_Debug) { \
fprintf(stderr, __VA_ARGS__); \
fflush(stderr); \
}
#else
#define PRINTF(...)
@@ -709,7 +708,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
offset = header_len + (function_len - npdu_len);
} else {
PRINTF("BIP6: Original-Unicast-NPDU: "
"VMAC is not me!\n");
"VMAC is not me!\n");
}
} else {
PRINTF(
@@ -740,13 +739,12 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
npdu = &mtu[offset];
if (npdu_confirmed_service(npdu, npdu_len)) {
offset = 0;
PRINTF(
"BIP6: Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
PRINTF("BIP6: Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
}
} else {
PRINTF("BIP6: Original-Broadcast-NPDU: Unable to "
"decode!\n");
"decode!\n");
}
}
break;
@@ -766,8 +764,7 @@ int bvlc6_bbmd_disabled_handler(BACNET_IP6_ADDRESS *addr,
bvlc6_vmac_address_set(src, vmac_src);
offset = header_len + (function_len - npdu_len);
} else {
PRINTF(
"BIP6: Forwarded-NPDU: Unable to decode!\n");
PRINTF("BIP6: Forwarded-NPDU: Unable to decode!\n");
}
}
break;
@@ -908,9 +905,8 @@ int bvlc6_bbmd_enabled_handler(BACNET_IP6_ADDRESS *addr,
network layer. */
if (npdu_confirmed_service(npdu, npdu_len)) {
offset = 0;
PRINTF(
"BIP6: Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
PRINTF("BIP6: Original-Broadcast-NPDU: "
"Confirmed Service! Discard!");
} else {
/* Upon receipt of a BVLL Original-Broadcast-NPDU
message from the local multicast domain, a BBMD
+4 -4
View File
@@ -47,10 +47,10 @@ static bool VMAC_Debug = false;
#if PRINT_ENABLED
#include <stdarg.h>
#include <stdio.h>
#define PRINTF(...) \
if (VMAC_Debug) { \
fprintf(stderr,__VA_ARGS__); \
fflush(stderr); \
#define PRINTF(...) \
if (VMAC_Debug) { \
fprintf(stderr, __VA_ARGS__); \
fflush(stderr); \
}
#else
#define PRINTF(...)
+5 -5
View File
@@ -484,7 +484,7 @@ void address_set_device_TTL(
pMatch->TimeToLive = TimeOut;
}
} else {
/* For unbound we can only set the time to live */
/* For unbound we can only set the time to live */
pMatch->TimeToLive = TimeOut;
}
break; /* Exit now if found at all - bound or unbound */
@@ -601,7 +601,7 @@ void address_add(uint32_t device_id, unsigned max_apdu, BACNET_ADDRESS *src)
/* Opportunistic entry so leave on short fuse */
pMatch->TimeToLive = BAC_ADDR_SHORT_TIME;
} else {
/* Renewing existing entry */
/* Renewing existing entry */
pMatch->TimeToLive = BAC_ADDR_LONG_TIME;
}
/* Clear bind request flag just in case */
@@ -1036,7 +1036,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
pMatch++;
/* Shall not happen as the count has been checked first. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
/* Issue with the table. */
/* Issue with the table. */
return (0);
}
}
@@ -1053,7 +1053,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
}
/* Shall not happen as the count has been checked first. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
/* Issue with the table. */
/* Issue with the table. */
return (0);
}
}
@@ -1104,7 +1104,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
pMatch++;
/* Can normally not happen. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
/* Issue with the table. */
/* Issue with the table. */
return (0);
}
}
+14 -21
View File
@@ -59,7 +59,7 @@ uint16_t npdu_network_number(void)
*/
void npdu_network_number_set(uint16_t net)
{
Local_Network_Number = net;
Local_Network_Number = net;
}
/**
@@ -69,8 +69,8 @@ void npdu_network_number_set(uint16_t net)
* @param status - 0=learned, 1=assigned
* @return number of bytes sent
*/
int npdu_send_network_number_is(BACNET_ADDRESS *dst,
uint16_t net, uint8_t status)
int npdu_send_network_number_is(
BACNET_ADDRESS *dst, uint16_t net, uint8_t status)
{
uint16_t len = 0;
int pdu_len = 0;
@@ -84,13 +84,11 @@ int npdu_send_network_number_is(BACNET_ADDRESS *dst,
transmit a local broadcast Network-Number-Is message
back to the source device. */
datalink_get_my_address(&my_address);
npdu_encode_npdu_network(&npdu_data,
NETWORK_MESSAGE_NETWORK_NUMBER_IS,
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_NETWORK_NUMBER_IS,
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], dst,
&my_address, &npdu_data);
len = encode_unsigned16(
&Handler_Transmit_Buffer[pdu_len], net);
pdu_len = npdu_encode_pdu(
&Handler_Transmit_Buffer[0], dst, &my_address, &npdu_data);
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], net);
pdu_len += len;
Handler_Transmit_Buffer[pdu_len] = status;
pdu_len++;
@@ -120,17 +118,14 @@ int npdu_send_what_is_network_number(BACNET_ADDRESS *dst)
datalink_get_broadcast_address(&daddr);
}
datalink_get_my_address(&saddr);
npdu_encode_npdu_network(&npdu_data,
NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER,
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER,
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(
&Handler_Transmit_Buffer[0],
&daddr, &saddr, &npdu_data);
&Handler_Transmit_Buffer[0], &daddr, &saddr, &npdu_data);
/* Now send the message */
return datalink_send_pdu(
dst, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
}
/** @file h_npdu.c Handles messages at the NPDU level of the BACnet stack. */
@@ -163,8 +158,8 @@ static void network_control_handler(BACNET_ADDRESS *src,
case NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER:
if (src->net == 0) {
if (Local_Network_Number) {
npdu_send_network_number_is(src, Local_Network_Number,
Local_Network_Number_Status);
npdu_send_network_number_is(
src, Local_Network_Number, Local_Network_Number_Status);
} else {
/* Upon receipt of a What-Is-Network-Number message,
a device that does not know the local network number
@@ -225,9 +220,7 @@ static void network_control_handler(BACNET_ADDRESS *src,
* @param pdu [in] Buffer containing the NPDU and APDU of the received packet.
* @param pdu_len [in] The size of the received message in the pdu[] buffer.
*/
void npdu_handler(BACNET_ADDRESS *src,
uint8_t *pdu,
uint16_t pdu_len)
void npdu_handler(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t pdu_len)
{
int apdu_offset = 0;
BACNET_ADDRESS dest = { 0 };
@@ -243,8 +236,8 @@ void npdu_handler(BACNET_ADDRESS *src,
bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data);
if (npdu_data.network_layer_message) {
if ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) {
network_control_handler(src, &npdu_data,
&pdu[apdu_offset], (uint16_t)(pdu_len - apdu_offset));
network_control_handler(src, &npdu_data, &pdu[apdu_offset],
(uint16_t)(pdu_len - apdu_offset));
} else {
debug_printf("NPDU: message for router. Discarded!\n");
}
+1 -2
View File
@@ -317,6 +317,5 @@ void Send_Network_Number_Is(BACNET_ADDRESS *dst, int dnet, int status)
iArgs[0] = dnet;
iArgs[1] = status;
Send_Network_Layer_Message(
NETWORK_MESSAGE_NETWORK_NUMBER_IS, dst, iArgs);
Send_Network_Layer_Message(NETWORK_MESSAGE_NETWORK_NUMBER_IS, dst, iArgs);
}
+5 -5
View File
@@ -69,13 +69,13 @@ void Accumulator_Property_Lists(
{
if (pRequired) {
*pRequired = Properties_Required;
}
}
if (pOptional) {
*pOptional = Properties_Optional;
}
}
if (pProprietary) {
*pProprietary = Properties_Proprietary;
}
}
return;
}
@@ -91,7 +91,7 @@ bool Accumulator_Valid_Instance(uint32_t object_instance)
{
if (object_instance < MAX_ACCUMULATORS) {
return true;
}
}
return false;
}
@@ -134,7 +134,7 @@ unsigned Accumulator_Instance_To_Index(uint32_t object_instance)
if (object_instance < MAX_ACCUMULATORS) {
index = object_instance;
}
}
return index;
}
+2 -2
View File
@@ -342,8 +342,8 @@ bool Access_Credential_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
Access_Credential_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_GLOBAL_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
ac_descr[object_index].global_identifier =
value.type.Unsigned_Int;
+12 -12
View File
@@ -462,8 +462,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
object_index = Access_Door_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -482,8 +482,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_NULL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
if (status) {
status = Access_Door_Present_Value_Relinquish(
wp_data->object_instance, wp_data->priority);
@@ -495,8 +495,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Access_Door_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
@@ -504,8 +504,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_DOOR_STATUS:
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
ad_descr[object_index].door_status =
(BACNET_DOOR_STATUS)value.type.Enumerated;
@@ -517,8 +517,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_LOCK_STATUS:
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
ad_descr[object_index].lock_status =
(BACNET_LOCK_STATUS)value.type.Enumerated;
@@ -530,8 +530,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_DOOR_ALARM_STATE:
if (Access_Door_Out_Of_Service(wp_data->object_instance)) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
ad_descr[object_index].door_alarm_state =
(BACNET_DOOR_ALARM_STATE)value.type.Enumerated;
+2 -2
View File
@@ -308,8 +308,8 @@ bool Access_Rights_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
object_index = Access_Rights_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_GLOBAL_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
ar_descr[object_index].global_identifier =
value.type.Unsigned_Int;
+2 -3
View File
@@ -250,8 +250,8 @@ bool Access_User_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
object_index = Access_User_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_GLOBAL_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
au_descr[object_index].global_identifier =
value.type.Unsigned_Int;
@@ -276,4 +276,3 @@ bool Access_User_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
return status;
}
+4 -4
View File
@@ -301,8 +301,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
object_index = Access_Zone_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_GLOBAL_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
az_descr[object_index].global_identifier =
value.type.Unsigned_Int;
@@ -310,8 +310,8 @@ bool Access_Zone_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_RELIABILITY:
if (Access_Zone_Out_Of_Service(wp_data->object_instance)) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
az_descr[object_index].reliability =
(BACNET_RELIABILITY)value.type.Enumerated;
+44 -49
View File
@@ -43,7 +43,7 @@
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
@@ -300,8 +300,8 @@ bool Analog_Input_Encode_Value_List(
}
out_of_service = AI_Descr[index].Out_Of_Service;
present_value = AI_Descr[index].Present_Value;
status = cov_value_list_encode_real(value_list, present_value,
in_alarm, fault, overridden, out_of_service);
status = cov_value_list_encode_real(value_list, present_value, in_alarm,
fault, overridden, out_of_service);
}
return status;
@@ -420,7 +420,7 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
Analog_Input_Event_State(rpdata->object_instance) !=
EVENT_STATE_NORMAL);
EVENT_STATE_NORMAL);
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
@@ -430,9 +430,8 @@ int Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
break;
case PROP_EVENT_STATE:
apdu_len =
encode_application_enumerated(&apdu[0],
Analog_Input_Event_State(rpdata->object_instance));
apdu_len = encode_application_enumerated(
&apdu[0], Analog_Input_Event_State(rpdata->object_instance));
break;
case PROP_RELIABILITY:
@@ -633,8 +632,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch ((int)wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
if (CurrentAI->Out_Of_Service == true) {
Analog_Input_Present_Value_Set(
@@ -648,8 +647,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Analog_Input_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
@@ -657,16 +656,16 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_UNITS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
CurrentAI->Units = value.type.Enumerated;
}
break;
case PROP_COV_INCREMENT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
if (value.type.Real >= 0.0) {
Analog_Input_COV_Increment_Set(
@@ -681,8 +680,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
#if defined(INTRINSIC_REPORTING)
case PROP_TIME_DELAY:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
CurrentAI->Time_Delay = value.type.Unsigned_Int;
CurrentAI->Remaining_Time_Delay = CurrentAI->Time_Delay;
@@ -690,40 +689,40 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_NOTIFICATION_CLASS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
CurrentAI->Notification_Class = value.type.Unsigned_Int;
}
break;
case PROP_HIGH_LIMIT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
CurrentAI->High_Limit = value.type.Real;
}
break;
case PROP_LOW_LIMIT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
CurrentAI->Low_Limit = value.type.Real;
}
break;
case PROP_DEADBAND:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
CurrentAI->Deadband = value.type.Real;
}
break;
case PROP_LIMIT_ENABLE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BIT_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
if (status) {
if (value.type.Bit_String.bits_used == 2) {
CurrentAI->Limit_Enable = value.type.Bit_String.value[0];
@@ -736,8 +735,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_EVENT_ENABLE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BIT_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
if (status) {
if (value.type.Bit_String.bits_used == 3) {
CurrentAI->Event_Enable = value.type.Bit_String.value[0];
@@ -750,8 +749,8 @@ bool Analog_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_NOTIFY_TYPE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
switch ((BACNET_NOTIFY_TYPE)value.type.Enumerated) {
case NOTIFY_EVENT:
@@ -968,8 +967,7 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
break;
} /* switch (ToState) */
PRINTF("Analog-Input[%d]: Event_State goes from %s to %s.\n",
object_instance,
bactext_event_state_name(FromState),
object_instance, bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
/* Notify Type */
event_data.notifyType = CurrentAI->Notify_Type;
@@ -1014,18 +1012,15 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
switch (ToState) {
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
datetime_copy(
&event_data.timeStamp.value.dateTime,
datetime_copy(&event_data.timeStamp.value.dateTime,
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_OFFNORMAL]);
break;
case EVENT_STATE_FAULT:
datetime_copy(
&event_data.timeStamp.value.dateTime,
datetime_copy(&event_data.timeStamp.value.dateTime,
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_FAULT]);
break;
case EVENT_STATE_NORMAL:
datetime_copy(
&event_data.timeStamp.value.dateTime,
datetime_copy(&event_data.timeStamp.value.dateTime,
&CurrentAI->Event_Time_Stamps[TRANSITION_TO_NORMAL]);
break;
default:
@@ -1083,16 +1078,16 @@ void Analog_Input_Intrinsic_Reporting(uint32_t object_instance)
/* add data from notification class */
PRINTF("Analog-Input[%d]: Notification Class[%d]-%s "
"%u/%u/%u-%u:%u:%u.%u!\n",
object_instance, event_data.notificationClass,
bactext_event_type_name(event_data.eventType),
(unsigned)event_data.timeStamp.value.dateTime.date.year,
(unsigned)event_data.timeStamp.value.dateTime.date.month,
(unsigned)event_data.timeStamp.value.dateTime.date.day,
(unsigned)event_data.timeStamp.value.dateTime.time.hour,
(unsigned)event_data.timeStamp.value.dateTime.time.min,
(unsigned)event_data.timeStamp.value.dateTime.time.sec,
(unsigned)event_data.timeStamp.value.dateTime.time.hundredths);
"%u/%u/%u-%u:%u:%u.%u!\n",
object_instance, event_data.notificationClass,
bactext_event_type_name(event_data.eventType),
(unsigned)event_data.timeStamp.value.dateTime.date.year,
(unsigned)event_data.timeStamp.value.dateTime.date.month,
(unsigned)event_data.timeStamp.value.dateTime.date.day,
(unsigned)event_data.timeStamp.value.dateTime.time.hour,
(unsigned)event_data.timeStamp.value.dateTime.time.min,
(unsigned)event_data.timeStamp.value.dateTime.time.sec,
(unsigned)event_data.timeStamp.value.dateTime.time.hundredths);
Notification_Class_common_reporting_function(&event_data);
/* Ack required */
+7 -7
View File
@@ -367,7 +367,7 @@ int Analog_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
} else {
real_value =
(float)Analog_Output_Level[object_index]
[rpdata->array_index - 1];
[rpdata->array_index - 1];
apdu_len =
encode_application_real(&apdu[0], real_value);
}
@@ -425,8 +425,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -445,8 +445,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_NULL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
if (status) {
status = Analog_Output_Present_Value_Relinquish(
wp_data->object_instance, wp_data->priority);
@@ -458,8 +458,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Analog_Output_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+28 -29
View File
@@ -382,8 +382,8 @@ bool Analog_Value_Encode_Value_List(
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_IN_ALARM, false);
} else {
bitstring_set_bit(&value_list->value.type.Bit_String,
STATUS_FLAG_IN_ALARM, true);
bitstring_set_bit(
&value_list->value.type.Bit_String, STATUS_FLAG_IN_ALARM, true);
}
bitstring_set_bit(
&value_list->value.type.Bit_String, STATUS_FLAG_FAULT, false);
@@ -526,7 +526,7 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM,
Analog_Value_Event_State(rpdata->object_instance) !=
EVENT_STATE_NORMAL);
EVENT_STATE_NORMAL);
bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE,
@@ -745,8 +745,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -772,24 +772,24 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
CurrentAV->Out_Of_Service = value.type.Boolean;
}
break;
case PROP_UNITS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
CurrentAV->Units = value.type.Enumerated;
}
break;
case PROP_COV_INCREMENT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
if (value.type.Real >= 0.0) {
Analog_Value_COV_Increment_Set(
@@ -804,8 +804,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
#if defined(INTRINSIC_REPORTING)
case PROP_TIME_DELAY:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
CurrentAV->Time_Delay = value.type.Unsigned_Int;
CurrentAV->Remaining_Time_Delay = CurrentAV->Time_Delay;
@@ -813,40 +813,40 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_NOTIFICATION_CLASS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
CurrentAV->Notification_Class = value.type.Unsigned_Int;
}
break;
case PROP_HIGH_LIMIT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
CurrentAV->High_Limit = value.type.Real;
}
break;
case PROP_LOW_LIMIT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
CurrentAV->Low_Limit = value.type.Real;
}
break;
case PROP_DEADBAND:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
CurrentAV->Deadband = value.type.Real;
}
break;
case PROP_LIMIT_ENABLE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BIT_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
if (status) {
if (value.type.Bit_String.bits_used == 2) {
CurrentAV->Limit_Enable = value.type.Bit_String.value[0];
@@ -859,8 +859,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_EVENT_ENABLE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BIT_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
if (status) {
if (value.type.Bit_String.bits_used == 3) {
CurrentAV->Event_Enable = value.type.Bit_String.value[0];
@@ -873,8 +873,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_NOTIFY_TYPE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
switch ((BACNET_NOTIFY_TYPE)value.type.Enumerated) {
case NOTIFY_EVENT:
@@ -1097,8 +1097,7 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
#if PRINT_ENABLED
fprintf(stderr, "Event_State for (%s,%u) goes from %s to %s.\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE),
(unsigned)object_instance,
bactext_event_state_name(FromState),
(unsigned)object_instance, bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
#endif /* PRINT_ENABLED */
+4 -4
View File
@@ -309,8 +309,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA *wp_data)
property shall be logical TRUE only if no changes have been
made to the file data by internal processes or through File
Access Services since the last time the object was archived. */
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
if (value.type.Boolean) {
/* FIXME: do something to wp_data->object_instance */
@@ -323,8 +323,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* If the file size can be changed by writing to the file,
and File_Access_Method is STREAM_ACCESS, then this property
shall be writable. */
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: do something with value.type.Unsigned
to wp_data->object_instance */
+6 -6
View File
@@ -429,8 +429,8 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
if (value.type.Enumerated <= MAX_BINARY_PV) {
Binary_Input_Present_Value_Set(wp_data->object_instance,
@@ -443,16 +443,16 @@ bool Binary_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Binary_Input_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
}
break;
case PROP_POLARITY:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
if (value.type.Enumerated < MAX_POLARITY) {
Binary_Input_Polarity_Set(wp_data->object_instance,
+6 -6
View File
@@ -363,8 +363,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
priority = wp_data->priority;
/* Command priority 6 is reserved for use by Minimum On/Off
@@ -396,8 +396,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_NULL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
if (status) {
level = BINARY_NULL;
object_index = Binary_Output_Instance_To_Index(
@@ -422,8 +422,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
object_index =
Binary_Output_Instance_To_Index(wp_data->object_instance);
+6 -6
View File
@@ -457,8 +457,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
priority = wp_data->priority;
/* Command priority 6 is reserved for use by Minimum On/Off
@@ -488,8 +488,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_NULL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
if (status) {
level = BINARY_NULL;
priority = wp_data->priority;
@@ -512,8 +512,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Binary_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+6 -6
View File
@@ -1513,8 +1513,8 @@ bool Channel_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = Channel_Present_Value_Set(wp_data, &value);
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Channel_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
@@ -1531,16 +1531,16 @@ bool Channel_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
break;
case PROP_CHANNEL_NUMBER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
Channel_Number_Set(
wp_data->object_instance, value.type.Unsigned_Int);
}
break;
case PROP_CONTROL_GROUPS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (wp_data->array_index == 0) {
/* Array element zero is the number of elements in the array
+23 -36
View File
@@ -833,70 +833,57 @@ int Color_Temperature_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
encode_application_enumerated(&apdu[0], rpdata->object_type);
break;
case PROP_PRESENT_VALUE:
apdu_len =
encode_application_unsigned(apdu,
Color_Temperature_Present_Value(
rpdata->object_instance));
apdu_len = encode_application_unsigned(
apdu, Color_Temperature_Present_Value(rpdata->object_instance));
break;
case PROP_MIN_PRES_VALUE:
apdu_len =
encode_application_unsigned(apdu,
Color_Temperature_Min_Pres_Value(
rpdata->object_instance));
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Min_Pres_Value(rpdata->object_instance));
break;
case PROP_MAX_PRES_VALUE:
apdu_len =
encode_application_unsigned(apdu,
Color_Temperature_Max_Pres_Value(
rpdata->object_instance));
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Max_Pres_Value(rpdata->object_instance));
break;
case PROP_TRACKING_VALUE:
apdu_len =
encode_application_unsigned(apdu,
Color_Temperature_Tracking_Value(
rpdata->object_instance));
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Tracking_Value(rpdata->object_instance));
break;
case PROP_COLOR_COMMAND:
if (Color_Temperature_Command(rpdata->object_instance, &color_command)) {
if (Color_Temperature_Command(
rpdata->object_instance, &color_command)) {
apdu_len = color_command_encode(apdu, &color_command);
}
break;
case PROP_IN_PROGRESS:
apdu_len =
encode_application_enumerated(apdu,
Color_Temperature_In_Progress(rpdata->object_instance));
apdu_len = encode_application_enumerated(
apdu, Color_Temperature_In_Progress(rpdata->object_instance));
break;
case PROP_DEFAULT_COLOR_TEMPERATURE:
apdu_len =
encode_application_unsigned(apdu,
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Default_Color_Temperature(
rpdata->object_instance));
break;
case PROP_DEFAULT_FADE_TIME:
apdu_len =
encode_application_unsigned(apdu,
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Default_Fade_Time(rpdata->object_instance));
break;
case PROP_DEFAULT_RAMP_RATE:
apdu_len =
encode_application_unsigned(apdu,
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Default_Ramp_Rate(rpdata->object_instance));
break;
case PROP_DEFAULT_STEP_INCREMENT:
apdu_len =
encode_application_unsigned(apdu,
Color_Temperature_Default_Step_Increment(rpdata->object_instance));
apdu_len = encode_application_unsigned(apdu,
Color_Temperature_Default_Step_Increment(
rpdata->object_instance));
break;
case PROP_TRANSITION:
apdu_len =
encode_application_enumerated(apdu,
Color_Temperature_Transition(rpdata->object_instance));
apdu_len = encode_application_enumerated(
apdu, Color_Temperature_Transition(rpdata->object_instance));
break;
case PROP_DESCRIPTION:
characterstring_init_ansi(
&char_string, Color_Temperature_Description(rpdata->object_instance));
apdu_len =
encode_application_character_string(apdu, &char_string);
characterstring_init_ansi(&char_string,
Color_Temperature_Description(rpdata->object_instance));
apdu_len = encode_application_character_string(apdu, &char_string);
break;
default:
rpdata->error_class = ERROR_CLASS_PROPERTY;
+3 -4
View File
@@ -195,8 +195,7 @@ int cl_decode_apdu(uint8_t *apdu,
if (tag_number != 2) {
return BACNET_STATUS_REJECT;
}
len = decode_enumerated(
&apdu[dec_len], len_value_type, &enum_value);
len = decode_enumerated(&apdu[dec_len], len_value_type, &enum_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
@@ -783,8 +782,8 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch ((int)wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int >= MAX_COMMAND_ACTIONS) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -333,8 +333,8 @@ bool Credential_Data_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_RELIABILITY:
if (Credential_Data_Input_Out_Of_Service(
wp_data->object_instance)) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
cdi_descr[object_index].reliability =
(BACNET_RELIABILITY)value.type.Enumerated;
+9 -11
View File
@@ -268,8 +268,7 @@ static void CharacterString_Value_Out_Of_Service_Set(
* @param object_instance - object-instance number of the object
* @return the COV change flag status
*/
bool CharacterString_Value_Change_Of_Value(
uint32_t object_instance)
bool CharacterString_Value_Change_Of_Value(uint32_t object_instance)
{
bool changed = false;
unsigned index = 0; /* offset from instance lookup */
@@ -286,8 +285,7 @@ bool CharacterString_Value_Change_Of_Value(
* @brief Clear the COV change flag
* @param object_instance - object-instance number of the object
*/
void CharacterString_Value_Change_Of_Value_Clear(
uint32_t object_instance)
void CharacterString_Value_Change_Of_Value_Clear(uint32_t object_instance)
{
unsigned index = 0; /* offset from instance lookup */
@@ -298,14 +296,14 @@ void CharacterString_Value_Change_Of_Value_Clear(
}
/**
* @brief For a given object instance-number, loads the value_list with the COV data.
* @brief For a given object instance-number, loads the value_list with the COV
* data.
* @param object_instance - object-instance number of the object
* @param value_list - list of COV data
* @return true if the value list is encoded
*/
bool CharacterString_Value_Encode_Value_List(
uint32_t object_instance,
BACNET_PROPERTY_VALUE * value_list)
uint32_t object_instance, BACNET_PROPERTY_VALUE *value_list)
{
bool status = false;
const bool in_alarm = false;
@@ -589,8 +587,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_CHARACTER_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
if (status) {
status = CharacterString_Value_Present_Value_Set(
wp_data->object_instance, &value.type.Character_String);
@@ -601,8 +599,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
CharacterString_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+38 -41
View File
@@ -228,12 +228,11 @@ static object_functions_t My_Object_Table[] = {
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
#endif
#if (BACNET_PROTOCOL_REVISION >= 24)
{ OBJECT_COLOR, Color_Init, Color_Count,
Color_Index_To_Instance, Color_Valid_Instance,
Color_Object_Name, Color_Read_Property,
Color_Write_Property, Color_Property_Lists,
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */,
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
{ OBJECT_COLOR, Color_Init, Color_Count, Color_Index_To_Instance,
Color_Valid_Instance, Color_Object_Name, Color_Read_Property,
Color_Write_Property, Color_Property_Lists, NULL /* ReadRangeInfo */,
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
{ OBJECT_COLOR_TEMPERATURE, Color_Temperature_Init, Color_Temperature_Count,
Color_Temperature_Index_To_Instance, Color_Temperature_Valid_Instance,
Color_Temperature_Object_Name, Color_Temperature_Read_Property,
@@ -1353,8 +1352,7 @@ static int Read_Property_Common(
}
apdu = rpdata->application_data;
if (property_list_common(rpdata->object_property)) {
apdu_len = property_list_common_encode(rpdata,
Object_Instance_Number);
apdu_len = property_list_common_encode(rpdata, Object_Instance_Number);
} else if (rpdata->object_property == PROP_OBJECT_NAME) {
/* only array properties can have array options */
if (rpdata->array_index != BACNET_ARRAY_ALL) {
@@ -1374,9 +1372,8 @@ static int Read_Property_Common(
} else if (rpdata->object_property == PROP_PROPERTY_LIST) {
Device_Objects_Property_List(
rpdata->object_type, rpdata->object_instance, &property_list);
apdu_len = property_list_encode(rpdata,
property_list.Required.pList, property_list.Optional.pList,
property_list.Proprietary.pList);
apdu_len = property_list_encode(rpdata, property_list.Required.pList,
property_list.Optional.pList, property_list.Proprietary.pList);
#endif
} else if (pObject->Object_Read_Property) {
apdu_len = pObject->Object_Read_Property(rpdata);
@@ -1451,8 +1448,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* FIXME: len < application_data_len: more data? */
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_OBJECT_ID);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(
@@ -1467,32 +1464,32 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_NUMBER_OF_APDU_RETRIES:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: bounds check? */
apdu_retries_set((uint8_t)value.type.Unsigned_Int);
}
break;
case PROP_APDU_TIMEOUT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: bounds check? */
apdu_timeout_set((uint16_t)value.type.Unsigned_Int);
}
break;
case PROP_VENDOR_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t)value.type.Unsigned_Int);
}
break;
case PROP_SYSTEM_STATUS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
result = Device_Set_System_Status(
(BACNET_DEVICE_STATUS)value.type.Enumerated, false);
@@ -1510,8 +1507,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OBJECT_NAME:
status = write_property_string_valid(wp_data, &value,
characterstring_capacity(&My_Object_Name));
status = write_property_string_valid(
wp_data, &value, characterstring_capacity(&My_Object_Name));
if (status) {
/* All the object names in a device must be unique */
if (Device_Valid_Object_Name(&value.type.Character_String,
@@ -1531,8 +1528,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_LOCATION:
status = write_property_empty_string_valid(wp_data, &value,
MAX_DEV_LOC_LEN);
status = write_property_empty_string_valid(
wp_data, &value, MAX_DEV_LOC_LEN);
if (status) {
Device_Set_Location(
characterstring_value(&value.type.Character_String),
@@ -1541,8 +1538,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_DESCRIPTION:
status = write_property_empty_string_valid(wp_data, &value,
MAX_DEV_DESC_LEN);
status = write_property_empty_string_valid(
wp_data, &value, MAX_DEV_DESC_LEN);
if (status) {
Device_Set_Description(
characterstring_value(&value.type.Character_String),
@@ -1550,8 +1547,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_MODEL_NAME:
status = write_property_empty_string_valid(wp_data, &value,
MAX_DEV_MOD_LEN);
status = write_property_empty_string_valid(
wp_data, &value, MAX_DEV_MOD_LEN);
if (status) {
Device_Set_Model_Name(
characterstring_value(&value.type.Character_String),
@@ -1560,8 +1557,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
#if defined(BACNET_TIME_MASTER)
case PROP_TIME_SYNCHRONIZATION_INTERVAL:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int < 65535) {
minutes = value.type.Unsigned_Int;
@@ -1574,16 +1571,16 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_ALIGN_INTERVALS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Device_Align_Intervals_Set(value.type.Boolean);
status = true;
}
break;
case PROP_INTERVAL_OFFSET:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int < 65535) {
minutes = value.type.Unsigned_Int;
@@ -1604,8 +1601,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
#endif
case PROP_UTC_OFFSET:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_SIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_SIGNED_INT);
if (status) {
if ((value.type.Signed_Int < (12 * 60)) &&
(value.type.Signed_Int > (-12 * 60))) {
@@ -1619,8 +1616,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
#if defined(BACDL_MSTP)
case PROP_MAX_INFO_FRAMES:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames(
@@ -1633,8 +1630,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_MAX_MASTER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if ((value.type.Unsigned_Int > 0) &&
(value.type.Unsigned_Int <= 127)) {
+8 -13
View File
@@ -213,8 +213,7 @@ void routed_get_my_address(BACNET_ADDRESS *my_address)
* meaning MAC broadcast, so it's an automatic match).
* Else False if no match or invalid idx is given.
*/
bool Routed_Device_Address_Lookup(
int idx, uint8_t dlen, uint8_t *dadr)
bool Routed_Device_Address_Lookup(int idx, uint8_t dlen, uint8_t *dadr)
{
bool result = false;
DEVICE_OBJECT_DATA *pDev = &Devices[idx];
@@ -371,15 +370,12 @@ uint32_t Routed_Device_Index_To_Instance(unsigned index)
* @param object_instance - object-instance number of the object
* @return index for the given instance-number, or 0 if not valid.
*/
static uint32_t Routed_Device_Instance_To_Index(
uint32_t Instance_Number)
static uint32_t Routed_Device_Instance_To_Index(uint32_t Instance_Number)
{
int i;
for ( i=0; i < MAX_NUM_DEVICES; i++) {
if (Devices[i].bacObj.Object_Instance_Number == Instance_Number)
{
for (i = 0; i < MAX_NUM_DEVICES; i++) {
if (Devices[i].bacObj.Object_Instance_Number == Instance_Number) {
/* Found Instance, so return the Device Index Number */
return i;
}
@@ -388,7 +384,6 @@ static uint32_t Routed_Device_Instance_To_Index(
/* We did not find instance... so simply return an Index of 0
All gateways will have at least a single root Device Object */
return 0;
}
/**
@@ -492,8 +487,8 @@ bool Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* FIXME: len < application_data_len: more data? */
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_OBJECT_ID);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Routed_Device_Set_Object_Instance_Number(
@@ -508,8 +503,8 @@ bool Routed_Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OBJECT_NAME:
status = write_property_string_valid(wp_data, &value,
MAX_DEV_NAME_LEN);
status =
write_property_string_valid(wp_data, &value, MAX_DEV_NAME_LEN);
if (status) {
Routed_Device_Set_Object_Name(
characterstring_encoding(&value.type.Character_String),
+4 -4
View File
@@ -431,16 +431,16 @@ bool Integer_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_SIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_SIGNED_INT);
if (status) {
Integer_Value_Present_Value_Set(wp_data->object_instance,
value.type.Signed_Int, wp_data->priority);
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Integer_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+23 -18
View File
@@ -880,7 +880,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* error while decoding - a smaller larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
return false;
}
/* decode the some of the request */
@@ -909,7 +909,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->application_data_len, &value,
PROP_REQUESTED_SHED_LEVEL);
if (len == BACNET_STATUS_ERROR) {
PRINTF("Load_Control_Write_Property() failure detected point D\n");
PRINTF(
"Load_Control_Write_Property() failure detected point D\n");
/* error! */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
@@ -935,7 +936,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
value.type.Real;
status = true;
} else {
PRINTF("Load_Control_Write_Property() failure detected point E\n");
PRINTF(
"Load_Control_Write_Property() failure detected point E\n");
/* error! */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE;
@@ -946,10 +948,11 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_START_TIME:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_DATE);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
if (!status) {
PRINTF("Load_Control_Write_Property() failure detected point F\n");
PRINTF(
"Load_Control_Write_Property() failure detected point F\n");
/* don't continue if we don't have a valid date */
break;
}
@@ -959,8 +962,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
bacapp_decode_application_data(wp_data->application_data + len,
wp_data->application_data_len - len, &value);
if (len) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_TIME);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
if (status) {
/* Write time and date and set written flag */
Start_Time[object_index].date = start_date;
@@ -968,7 +971,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
Start_Time_Property_Written[object_index] = true;
}
} else {
PRINTF("Load_Control_Write_Property() failure detected point G\n");
PRINTF(
"Load_Control_Write_Property() failure detected point G\n");
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -976,19 +980,20 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_SHED_DURATION:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
Shed_Duration[object_index] = value.type.Unsigned_Int;
Load_Control_Request_Written[object_index] = true;
} else {
PRINTF("Load_Control_Write_Property() failure detected point H\n");
PRINTF(
"Load_Control_Write_Property() failure detected point H\n");
}
break;
case PROP_DUTY_WINDOW:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
Duty_Window[object_index] = value.type.Unsigned_Int;
Load_Control_Request_Written[object_index] = true;
@@ -996,8 +1001,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_SHED_LEVELS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* re-write the size of the array? */
if (wp_data->array_index == 0) {
@@ -1020,8 +1025,8 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_ENABLE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Load_Control_Enable[object_index] = value.type.Boolean;
}
+8 -8
View File
@@ -1111,8 +1111,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_REAL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_REAL);
if (status) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -1131,8 +1131,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_NULL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
if (status) {
if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum
@@ -1154,8 +1154,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_LIGHTING_COMMAND:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
if (status) {
status = Lighting_Output_Lighting_Command_Set(
wp_data->object_instance, &value.type.Lighting_Command);
@@ -1166,8 +1166,8 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Lighting_Output_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+4 -4
View File
@@ -322,8 +322,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_MODE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
object_index = Life_Safety_Point_Instance_To_Index(
@@ -338,8 +338,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
object_index = Life_Safety_Point_Instance_To_Index(
wp_data->object_instance);
+11 -12
View File
@@ -603,8 +603,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_OBJECT_NAME:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_CHARACTER_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
if (status) {
/* All the object names in a device must be unique */
if (Device_Valid_Object_Name(&value.type.Character_String,
@@ -626,8 +626,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_DESCRIPTION:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_CHARACTER_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_CHARACTER_STRING);
if (status) {
status = Multistate_Input_Description_Write(
wp_data->object_instance, &value.type.Character_String,
@@ -635,8 +635,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
status = Multistate_Input_Present_Value_Set(
wp_data->object_instance, value.type.Unsigned_Int);
@@ -647,8 +647,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Multistate_Input_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
@@ -675,8 +675,8 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
if (element_len) {
status = Multistate_Input_State_Text_Write(
wp_data->object_instance, array_index,
&value.type.Character_String,
&wp_data->error_class, &wp_data->error_code);
&value.type.Character_String, &wp_data->error_class,
&wp_data->error_code);
}
max_states--;
array_index++;
@@ -686,8 +686,7 @@ bool Multistate_Input_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->application_data_len - len, &value);
if (element_len < 0) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_VALUE_OUT_OF_RANGE;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
break;
}
len += element_len;
+6 -6
View File
@@ -375,8 +375,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
priority = wp_data->priority;
/* Command priority 6 is reserved for use by Minimum On/Off
@@ -410,8 +410,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_NULL);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
if (status) {
level = MULTISTATE_NULL;
object_index = Multistate_Output_Instance_To_Index(
@@ -437,8 +437,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Multistate_Output_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+4 -4
View File
@@ -538,8 +538,8 @@ bool Multistate_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
status = Multistate_Value_Present_Value_Set(
wp_data->object_instance, value.type.Unsigned_Int);
@@ -550,8 +550,8 @@ bool Multistate_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Multistate_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
+20 -21
View File
@@ -50,7 +50,7 @@
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
@@ -101,25 +101,24 @@ void Notification_Class_Init(void)
255; /* PRINTF lowest priority for Normal message. */
/* configure for every day, all day long */
for (i = 0; i < MAX_BACNET_DAYS_OF_WEEK; i++) {
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1<<i);
NC_Info[NotifyIdx].Recipient_List->ValidDays |= (1 << i);
}
NC_Info[NotifyIdx].Recipient_List->FromTime.hour = 0;
NC_Info[NotifyIdx].Recipient_List->FromTime.min = 0;
NC_Info[NotifyIdx].Recipient_List->FromTime.sec = 0;
NC_Info[NotifyIdx].Recipient_List->FromTime.hundredths = 0;
NC_Info[NotifyIdx].Recipient_List->ToTime.hour = 23;
NC_Info[NotifyIdx].Recipient_List->ToTime.min = 59;
NC_Info[NotifyIdx].Recipient_List->ToTime.sec = 59;
NC_Info[NotifyIdx].Recipient_List->ToTime.hundredths = 0;
NC_Info[NotifyIdx].Recipient_List->Transitions =
TRANSITION_TO_OFFNORMAL_MASKED |
TRANSITION_TO_FAULT_MASKED |
NC_Info[NotifyIdx].Recipient_List->FromTime.hour = 0;
NC_Info[NotifyIdx].Recipient_List->FromTime.min = 0;
NC_Info[NotifyIdx].Recipient_List->FromTime.sec = 0;
NC_Info[NotifyIdx].Recipient_List->FromTime.hundredths = 0;
NC_Info[NotifyIdx].Recipient_List->ToTime.hour = 23;
NC_Info[NotifyIdx].Recipient_List->ToTime.min = 59;
NC_Info[NotifyIdx].Recipient_List->ToTime.sec = 59;
NC_Info[NotifyIdx].Recipient_List->ToTime.hundredths = 0;
NC_Info[NotifyIdx].Recipient_List->Transitions =
TRANSITION_TO_OFFNORMAL_MASKED | TRANSITION_TO_FAULT_MASKED |
TRANSITION_TO_NORMAL_MASKED;
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
NC_Info[NotifyIdx].Recipient_List->Recipient.RecipientType =
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
NC_Info[NotifyIdx].Recipient_List->ConfirmedNotify = false;
NC_Info[NotifyIdx].Recipient_List->Recipient.RecipientType =
RECIPIENT_TYPE_DEVICE;
NC_Info[NotifyIdx].Recipient_List->Recipient._.DeviceIdentifier =
NC_Info[NotifyIdx].Recipient_List->Recipient._.DeviceIdentifier =
4194303;
}
@@ -418,8 +417,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_PRIORITY:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (wp_data->array_index == 0) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -471,8 +470,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_ACK_REQUIRED:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BIT_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BIT_STRING);
if (status) {
if (value.type.Bit_String.bits_used == 3) {
CurrentNotify->Ack_Required =
+17 -23
View File
@@ -613,8 +613,8 @@ bool Network_Port_MAC_Address(
memcpy(
&ip_mac[0], &Object_List[index].Network.IPv4.IP_Address, 4);
/* convert port from host-byte-order to network-byte-order */
encode_unsigned16(&ip_mac[4],
Object_List[index].Network.IPv4.Port);
encode_unsigned16(
&ip_mac[4], Object_List[index].Network.IPv4.Port);
mac = &ip_mac[0];
mac_len = sizeof(ip_mac);
break;
@@ -1326,9 +1326,7 @@ void *Network_Port_BBMD_BD_Table(uint32_t object_instance)
* @return true if the Broadcast Distribution Table linked list head
* property value was set
*/
bool Network_Port_BBMD_BD_Table_Set(
uint32_t object_instance,
void *bdt_head)
bool Network_Port_BBMD_BD_Table_Set(uint32_t object_instance, void *bdt_head)
{
bool status = false;
unsigned index = 0;
@@ -1379,9 +1377,7 @@ void *Network_Port_BBMD_FD_Table(uint32_t object_instance)
*
* @return true if the BBMD-Accept-FD-Registrations property value was set
*/
bool Network_Port_BBMD_FD_Table_Set(
uint32_t object_instance,
void *fdt_head)
bool Network_Port_BBMD_FD_Table_Set(uint32_t object_instance, void *fdt_head)
{
bool status = false;
unsigned index = 0;
@@ -1449,8 +1445,7 @@ static bool Network_Port_Remote_BBMD_IP_Address_And_Port(
* @return true if ip-address was retrieved
*/
bool Network_Port_Remote_BBMD_IP_Address(
uint32_t object_instance,
uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d)
uint32_t object_instance, uint8_t *a, uint8_t *b, uint8_t *c, uint8_t *d)
{
unsigned index = 0; /* offset from instance lookup */
bool status = false;
@@ -1539,8 +1534,8 @@ uint16_t Network_Port_Remote_BBMD_BIP_Port(uint32_t object_instance)
*
* @return true if values are within range and property is set.
*/
bool Network_Port_Remote_BBMD_BIP_Port_Set(uint32_t object_instance,
uint16_t value)
bool Network_Port_Remote_BBMD_BIP_Port_Set(
uint32_t object_instance, uint16_t value)
{
bool status = false;
unsigned index = 0;
@@ -1591,8 +1586,8 @@ uint16_t Network_Port_Remote_BBMD_BIP_Lifetime(uint32_t object_instance)
*
* @return true if values are within range and property is set.
*/
bool Network_Port_Remote_BBMD_BIP_Lifetime_Set(uint32_t object_instance,
uint16_t value)
bool Network_Port_Remote_BBMD_BIP_Lifetime_Set(
uint32_t object_instance, uint16_t value)
{
bool status = false;
unsigned index = 0;
@@ -2357,13 +2352,12 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
case PROP_FD_BBMD_ADDRESS:
Network_Port_Remote_BBMD_IP_Address_And_Port(
rpdata->object_instance, &ip_address);
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(&apdu[0],
apdu_size, &ip_address);
apdu_len = bvlc_foreign_device_bbmd_host_address_encode(
&apdu[0], apdu_size, &ip_address);
break;
case PROP_FD_SUBSCRIPTION_LIFETIME:
apdu_len = encode_application_unsigned(
&apdu[0], Network_Port_Remote_BBMD_BIP_Lifetime(
rpdata->object_instance));
apdu_len = encode_application_unsigned(&apdu[0],
Network_Port_Remote_BBMD_BIP_Lifetime(rpdata->object_instance));
break;
#endif
case PROP_BACNET_IPV6_MODE:
@@ -2497,8 +2491,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* FIXME: len < application_data_len: more data? */
switch (wp_data->object_property) {
case PROP_MAX_MASTER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int <= 255) {
status = Network_Port_MSTP_Max_Master_Set(
@@ -2514,8 +2508,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_MAX_INFO_FRAMES:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int <= 255) {
status = Network_Port_MSTP_Max_Info_Frames_Set(
+1 -1
View File
@@ -123,7 +123,7 @@ bool objects_device_delete(int index)
Keylist_Delete(pDevice->Object_List);
}
free(pDevice);
result = true;
result = true;
}
}
return result;
+4 -4
View File
@@ -303,8 +303,8 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_OCTET_STRING);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_OCTET_STRING);
if (status) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -327,8 +327,8 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
CurrentAV->Out_Of_Service = value.type.Boolean;
}
+4 -4
View File
@@ -309,8 +309,8 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -333,8 +333,8 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
CurrentAV->Out_Of_Service = value.type.Boolean;
}
+6 -4
View File
@@ -86,7 +86,8 @@ void Schedule_Init(void)
for (j = 0; j < 7; j++) {
psched->Weekly_Schedule[j].TV_Count = 0;
}
memcpy(&psched->Present_Value, &psched->Schedule_Default, sizeof(psched->Present_Value));
memcpy(&psched->Present_Value, &psched->Schedule_Default,
sizeof(psched->Present_Value));
psched->Schedule_Default.context_specific = false;
psched->Schedule_Default.tag = BACNET_APPLICATION_TAG_REAL;
psched->Schedule_Default.type.Real = 21.0f; /* 21 C, room temperature */
@@ -347,8 +348,8 @@ bool Schedule_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
suitable time for
review by all interested parties. Say 6 months -> September
2016 */
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
Schedule_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
@@ -421,6 +422,7 @@ void Schedule_Recalculate_PV(
}
if (desc->Present_Value.tag == BACNET_APPLICATION_TAG_NULL) {
memcpy(&desc->Present_Value, &desc->Schedule_Default, sizeof(desc->Present_Value));
memcpy(&desc->Present_Value, &desc->Schedule_Default,
sizeof(desc->Present_Value));
}
}
+27 -27
View File
@@ -458,8 +458,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
switch (wp_data->object_property) {
case PROP_ENABLE:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
/* Section 12.25.5 can't enable a full log with stop when full
* set */
@@ -500,8 +500,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_STOP_WHEN_FULL:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
/* Only trigger this on a change of state */
if (CurrentLog->bStopWhenFull != value.type.Boolean) {
@@ -532,8 +532,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_RECORD_COUNT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int == 0) {
/* Time to clear down the log */
@@ -549,8 +549,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* logic
* triggered and polled options.
*/
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
if (value.type.Enumerated != LOGGING_TYPE_COV) {
CurrentLog->LoggingType =
@@ -579,8 +579,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_START_TIME:
/* Copy the date part to safe place */
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_DATE);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
if (!status) {
break;
}
@@ -591,14 +591,14 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->application_data_len - len, &value);
if (len) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_TIME);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
if (!status) {
break;
}
/* First record the current enable state of the log */
bEffectiveEnable = TL_Is_Enabled(log_index);
/* Safe to copy the date now */
/* Safe to copy the date now */
CurrentLog->StartTime.date = start_date;
CurrentLog->StartTime.time = value.type.Time;
@@ -630,8 +630,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_STOP_TIME:
/* Copy the date part to safe place */
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_DATE);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_DATE);
if (!status) {
break;
}
@@ -642,14 +642,14 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->application_data_len - len, &value);
if (len) {
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_TIME);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_TIME);
if (!status) {
break;
}
/* First record the current enable state of the log */
bEffectiveEnable = TL_Is_Enabled(log_index);
/* Safe to copy the date now */
/* Safe to copy the date now */
CurrentLog->StopTime.date = stop_date;
CurrentLog->StopTime.time = value.type.Time;
@@ -684,7 +684,7 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->application_data, &TempSource);
if ((len < 0) ||
(len > wp_data->application_data_len)) /* Hmm, that didn't go */
/* as planned... */
/* as planned... */
{
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_OTHER;
@@ -720,8 +720,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if ((CurrentLog->LoggingType == LOGGING_TYPE_POLLED) &&
(value.type.Unsigned_Int == 0)) {
@@ -745,8 +745,8 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_ALIGN_INTERVALS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
CurrentLog->bAlignIntervals = value.type.Boolean;
}
@@ -755,16 +755,16 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_INTERVAL_OFFSET:
/* We only log to 1 sec accuracy so must divide by 100 before
* passing it on */
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
CurrentLog->ulIntervalOffset = value.type.Unsigned_Int / 100;
}
break;
case PROP_TRIGGER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_BOOLEAN);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
if (status) {
/* We will not allow triggered operation if polling with
* aligning to the clock as that will produce non aligned
+12 -15
View File
@@ -342,8 +342,7 @@ bool apdu_complex_error(uint8_t service_choice)
* handling.
*/
void apdu_set_error_handler(
BACNET_CONFIRMED_SERVICE service_choice,
error_function pFunction)
BACNET_CONFIRMED_SERVICE service_choice, error_function pFunction)
{
if ((service_choice < MAX_BACNET_CONFIRMED_SERVICE) &&
(!apdu_complex_error(service_choice))) {
@@ -359,8 +358,7 @@ void apdu_set_error_handler(
* handling.
*/
void apdu_set_complex_error_handler(
BACNET_CONFIRMED_SERVICE service_choice,
complex_error_function pFunction)
BACNET_CONFIRMED_SERVICE service_choice, complex_error_function pFunction)
{
if (apdu_complex_error(service_choice)) {
Error_Function[service_choice].complex = pFunction;
@@ -556,9 +554,9 @@ void apdu_handler(BACNET_ADDRESS *src,
/* PDU Type */
switch (apdu[0] & 0xF0) {
case PDU_TYPE_CONFIRMED_SERVICE_REQUEST:
len = apdu_decode_confirmed_service_request(
&apdu[0], apdu_len, &service_data, &service_choice,
&service_request, &service_request_len);
len = apdu_decode_confirmed_service_request(&apdu[0], apdu_len,
&service_data, &service_choice, &service_request,
&service_request_len);
if (len == 0) {
/* service data unable to be decoded - simply drop */
break;
@@ -672,8 +670,8 @@ void apdu_handler(BACNET_ADDRESS *src,
case SERVICE_CONFIRMED_VT_DATA:
/* Security Services */
case SERVICE_CONFIRMED_AUTHENTICATE:
if (Confirmed_ACK_Function[service_choice].complex !=
NULL) {
if (Confirmed_ACK_Function[service_choice]
.complex != NULL) {
Confirmed_ACK_Function[service_choice].complex(
service_request, service_request_len, src,
&service_ack_data);
@@ -697,16 +695,15 @@ void apdu_handler(BACNET_ADDRESS *src,
if (apdu_complex_error(service_choice)) {
if (Error_Function[service_choice].complex) {
Error_Function[service_choice].complex(src,
invoke_id, service_choice,
&apdu[3], apdu_len - 3);
invoke_id, service_choice, &apdu[3],
apdu_len - 3);
}
} else if (service_choice < MAX_BACNET_CONFIRMED_SERVICE) {
len = bacerror_decode_error_class_and_code(&apdu[3],
apdu_len - 3, &error_class, &error_code);
len = bacerror_decode_error_class_and_code(
&apdu[3], apdu_len - 3, &error_class, &error_code);
if ((len != 0) &&
(Error_Function[service_choice].error)) {
Error_Function[service_choice].error(src,
invoke_id,
Error_Function[service_choice].error(src, invoke_id,
(BACNET_ERROR_CLASS)error_class,
(BACNET_ERROR_CODE)error_code);
}
+4 -7
View File
@@ -43,7 +43,7 @@
/** @file h_ccov.c Handles Confirmed COV Notifications. */
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
@@ -60,8 +60,7 @@ static BACNET_COV_NOTIFICATION Confirmed_COV_Notification_Head;
* @brief call the COV notification callbacks
* @param cov_data - data decoded from the COV notification
*/
static void handler_ccov_notification_callback(
BACNET_COV_DATA *cov_data)
static void handler_ccov_notification_callback(BACNET_COV_DATA *cov_data)
{
BACNET_COV_NOTIFICATION *head;
@@ -78,8 +77,7 @@ static void handler_ccov_notification_callback(
* @brief Add a Confirmed COV notification callback
* @param cb - COV notification callback to be added
*/
void handler_ccov_notification_add(
BACNET_COV_NOTIFICATION *cb)
void handler_ccov_notification_add(BACNET_COV_NOTIFICATION *cb)
{
BACNET_COV_NOTIFICATION *head;
@@ -161,8 +159,7 @@ void handler_ccov_notification(uint8_t *service_request,
PRINTF("%s ",
bactext_property_name(pProperty_value->propertyIdentifier));
} else {
PRINTF("proprietary %u ",
pProperty_value->propertyIdentifier);
PRINTF("proprietary %u ", pProperty_value->propertyIdentifier);
}
if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) {
PRINTF("%u ", pProperty_value->propertyArrayIndex);
+1 -2
View File
@@ -149,8 +149,7 @@ void handler_device_communication_control(uint8_t *service_request,
#endif
} else if (len == BACNET_STATUS_REJECT) {
len = reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
REJECT_REASON_PARAMETER_OUT_OF_RANGE);
service_data->invoke_id, REJECT_REASON_PARAMETER_OUT_OF_RANGE);
#if PRINT_ENABLED
fprintf(stderr, "DCC: Sending Reject!\n");
#endif
+18 -17
View File
@@ -92,9 +92,9 @@ void handler_read_property(uint8_t *service_request,
if (npdu_len <= 0) {
/* If 0 or negative, there were problems with the data or encoding. */
len = BACNET_STATUS_ABORT;
#if PRINT_ENABLED
fprintf(stderr, "RP: npdu_encode_pdu error. Sending Abort!\n");
#endif
#if PRINT_ENABLED
fprintf(stderr, "RP: npdu_encode_pdu error. Sending Abort!\n");
#endif
} else if (service_data->segmented_message) {
/* we don't support segmentation - send an abort */
len = BACNET_STATUS_ABORT;
@@ -103,17 +103,17 @@ void handler_read_property(uint8_t *service_request,
#endif
} else {
len = rp_decode_service_request(service_request, service_len, &rpdata);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (len <= 0) {
fprintf(stderr, "RP: Unable to decode Request!\n");
}
#endif
#endif
if (len < 0) {
/* bad decoding - skip to error/reject/abort handling */
error = true;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RP: Bad Encoding.\n");
#endif
#endif
} else {
/* When the object-type in the Object Identifier parameter
contains the value DEVICE and the instance in the 'Object
@@ -140,9 +140,9 @@ void handler_read_property(uint8_t *service_request,
rpdata.object_instance = Network_Port_Index_To_Instance(0);
}
#endif
apdu_len = rp_ack_encode_apdu_init(
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
&rpdata);
apdu_len =
rp_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, &rpdata);
/* configure our storage */
rpdata.application_data =
&Handler_Transmit_Buffer[npdu_len + apdu_len];
@@ -157,21 +157,22 @@ void handler_read_property(uint8_t *service_request,
if (apdu_len > service_data->max_resp) {
/* too big for the sender - send an abort!
Setting of error code needed here as read property
processing may have overridden the default set at start */
processing may have overridden the default set at start
*/
rpdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
len = BACNET_STATUS_ABORT;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RP: Message too large.\n");
#endif
#endif
} else {
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RP: Sending Ack!\n");
#endif
#endif
error = false;
}
} else {
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RP: Device_Read_Property: ");
if (len == BACNET_STATUS_ABORT) {
fprintf(stderr, "Abort!\n");
@@ -182,7 +183,7 @@ void handler_read_property(uint8_t *service_request,
} else {
fprintf(stderr, "Unknown Len=%d\n", len);
}
#endif
#endif
}
}
}
+5 -5
View File
@@ -41,8 +41,8 @@
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stdout,__VA_ARGS__)
#define PRINTF_ERR(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#define PRINTF_ERR(...)
@@ -73,9 +73,9 @@ void rp_ack_print_data(BACNET_READ_PROPERTY_DATA *data)
/* FIXME: what if application_data_len is bigger than 255? */
/* value? need to loop until all of the len is gone... */
for (;;) {
len = bacapp_decode_known_property(
application_data, (unsigned)application_data_len, &value,
data->object_type, data->object_property);
len = bacapp_decode_known_property(application_data,
(unsigned)application_data_len, &value, data->object_type,
data->object_property);
if (len < 0) {
PRINTF_ERR("RP Ack: unable to decode! %s:%s\n",
+10 -8
View File
@@ -287,8 +287,9 @@ void handler_read_property_multiple(uint8_t *service_request,
#endif
error = len;
berror = true;
break; /* The berror flag ensures that both loops will */
/* be broken! */
break; /* The berror flag ensures that both loops will
*/
/* be broken! */
}
decode_len += len;
/* handle the special properties */
@@ -321,7 +322,7 @@ void handler_read_property_multiple(uint8_t *service_request,
error = BACNET_STATUS_ABORT;
berror = true;
break; /* The berror flag ensures that both */
/* loops will be broken! */
/* loops will be broken! */
}
apdu_len += len;
@@ -343,7 +344,7 @@ void handler_read_property_multiple(uint8_t *service_request,
error = BACNET_STATUS_ABORT;
berror = true;
break; /* The berror flag ensures that both */
/* loops will be broken! */
/* loops will be broken! */
}
apdu_len += len;
} else {
@@ -379,8 +380,9 @@ void handler_read_property_multiple(uint8_t *service_request,
#endif
error = len;
berror = true;
break; /* The berror flag ensures that */
/* both loops will be broken! */
break; /* The berror flag ensures that
*/
/* both loops will be broken! */
}
}
}
@@ -400,7 +402,7 @@ void handler_read_property_multiple(uint8_t *service_request,
error = len;
berror = true;
break; /* The berror flag ensures that both loops */
/* will be broken! */
/* will be broken! */
}
}
@@ -422,7 +424,7 @@ void handler_read_property_multiple(uint8_t *service_request,
error = BACNET_STATUS_ABORT;
berror = true;
break; /* The berror flag ensures that both loops */
/* will be broken! */
/* will be broken! */
} else {
apdu_len += copy_len;
}
+8 -9
View File
@@ -41,8 +41,8 @@
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stdout,__VA_ARGS__)
#define PRINTF_ERR(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stdout, __VA_ARGS__)
#define PRINTF_ERR(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#define PRINTF_ERR(...)
@@ -124,9 +124,8 @@ int rpm_ack_decode_service_request(
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
rpm_property->value = value;
while (value && (apdu_len > 0)) {
len = bacapp_decode_known_property(
apdu, (unsigned)apdu_len, value,
rpm_object->object_type,
len = bacapp_decode_known_property(apdu, (unsigned)apdu_len,
value, rpm_object->object_type,
rpm_property->propertyIdentifier);
/* If len == 0 then it's an empty structure, which is OK. */
if (len < 0) {
@@ -134,7 +133,7 @@ int rpm_ack_decode_service_request(
PRINTF_ERR("RPM Ack: unable to decode! %s:%s\n",
bactext_object_type_name(rpm_object->object_type),
bactext_property_name(
rpm_property->propertyIdentifier));
rpm_property->propertyIdentifier));
/* note: caller will free the memory */
return BACNET_STATUS_ERROR;
}
@@ -155,7 +154,8 @@ int rpm_ack_decode_service_request(
PRINTF_ERR("RPM Ack: decoded %s:%s len=%d\n",
bactext_object_type_name(rpm_object->object_type),
bactext_property_name(
rpm_property->propertyIdentifier), len);
rpm_property->propertyIdentifier),
len);
break;
}
}
@@ -225,8 +225,7 @@ void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
bool array_value = false;
if (rpm_data) {
PRINTF("%s #%lu\r\n",
bactext_object_type_name(rpm_data->object_type),
PRINTF("%s #%lu\r\n", bactext_object_type_name(rpm_data->object_type),
(unsigned long)rpm_data->object_instance);
PRINTF("{\r\n");
listOfProperties = rpm_data->listOfProperties;
+16 -14
View File
@@ -153,17 +153,17 @@ void handler_read_range(uint8_t *service_request,
} else {
memset(&data, 0, sizeof(data)); /* start with blank canvas */
len = rr_decode_service_request(service_request, service_len, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (len <= 0)
fprintf(stderr, "RR: Unable to decode Request!\n");
#endif
#endif
if (len < 0) {
/* bad decoding - send an abort */
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, ABORT_REASON_OTHER, true);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RR: Bad Encoding. Sending Abort!\n");
#endif
#endif
} else {
/* assume that there is an error */
error = true;
@@ -173,29 +173,31 @@ void handler_read_range(uint8_t *service_request,
data.application_data = &Temp_Buf[0];
data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */
len = rr_ack_encode_apdu(
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, &data);
#if PRINT_ENABLED
len = rr_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, &data);
#if PRINT_ENABLED
fprintf(stderr, "RR: Sending Ack!\n");
#endif
#endif
error = false;
}
if (error) {
if (len == -2) {
/* BACnet APDU too small to fit data, so proper response is Abort */
/* BACnet APDU too small to fit data, so proper response is
* Abort */
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RR: Reply too big to fit into APDU!\n");
#endif
#endif
} else {
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
len = bacerror_encode_apdu(
&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_READ_RANGE,
data.error_class, data.error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "RR: Sending Error!\n");
#endif
#endif
}
}
}
+6 -10
View File
@@ -41,7 +41,7 @@
/** @file h_ucov.c Handles Unconfirmed COV Notifications. */
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
@@ -57,8 +57,7 @@ static BACNET_COV_NOTIFICATION Unconfirmed_COV_Notification_Head;
* @brief call the COV notification callbacks
* @param cov_data - data decoded from the COV notification
*/
static void handler_ucov_notification_callback(
BACNET_COV_DATA *cov_data)
static void handler_ucov_notification_callback(BACNET_COV_DATA *cov_data)
{
BACNET_COV_NOTIFICATION *head;
@@ -75,8 +74,7 @@ static void handler_ucov_notification_callback(
* @brief Add a Confirmed COV notification callback
* @param cb - COV notification callback to be added
*/
void handler_ucov_notification_add(
BACNET_COV_NOTIFICATION *cb)
void handler_ucov_notification_add(BACNET_COV_NOTIFICATION *cb)
{
BACNET_COV_NOTIFICATION *head;
@@ -122,9 +120,8 @@ void handler_ucov_notification(
cov_data.listOfValues = &property_value[0];
PRINTF("UCOV: Received Notification!\n");
/* decode the service request only */
len =
cov_notify_decode_service_request(
service_request, service_len, &cov_data);
len = cov_notify_decode_service_request(
service_request, service_len, &cov_data);
if (len > 0) {
handler_ucov_notification_callback(&cov_data);
PRINTF("UCOV: PID=%u ", cov_data.subscriberProcessIdentifier);
@@ -141,8 +138,7 @@ void handler_ucov_notification(
PRINTF("%s ",
bactext_property_name(pProperty_value->propertyIdentifier));
} else {
PRINTF("proprietary %u ",
pProperty_value->propertyIdentifier);
PRINTF("proprietary %u ", pProperty_value->propertyIdentifier);
}
if (pProperty_value->propertyArrayIndex != BACNET_ARRAY_ALL) {
PRINTF("%u ", pProperty_value->propertyArrayIndex);
+10 -10
View File
@@ -46,7 +46,7 @@
/** @file h_wpm.c Handles Write Property Multiple requests. */
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
@@ -61,8 +61,8 @@
* @return number of bytes decoded, or BACNET_STATUS_REJECT,
* or BACNET_STATUS_ERROR
*/
static int write_property_multiple_decode(
uint8_t *apdu, uint16_t apdu_len,
static int write_property_multiple_decode(uint8_t *apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA *wp_data,
write_property_function device_write_property)
{
@@ -83,12 +83,12 @@ static int write_property_multiple_decode(
(3) an optional 'Property Array Index'
(4) a 'Property Value'
(5) an optional 'Priority' */
len = wpm_decode_object_property(&apdu[offset],
apdu_len - offset, wp_data);
len = wpm_decode_object_property(
&apdu[offset], apdu_len - offset, wp_data);
if (len > 0) {
offset += len;
PRINTF("WPM: type=%lu instance=%lu property=%lu "
"priority=%lu index=%ld\n",
"priority=%lu index=%ld\n",
(unsigned long)wp_data->object_type,
(unsigned long)wp_data->object_instance,
(unsigned long)wp_data->object_property,
@@ -160,11 +160,11 @@ void handler_write_property_multiple(uint8_t *service_request,
PRINTF("WPM: Segmented message. Sending Abort!\n");
} else {
/* first time - detect malformed request before writing any data */
len = write_property_multiple_decode(service_request, service_len,
&wp_data, NULL);
len = write_property_multiple_decode(
service_request, service_len, &wp_data, NULL);
if (len > 0) {
len = write_property_multiple_decode(service_request, service_len,
&wp_data, Device_Write_Property);
len = write_property_multiple_decode(
service_request, service_len, &wp_data, Device_Write_Property);
}
}
/* encode the confirmed reply */
+10 -10
View File
@@ -44,7 +44,7 @@
/** @file s_ack_alarm.c Send an Alarm Acknowledgment. */
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
@@ -58,8 +58,10 @@
* @return invoke id of outgoing message, or 0 if communication is disabled,
* or no tsm slot is available.
*/
uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
BACNET_ALARM_ACK_DATA *data, BACNET_ADDRESS *dest)
uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu,
uint16_t pdu_size,
BACNET_ALARM_ACK_DATA *data,
BACNET_ADDRESS *dest)
{
int len = 0;
int pdu_len = 0;
@@ -91,10 +93,9 @@ uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((uint16_t)pdu_len < pdu_size) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest,
&npdu_data, pdu, (uint16_t)pdu_len);
bytes_sent =
datalink_send_pdu(dest, &npdu_data, pdu, pdu_len);
tsm_set_confirmed_unsegmented_transaction(
invoke_id, dest, &npdu_data, pdu, (uint16_t)pdu_len);
bytes_sent = datalink_send_pdu(dest, &npdu_data, pdu, pdu_len);
if (bytes_sent <= 0) {
PRINTF("Failed to Send Alarm Ack Request (%s)!\n",
strerror(errno));
@@ -103,7 +104,7 @@ uint8_t Send_Alarm_Acknowledgement_Address(uint8_t *pdu, uint16_t pdu_size,
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
PRINTF("Failed to Send Alarm Ack Request "
"(exceeds destination maximum APDU)!\n");
"(exceeds destination maximum APDU)!\n");
}
}
@@ -133,8 +134,7 @@ uint8_t Send_Alarm_Acknowledgement(
max_apdu = sizeof(Handler_Transmit_Buffer);
}
invoke_id = Send_Alarm_Acknowledgement_Address(
Handler_Transmit_Buffer, max_apdu,
data, &dest);
Handler_Transmit_Buffer, max_apdu, data, &dest);
}
return invoke_id;
+7 -6
View File
@@ -47,8 +47,10 @@
* @return invoke id of outgoing message, or 0 if communication is disabled,
* or no tsm slot is available.
*/
uint8_t Send_CEvent_Notify_Address(uint8_t *pdu, uint16_t pdu_size,
BACNET_EVENT_NOTIFICATION_DATA *data, BACNET_ADDRESS *dest)
uint8_t Send_CEvent_Notify_Address(uint8_t *pdu,
uint16_t pdu_size,
BACNET_EVENT_NOTIFICATION_DATA *data,
BACNET_ADDRESS *dest)
{
int len = 0;
int pdu_len = 0;
@@ -81,8 +83,8 @@ uint8_t Send_CEvent_Notify_Address(uint8_t *pdu, uint16_t pdu_size,
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((uint16_t)pdu_len < pdu_size) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest,
&npdu_data, pdu, (uint16_t)pdu_len);
tsm_set_confirmed_unsegmented_transaction(
invoke_id, dest, &npdu_data, pdu, (uint16_t)pdu_len);
#if PRINT_ENABLED
bytes_sent =
#endif
@@ -131,8 +133,7 @@ uint8_t Send_CEvent_Notify(
max_apdu = sizeof(Handler_Transmit_Buffer);
}
invoke_id = Send_CEvent_Notify_Address(
Handler_Transmit_Buffer, max_apdu,
data, &dest);
Handler_Transmit_Buffer, max_apdu, data, &dest);
}
return invoke_id;
+2 -1
View File
@@ -144,7 +144,8 @@ uint8_t Send_COV_Subscribe(
/* encode the APDU portion of the packet */
if (cov_data->covSubscribeToProperty) {
/* subscribe to 1 property */
len = cov_subscribe_property_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
len = cov_subscribe_property_encode_apdu(
&Handler_Transmit_Buffer[pdu_len],
sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id, cov_data);
} else {
/* subscribe to object */
+110 -179
View File
@@ -43,8 +43,12 @@ static double clamp(double d, double min, double max)
* @param brightness - return brightness of the CIE xy color 0..255
* @note http://en.wikipedia.org/wiki/Srgb
*/
void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
float *x_coordinate, float *y_coordinate, uint8_t *brightness)
void color_rgb_to_xy(uint8_t r,
uint8_t g,
uint8_t b,
float *x_coordinate,
float *y_coordinate,
uint8_t *brightness)
{
/* Get the RGB values from your color object
and convert them to be between 0 and 1.
@@ -63,15 +67,12 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
This gamma correction is also applied to the screen
of your computer or phone, thus we need this to create
the same color on the light as on screen. */
red = (red > 0.04045f) ?
pow((red + 0.055f) / (1.0f + 0.055f), 2.4f) :
(red / 12.92f);
green = (green > 0.04045f) ?
pow((green + 0.055f) / (1.0f + 0.055f), 2.4f) :
(green / 12.92f);
blue = (blue > 0.04045f) ?
pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f) :
(blue / 12.92f);
red = (red > 0.04045f) ? pow((red + 0.055f) / (1.0f + 0.055f), 2.4f)
: (red / 12.92f);
green = (green > 0.04045f) ? pow((green + 0.055f) / (1.0f + 0.055f), 2.4f)
: (green / 12.92f);
blue = (blue > 0.04045f) ? pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f)
: (blue / 12.92f);
/* Convert the RGB values to XYZ using the
Wide RGB D65 conversion formula */
@@ -97,7 +98,7 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
/* Use the Y value of XYZ as brightness
The Y value indicates the brightness
of the converted color. */
Y = Y*255.0f;
Y = Y * 255.0f;
Y = clamp(Y, 0.0f, 255.0f);
if (brightness) {
*brightness = (uint8_t)Y;
@@ -114,8 +115,12 @@ void color_rgb_to_xy(uint8_t r, uint8_t g, uint8_t b,
* @param brightness - brightness of the CIE xy color
* @note http://en.wikipedia.org/wiki/Srgb
*/
void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
float x_coordinate, float y_coordinate, uint8_t brightness)
void color_rgb_from_xy(uint8_t *red,
uint8_t *green,
uint8_t *blue,
float x_coordinate,
float y_coordinate,
uint8_t brightness)
{
/* Calculate XYZ values */
float x = x_coordinate;
@@ -133,21 +138,21 @@ void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
float b = X * 0.0349342f - Y * 0.0968930f + Z * 1.2884099f;
/* Apply reverse gamma correction */
r = r <= 0.0031308f ? 12.92f * r :
(1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
g = g <= 0.0031308f ? 12.92f * g :
(1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
b = b <= 0.0031308f ? 12.92f * b :
(1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
r = r <= 0.0031308f ? 12.92f * r
: (1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;
g = g <= 0.0031308f ? 12.92f * g
: (1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;
b = b <= 0.0031308f ? 12.92f * b
: (1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;
/* Convert the RGB values to your color object
The rgb values from the above formulas are
between 0.0 and 1.0. */
r = r*255.0f;
r = r * 255.0f;
r = clamp(r, 0.0f, 255.0f);
g = g*255;
g = g * 255;
g = clamp(g, 0.0f, 255.0f);
b = b*255;
b = b * 255;
b = clamp(b, 0.0f, 255.0f);
/* copy to return value if possible */
if (red) {
@@ -169,155 +174,81 @@ struct css_color_rgb {
uint8_t blue;
};
static struct css_color_rgb CSS_Color_RGB_Table[] = {
{"aliceblue", 240, 248, 255},
{"antiquewhite", 250, 235, 215},
{"aqua", 0, 255, 255},
{"aquamarine", 127, 255, 212},
{"azure", 240, 255, 255},
{"beige", 245, 245, 220},
{"bisque", 255, 228, 196},
{"black", 0, 0, 0},
{"blanchedalmond", 255, 235, 205},
{"blue", 0, 0, 255},
{"blueviolet", 138, 43, 226},
{"brown", 165, 42, 42},
{"burlywood", 222, 184, 135},
{"cadetblue", 95, 158, 160},
{"chartreuse", 127, 255, 0},
{"chocolate", 210, 105, 30},
{"coral", 255, 127, 80},
{"cornflowerblue", 100, 149, 237},
{"cornsilk", 255, 248, 220},
{"crimson", 220, 20, 60},
{"cyan", 0, 255, 255},
{"darkblue", 0, 0, 139},
{"darkcyan", 0, 139, 139},
{"darkgoldenrod", 184, 134, 11},
{"darkgray", 169, 169, 169},
{"darkgreen", 0, 100, 0},
{"darkgrey", 169, 169, 169},
{"darkkhaki", 189, 183, 107},
{"darkmagenta", 139, 0, 139},
{"darkolivegreen", 85, 107, 47},
{"darkorange", 255, 140, 0},
{"darkorchid", 153, 50, 204},
{"darkred", 139, 0, 0},
{"darksalmon", 233, 150, 122},
{"darkseagreen", 143, 188, 143},
{"darkslateblue", 72, 61, 139},
{"darkslategray", 47, 79, 79},
{"darkslategrey", 47, 79, 79},
{"darkturquoise", 0, 206, 209},
{"darkviolet", 148, 0, 211},
{"deeppink", 255, 20, 147},
{"deepskyblue", 0, 191, 255},
{"dimgray", 105, 105, 105},
{"dimgrey", 105, 105, 105},
{"dodgerblue", 30, 144, 255},
{"firebrick", 178, 34, 34},
{"floralwhite", 255, 250, 240},
{"forestgreen", 34, 139, 34},
{"fuchsia", 255, 0, 255},
{"gainsboro", 220, 220, 220},
{"ghostwhite", 248, 248, 255},
{"gold", 255, 215, 0},
{"goldenrod", 218, 165, 32},
{"gray", 128, 128, 128},
{"green", 0, 128, 0},
{"greenyellow", 173, 255, 47},
{"grey", 128, 128, 128},
{"honeydew", 240, 255, 240},
{"hotpink", 255, 105, 180},
{"indianred", 205, 92, 92},
{"indigo", 75, 0, 130},
{"ivory", 255, 255, 240},
{"khaki", 240, 230, 140},
{"lavender", 230, 230, 250},
{"lavenderblush", 255, 240, 245},
{"lawngreen", 124, 252, 0},
{"lemonchiffon", 255, 250, 205},
{"lightblue", 173, 216, 230},
{"lightcoral", 240, 128, 128},
{"lightcyan", 224, 255, 255},
{"lightgoldenrodyellow", 250, 250, 210},
{"lightgray", 211, 211, 211},
{"lightgreen", 144, 238, 144},
{"lightgrey", 211, 211, 211},
{"lightpink", 255, 182, 193},
{"lightsalmon", 255, 160, 122},
{"lightseagreen", 32, 178, 170},
{"lightskyblue", 135, 206, 250},
{"lightslategray", 119, 136, 153},
{"lightslategrey", 119, 136, 153},
{"lightsteelblue", 176, 196, 222},
{"lightyellow", 255, 255, 224},
{"lime", 0, 255, 0},
{"limegreen", 50, 205, 50},
{"linen", 250, 240, 230},
{"magenta", 255, 0, 255},
{"maroon", 128, 0, 0},
{"mediumaquamarine", 102, 205, 170},
{"mediumblue", 0, 0, 205},
{"mediumorchid", 186, 85, 211},
{"mediumpurple", 147, 112, 219},
{"mediumseagreen", 60, 179, 113},
{"mediumslateblue", 123, 104, 238},
{"mediumspringgreen", 0, 250, 154},
{"mediumturquoise", 72, 209, 204},
{"mediumvioletred", 199, 21, 133},
{"midnightblue", 25, 25, 112},
{"mintcream", 245, 255, 250},
{"mistyrose", 255, 228, 225},
{"moccasin", 255, 228, 181},
{"navajowhite", 255, 222, 173},
{"navy", 0, 0, 128},
{"navyblue", 0, 0, 128},
{"oldlace", 253, 245, 230},
{"olive", 128, 128, 0},
{"olivedrab", 107, 142, 35},
{"orange", 255, 165, 0},
{"orangered", 255, 69, 0},
{"orchid", 218, 112, 214},
{"palegoldenrod", 238, 232, 170},
{"palegreen", 152, 251, 152},
{"paleturquoise", 175, 238, 238},
{"palevioletred", 219, 112, 147},
{"papayawhip", 255, 239, 213},
{"peachpuff", 255, 218, 185},
{"peru", 205, 133, 63},
{"pink", 255, 192, 203},
{"plum", 221, 160, 221},
{"powderblue", 176, 224, 230},
{"purple", 128, 0, 128},
{"red", 255, 0, 0},
{"rosybrown", 188, 143, 143},
{"royalblue", 65, 105, 225},
{"saddlebrown", 139, 69, 19},
{"salmon", 250, 128, 114},
{"sandybrown", 244, 164, 96},
{"seagreen", 46, 139, 87},
{"seashell", 255, 245, 238},
{"sienna", 160, 82, 45},
{"silver", 192, 192, 192},
{"skyblue", 135, 206, 235},
{"slateblue", 106, 90, 205},
{"slategray", 112, 128, 144},
{"slategrey", 112, 128, 144},
{"snow", 255, 250, 250},
{"springgreen", 0, 255, 127},
{"steelblue", 70, 130, 180},
{"tan", 210, 180, 140},
{"teal", 0, 128, 128},
{"thistle", 216, 191, 216},
{"tomato", 255, 99, 71},
{"turquoise", 64, 224, 208},
{"violet", 238, 130, 238},
{"wheat", 245, 222, 179},
{"white", 255, 255, 255},
{"whitesmoke", 245, 245, 245},
{"yellow", 255, 255, 0},
{"yellowgreen", 154, 205, 50},
{NULL, 0, 0, 0}
{ "aliceblue", 240, 248, 255 }, { "antiquewhite", 250, 235, 215 },
{ "aqua", 0, 255, 255 }, { "aquamarine", 127, 255, 212 },
{ "azure", 240, 255, 255 }, { "beige", 245, 245, 220 },
{ "bisque", 255, 228, 196 }, { "black", 0, 0, 0 },
{ "blanchedalmond", 255, 235, 205 }, { "blue", 0, 0, 255 },
{ "blueviolet", 138, 43, 226 }, { "brown", 165, 42, 42 },
{ "burlywood", 222, 184, 135 }, { "cadetblue", 95, 158, 160 },
{ "chartreuse", 127, 255, 0 }, { "chocolate", 210, 105, 30 },
{ "coral", 255, 127, 80 }, { "cornflowerblue", 100, 149, 237 },
{ "cornsilk", 255, 248, 220 }, { "crimson", 220, 20, 60 },
{ "cyan", 0, 255, 255 }, { "darkblue", 0, 0, 139 },
{ "darkcyan", 0, 139, 139 }, { "darkgoldenrod", 184, 134, 11 },
{ "darkgray", 169, 169, 169 }, { "darkgreen", 0, 100, 0 },
{ "darkgrey", 169, 169, 169 }, { "darkkhaki", 189, 183, 107 },
{ "darkmagenta", 139, 0, 139 }, { "darkolivegreen", 85, 107, 47 },
{ "darkorange", 255, 140, 0 }, { "darkorchid", 153, 50, 204 },
{ "darkred", 139, 0, 0 }, { "darksalmon", 233, 150, 122 },
{ "darkseagreen", 143, 188, 143 }, { "darkslateblue", 72, 61, 139 },
{ "darkslategray", 47, 79, 79 }, { "darkslategrey", 47, 79, 79 },
{ "darkturquoise", 0, 206, 209 }, { "darkviolet", 148, 0, 211 },
{ "deeppink", 255, 20, 147 }, { "deepskyblue", 0, 191, 255 },
{ "dimgray", 105, 105, 105 }, { "dimgrey", 105, 105, 105 },
{ "dodgerblue", 30, 144, 255 }, { "firebrick", 178, 34, 34 },
{ "floralwhite", 255, 250, 240 }, { "forestgreen", 34, 139, 34 },
{ "fuchsia", 255, 0, 255 }, { "gainsboro", 220, 220, 220 },
{ "ghostwhite", 248, 248, 255 }, { "gold", 255, 215, 0 },
{ "goldenrod", 218, 165, 32 }, { "gray", 128, 128, 128 },
{ "green", 0, 128, 0 }, { "greenyellow", 173, 255, 47 },
{ "grey", 128, 128, 128 }, { "honeydew", 240, 255, 240 },
{ "hotpink", 255, 105, 180 }, { "indianred", 205, 92, 92 },
{ "indigo", 75, 0, 130 }, { "ivory", 255, 255, 240 },
{ "khaki", 240, 230, 140 }, { "lavender", 230, 230, 250 },
{ "lavenderblush", 255, 240, 245 }, { "lawngreen", 124, 252, 0 },
{ "lemonchiffon", 255, 250, 205 }, { "lightblue", 173, 216, 230 },
{ "lightcoral", 240, 128, 128 }, { "lightcyan", 224, 255, 255 },
{ "lightgoldenrodyellow", 250, 250, 210 }, { "lightgray", 211, 211, 211 },
{ "lightgreen", 144, 238, 144 }, { "lightgrey", 211, 211, 211 },
{ "lightpink", 255, 182, 193 }, { "lightsalmon", 255, 160, 122 },
{ "lightseagreen", 32, 178, 170 }, { "lightskyblue", 135, 206, 250 },
{ "lightslategray", 119, 136, 153 }, { "lightslategrey", 119, 136, 153 },
{ "lightsteelblue", 176, 196, 222 }, { "lightyellow", 255, 255, 224 },
{ "lime", 0, 255, 0 }, { "limegreen", 50, 205, 50 },
{ "linen", 250, 240, 230 }, { "magenta", 255, 0, 255 },
{ "maroon", 128, 0, 0 }, { "mediumaquamarine", 102, 205, 170 },
{ "mediumblue", 0, 0, 205 }, { "mediumorchid", 186, 85, 211 },
{ "mediumpurple", 147, 112, 219 }, { "mediumseagreen", 60, 179, 113 },
{ "mediumslateblue", 123, 104, 238 }, { "mediumspringgreen", 0, 250, 154 },
{ "mediumturquoise", 72, 209, 204 }, { "mediumvioletred", 199, 21, 133 },
{ "midnightblue", 25, 25, 112 }, { "mintcream", 245, 255, 250 },
{ "mistyrose", 255, 228, 225 }, { "moccasin", 255, 228, 181 },
{ "navajowhite", 255, 222, 173 }, { "navy", 0, 0, 128 },
{ "navyblue", 0, 0, 128 }, { "oldlace", 253, 245, 230 },
{ "olive", 128, 128, 0 }, { "olivedrab", 107, 142, 35 },
{ "orange", 255, 165, 0 }, { "orangered", 255, 69, 0 },
{ "orchid", 218, 112, 214 }, { "palegoldenrod", 238, 232, 170 },
{ "palegreen", 152, 251, 152 }, { "paleturquoise", 175, 238, 238 },
{ "palevioletred", 219, 112, 147 }, { "papayawhip", 255, 239, 213 },
{ "peachpuff", 255, 218, 185 }, { "peru", 205, 133, 63 },
{ "pink", 255, 192, 203 }, { "plum", 221, 160, 221 },
{ "powderblue", 176, 224, 230 }, { "purple", 128, 0, 128 },
{ "red", 255, 0, 0 }, { "rosybrown", 188, 143, 143 },
{ "royalblue", 65, 105, 225 }, { "saddlebrown", 139, 69, 19 },
{ "salmon", 250, 128, 114 }, { "sandybrown", 244, 164, 96 },
{ "seagreen", 46, 139, 87 }, { "seashell", 255, 245, 238 },
{ "sienna", 160, 82, 45 }, { "silver", 192, 192, 192 },
{ "skyblue", 135, 206, 235 }, { "slateblue", 106, 90, 205 },
{ "slategray", 112, 128, 144 }, { "slategrey", 112, 128, 144 },
{ "snow", 255, 250, 250 }, { "springgreen", 0, 255, 127 },
{ "steelblue", 70, 130, 180 }, { "tan", 210, 180, 140 },
{ "teal", 0, 128, 128 }, { "thistle", 216, 191, 216 },
{ "tomato", 255, 99, 71 }, { "turquoise", 64, 224, 208 },
{ "violet", 238, 130, 238 }, { "wheat", 245, 222, 179 },
{ "white", 255, 255, 255 }, { "whitesmoke", 245, 245, 245 },
{ "yellow", 255, 255, 0 }, { "yellowgreen", 154, 205, 50 },
{ NULL, 0, 0, 0 }
};
/**
@@ -330,9 +261,9 @@ static struct css_color_rgb CSS_Color_RGB_Table[] = {
* https://www.w3.org/TR/2010/PR-css3-color-20101028/#html4
* names do not have spaces
*/
const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
const char *color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
{
const char * name = "";
const char *name = "";
unsigned index = 0;
while (CSS_Color_RGB_Table[index].name) {
@@ -355,8 +286,8 @@ const char * color_rgb_to_ascii(uint8_t red, uint8_t green, uint8_t blue)
* @param name - CSS color name from W3C
* @return index 0..color_rgb_count(), where color_rgb_count() is not found.
*/
unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
const char *name)
unsigned color_rgb_from_ascii(
uint8_t *red, uint8_t *green, uint8_t *blue, const char *name)
{
unsigned index = 0;
@@ -386,7 +317,8 @@ unsigned color_rgb_from_ascii(uint8_t *red, uint8_t *green, uint8_t *blue,
* @param blue - return B value of sRGB
* @return CSS ASCII color name from W3C or NULL if invalid index
*/
const char *color_rgb_from_index(unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue)
const char *color_rgb_from_index(
unsigned target_index, uint8_t *red, uint8_t *green, uint8_t *blue)
{
unsigned index = 0;
@@ -431,8 +363,7 @@ unsigned color_rgb_count(void)
* http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
*/
void color_rgb_from_temperature(
uint16_t temperature_kelvin,
uint8_t *r, uint8_t *g, uint8_t *b)
uint16_t temperature_kelvin, uint8_t *r, uint8_t *g, uint8_t *b)
{
float red = 0, green = 0, blue = 0;
+15 -20
View File
@@ -24,7 +24,7 @@ bool days_is_leap_year(uint16_t year)
{
if ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
return true;
}
}
return (false);
}
@@ -47,7 +47,7 @@ uint8_t days_per_month(uint16_t year, uint8_t month)
return (29);
} else if (month >= 1 && month <= 12) {
return (month_days[month]);
}
}
return 0;
}
@@ -200,20 +200,18 @@ uint32_t days_apart(uint16_t year1,
* @param day - day of month (1-31)
* @return number of days since epoch, or 0 if out of range
*/
uint32_t days_since_epoch(uint16_t epoch_year,
uint16_t year,
uint8_t month,
uint8_t day)
uint32_t days_since_epoch(
uint16_t epoch_year, uint16_t year, uint8_t month, uint8_t day)
{
uint32_t days = 0; /* return value */
uint16_t yy = 0; /* year */
uint8_t mm = 0; /* months counter */
uint8_t monthdays = 0; /* days in a month */
uint32_t days = 0; /* return value */
uint16_t yy = 0; /* year */
uint8_t mm = 0; /* months counter */
uint8_t monthdays = 0; /* days in a month */
/* validate the date conforms to our range */
monthdays = days_per_month(year, month);
if ((year >= epoch_year) && (year <= 9999) &&
(monthdays > 0) && (day >= 1) && (day <= monthdays)) {
if ((year >= epoch_year) && (year <= 9999) && (monthdays > 0) &&
(day >= 1) && (day <= monthdays)) {
for (yy = epoch_year; yy < year; yy++) {
days += 365;
if (days_is_leap_year(yy)) {
@@ -238,12 +236,11 @@ uint32_t days_since_epoch(uint16_t epoch_year,
* @param pDay - day of month (1-31)
* @return nothing
*/
void days_since_epoch_to_date(
uint16_t epoch_year,
void days_since_epoch_to_date(uint16_t epoch_year,
uint32_t days,
uint16_t * pYear,
uint8_t * pMonth,
uint8_t * pDay)
uint16_t *pYear,
uint8_t *pMonth,
uint8_t *pDay)
{
uint8_t month = 1;
uint8_t day = 0;
@@ -281,9 +278,7 @@ void days_since_epoch_to_date(
* @param day - day of month (1-31)
* @return true if the date is valid
*/
bool days_date_is_valid(uint16_t year,
uint8_t month,
uint8_t day)
bool days_date_is_valid(uint16_t year, uint8_t month, uint8_t day)
{
uint8_t month_days = 0;
bool valid = false; /* return value */