Code cleanup to get rid of some warnings during compilation.
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
#include "wp.h"
|
||||
#include "event.h"
|
||||
#include "lso.h"
|
||||
#include "alarm_ack.h"
|
||||
|
||||
/* required object - note: developer must supply the device.c file
|
||||
since it is not included in the library. However, the library
|
||||
|
||||
@@ -123,6 +123,7 @@ int alarm_ack_decode_service_request(
|
||||
{
|
||||
int len = 0;
|
||||
int section_len;
|
||||
uint32_t enumValue;
|
||||
|
||||
if (-1 == (section_len =
|
||||
decode_context_unsigned(&apdu[len], 0,
|
||||
@@ -141,9 +142,10 @@ int alarm_ack_decode_service_request(
|
||||
|
||||
if (-1 == (section_len =
|
||||
decode_context_enumerated(&apdu[len], 2,
|
||||
(int *) &data->eventTypeAcked))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
data->eventTypeAcked = (BACNET_EVENT_TYPE)enumValue;
|
||||
len += section_len;
|
||||
|
||||
if (-1 == (section_len =
|
||||
|
||||
@@ -105,7 +105,7 @@ int arf_decode_service_request(
|
||||
if (tag_number != BACNET_APPLICATION_TAG_OBJECT_ID)
|
||||
return -1;
|
||||
len += decode_object_id(&apdu[len], &type, &data->object_instance);
|
||||
data->object_type = type;
|
||||
data->object_type = (BACNET_OBJECT_TYPE)type;
|
||||
if (decode_is_opening_tag_number(&apdu[len], 0)) {
|
||||
data->access = FILE_STREAM_ACCESS;
|
||||
/* a tag number is not extended so only one octet */
|
||||
|
||||
@@ -110,7 +110,7 @@ int awf_decode_service_request(
|
||||
if (tag_number != BACNET_APPLICATION_TAG_OBJECT_ID)
|
||||
return -1;
|
||||
len += decode_object_id(&apdu[len], &type, &data->object_instance);
|
||||
data->object_type = type;
|
||||
data->object_type = (BACNET_OBJECT_TYPE)type;
|
||||
if (decode_is_opening_tag_number(&apdu[len], 0)) {
|
||||
data->access = FILE_STREAM_ACCESS;
|
||||
/* a tag number of 2 is not extended so only one octet */
|
||||
|
||||
@@ -95,7 +95,7 @@ int bacapp_decode_device_obj_property_ref(
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
uint32_t enumValue;
|
||||
if (-1 == (len =
|
||||
decode_context_object_id(&apdu[apdu_len], 0,
|
||||
&value->objectIdentifier.type,
|
||||
@@ -106,9 +106,10 @@ int bacapp_decode_device_obj_property_ref(
|
||||
|
||||
if (-1 == (len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 1,
|
||||
&value->propertyIdentifier))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->propertyIdentifier = (BACNET_PROPERTY_ID)enumValue;
|
||||
apdu_len += len;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
|
||||
@@ -46,7 +46,7 @@ int bacapp_decode_property_state(
|
||||
int len = 0;
|
||||
uint32_t len_value_type;
|
||||
int section_length;
|
||||
|
||||
uint32_t enumValue;
|
||||
|
||||
section_length =
|
||||
decode_tag_number_and_value(&apdu[len], (uint8_t *) & value->tag,
|
||||
@@ -65,81 +65,91 @@ int bacapp_decode_property_state(
|
||||
case BINARY_VALUE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.binaryValue))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.binaryValue = (BACNET_BINARY_PV)enumValue;
|
||||
break;
|
||||
|
||||
case EVENT_TYPE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.eventType))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.eventType = (BACNET_EVENT_TYPE)enumValue;
|
||||
break;
|
||||
|
||||
case POLARITY:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.polarity))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.polarity = (BACNET_POLARITY)enumValue;
|
||||
break;
|
||||
|
||||
case PROGRAM_CHANGE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.programChange))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.programChange = (BACNET_PROGRAM_REQUEST)enumValue;
|
||||
break;
|
||||
|
||||
case PROGRAM_STATE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.programState))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.programState = (BACNET_PROGRAM_STATE)enumValue;
|
||||
break;
|
||||
|
||||
case REASON_FOR_HALT:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.programError))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.programError = (BACNET_PROGRAM_ERROR)enumValue;
|
||||
break;
|
||||
|
||||
case RELIABILITY:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.reliability))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.reliability = (BACNET_RELIABILITY)enumValue;
|
||||
break;
|
||||
|
||||
case STATE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.state))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.state = (BACNET_EVENT_STATE)enumValue;
|
||||
break;
|
||||
|
||||
case SYSTEM_STATUS:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.systemStatus))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.systemStatus = (BACNET_DEVICE_STATUS)enumValue;
|
||||
break;
|
||||
|
||||
case UNITS:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.units))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.units = (BACNET_ENGINEERING_UNITS)enumValue;
|
||||
break;
|
||||
|
||||
case UNSIGNED_VALUE:
|
||||
@@ -153,17 +163,19 @@ int bacapp_decode_property_state(
|
||||
case LIFE_SAFETY_MODE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.lifeSafetyMode))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.lifeSafetyMode = (BACNET_LIFE_SAFETY_MODE)enumValue;
|
||||
break;
|
||||
|
||||
case LIFE_SAFETY_STATE:
|
||||
if (-1 == (section_length =
|
||||
decode_enumerated(&apdu[len], len_value_type,
|
||||
&value->state.lifeSafetyState))) {
|
||||
&enumValue))) {
|
||||
return -1;
|
||||
}
|
||||
value->state.lifeSafetyState = (BACNET_LIFE_SAFETY_STATE)enumValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -204,7 +204,7 @@ uint16_t bip_receive(
|
||||
fd_set read_fds;
|
||||
int max = 0;
|
||||
struct timeval select_timeout;
|
||||
struct sockaddr_in sin = { -1 };
|
||||
struct sockaddr_in sin = { 0 };
|
||||
socklen_t sin_len = sizeof(sin);
|
||||
uint16_t i = 0;
|
||||
|
||||
@@ -224,7 +224,7 @@ uint16_t bip_receive(
|
||||
select_timeout.tv_usec = 1000 * timeout;
|
||||
}
|
||||
FD_ZERO(&read_fds);
|
||||
FD_SET((unsigned int) BIP_Socket, &read_fds);
|
||||
FD_SET(BIP_Socket, &read_fds);
|
||||
max = BIP_Socket;
|
||||
/* see if there is a packet for us */
|
||||
if (select(max + 1, &read_fds, NULL, NULL, &select_timeout) > 0)
|
||||
|
||||
@@ -659,7 +659,6 @@ static void bvlc_bdt_forward_npdu(
|
||||
{ /* length of the NPDU */
|
||||
uint8_t mtu[MAX_MPDU] = { 0 };
|
||||
uint16_t mtu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
unsigned i = 0; /* loop counter */
|
||||
struct sockaddr_in bip_dest = { 0 };
|
||||
|
||||
@@ -685,7 +684,7 @@ static void bvlc_bdt_forward_npdu(
|
||||
(bip_dest.sin_port == htons(bip_get_port()))) {
|
||||
continue;
|
||||
}
|
||||
bytes_sent = bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
|
||||
bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
|
||||
debug_printf("BVLC: BDT Sent Forwarded-NPDU to %s:%04X\n",
|
||||
inet_ntoa(bip_dest.sin_addr), ntohs(bip_dest.sin_port));
|
||||
}
|
||||
@@ -719,7 +718,6 @@ static void bvlc_fdt_forward_npdu(
|
||||
{ /* amount of space available in the NPDU */
|
||||
uint8_t mtu[MAX_MPDU] = { 0 };
|
||||
uint16_t mtu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
unsigned i = 0; /* loop counter */
|
||||
struct sockaddr_in bip_dest = { 0 };
|
||||
|
||||
@@ -739,7 +737,7 @@ static void bvlc_fdt_forward_npdu(
|
||||
(bip_dest.sin_port == sin->sin_port)) {
|
||||
continue;
|
||||
}
|
||||
bytes_sent = bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
|
||||
bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
|
||||
debug_printf("BVLC: FDT Sent Forwarded-NPDU to %s:%04X\n",
|
||||
inet_ntoa(bip_dest.sin_addr), ntohs(bip_dest.sin_port));
|
||||
}
|
||||
@@ -846,9 +844,9 @@ uint16_t bvlc_receive(
|
||||
fd_set read_fds;
|
||||
int max = 0;
|
||||
struct timeval select_timeout;
|
||||
struct sockaddr_in sin = { -1 };
|
||||
struct sockaddr_in original_sin = { -1 };
|
||||
struct sockaddr_in dest = { -1 };
|
||||
struct sockaddr_in sin = { 0 };
|
||||
struct sockaddr_in original_sin = { 0 };
|
||||
struct sockaddr_in dest = { 0 };
|
||||
socklen_t sin_len = sizeof(sin);
|
||||
int function_type = 0;
|
||||
int received_bytes = 0;
|
||||
@@ -874,7 +872,7 @@ uint16_t bvlc_receive(
|
||||
select_timeout.tv_usec = 1000 * timeout;
|
||||
}
|
||||
FD_ZERO(&read_fds);
|
||||
FD_SET((unsigned int) bip_socket(), &read_fds);
|
||||
FD_SET(bip_socket(), &read_fds);
|
||||
max = bip_socket();
|
||||
/* see if there is a packet for us */
|
||||
if (select(max + 1, &read_fds, NULL, NULL, &select_timeout) > 0) {
|
||||
@@ -912,7 +910,7 @@ uint16_t bvlc_receive(
|
||||
Register-Foreign-Device message */
|
||||
/* FIXME: clients may need this result */
|
||||
(void) decode_unsigned16(&npdu[4], &result_code);
|
||||
BVLC_Result_Code = result_code;
|
||||
BVLC_Result_Code = (BACNET_BVLC_RESULT)result_code;
|
||||
debug_printf("BVLC: Result Code=%d\n", BVLC_Result_Code);
|
||||
/* not an NPDU */
|
||||
npdu_len = 0;
|
||||
|
||||
@@ -238,7 +238,7 @@ int cov_notify_decode_service_request(
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value);
|
||||
len += decode_enumerated(&apdu[len], len_value, &property);
|
||||
value->propertyIdentifier = property;
|
||||
value->propertyIdentifier = (BACNET_PROPERTY_ID)property;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -572,7 +572,7 @@ int cov_subscribe_property_decode_service_request(
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number,
|
||||
&len_value);
|
||||
len += decode_enumerated(&apdu[len], len_value, &property);
|
||||
data->monitoredProperty.propertyIdentifier = property;
|
||||
data->monitoredProperty.propertyIdentifier = (BACNET_PROPERTY_ID)property;
|
||||
} else
|
||||
return -4;
|
||||
/* the optional array index is tag 1 */
|
||||
|
||||
@@ -504,7 +504,7 @@ int event_notify_decode_service_request(
|
||||
decode_context_enumerated(&apdu[len], 6, &value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->eventType = value;
|
||||
data->eventType = (BACNET_EVENT_TYPE)value;
|
||||
len += section_length;
|
||||
}
|
||||
/* tag 7 - messageText */
|
||||
@@ -533,7 +533,7 @@ int event_notify_decode_service_request(
|
||||
decode_context_enumerated(&apdu[len], 8, &value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->notifyType = value;
|
||||
data->notifyType = (BACNET_NOTIFY_TYPE)value;
|
||||
len += section_length;
|
||||
}
|
||||
switch (data->notifyType) {
|
||||
@@ -553,7 +553,7 @@ int event_notify_decode_service_request(
|
||||
&value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->fromState = value;
|
||||
data->fromState = (BACNET_EVENT_STATE)value;
|
||||
len += section_length;
|
||||
}
|
||||
break;
|
||||
@@ -561,15 +561,14 @@ int event_notify_decode_service_request(
|
||||
/* FIXME: handle this case */
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
/* tag 11 - toState */
|
||||
if ((section_length =
|
||||
decode_context_enumerated(&apdu[len], 11, &value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->toState = value;
|
||||
data->toState = (BACNET_EVENT_STATE)value;
|
||||
len += section_length;
|
||||
}
|
||||
/* tag 12 - eventValues */
|
||||
@@ -751,7 +750,7 @@ int event_notify_decode_service_request(
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.changeOfLifeSafety.newState =
|
||||
value;
|
||||
(BACNET_LIFE_SAFETY_STATE)value;
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
@@ -760,7 +759,7 @@ int event_notify_decode_service_request(
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.changeOfLifeSafety.newMode =
|
||||
value;
|
||||
(BACNET_LIFE_SAFETY_MODE)value;
|
||||
len += section_length;
|
||||
|
||||
if (-1 == (section_length =
|
||||
@@ -777,7 +776,7 @@ int event_notify_decode_service_request(
|
||||
return -1;
|
||||
}
|
||||
data->notificationParams.changeOfLifeSafety.
|
||||
operationExpected = value;
|
||||
operationExpected = (BACNET_LIFE_SAFETY_OPERATION)value;
|
||||
len += section_length;
|
||||
break;
|
||||
|
||||
@@ -853,7 +852,6 @@ int event_notify_decode_service_request(
|
||||
/* FIXME: handle this case */
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ int lso_decode_service_request(
|
||||
decode_context_enumerated(&apdu[len], 2, &operation)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
data->operation = operation;
|
||||
data->operation = (BACNET_LIFE_SAFETY_OPERATION)operation;
|
||||
len += section_length;
|
||||
|
||||
/*
|
||||
|
||||
@@ -242,7 +242,6 @@ void tsm_timer_milliseconds(
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
unsigned i = 0; /* counter */
|
||||
int bytes_sent = 0;
|
||||
|
||||
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
|
||||
if (TSM_List[i].state == TSM_STATE_AWAIT_CONFIRMATION) {
|
||||
@@ -255,7 +254,6 @@ void tsm_timer_milliseconds(
|
||||
TSM_List[i].RetryCount--;
|
||||
TSM_List[i].RequestTimer = apdu_timeout();
|
||||
if (TSM_List[i].RetryCount) {
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&TSM_List[i].dest,
|
||||
&TSM_List[i].npdu_data, &TSM_List[i].apdu[0],
|
||||
TSM_List[i].apdu_len);
|
||||
|
||||
Reference in New Issue
Block a user