Indented.

This commit is contained in:
skarg
2007-11-29 15:56:53 +00:00
parent c585241c03
commit 411d6c1b24
236 changed files with 17864 additions and 15724 deletions
+7 -5
View File
@@ -40,7 +40,7 @@
#include "ai.h"
#include "ao.h"
#if defined(BACFILE)
#include "bacfile.h"
#include "bacfile.h"
#endif
/*
@@ -95,9 +95,11 @@ shall be TRUE, otherwise FALSE.
*/
#if defined(BACFILE)
void handler_atomic_read_file(uint8_t * service_request,
void handler_atomic_read_file(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
BACNET_ATOMIC_READ_FILE_DATA data;
int len = 0;
@@ -125,7 +127,7 @@ void handler_atomic_read_file(uint8_t * service_request,
fprintf(stderr, "ARF: Segmented Message. Sending Abort!\n");
#endif
goto ARF_ABORT;
}
}
len = arf_decode_service_request(service_request, service_len, &data);
/* bad decoding - send an abort */
if (len < 0) {
@@ -186,7 +188,7 @@ void handler_atomic_read_file(uint8_t * service_request,
service_data->invoke_id,
SERVICE_CONFIRMED_ATOMIC_READ_FILE, error_class, error_code);
}
ARF_ABORT:
ARF_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+5 -4
View File
@@ -47,9 +47,11 @@
/* that someone can read from us. It is common to */
/* use the description as the file name. */
#if defined(BACFILE)
void handler_atomic_read_file_ack(uint8_t * service_request,
void handler_atomic_read_file_ack(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
{
int len = 0;
BACNET_ATOMIC_READ_FILE_DATA data;
@@ -60,8 +62,7 @@ void handler_atomic_read_file_ack(uint8_t * service_request,
(void) src;
/* get the file instance from the tsm data before freeing it */
instance = bacfile_instance_from_tsm(service_data->invoke_id);
len = arf_ack_decode_service_request(service_request,
service_len, &data);
len = arf_ack_decode_service_request(service_request, service_len, &data);
#if PRINT_ENABLED
fprintf(stderr, "Received Read-File Ack!\n");
#endif
+8 -6
View File
@@ -40,7 +40,7 @@
/* demo objects */
#include "device.h"
#if defined(BACFILE)
#include "bacfile.h"
#include "bacfile.h"
#endif
/*
@@ -73,9 +73,11 @@ standard.
*/
#if defined(BACFILE)
void handler_atomic_write_file(uint8_t * service_request,
void handler_atomic_write_file(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
BACNET_ATOMIC_WRITE_FILE_DATA data;
int len = 0;
@@ -113,7 +115,7 @@ void handler_atomic_write_file(uint8_t * service_request,
fprintf(stderr, "Bad Encoding. Sending Abort!\n");
#endif
goto AWF_ABORT;
}
}
if (data.object_type == OBJECT_FILE) {
if (!bacfile_valid_instance(data.object_instance)) {
error = true;
@@ -126,7 +128,7 @@ void handler_atomic_write_file(uint8_t * service_request,
#endif
len =
awf_ack_encode_apdu(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id, &data);
[pdu_len], service_data->invoke_id, &data);
} else {
error = true;
error_class = ERROR_CLASS_OBJECT;
@@ -151,7 +153,7 @@ void handler_atomic_write_file(uint8_t * service_request,
service_data->invoke_id,
SERVICE_CONFIRMED_ATOMIC_READ_FILE, error_class, error_code);
}
AWF_ABORT:
AWF_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+6 -4
View File
@@ -40,9 +40,11 @@
static char *My_Password = "filister";
void handler_device_communication_control(uint8_t * service_request,
void handler_device_communication_control(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
uint16_t timeDuration = 0;
BACNET_COMMUNICATION_ENABLE_DISABLE state = COMMUNICATION_ENABLE;
@@ -70,7 +72,7 @@ void handler_device_communication_control(uint8_t * service_request,
"Sending Abort - segmented message.\n");
#endif
goto DCC_ABORT;
}
}
/* decode the service request only */
len = dcc_decode_service_request(service_request,
service_len, &timeDuration, &state, &password);
@@ -121,7 +123,7 @@ void handler_device_communication_control(uint8_t * service_request,
#endif
}
}
DCC_ABORT:
DCC_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+8 -4
View File
@@ -32,8 +32,10 @@
#include "iam.h"
#include "address.h"
void handler_i_am_add(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_i_am_add(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
uint32_t device_id = 0;
@@ -61,8 +63,10 @@ void handler_i_am_add(uint8_t * service_request,
return;
}
void handler_i_am_bind(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_i_am_bind(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
uint32_t device_id = 0;
+5 -4
View File
@@ -32,16 +32,17 @@
#include "bactext.h"
#include "ihave.h"
void handler_i_have(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_i_have(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
BACNET_I_HAVE_DATA data;
(void) service_len;
(void) src;
len = ihave_decode_service_request(service_request,
service_len, &data);
len = ihave_decode_service_request(service_request, service_len, &data);
if (len != -1) {
#if PRINT_ENABLED
fprintf(stderr, "I-Have: %s %d from %s %u!\r\n",
+6 -4
View File
@@ -41,9 +41,11 @@
static char *Password = "Jesus";
static BACNET_CHARACTER_STRING My_Password;
void handler_reinitialize_device(uint8_t * service_request,
void handler_reinitialize_device(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
BACNET_REINITIALIZED_STATE state;
BACNET_CHARACTER_STRING their_password;
@@ -70,7 +72,7 @@ void handler_reinitialize_device(uint8_t * service_request,
"ReinitializeDevice: Sending Abort - segmented message.\n");
#endif
goto RD_ABORT;
}
}
/* decode the service request only */
len = rd_decode_service_request(service_request,
service_len, &state, &their_password);
@@ -124,7 +126,7 @@ void handler_reinitialize_device(uint8_t * service_request,
#endif
}
}
RD_ABORT:
RD_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+32 -67
View File
@@ -47,7 +47,7 @@
#include "lsp.h"
#include "mso.h"
#if defined(BACFILE)
#include "bacfile.h"
#include "bacfile.h"
#endif
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
@@ -69,115 +69,82 @@ int Encode_Property_APDU(
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
/* handle each object type */
switch(object_type) {
switch (object_type) {
case OBJECT_DEVICE:
if (Device_Valid_Object_Instance_Number(object_instance)) {
apdu_len = Device_Encode_Property_APDU(
&apdu[0],
property,
array_index,
error_class, error_code);
apdu_len = Device_Encode_Property_APDU(&apdu[0],
property, array_index, error_class, error_code);
}
break;
case OBJECT_ANALOG_INPUT:
if (Analog_Input_Valid_Instance(object_instance)) {
apdu_len = Analog_Input_Encode_Property_APDU(
&apdu[0],
apdu_len = Analog_Input_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_ANALOG_OUTPUT:
if (Analog_Output_Valid_Instance(object_instance)) {
apdu_len = Analog_Output_Encode_Property_APDU(
&apdu[0],
apdu_len = Analog_Output_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_ANALOG_VALUE:
if (Analog_Value_Valid_Instance(object_instance)) {
apdu_len = Analog_Value_Encode_Property_APDU(
&apdu[0],
apdu_len = Analog_Value_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_BINARY_INPUT:
if (Binary_Input_Valid_Instance(object_instance)) {
apdu_len = Binary_Input_Encode_Property_APDU(
&apdu[0],
apdu_len = Binary_Input_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_BINARY_OUTPUT:
if (Binary_Output_Valid_Instance(object_instance)) {
apdu_len = Binary_Output_Encode_Property_APDU(
&apdu[0],
apdu_len = Binary_Output_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_BINARY_VALUE:
if (Binary_Value_Valid_Instance(object_instance)) {
apdu_len = Binary_Value_Encode_Property_APDU(
&apdu[0],
apdu_len = Binary_Value_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_LIFE_SAFETY_POINT:
if (Life_Safety_Point_Valid_Instance(object_instance)) {
apdu_len = Life_Safety_Point_Encode_Property_APDU(
&apdu[0],
apdu_len = Life_Safety_Point_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_LOAD_CONTROL:
if (Load_Control_Valid_Instance(object_instance)) {
apdu_len = Load_Control_Encode_Property_APDU(
&apdu[0],
apdu_len = Load_Control_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
case OBJECT_MULTI_STATE_OUTPUT:
if (Multistate_Output_Valid_Instance(object_instance)) {
apdu_len = Multistate_Output_Encode_Property_APDU(
&apdu[0],
apdu_len = Multistate_Output_Encode_Property_APDU(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
#if defined(BACFILE)
case OBJECT_FILE:
if (bacfile_valid_instance(object_instance)) {
apdu_len = bacfile_encode_property_apdu(
&apdu[0],
apdu_len = bacfile_encode_property_apdu(&apdu[0],
object_instance,
property,
array_index,
error_class, error_code);
property, array_index, error_class, error_code);
}
break;
#endif
@@ -190,9 +157,11 @@ int Encode_Property_APDU(
return apdu_len;
}
void handler_read_property(uint8_t * service_request,
void handler_read_property(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
BACNET_READ_PROPERTY_DATA data;
int len = 0;
@@ -237,13 +206,10 @@ void handler_read_property(uint8_t * service_request,
/* assume that there is an error */
error = true;
len = Encode_Property_APDU(
&Temp_Buf[0],
len = Encode_Property_APDU(&Temp_Buf[0],
data.object_type,
data.object_instance,
data.object_property,
data.array_index,
&error_class, &error_code);
data.object_property, data.array_index, &error_class, &error_code);
if (len >= 0) {
/* encode the APDU portion of the packet */
data.application_data = &Temp_Buf[0];
@@ -253,8 +219,7 @@ void handler_read_property(uint8_t * service_request,
rp_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, &data);
#if PRINT_ENABLED
fprintf(stderr,
"RP: Sending Ack!\n");
fprintf(stderr, "RP: Sending Ack!\n");
#endif
error = false;
}
@@ -276,7 +241,7 @@ void handler_read_property(uint8_t * service_request,
#endif
}
}
RP_ABORT:
RP_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+7 -5
View File
@@ -42,7 +42,8 @@
#include "txbuf.h"
/* for debugging... */
static void PrintReadPropertyData(BACNET_READ_PROPERTY_DATA * data)
static void PrintReadPropertyData(
BACNET_READ_PROPERTY_DATA * data)
{
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
int len = 0;
@@ -95,17 +96,18 @@ static void PrintReadPropertyData(BACNET_READ_PROPERTY_DATA * data)
}
}
void handler_read_property_ack(uint8_t * service_request,
void handler_read_property_ack(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
{
int len = 0;
BACNET_READ_PROPERTY_DATA data;
(void) src;
(void) service_data; /* we could use these... */
len = rp_ack_decode_service_request(service_request,
service_len, &data);
len = rp_ack_decode_service_request(service_request, service_len, &data);
#if 0
fprintf(stderr, "Received Read-Property Ack!\n");
#endif
+143 -190
View File
@@ -49,25 +49,24 @@
#include "lsp.h"
#include "mso.h"
#if defined(BACFILE)
#include "bacfile.h"
#include "bacfile.h"
#endif
static uint8_t Temp_Buf[MAX_APDU] = { 0 };
struct property_list_t
{
struct property_list_t {
const int *pList;
unsigned count;
};
struct special_property_list_t
{
struct special_property_list_t {
struct property_list_t Required;
struct property_list_t Optional;
struct property_list_t Proprietary;
};
static unsigned property_list_count(const int *pList)
static unsigned property_list_count(
const int *pList)
{
unsigned property_count = 0;
@@ -90,72 +89,62 @@ static void RPM_Property_List(
pPropertyList->Optional.pList = NULL;
pPropertyList->Proprietary.pList = NULL;
switch (object_type) {
case OBJECT_ANALOG_INPUT:
Analog_Input_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_ANALOG_OUTPUT:
Analog_Output_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_ANALOG_VALUE:
Analog_Value_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_BINARY_INPUT:
Binary_Input_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_BINARY_OUTPUT:
Binary_Output_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_BINARY_VALUE:
Binary_Value_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_LIFE_SAFETY_POINT:
Life_Safety_Point_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_LOAD_CONTROL:
Load_Control_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_MULTI_STATE_OUTPUT:
break;
case OBJECT_ANALOG_INPUT:
Analog_Input_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_ANALOG_OUTPUT:
Analog_Output_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_ANALOG_VALUE:
Analog_Value_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_BINARY_INPUT:
Binary_Input_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_BINARY_OUTPUT:
Binary_Output_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_BINARY_VALUE:
Binary_Value_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_LIFE_SAFETY_POINT:
Life_Safety_Point_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_LOAD_CONTROL:
Load_Control_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_MULTI_STATE_OUTPUT:
break;
#if defined(BACFILE)
case OBJECT_FILE:
BACfile_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
case OBJECT_FILE:
BACfile_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
#endif
case OBJECT_DEVICE:
Device_Property_Lists(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
default:
break;
case OBJECT_DEVICE:
Device_Property_Lists(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
break;
default:
break;
}
/* fill the count */
pPropertyList->Required.count =
@@ -173,7 +162,7 @@ static int RPM_Object_Property(
BACNET_PROPERTY_ID special_property,
unsigned index)
{
int property = -1; /* return value */
int property = -1; /* return value */
unsigned required, optional, proprietary;
required = pPropertyList->Required.count;
@@ -210,8 +199,7 @@ static unsigned RPM_Object_Property_Count(
if (special_property == PROP_ALL) {
count = pPropertyList->Required.count +
pPropertyList->Optional.count +
pPropertyList->Proprietary.count;
pPropertyList->Optional.count + pPropertyList->Proprietary.count;
} else if (special_property == PROP_REQUIRED) {
count = pPropertyList->Required.count;
} else if (special_property == PROP_OPTIONAL) {
@@ -222,14 +210,19 @@ static unsigned RPM_Object_Property_Count(
}
/* copy len bytes from src to offset of dest if there is enough space. */
int apdu_copy(uint8_t *dest, uint8_t *src, int offset, int len, int max)
int apdu_copy(
uint8_t * dest,
uint8_t * src,
int offset,
int len,
int max)
{
int i;
int copy_len = 0;
if (len <= (max-offset)) {
if (len <= (max - offset)) {
for (i = 0; i < len; i++) {
dest[offset+i] = src[i];
dest[offset + i] = src[i];
copy_len++;
}
}
@@ -239,7 +232,8 @@ int apdu_copy(uint8_t *dest, uint8_t *src, int offset, int len, int max)
/* Encode the RPM property returning the length of the encoding,
or 0 if there is no room to fit the encoding. */
int RPM_Encode_Property(uint8_t *apdu,
int RPM_Encode_Property(
uint8_t * apdu,
uint16_t offset,
uint16_t max_apdu,
BACNET_OBJECT_TYPE object_type,
@@ -252,35 +246,30 @@ int RPM_Encode_Property(uint8_t *apdu,
BACNET_ERROR_CLASS error_class = ERROR_CLASS_OBJECT;
BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT;
len = rpm_ack_encode_apdu_object_property(
&Temp_Buf[0],
object_property,
array_index);
len = rpm_ack_encode_apdu_object_property(&Temp_Buf[0],
object_property, array_index);
len = apdu_copy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu);
if (!len)
return 0;
apdu_len += len;
len = Encode_Property_APDU(
&Temp_Buf[0],
len = Encode_Property_APDU(&Temp_Buf[0],
object_type,
object_instance,
object_property,
array_index,
&error_class, &error_code);
object_property, array_index, &error_class, &error_code);
if (len < 0) {
/* error was returned - encode that for the response */
len = rpm_ack_encode_apdu_object_property_error(
&Temp_Buf[0],
len = rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0],
error_class, error_code);
len = apdu_copy(&apdu[0], &Temp_Buf[0], offset+apdu_len, len, max_apdu);
len =
apdu_copy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len,
max_apdu);
if (!len)
return 0;
} else if ((offset+apdu_len+1+len+1) < max_apdu) {
} else if ((offset + apdu_len + 1 + len + 1) < max_apdu) {
/* enough room to fit the property value and tags */
len = rpm_ack_encode_apdu_object_property_value(
&apdu[offset+apdu_len],
&Temp_Buf[0],
len);
len =
rpm_ack_encode_apdu_object_property_value(&apdu[offset + apdu_len],
&Temp_Buf[0], len);
} else {
/* not enough room - abort! */
return 0;
@@ -311,16 +300,14 @@ void handler_read_property_multiple(
int32_t array_index = 0;
/* jps_debug - see if we are utilizing all the buffer */
/* memset(&Handler_Transmit_Buffer[0], 0xff, sizeof(Handler_Transmit_Buffer));*/
/* memset(&Handler_Transmit_Buffer[0], 0xff, sizeof(Handler_Transmit_Buffer)); */
/* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address);
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
npdu_len = npdu_encode_pdu(
&Handler_Transmit_Buffer[0],
npdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0],
src, &my_address, &npdu_data);
if (service_data->segmented_message) {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
#if PRINT_ENABLED
@@ -330,102 +317,82 @@ void handler_read_property_multiple(
}
/* decode apdu request & encode apdu reply
encode complex ack, invoke id, service choice */
apdu_len = rpm_ack_encode_apdu_init(
&Handler_Transmit_Buffer[npdu_len],
apdu_len = rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id);
do
{
len = rpm_decode_object_id(
&service_request[decode_len],
service_len - decode_len,
&object_type, &object_instance);
do {
len = rpm_decode_object_id(&service_request[decode_len],
service_len - decode_len, &object_type, &object_instance);
/* end of object? */
if (len > 0) {
decode_len += len;
} else {
len = rpm_decode_object_end(
&service_request[decode_len],
len = rpm_decode_object_end(&service_request[decode_len],
service_len - decode_len);
if (len == 1) {
decode_len++;
len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]);
copy_len = apdu_copy(
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
apdu_len, len,
sizeof(Handler_Transmit_Buffer));
copy_len =
apdu_copy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
apdu_len, len, sizeof(Handler_Transmit_Buffer));
if (!copy_len) {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
apdu_len =
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
true);
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
} else {
apdu_len += copy_len;
}
} else {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_OTHER, true);
apdu_len =
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, ABORT_REASON_OTHER, true);
goto RPM_ABORT;
}
break;
}
len = rpm_ack_encode_apdu_object_begin(
&Temp_Buf[0],
len = rpm_ack_encode_apdu_object_begin(&Temp_Buf[0],
object_type, object_instance);
copy_len = apdu_copy(
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
apdu_len, len,
sizeof(Handler_Transmit_Buffer));
copy_len = apdu_copy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
apdu_len, len, sizeof(Handler_Transmit_Buffer));
if (!copy_len) {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
true);
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
} else {
apdu_len += copy_len;
}
/* do each property of this object of the RPM request */
do
{
len = rpm_decode_object_property(
&service_request[decode_len],
service_len - decode_len,
&object_property,
&array_index);
do {
len = rpm_decode_object_property(&service_request[decode_len],
service_len - decode_len, &object_property, &array_index);
/* end of property list? */
if (len > 0) {
decode_len += len;
} else {
len = rpm_decode_object_end(
&service_request[decode_len],
len = rpm_decode_object_end(&service_request[decode_len],
service_len - decode_len);
if (len == 1) {
decode_len++;
len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]);
copy_len = apdu_copy(
&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
apdu_len, len,
copy_len =
apdu_copy(&Handler_Transmit_Buffer[npdu_len],
&Temp_Buf[0], apdu_len, len,
sizeof(Handler_Transmit_Buffer));
if (!copy_len) {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
true);
apdu_len =
abort_encode_apdu(&Handler_Transmit_Buffer
[npdu_len], service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
} else {
apdu_len += copy_len;
}
} else {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_OTHER, true);
apdu_len =
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, ABORT_REASON_OTHER, true);
goto RPM_ABORT;
}
/* stop decoding properties */
@@ -434,8 +401,7 @@ void handler_read_property_multiple(
/* handle the special properties */
if ((object_property == PROP_ALL) ||
(object_property == PROP_REQUIRED) ||
(object_property == PROP_OPTIONAL))
{
(object_property == PROP_OPTIONAL)) {
struct special_property_list_t property_list;
unsigned property_count = 0;
unsigned index = 0;
@@ -443,63 +409,50 @@ void handler_read_property_multiple(
special_object_property = object_property;
RPM_Property_List(object_type, &property_list);
property_count = RPM_Object_Property_Count(
&property_list,
property_count = RPM_Object_Property_Count(&property_list,
special_object_property);
for (index = 0; index < property_count; index++)
{
object_property = RPM_Object_Property(
&property_list,
special_object_property,
index);
len = RPM_Encode_Property(
&Handler_Transmit_Buffer[0],
for (index = 0; index < property_count; index++) {
object_property = RPM_Object_Property(&property_list,
special_object_property, index);
len = RPM_Encode_Property(&Handler_Transmit_Buffer[0],
npdu_len + apdu_len,
sizeof(Handler_Transmit_Buffer),
object_type,
object_instance,
object_property,
array_index);
object_instance, object_property, array_index);
if (len > 0) {
apdu_len += len;
} else {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
apdu_len =
abort_encode_apdu(&Handler_Transmit_Buffer
[npdu_len], service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
}
}
} else {
/* handle an individual property */
len = RPM_Encode_Property(
&Handler_Transmit_Buffer[0],
len = RPM_Encode_Property(&Handler_Transmit_Buffer[0],
npdu_len + apdu_len,
sizeof(Handler_Transmit_Buffer),
object_type,
object_instance,
object_property,
array_index);
object_instance, object_property, array_index);
if (len > 0) {
apdu_len += len;
} else {
apdu_len = abort_encode_apdu(
&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
apdu_len =
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
goto RPM_ABORT;
}
}
} while(1);
} while (1);
if (decode_len >= service_len) {
break;
}
} while(1);
RPM_ABORT:
} while (1);
RPM_ABORT:
pdu_len = apdu_len + npdu_len;
bytes_sent = datalink_send_pdu(
src,
&npdu_data,
&Handler_Transmit_Buffer[0],
pdu_len);
bytes_sent = datalink_send_pdu(src,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
}
+11 -6
View File
@@ -32,7 +32,9 @@
#include "timesync.h"
#if PRINT_ENABLED
static void show_bacnet_date_time(BACNET_DATE * bdate, BACNET_TIME * btime)
static void show_bacnet_date_time(
BACNET_DATE * bdate,
BACNET_TIME * btime)
{
/* show the date received */
fprintf(stderr, "%u", (unsigned) bdate->year);
@@ -47,8 +49,10 @@ static void show_bacnet_date_time(BACNET_DATE * bdate, BACNET_TIME * btime)
}
#endif
void handler_timesync(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_timesync(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
BACNET_DATE bdate;
@@ -67,8 +71,10 @@ void handler_timesync(uint8_t * service_request,
return;
}
void handler_timesync_utc(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_timesync_utc(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
BACNET_DATE bdate;
@@ -86,4 +92,3 @@ void handler_timesync_utc(uint8_t * service_request,
return;
}
+7 -8
View File
@@ -35,8 +35,10 @@
#include "device.h"
#include "client.h"
void handler_who_has(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_who_has(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
BACNET_WHO_HAS_DATA data;
@@ -47,15 +49,12 @@ void handler_who_has(uint8_t * service_request,
bool found = false;
(void) src;
len = whohas_decode_service_request(service_request,
service_len, &data);
len = whohas_decode_service_request(service_request, service_len, &data);
if (len > 0) {
if ((data.low_limit == -1) || (data.high_limit == -1))
directed_to_me = true;
else if ((Device_Object_Instance_Number() >=
(uint32_t) data.low_limit)
&& (Device_Object_Instance_Number() <=
(uint32_t) data.high_limit))
else if ((Device_Object_Instance_Number() >= (uint32_t) data.low_limit)
&& (Device_Object_Instance_Number() <= (uint32_t) data.high_limit))
directed_to_me = true;
if (directed_to_me) {
/* do we have such an object? If so, send an I-Have.
+4 -2
View File
@@ -37,8 +37,10 @@
#include "client.h"
#include "txbuf.h"
void handler_who_is(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
void handler_who_is(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src)
{
int len = 0;
int32_t low_limit = 0;
+204 -231
View File
@@ -47,12 +47,14 @@
#include "lsp.h"
#include "mso.h"
#if defined(BACFILE)
#include "bacfile.h"
#include "bacfile.h"
#endif
void handler_write_property(uint8_t * service_request,
void handler_write_property(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
BACNET_WRITE_PROPERTY_DATA wp_data;
int len = 0;
@@ -79,9 +81,8 @@ void handler_write_property(uint8_t * service_request,
fprintf(stderr, "WP: Segmented message. Sending Abort!\n");
#endif
goto WP_ABORT;
} /* decode the service request only */
len = wp_decode_service_request(service_request,
service_len, &wp_data);
} /* decode the service request only */
len = wp_decode_service_request(service_request, service_len, &wp_data);
#if PRINT_ENABLED
if (len > 0)
fprintf(stderr, "WP: type=%u instance=%u property=%u index=%d\n",
@@ -99,232 +100,204 @@ void handler_write_property(uint8_t * service_request,
fprintf(stderr, "WP: Bad Encoding. Sending Abort!\n");
#endif
goto WP_ABORT;
}
switch (wp_data.object_type) {
case OBJECT_DEVICE:
if (Device_Write_Property(&wp_data, &error_class, &error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for Device!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Error for Device!\n");
#endif
}
break;
case OBJECT_ANALOG_INPUT:
case OBJECT_BINARY_INPUT:
error_class = ERROR_CLASS_PROPERTY;
error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error!\n");
#endif
break;
case OBJECT_BINARY_OUTPUT:
if (Binary_Output_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for BO!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for BO!\n");
#endif
}
break;
case OBJECT_BINARY_VALUE:
if (Binary_Value_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for BV!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for BV!\n");
#endif
}
break;
case OBJECT_ANALOG_OUTPUT:
if (Analog_Output_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for AO!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for AO!\n");
#endif
}
break;
case OBJECT_ANALOG_VALUE:
if (Analog_Value_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for AV!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for AV!\n");
#endif
}
break;
case OBJECT_LIFE_SAFETY_POINT:
if (Life_Safety_Point_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for LSP!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for LSP!\n");
#endif
}
break;
case OBJECT_LOAD_CONTROL:
if (Load_Control_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for Load Control!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Write Access Error for Load Control!\n");
#endif
}
break;
case OBJECT_MULTI_STATE_OUTPUT:
if (Multistate_Output_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Write Property Simple Ack for MSO!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for MSO!\n");
#endif
}
break;
#if defined(BACFILE)
case OBJECT_FILE:
if (bacfile_write_property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Simple Ack for File!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for File!\n");
#endif
}
break;
#endif /* BACFILE */
default:
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Unknown Object Error!\n");
#endif
break;
}
WP_ABORT:
switch (wp_data.object_type) {
case OBJECT_DEVICE:
if (Device_Write_Property(&wp_data, &error_class, &error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for Device!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Error for Device!\n");
#endif
}
break;
case OBJECT_ANALOG_INPUT:
case OBJECT_BINARY_INPUT:
error_class = ERROR_CLASS_PROPERTY;
error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error!\n");
#endif
break;
case OBJECT_BINARY_OUTPUT:
if (Binary_Output_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for BO!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for BO!\n");
#endif
}
break;
case OBJECT_BINARY_VALUE:
if (Binary_Value_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for BV!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for BV!\n");
#endif
}
break;
case OBJECT_ANALOG_OUTPUT:
if (Analog_Output_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for AO!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for AO!\n");
#endif
}
break;
case OBJECT_ANALOG_VALUE:
if (Analog_Value_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for AV!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for AV!\n");
#endif
}
break;
case OBJECT_LIFE_SAFETY_POINT:
if (Life_Safety_Point_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for LSP!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for LSP!\n");
#endif
}
break;
case OBJECT_LOAD_CONTROL:
if (Load_Control_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for Load Control!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Write Access Error for Load Control!\n");
#endif
}
break;
case OBJECT_MULTI_STATE_OUTPUT:
if (Multistate_Output_Write_Property(&wp_data, &error_class,
&error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr,
"WP: Sending Write Property Simple Ack for MSO!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for MSO!\n");
#endif
}
break;
#if defined(BACFILE)
case OBJECT_FILE:
if (bacfile_write_property(&wp_data, &error_class, &error_code)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Simple Ack for File!\n");
#endif
} else {
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Write Access Error for File!\n");
#endif
}
break;
#endif /* BACFILE */
default:
len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
error_class, error_code);
#if PRINT_ENABLED
fprintf(stderr, "WP: Sending Unknown Object Error!\n");
#endif
break;
}
WP_ABORT:
pdu_len += len;
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+4 -2
View File
@@ -34,9 +34,11 @@
#include "npdu.h"
#include "reject.h"
void handler_unrecognized_service(uint8_t * service_request,
void handler_unrecognized_service(
uint8_t * service_request,
uint16_t service_len,
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data)
{
int len = 0;
int pdu_len = 0;
+4 -2
View File
@@ -42,9 +42,11 @@
#include "handlers.h"
#include "txbuf.h"
uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
uint8_t Send_Atomic_Read_File_Stream(
uint32_t device_id,
uint32_t file_instance,
int fileStartPosition, unsigned requestedOctetCount)
int fileStartPosition,
unsigned requestedOctetCount)
{
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
+6 -6
View File
@@ -42,9 +42,11 @@
#include "handlers.h"
#include "txbuf.h"
uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
uint8_t Send_Atomic_Write_File_Stream(
uint32_t device_id,
uint32_t file_instance,
int fileStartPosition, BACNET_OCTET_STRING * fileData)
int fileStartPosition,
BACNET_OCTET_STRING * fileData)
{
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
@@ -76,8 +78,7 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
if (status) {
/* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address);
npdu_encode_npdu_data(&npdu_data, true,
MESSAGE_PRIORITY_NORMAL);
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest,
&my_address, &npdu_data);
@@ -116,8 +117,7 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
invoke_id = 0;
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send AtomicWriteFile Request "
"(payload [%d] exceeds octet string capacity)!\n",
pdu_len);
"(payload [%d] exceeds octet string capacity)!\n", pdu_len);
#endif
}
}
+6 -3
View File
@@ -42,9 +42,12 @@
#include "handlers.h"
#include "txbuf.h"
uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t timeDuration, /* 0=optional */
BACNET_COMMUNICATION_ENABLE_DISABLE state, char *password)
{ /* NULL=optional */
uint8_t Send_Device_Communication_Control_Request(
uint32_t device_id,
uint16_t timeDuration, /* 0=optional */
BACNET_COMMUNICATION_ENABLE_DISABLE state,
char *password)
{ /* NULL=optional */
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
unsigned max_apdu = 0;
+4 -2
View File
@@ -44,9 +44,11 @@
#include "txbuf.h"
/* find a specific device, or use -1 for limit if you want unlimited */
void Send_I_Have(uint32_t device_id,
void Send_I_Have(
uint32_t device_id,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance, char *object_name)
uint32_t object_instance,
char *object_name)
{
int len = 0;
int pdu_len = 0;
+4 -2
View File
@@ -42,8 +42,10 @@
#include "handlers.h"
#include "txbuf.h"
uint8_t Send_Reinitialize_Device_Request(uint32_t device_id,
BACNET_REINITIALIZED_STATE state, char *password)
uint8_t Send_Reinitialize_Device_Request(
uint32_t device_id,
BACNET_REINITIALIZED_STATE state,
char *password)
{
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
+5 -4
View File
@@ -44,10 +44,12 @@
#include "txbuf.h"
/* returns invoke id of 0 if device is not bound or no tsm available */
uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
uint8_t Send_Read_Property_Request(
uint32_t device_id, /* destination device */
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_PROPERTY_ID object_property, int32_t array_index)
BACNET_PROPERTY_ID object_property,
int32_t array_index)
{
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
@@ -89,8 +91,7 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0],
(uint16_t) pdu_len);
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
+6 -2
View File
@@ -42,7 +42,9 @@
#include "handlers.h"
#include "txbuf.h"
void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime)
void Send_TimeSync(
BACNET_DATE * bdate,
BACNET_TIME * btime)
{
int len = 0;
int pdu_len = 0;
@@ -74,7 +76,9 @@ void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime)
#endif
}
void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime)
void Send_TimeSyncUTC(
BACNET_DATE * bdate,
BACNET_TIME * btime)
{
int pdu_len = 0;
BACNET_ADDRESS dest;
+8 -4
View File
@@ -43,8 +43,10 @@
#include "txbuf.h"
/* find a specific device, or use -1 for limit if you want unlimited */
void Send_WhoHas_Name(int32_t low_limit,
int32_t high_limit, char *object_name)
void Send_WhoHas_Name(
int32_t low_limit,
int32_t high_limit,
char *object_name)
{
int len = 0;
int pdu_len = 0;
@@ -80,9 +82,11 @@ void Send_WhoHas_Name(int32_t low_limit,
}
/* find a specific device, or use -1 for limit if you want unlimited */
void Send_WhoHas_Object(int32_t low_limit,
void Send_WhoHas_Object(
int32_t low_limit,
int32_t high_limit,
BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance)
{
int len = 0;
int pdu_len = 0;
+3 -1
View File
@@ -44,7 +44,9 @@
#include "txbuf.h"
/* find a specific device, or use -1 for limit if you want unlimited */
void Send_WhoIs(int32_t low_limit, int32_t high_limit)
void Send_WhoIs(
int32_t low_limit,
int32_t high_limit)
{
int len = 0;
int pdu_len = 0;
+14 -10
View File
@@ -44,12 +44,15 @@
#include "txbuf.h"
/* returns the invoke ID for confirmed request, or zero on failure */
uint8_t Send_Write_Property_Request_Data(uint32_t device_id,
uint8_t Send_Write_Property_Request_Data(
uint32_t device_id,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_PROPERTY_ID object_property,
uint8_t * application_data,
int application_data_len, uint8_t priority, int32_t array_index)
int application_data_len,
uint8_t priority,
int32_t array_index)
{
BACNET_ADDRESS dest;
BACNET_ADDRESS my_address;
@@ -95,8 +98,7 @@ uint8_t Send_Write_Property_Request_Data(uint32_t device_id,
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0],
(uint16_t) pdu_len);
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
@@ -119,12 +121,14 @@ uint8_t Send_Write_Property_Request_Data(uint32_t device_id,
return invoke_id;
}
uint8_t Send_Write_Property_Request(uint32_t device_id,
uint8_t Send_Write_Property_Request(
uint32_t device_id,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
BACNET_PROPERTY_ID object_property,
BACNET_APPLICATION_DATA_VALUE * object_value,
uint8_t priority, int32_t array_index)
uint8_t priority,
int32_t array_index)
{
uint8_t application_data[MAX_APDU] = { 0 };
int apdu_len = 0, len = 0;
@@ -133,11 +137,11 @@ uint8_t Send_Write_Property_Request(uint32_t device_id,
#if PRINT_ENABLED_DEBUG
fprintf(stderr, "WriteProperty service: "
"%s tag=%d\n",
(object_value->context_specific?"context":"application"),
(int)(object_value->context_specific?object_value->context_tag:object_value->tag) );
(object_value->context_specific ? "context" : "application"),
(int) (object_value->context_specific ? object_value->
context_tag : object_value->tag));
#endif
len = bacapp_encode_data(&application_data[apdu_len],
object_value);
len = bacapp_encode_data(&application_data[apdu_len], object_value);
if ((len + apdu_len) < MAX_APDU) {
apdu_len += len;
} else {