diff --git a/bacnet-stack/demo/dcc/main.c b/bacnet-stack/demo/dcc/main.c index a0fe304d..078d8712 100644 --- a/bacnet-stack/demo/dcc/main.c +++ b/bacnet-stack/demo/dcc/main.c @@ -116,6 +116,11 @@ void MyDeviceCommunicationControlSimpleAckHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/epics/main.c b/bacnet-stack/demo/epics/main.c index e83150aa..cc932ba0 100644 --- a/bacnet-stack/demo/epics/main.c +++ b/bacnet-stack/demo/epics/main.c @@ -241,6 +241,11 @@ void MyReadPropertyAckHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/handler/h_rp.c b/bacnet-stack/demo/handler/h_rp.c index 9ceeb895..9a6db103 100644 --- a/bacnet-stack/demo/handler/h_rp.c +++ b/bacnet-stack/demo/handler/h_rp.c @@ -31,41 +31,31 @@ #include "txbuf.h" #include "bacdef.h" #include "bacdcode.h" +#include "bacerror.h" #include "apdu.h" #include "npdu.h" #include "abort.h" #include "rp.h" -/* demo objects */ -#include "device.h" -#include "ai.h" -#include "ao.h" -#include "av.h" -#include "bi.h" -#include "bo.h" -#include "bv.h" -#include "lc.h" -#include "lsp.h" -#include "mso.h" -#if defined(BACFILE) -#include "bacfile.h" -#endif static uint8_t Temp_Buf[MAX_APDU] = { 0 }; - static read_property_function Read_Property[MAX_BACNET_OBJECT_TYPE]; - + +static object_valid_instance_function + Valid_Instance[MAX_BACNET_OBJECT_TYPE]; + void handler_read_property_object_set( BACNET_OBJECT_TYPE object_type, - read_property_function pFunction) + read_property_function pFunction1, + object_valid_instance_function pFunction2) { if (object_type < MAX_BACNET_OBJECT_TYPE) { - Read_Property[object_type] = pFunction; + Read_Property[object_type] = pFunction1; + Valid_Instance[object_type] = pFunction2; } } - /* Encodes the property APDU and returns the length, or sets the error, and returns -1 */ int Encode_Property_APDU( @@ -78,104 +68,25 @@ int Encode_Property_APDU( BACNET_ERROR_CODE * error_code) { int apdu_len = -1; + read_property_function object_rp = NULL; + object_valid_instance_function object_valid = NULL; /* initialize the default return values */ *error_class = ERROR_CLASS_OBJECT; *error_code = ERROR_CODE_UNKNOWN_OBJECT; /* handle each 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); - } - break; - case OBJECT_ANALOG_INPUT: - if (Analog_Input_Valid_Instance(object_instance)) { - apdu_len = - Analog_Input_Encode_Property_APDU(&apdu[0], - object_instance, 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], - object_instance, 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], - object_instance, 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], - object_instance, 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], - object_instance, 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], - object_instance, 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], - object_instance, 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], - object_instance, 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], - object_instance, 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], object_instance, - property, array_index, error_class, error_code); - } - break; -#endif - default: - *error_class = ERROR_CLASS_OBJECT; - *error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE; - break; + if (object_type < MAX_BACNET_OBJECT_TYPE) { + object_rp = Read_Property[object_type]; + object_valid = Valid_Instance[object_type]; + } + if (object_rp && object_valid && + object_valid(object_instance)) { + apdu_len = object_rp( + &apdu[0], object_instance, property, + array_index, error_class, error_code); + } else { + *error_class = ERROR_CLASS_OBJECT; + *error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE; } return apdu_len; diff --git a/bacnet-stack/demo/handler/h_rpm.c b/bacnet-stack/demo/handler/h_rpm.c index 6e9c40c1..10d75ae8 100644 --- a/bacnet-stack/demo/handler/h_rpm.c +++ b/bacnet-stack/demo/handler/h_rpm.c @@ -38,23 +38,12 @@ #include "abort.h" #include "rpm.h" #include "handlers.h" -/* demo objects */ -#include "device.h" -#include "ai.h" -#include "ao.h" -#include "av.h" -#include "bi.h" -#include "bo.h" -#include "bv.h" -#include "lc.h" -#include "lsp.h" -#include "mso.h" -#if defined(BACFILE) -#include "bacfile.h" -#endif static uint8_t Temp_Buf[MAX_APDU] = { 0 }; +static rpm_property_lists_function + RPM_Lists[MAX_BACNET_OBJECT_TYPE]; + struct property_list_t { const int *pList; unsigned count; @@ -81,75 +70,34 @@ static unsigned property_list_count( return property_count; } +void handler_read_property_multiple_list_set( + BACNET_OBJECT_TYPE object_type, + rpm_property_lists_function pFunction) +{ + if (object_type < MAX_BACNET_OBJECT_TYPE) { + RPM_Lists[object_type] = pFunction; + } +} + /* for a given object type, returns the special property list */ static void RPM_Property_List( BACNET_OBJECT_TYPE object_type, struct special_property_list_t *pPropertyList) { + rpm_property_lists_function object_property_list = NULL; pPropertyList->Required.pList = NULL; 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: - Multistate_Output_Property_Lists(&pPropertyList->Required.pList, - &pPropertyList->Optional.pList, - &pPropertyList->Proprietary.pList); - break; -#if defined(BACFILE) - 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; - } + + if (object_type < MAX_BACNET_OBJECT_TYPE) { + object_property_list = RPM_Lists[object_type]; + } + if (object_property_list) { + object_property_list( + &pPropertyList->Required.pList, + &pPropertyList->Optional.pList, + &pPropertyList->Proprietary.pList); + } /* fill the count */ if (pPropertyList->Required.pList) { pPropertyList->Required.count = diff --git a/bacnet-stack/demo/handler/h_wp.c b/bacnet-stack/demo/handler/h_wp.c index 7386d2a2..f9b8a035 100644 --- a/bacnet-stack/demo/handler/h_wp.c +++ b/bacnet-stack/demo/handler/h_wp.c @@ -31,24 +31,11 @@ #include "txbuf.h" #include "bacdef.h" #include "bacdcode.h" +#include "bacerror.h" #include "apdu.h" #include "npdu.h" #include "abort.h" #include "wp.h" -/* demo objects */ -#include "device.h" -#include "ai.h" -#include "ao.h" -#include "av.h" -#include "bi.h" -#include "bo.h" -#include "bv.h" -#include "lc.h" -#include "lsp.h" -#include "mso.h" -#if defined(BACFILE) -#include "bacfile.h" -#endif static write_property_function Write_Property[MAX_BACNET_OBJECT_TYPE]; diff --git a/bacnet-stack/demo/iamrouter/main.c b/bacnet-stack/demo/iamrouter/main.c index d338fd33..5fc35ef1 100644 --- a/bacnet-stack/demo/iamrouter/main.c +++ b/bacnet-stack/demo/iamrouter/main.c @@ -84,6 +84,11 @@ void MyRejectHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/initrouter/main.c b/bacnet-stack/demo/initrouter/main.c index d1418584..639670fd 100644 --- a/bacnet-stack/demo/initrouter/main.c +++ b/bacnet-stack/demo/initrouter/main.c @@ -206,6 +206,11 @@ static void My_NPDU_Handler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/object/ai.c b/bacnet-stack/demo/object/ai.c index 9ae38da9..94a8cd38 100644 --- a/bacnet-stack/demo/object/ai.c +++ b/bacnet-stack/demo/object/ai.c @@ -40,7 +40,7 @@ static float Present_Value[MAX_ANALOG_INPUTS]; /* These three arrays are used by the ReadPropertyMultiple handler */ -static const int Analog_Input_Properties_Required[] = { +static const int Properties_Required[] = { PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, @@ -52,12 +52,12 @@ static const int Analog_Input_Properties_Required[] = { -1 }; -static const int Analog_Input_Properties_Optional[] = { +static const int Properties_Optional[] = { PROP_DESCRIPTION, -1 }; -static const int Analog_Input_Properties_Proprietary[] = { +static const int Properties_Proprietary[] = { 9997, 9998, 9999, @@ -70,11 +70,11 @@ void Analog_Input_Property_Lists( const int **pProprietary) { if (pRequired) - *pRequired = Analog_Input_Properties_Required; + *pRequired = Properties_Required; if (pOptional) - *pOptional = Analog_Input_Properties_Optional; + *pOptional = Properties_Optional; if (pProprietary) - *pProprietary = Analog_Input_Properties_Proprietary; + *pProprietary = Properties_Proprietary; return; } @@ -217,6 +217,10 @@ int Analog_Input_Encode_Property_APDU( return apdu_len; } +void Analog_Input_Init(void) +{ +} + #ifdef TEST #include #include diff --git a/bacnet-stack/demo/object/ao.c b/bacnet-stack/demo/object/ao.c index 43835c4a..ab125ee1 100644 --- a/bacnet-stack/demo/object/ao.c +++ b/bacnet-stack/demo/object/ao.c @@ -57,7 +57,7 @@ static bool Analog_Output_Out_Of_Service[MAX_ANALOG_OUTPUTS]; static bool Analog_Output_Initialized = false; /* These three arrays are used by the ReadPropertyMultiple handler */ -static const int Analog_Output_Properties_Required[] = { +static const int Properties_Required[] = { PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, @@ -71,12 +71,12 @@ static const int Analog_Output_Properties_Required[] = { -1 }; -static const int Analog_Output_Properties_Optional[] = { +static const int Properties_Optional[] = { PROP_DESCRIPTION, -1 }; -static const int Analog_Output_Properties_Proprietary[] = { +static const int Properties_Proprietary[] = { -1 }; @@ -86,11 +86,11 @@ void Analog_Output_Property_Lists( const int **pProprietary) { if (pRequired) - *pRequired = Analog_Output_Properties_Required; + *pRequired = Properties_Required; if (pOptional) - *pOptional = Analog_Output_Properties_Optional; + *pOptional = Properties_Optional; if (pProprietary) - *pProprietary = Analog_Output_Properties_Proprietary; + *pProprietary = Properties_Proprietary; return; } @@ -120,7 +120,6 @@ void Analog_Output_Init( bool Analog_Output_Valid_Instance( uint32_t object_instance) { - Analog_Output_Init(); if (object_instance < MAX_ANALOG_OUTPUTS) return true; @@ -132,7 +131,6 @@ bool Analog_Output_Valid_Instance( unsigned Analog_Output_Count( void) { - Analog_Output_Init(); return MAX_ANALOG_OUTPUTS; } @@ -142,7 +140,6 @@ unsigned Analog_Output_Count( uint32_t Analog_Output_Index_To_Instance( unsigned index) { - Analog_Output_Init(); return index; } @@ -154,7 +151,6 @@ unsigned Analog_Output_Instance_To_Index( { unsigned index = MAX_ANALOG_OUTPUTS; - Analog_Output_Init(); if (object_instance < MAX_ANALOG_OUTPUTS) index = object_instance; @@ -168,7 +164,6 @@ float Analog_Output_Present_Value( unsigned index = 0; unsigned i = 0; - Analog_Output_Init(); index = Analog_Output_Instance_To_Index(object_instance); if (index < MAX_ANALOG_OUTPUTS) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) { @@ -189,7 +184,6 @@ unsigned Analog_Output_Present_Value_Priority( unsigned i = 0; /* loop counter */ unsigned priority = 0; /* return value */ - Analog_Output_Init(); index = Analog_Output_Instance_To_Index(object_instance); if (index < MAX_ANALOG_OUTPUTS) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) { @@ -287,7 +281,6 @@ int Analog_Output_Encode_Property_APDU( unsigned i = 0; bool state = false; - Analog_Output_Init(); switch (property) { case PROP_OBJECT_IDENTIFIER: apdu_len = @@ -405,7 +398,6 @@ bool Analog_Output_Write_Property( int len = 0; BACNET_APPLICATION_DATA_VALUE value; - Analog_Output_Init(); if (!Analog_Output_Valid_Instance(wp_data->object_instance)) { *error_class = ERROR_CLASS_OBJECT; *error_code = ERROR_CODE_UNKNOWN_OBJECT; diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index 7cb97aee..79154cc2 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -462,3 +462,7 @@ bool bacfile_write_stream_data( return found; } + +void bacfile_init(void) +{ +} diff --git a/bacnet-stack/demo/object/bi.c b/bacnet-stack/demo/object/bi.c index 4d90bd9e..28ad7751 100644 --- a/bacnet-stack/demo/object/bi.c +++ b/bacnet-stack/demo/object/bi.c @@ -140,7 +140,6 @@ unsigned Binary_Input_Instance_To_Index( { unsigned index = MAX_BINARY_INPUTS; - Binary_Input_Init(); if (object_instance < MAX_BINARY_INPUTS) { index = object_instance; } @@ -154,7 +153,6 @@ static BACNET_BINARY_PV Binary_Input_Present_Value( BACNET_BINARY_PV value = BINARY_INACTIVE; unsigned index = 0; - Binary_Input_Init(); index = Binary_Input_Instance_To_Index(object_instance); if (index < MAX_BINARY_INPUTS) { value = Present_Value[index]; @@ -169,7 +167,6 @@ static bool Binary_Input_Out_Of_Service( bool value = false; unsigned index = 0; - Binary_Input_Init(); index = Binary_Input_Instance_To_Index(object_instance); if (index < MAX_BINARY_INPUTS) { value = Out_Of_Service[index]; @@ -248,7 +245,6 @@ static void Binary_Input_Present_Value_Set( { unsigned index = 0; - Binary_Input_Init(); index = Binary_Input_Instance_To_Index(object_instance); if (index < MAX_BINARY_INPUTS) { if (Present_Value[index] != value) { @@ -266,7 +262,6 @@ static void Binary_Input_Out_Of_Service_Set( { unsigned index = 0; - Binary_Input_Init(); index = Binary_Input_Instance_To_Index(object_instance); if (index < MAX_BINARY_INPUTS) { if (Out_Of_Service[index] != value) { @@ -283,7 +278,6 @@ char *Binary_Input_Name( { static char text_string[32] = ""; /* okay for single thread */ - Binary_Input_Init(); if (object_instance < MAX_BINARY_INPUTS) { sprintf(text_string, "BINARY INPUT %u", object_instance); return text_string; @@ -308,7 +302,6 @@ int Binary_Input_Encode_Property_APDU( BACNET_POLARITY polarity = POLARITY_NORMAL; (void) array_index; - Binary_Input_Init(); switch (property) { case PROP_OBJECT_IDENTIFIER: apdu_len = @@ -381,7 +374,6 @@ bool Binary_Input_Write_Property( int len = 0; BACNET_APPLICATION_DATA_VALUE value; - Binary_Input_Init(); if (!Binary_Input_Valid_Instance(wp_data->object_instance)) { *error_class = ERROR_CLASS_OBJECT; *error_code = ERROR_CODE_UNKNOWN_OBJECT; diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index 3b26d9a5..46797374 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -32,15 +32,6 @@ #include "bacapp.h" #include "config.h" /* the custom stuff */ #include "apdu.h" -#include "ai.h" /* object list dependency */ -#include "ao.h" /* object list dependency */ -#include "av.h" /* object list dependency */ -#include "bi.h" /* object list dependency */ -#include "bo.h" /* object list dependency */ -#include "bv.h" /* object list dependency */ -#include "lc.h" /* object list dependency */ -#include "lsp.h" /* object list dependency */ -#include "mso.h" /* object list dependency */ #include "wp.h" /* write property handling */ #include "version.h" #include "device.h" /* me */ @@ -50,6 +41,26 @@ #include "bacfile.h" /* object list dependency */ #endif +static object_count_function + Object_Count[MAX_BACNET_OBJECT_TYPE]; +static object_index_to_instance_function + Object_Index_To_Instance[MAX_BACNET_OBJECT_TYPE]; +static object_name_function + Object_Name[MAX_BACNET_OBJECT_TYPE]; + +void Device_Object_Function_Set( + BACNET_OBJECT_TYPE object_type, + object_count_function count_function, + object_index_to_instance_function index_function, + object_name_function name_function) +{ + if (object_type < MAX_BACNET_OBJECT_TYPE) { + Object_Count[object_type] = count_function; + Object_Index_To_Instance[object_type] = index_function; + Object_Name[object_type] = name_function; + } +} + /* These three arrays are used by the ReadPropertyMultiple handler */ static const int Device_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, @@ -114,7 +125,7 @@ void Device_Property_Lists( The properties that are constant can be hard coded into the read-property encoding. */ static uint32_t Object_Instance_Number = 260001; -static char Object_Name[16] = "SimpleServer"; +static char My_Object_Name[16] = "SimpleServer"; static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL; static char *Vendor_Name = BACNET_VENDOR_NAME; static uint16_t Vendor_Identifier = BACNET_VENDOR_ID; @@ -186,7 +197,7 @@ bool Device_Valid_Object_Instance_Number( const char *Device_Object_Name( void) { - return Object_Name; + return My_Object_Name; } bool Device_Set_Object_Name( @@ -200,7 +211,7 @@ bool Device_Set_Object_Name( the device. */ if (length < sizeof(Object_Name)) { memmove(Object_Name, name, length); - Object_Name[length] = 0; + My_Object_Name[length] = 0; status = true; } @@ -363,20 +374,14 @@ void Device_Set_Database_Revision( unsigned Device_Object_List_Count( void) { - unsigned count = 1; - - count += Analog_Input_Count(); - count += Analog_Output_Count(); - count += Analog_Value_Count(); - count += Binary_Input_Count(); - count += Binary_Output_Count(); - count += Binary_Value_Count(); - count += Life_Safety_Point_Count(); - count += Load_Control_Count(); - count += Multistate_Output_Count(); -#if defined(BACFILE) - count += bacfile_count(); -#endif + unsigned count = 1; /* 1 for the device object */ + unsigned i = 0; /* loop counter */ + + for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) { + if (Object_Count[i]) { + count += Object_Count[i](); + } + } return count; } @@ -388,144 +393,38 @@ bool Device_Object_List_Identifier( { bool status = false; unsigned object_index = 0; - unsigned object_count = 0; + unsigned count = 0; + unsigned i = 0; /* loop counter */ - /* device object */ + if (array_index == 0) { + return status; + } + /* device object */ if (array_index == 1) { *object_type = OBJECT_DEVICE; *instance = Object_Instance_Number; status = true; } - /* analog input objects */ + if (!status) { - /* array index starts at 1, and 1 for the device object */ + /* array index starts at 1, and if we are this far, + we are not the device object, so array_index must + be at least 2. */ object_index = array_index - 2; - object_count = Analog_Input_Count(); - if (object_index < object_count) { - *object_type = OBJECT_ANALOG_INPUT; - *instance = Analog_Input_Index_To_Instance(object_index); - status = true; + /* look through the objects to find the right index */ + for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) { + if (Object_Count[i] && Object_Index_To_Instance[i]) { + object_index -= count; + count = Object_Count[i](); + if (object_index < count) { + *object_type = i; + *instance = Object_Index_To_Instance[i](object_index); + status = true; + break; + } + } } } - /* analog output objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Analog_Output_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_ANALOG_OUTPUT; - *instance = Analog_Output_Index_To_Instance(object_index); - status = true; - } - } - /* analog value objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Analog_Value_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_ANALOG_VALUE; - *instance = Analog_Value_Index_To_Instance(object_index); - status = true; - } - } - /* binary input objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Binary_Input_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_BINARY_INPUT; - *instance = Binary_Input_Index_To_Instance(object_index); - status = true; - } - } - /* binary output objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Binary_Output_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_BINARY_OUTPUT; - *instance = Binary_Output_Index_To_Instance(object_index); - status = true; - } - } - /* binary value objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Binary_Value_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_BINARY_VALUE; - *instance = Binary_Value_Index_To_Instance(object_index); - status = true; - } - } - /* life safety point objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Life_Safety_Point_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_LIFE_SAFETY_POINT; - *instance = Life_Safety_Point_Index_To_Instance(object_index); - status = true; - } - } - /* load control objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Load_Control_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_LOAD_CONTROL; - *instance = Load_Control_Index_To_Instance(object_index); - status = true; - } - } - /* multi-state output objects */ - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = Multistate_Output_Count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_MULTI_STATE_OUTPUT; - *instance = Multistate_Output_Index_To_Instance(object_index); - status = true; - } - } - /* file objects */ -#if defined(BACFILE) - if (!status) { - /* normalize the index since - we know it is not the previous objects */ - object_index -= object_count; - object_count = bacfile_count(); - /* is it a valid index for this object? */ - if (object_index < object_count) { - *object_type = OBJECT_FILE; - *instance = bacfile_index_to_instance(object_index); - status = true; - } - } -#endif return status; } @@ -549,10 +448,12 @@ bool Device_Valid_Object_Name( name = Device_Valid_Object_Id(type, instance); if (strcmp(name, object_name) == 0) { found = true; - if (object_type) + if (object_type) { *object_type = type; - if (object_instance) + } + if (object_instance) { *object_instance = instance; + } break; } } @@ -567,46 +468,18 @@ char *Device_Valid_Object_Id( uint32_t object_instance) { char *name = NULL; /* return value */ + object_name_function name_function = NULL; - switch (object_type) { - case OBJECT_ANALOG_INPUT: - name = Analog_Input_Name(object_instance); - break; - case OBJECT_ANALOG_OUTPUT: - name = Analog_Output_Name(object_instance); - break; - case OBJECT_ANALOG_VALUE: - name = Analog_Value_Name(object_instance); - break; - case OBJECT_BINARY_INPUT: - name = Binary_Input_Name(object_instance); - break; - case OBJECT_BINARY_OUTPUT: - name = Binary_Output_Name(object_instance); - break; - case OBJECT_BINARY_VALUE: - name = Binary_Value_Name(object_instance); - break; - case OBJECT_LIFE_SAFETY_POINT: - name = Life_Safety_Point_Name(object_instance); - break; - case OBJECT_LOAD_CONTROL: - name = Load_Control_Name(object_instance); - break; - case OBJECT_MULTI_STATE_OUTPUT: - name = Multistate_Output_Name(object_instance); - break; -#if defined(BACFILE) - case OBJECT_FILE: - name = bacfile_name(object_instance); - break; -#endif - case OBJECT_DEVICE: - if (object_instance == Object_Instance_Number) - name = Object_Name; - break; - default: - break; + if (object_type < MAX_BACNET_OBJECT_TYPE) { + name_function = Object_Name[object_type]; + } + if (name_function) { + name = name_function(object_instance); + } else { + if ((object_type == OBJECT_DEVICE) && + (object_instance == Object_Instance_Number)) { + name = My_Object_Name; + } } return name; @@ -616,6 +489,7 @@ char *Device_Valid_Object_Id( -2 for abort message */ int Device_Encode_Property_APDU( uint8_t * apdu, + uint32_t object_instance, BACNET_PROPERTY_ID property, int32_t array_index, BACNET_ERROR_CLASS * error_class, @@ -629,7 +503,8 @@ int Device_Encode_Property_APDU( int object_type = 0; uint32_t instance = 0; unsigned count = 0; - + + object_instance = object_instance; switch (property) { case PROP_OBJECT_IDENTIFIER: apdu_len = @@ -637,7 +512,7 @@ int Device_Encode_Property_APDU( Object_Instance_Number); break; case PROP_OBJECT_NAME: - characterstring_init_ansi(&char_string, Object_Name); + characterstring_init_ansi(&char_string, My_Object_Name); apdu_len = encode_application_character_string(&apdu[0], &char_string); break; @@ -737,34 +612,13 @@ int Device_Encode_Property_APDU( not a list of objects that this device can access */ bitstring_init(&bit_string); for (i = 0; i < MAX_ASHRAE_OBJECT_TYPE; i++) { - /* initialize all the object types to not-supported */ - bitstring_set_bit(&bit_string, (uint8_t) i, false); + if ((i == OBJECT_DEVICE) || Object_Count[i]) { + bitstring_set_bit(&bit_string, i, true); + } else { + /* initialize all the object types to not-supported */ + bitstring_set_bit(&bit_string, (uint8_t) i, false); + } } - /* FIXME: indicate the objects that YOU support */ - bitstring_set_bit(&bit_string, OBJECT_DEVICE, true); - if (Analog_Input_Count()) - bitstring_set_bit(&bit_string, OBJECT_ANALOG_INPUT, true); - if (Analog_Output_Count()) - bitstring_set_bit(&bit_string, OBJECT_ANALOG_OUTPUT, true); - if (Analog_Value_Count()) - bitstring_set_bit(&bit_string, OBJECT_ANALOG_VALUE, true); - if (Binary_Input_Count()) - bitstring_set_bit(&bit_string, OBJECT_BINARY_INPUT, true); - if (Binary_Output_Count()) - bitstring_set_bit(&bit_string, OBJECT_BINARY_OUTPUT, true); - if (Binary_Value_Count()) - bitstring_set_bit(&bit_string, OBJECT_BINARY_VALUE, true); - if (Life_Safety_Point_Count()) - bitstring_set_bit(&bit_string, OBJECT_LIFE_SAFETY_POINT, true); - if (Load_Control_Count()) - bitstring_set_bit(&bit_string, OBJECT_LOAD_CONTROL, true); - if (Multistate_Output_Count()) - bitstring_set_bit(&bit_string, OBJECT_MULTI_STATE_OUTPUT, - true); -#if defined(BACFILE) - if (bacfile_count()) - bitstring_set_bit(&bit_string, OBJECT_FILE, true); -#endif apdu_len = encode_application_bitstring(&apdu[0], &bit_string); break; case PROP_OBJECT_LIST: @@ -1004,12 +858,6 @@ bool Device_Write_Property( void Device_Init(void) { - handler_write_property_object_set( - OBJECT_DEVICE, - Device_Write_Property); - handler_read_property_object_set( - OBJECT_DEVICE, - Device_Encode_Property_APDU); } #ifdef TEST @@ -1051,194 +899,6 @@ void testDevice( } #ifdef TEST_DEVICE -/* stubs to dependencies to keep unit test simple */ -char *Analog_Input_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Analog_Input_Count( - void) -{ - return 0; -} - -uint32_t Analog_Input_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Analog_Output_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Analog_Output_Count( - void) -{ - return 0; -} - -uint32_t Analog_Output_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Analog_Value_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Analog_Value_Count( - void) -{ - return 0; -} - -uint32_t Analog_Value_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Binary_Input_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Binary_Input_Count( - void) -{ - return 0; -} - -uint32_t Binary_Input_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Binary_Output_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Binary_Output_Count( - void) -{ - return 0; -} - -uint32_t Binary_Output_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Binary_Value_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Binary_Value_Count( - void) -{ - return 0; -} - -uint32_t Binary_Value_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Life_Safety_Point_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Life_Safety_Point_Count( - void) -{ - return 0; -} - -uint32_t Life_Safety_Point_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Load_Control_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Load_Control_Count( - void) -{ - return 0; -} - -uint32_t Load_Control_Index_To_Instance( - unsigned index) -{ - return index; -} - -char *Multistate_Output_Name( - uint32_t object_instance) -{ - (void) object_instance; - return ""; -} - -unsigned Multistate_Output_Count( - void) -{ - return 0; -} - -uint32_t Multistate_Output_Index_To_Instance( - unsigned index) -{ - return index; -} - -#if defined(BACFILE) -uint32_t bacfile_count( - void) -{ - return 0; -} -#endif - -#if defined(BACFILE) -uint32_t bacfile_index_to_instance( - unsigned find_index) -{ - return find_index; -} -#endif - int main( void) { diff --git a/bacnet-stack/demo/readfile/main.c b/bacnet-stack/demo/readfile/main.c index 27bb5243..a1e26212 100644 --- a/bacnet-stack/demo/readfile/main.c +++ b/bacnet-stack/demo/readfile/main.c @@ -175,6 +175,11 @@ static void LocalIAmHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/readprop/main.c b/bacnet-stack/demo/readprop/main.c index 83a20f5c..1d80f067 100644 --- a/bacnet-stack/demo/readprop/main.c +++ b/bacnet-stack/demo/readprop/main.c @@ -112,6 +112,11 @@ void MyRejectHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/readpropm/main.c b/bacnet-stack/demo/readpropm/main.c index e7a67b5e..47eac967 100644 --- a/bacnet-stack/demo/readpropm/main.c +++ b/bacnet-stack/demo/readpropm/main.c @@ -110,6 +110,11 @@ void MyRejectHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/reinit/main.c b/bacnet-stack/demo/reinit/main.c index bd7168b7..e534bfb3 100644 --- a/bacnet-stack/demo/reinit/main.c +++ b/bacnet-stack/demo/reinit/main.c @@ -114,6 +114,11 @@ void MyReinitializeDeviceSimpleAckHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/server/main.c b/bacnet-stack/demo/server/main.c index b3e4ffa9..01f4e567 100644 --- a/bacnet-stack/demo/server/main.c +++ b/bacnet-stack/demo/server/main.c @@ -47,12 +47,177 @@ #include "txbuf.h" #include "lc.h" #include "version.h" +/* include the objects */ +#include "device.h" +#include "ai.h" +#include "ao.h" +#include "av.h" +#include "bi.h" +#include "bo.h" +#include "bv.h" +#include "lc.h" +#include "lsp.h" +#include "mso.h" +#include "bacfile.h" /* This is an example server application using the BACnet Stack */ /* buffers used for receiving */ static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; +static void Init_Object( + BACNET_OBJECT_TYPE object_type, + rpm_property_lists_function rpm_list_function, + read_property_function rp_function, + object_valid_instance_function object_valid_function, + write_property_function wp_function, + object_count_function count_function, + object_index_to_instance_function index_function, + object_name_function name_function) +{ + handler_read_property_object_set( + object_type, + rp_function, + object_valid_function); + handler_write_property_object_set( + object_type, + wp_function); + handler_read_property_multiple_list_set( + object_type, + rpm_list_function); + Device_Object_Function_Set( + object_type, + count_function, + index_function, + name_function); +} + +static void Init_Objects(void) +{ + Device_Init(); + Init_Object( + OBJECT_DEVICE, + Device_Property_Lists, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number, + Device_Write_Property, + NULL, + NULL, + NULL); + + Analog_Input_Init(); + Init_Object( + OBJECT_ANALOG_INPUT, + Analog_Input_Property_Lists, + Analog_Input_Encode_Property_APDU, + Analog_Input_Valid_Instance, + NULL, + Analog_Input_Count, + Analog_Input_Index_To_Instance, + Analog_Input_Name); + + Analog_Output_Init(); + Init_Object( + OBJECT_ANALOG_OUTPUT, + Analog_Output_Property_Lists, + Analog_Output_Encode_Property_APDU, + Analog_Output_Valid_Instance, + Analog_Output_Write_Property, + Analog_Output_Count, + Analog_Output_Index_To_Instance, + Analog_Output_Name); + + Analog_Value_Init(); + Init_Object( + OBJECT_ANALOG_VALUE, + Analog_Value_Property_Lists, + Analog_Value_Encode_Property_APDU, + Analog_Value_Valid_Instance, + Analog_Value_Write_Property, + Analog_Value_Count, + Analog_Value_Index_To_Instance, + Analog_Value_Name); + + Binary_Input_Init(); + Init_Object( + OBJECT_BINARY_INPUT, + Binary_Input_Property_Lists, + Binary_Input_Encode_Property_APDU, + Binary_Input_Valid_Instance, + NULL, + Binary_Input_Count, + Binary_Input_Index_To_Instance, + Binary_Input_Name); + + Binary_Output_Init(); + Init_Object( + OBJECT_BINARY_OUTPUT, + Binary_Output_Property_Lists, + Binary_Output_Encode_Property_APDU, + Binary_Output_Valid_Instance, + Binary_Output_Write_Property, + Binary_Output_Count, + Binary_Output_Index_To_Instance, + Binary_Output_Name); + + Binary_Value_Init(); + Init_Object( + OBJECT_BINARY_VALUE, + Binary_Value_Property_Lists, + Binary_Value_Encode_Property_APDU, + Binary_Value_Valid_Instance, + Binary_Value_Write_Property, + Binary_Value_Count, + Binary_Value_Index_To_Instance, + Binary_Value_Name); + + Life_Safety_Point_Init(); + Init_Object( + OBJECT_LIFE_SAFETY_POINT, + Life_Safety_Point_Property_Lists, + Life_Safety_Point_Encode_Property_APDU, + Life_Safety_Point_Valid_Instance, + Life_Safety_Point_Write_Property, + Life_Safety_Point_Count, + Life_Safety_Point_Index_To_Instance, + Life_Safety_Point_Name); + + Load_Control_Init(); + Init_Object( + OBJECT_LOAD_CONTROL, + Load_Control_Property_Lists, + Load_Control_Encode_Property_APDU, + Load_Control_Valid_Instance, + Load_Control_Write_Property, + Load_Control_Count, + Load_Control_Index_To_Instance, + Load_Control_Name); + + Multistate_Output_Init(); + Init_Object( + OBJECT_LIFE_SAFETY_POINT, + Multistate_Output_Property_Lists, + Multistate_Output_Encode_Property_APDU, + Multistate_Output_Valid_Instance, + Multistate_Output_Write_Property, + Multistate_Output_Count, + Multistate_Output_Index_To_Instance, + Multistate_Output_Name); + +#if defined(BACFILE) + bacfile_init(); + Init_Object( + OBJECT_FILE, + BACfile_Property_Lists, + bacfile_encode_property_apdu, + bacfile_valid_instance, + bacfile_write_property, + bacfile_count, + bacfile_index_to_instance, + bacfile_name); +#endif +} + static void Init_Service_Handlers( void) { @@ -118,6 +283,7 @@ int main( printf("BACnet Server Demo\n" "BACnet Stack Version %s\n" "BACnet Device ID: %u\n" "Max APDU: %d\n", BACnet_Version, Device_Object_Instance_Number(), MAX_APDU); + Init_Objects(); Init_Service_Handlers(); dlenv_init(); atexit(cleanup); diff --git a/bacnet-stack/demo/timesync/main.c b/bacnet-stack/demo/timesync/main.c index 999a025e..88a8c55f 100644 --- a/bacnet-stack/demo/timesync/main.c +++ b/bacnet-stack/demo/timesync/main.c @@ -86,6 +86,11 @@ void MyRejectHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/ucov/main.c b/bacnet-stack/demo/ucov/main.c index 95cc8528..1c5fb2a8 100644 --- a/bacnet-stack/demo/ucov/main.c +++ b/bacnet-stack/demo/ucov/main.c @@ -53,6 +53,11 @@ static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); diff --git a/bacnet-stack/demo/whohas/main.c b/bacnet-stack/demo/whohas/main.c index a335ab73..a1c6f127 100644 --- a/bacnet-stack/demo/whohas/main.c +++ b/bacnet-stack/demo/whohas/main.c @@ -48,6 +48,7 @@ #include "handlers.h" #include "client.h" #include "txbuf.h" +#include "dlenv.h" /* buffer used for receive */ static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; @@ -88,6 +89,11 @@ void MyRejectHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); @@ -105,100 +111,6 @@ static void Init_Service_Handlers( apdu_set_reject_handler(MyRejectHandler); } -static void Init_DataLink( - void) -{ - char *pEnv = NULL; -#if defined(BACDL_BIP) && BBMD_ENABLED - long bbmd_port = 0xBAC0; - long bbmd_address = 0; - long bbmd_timetolive_seconds = 60000; -#endif - -#if defined(BACDL_ALL) - pEnv = getenv("BACNET_DATALINK"); - if (pEnv) { - datalink_set(pEnv)); - } else { - datalink_set(NULL); - } -#endif - -#if defined(BACDL_BIP) - pEnv = getenv("BACNET_IP_PORT"); - if (pEnv) { - bip_set_port(strtol(pEnv, NULL, 0)); - } else { - bip_set_port(0xBAC0); - } -#elif defined(BACDL_MSTP) - pEnv = getenv("BACNET_MAX_INFO_FRAMES"); - if (pEnv) { - dlmstp_set_max_info_frames(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_info_frames(1); - } - pEnv = getenv("BACNET_MAX_MASTER"); - if (pEnv) { - dlmstp_set_max_master(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_master(127); - } - pEnv = getenv("BACNET_MSTP_BAUD"); - if (pEnv) { - dlmstp_set_baud_rate(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_baud_rate(38400); - } - pEnv = getenv("BACNET_MSTP_MAC"); - if (pEnv) { - dlmstp_set_mac_address(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_mac_address(127); - } -#endif - pEnv = getenv("BACNET_APDU_TIMEOUT"); - if (pEnv) { - apdu_timeout_set(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); - } else { -#if defined(BACDL_MSTP) - apdu_timeout_set(60000); -#endif - } - if (!datalink_init(getenv("BACNET_IFACE"))) { - exit(1); - } -#if defined(BACDL_BIP) && BBMD_ENABLED - pEnv = getenv("BACNET_BBMD_PORT"); - if (pEnv) { - bbmd_port = strtol(pEnv, NULL, 0); - if (bbmd_port > 0xFFFF) { - bbmd_port = 0xBAC0; - } - } - pEnv = getenv("BACNET_BBMD_TIMETOLIVE"); - if (pEnv) { - bbmd_timetolive_seconds = strtol(pEnv, NULL, 0); - if (bbmd_timetolive_seconds > 0xFFFF) { - bbmd_timetolive_seconds = 0xFFFF; - } - } - pEnv = getenv("BACNET_BBMD_ADDRESS"); - if (pEnv) { - bbmd_address = bip_getaddrbyname(pEnv); - if (bbmd_address) { - struct in_addr addr; - addr.s_addr = bbmd_address; - printf("WhoHas: Registering with BBMD at %s:%ld for %ld seconds\n", - inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); - bvlc_register_with_bbmd(bbmd_address, bbmd_port, - bbmd_timetolive_seconds); - } - } -#endif -} - int main(int argc, char *argv[]) { BACNET_ADDRESS src = { 0}; /* address where message came from */ @@ -240,7 +152,7 @@ int main(int argc, char *argv[]) { /* setup my info */ Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); Init_Service_Handlers(); - Init_DataLink(); + dlenv_init(); /* configure the timeout values */ last_seconds = time(NULL); timeout_seconds = apdu_timeout() / 1000; diff --git a/bacnet-stack/demo/whois/main.c b/bacnet-stack/demo/whois/main.c index 3eddb871..b6123c7e 100644 --- a/bacnet-stack/demo/whois/main.c +++ b/bacnet-stack/demo/whois/main.c @@ -47,6 +47,7 @@ #if defined(BACDL_MSTP) #include "rs485.h" #endif +#include "dlenv.h" /* buffer used for receive */ static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; @@ -88,6 +89,11 @@ void MyRejectHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* Note: this applications doesn't need to handle who-is it is confusing for the user! */ /* set the handler for all the services we don't implement @@ -153,100 +159,6 @@ static void print_address_cache( } } -static void Init_DataLink( - void) -{ - char *pEnv = NULL; -#if defined(BACDL_BIP) && BBMD_ENABLED - long bbmd_port = 0xBAC0; - long bbmd_address = 0; - long bbmd_timetolive_seconds = 60000; -#endif - -#if defined(BACDL_ALL) - pEnv = getenv("BACNET_DATALINK"); - if (pEnv) { - datalink_set(pEnv)); - } else { - datalink_set(NULL); - } -#endif - -#if defined(BACDL_BIP) - pEnv = getenv("BACNET_IP_PORT"); - if (pEnv) { - bip_set_port(strtol(pEnv, NULL, 0)); - } else { - bip_set_port(0xBAC0); - } -#elif defined(BACDL_MSTP) - pEnv = getenv("BACNET_MAX_INFO_FRAMES"); - if (pEnv) { - dlmstp_set_max_info_frames(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_info_frames(1); - } - pEnv = getenv("BACNET_MAX_MASTER"); - if (pEnv) { - dlmstp_set_max_master(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_master(127); - } - pEnv = getenv("BACNET_MSTP_BAUD"); - if (pEnv) { - dlmstp_set_baud_rate(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_baud_rate(38400); - } - pEnv = getenv("BACNET_MSTP_MAC"); - if (pEnv) { - dlmstp_set_mac_address(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_mac_address(127); - } -#endif - pEnv = getenv("BACNET_APDU_TIMEOUT"); - if (pEnv) { - apdu_timeout_set(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); - } else { -#if defined(BACDL_MSTP) - apdu_timeout_set(60000); -#endif - } - if (!datalink_init(getenv("BACNET_IFACE"))) { - exit(1); - } -#if defined(BACDL_BIP) && BBMD_ENABLED - pEnv = getenv("BACNET_BBMD_PORT"); - if (pEnv) { - bbmd_port = strtol(pEnv, NULL, 0); - if (bbmd_port > 0xFFFF) { - bbmd_port = 0xBAC0; - } - } - pEnv = getenv("BACNET_BBMD_TIMETOLIVE"); - if (pEnv) { - bbmd_timetolive_seconds = strtol(pEnv, NULL, 0); - if (bbmd_timetolive_seconds > 0xFFFF) { - bbmd_timetolive_seconds = 0xFFFF; - } - } - pEnv = getenv("BACNET_BBMD_ADDRESS"); - if (pEnv) { - bbmd_address = bip_getaddrbyname(pEnv); - if (bbmd_address) { - struct in_addr addr; - addr.s_addr = bbmd_address; - printf("WhoIs: Registering with BBMD at %s:%ld for %ld seconds\n", - inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); - bvlc_register_with_bbmd(bbmd_address, bbmd_port, - bbmd_timetolive_seconds); - } - } -#endif -} - int main(int argc, char *argv[]) { BACNET_ADDRESS src = { 0}; /* address where message came from */ @@ -312,7 +224,7 @@ int main(int argc, char *argv[]) { Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); Init_Service_Handlers(); address_init(); - Init_DataLink(); + dlenv_init(); /* configure the timeout values */ last_seconds = time(NULL); timeout_seconds = apdu_timeout() / 1000; diff --git a/bacnet-stack/demo/whoisrouter/main.c b/bacnet-stack/demo/whoisrouter/main.c index c6eb4ba2..63f1ac77 100644 --- a/bacnet-stack/demo/whoisrouter/main.c +++ b/bacnet-stack/demo/whoisrouter/main.c @@ -49,6 +49,7 @@ #if defined(BACDL_MSTP) #include "rs485.h" #endif +#include "dlenv.h" /* buffer used for receive */ static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; @@ -168,6 +169,11 @@ void My_NPDU_Handler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); @@ -185,99 +191,6 @@ static void Init_Service_Handlers( apdu_set_reject_handler(MyRejectHandler); } -static void Init_DataLink( - void) -{ - char *pEnv = NULL; -#if defined(BACDL_BIP) && BBMD_ENABLED - long bbmd_port = 0xBAC0; - long bbmd_address = 0; - long bbmd_timetolive_seconds = 60000; -#endif - -#if defined(BACDL_ALL) - pEnv = getenv("BACNET_DATALINK"); - if (pEnv) { - datalink_set(pEnv)); - } else { - datalink_set(NULL); - } -#endif - -#if defined(BACDL_BIP) - pEnv = getenv("BACNET_IP_PORT"); - if (pEnv) { - bip_set_port(strtol(pEnv, NULL, 0)); - } else { - bip_set_port(0xBAC0); - } -#elif defined(BACDL_MSTP) - pEnv = getenv("BACNET_MAX_INFO_FRAMES"); - if (pEnv) { - dlmstp_set_max_info_frames(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_info_frames(1); - } - pEnv = getenv("BACNET_MAX_MASTER"); - if (pEnv) { - dlmstp_set_max_master(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_master(127); - } - pEnv = getenv("BACNET_MSTP_BAUD"); - if (pEnv) { - dlmstp_set_baud_rate(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_baud_rate(38400); - } - pEnv = getenv("BACNET_MSTP_MAC"); - if (pEnv) { - dlmstp_set_mac_address(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_mac_address(127); - } -#endif - pEnv = getenv("BACNET_APDU_TIMEOUT"); - if (pEnv) { - apdu_timeout_set(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); - } else { -#if defined(BACDL_MSTP) - apdu_timeout_set(60000); -#endif - } - if (!datalink_init(getenv("BACNET_IFACE"))) { - exit(1); - } -#if defined(BACDL_BIP) && BBMD_ENABLED - pEnv = getenv("BACNET_BBMD_PORT"); - if (pEnv) { - bbmd_port = strtol(pEnv, NULL, 0); - if (bbmd_port > 0xFFFF) { - bbmd_port = 0xBAC0; - } - } - pEnv = getenv("BACNET_BBMD_TIMETOLIVE"); - if (pEnv) { - bbmd_timetolive_seconds = strtol(pEnv, NULL, 0); - if (bbmd_timetolive_seconds > 0xFFFF) { - bbmd_timetolive_seconds = 0xFFFF; - } - } - pEnv = getenv("BACNET_BBMD_ADDRESS"); - if (pEnv) { - bbmd_address = bip_getaddrbyname(pEnv); - if (bbmd_address) { - struct in_addr addr; - addr.s_addr = bbmd_address; - printf("WhoIs: Registering with BBMD at %s:%ld for %ld seconds\n", - inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); - bvlc_register_with_bbmd(bbmd_address, bbmd_port, - bbmd_timetolive_seconds); - } - } -#endif -} static void address_parse(BACNET_ADDRESS * dst, int argc, char *argv[]) { @@ -373,7 +286,7 @@ int main(int argc, char *argv[]) { Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); Init_Service_Handlers(); address_init(); - Init_DataLink(); + dlenv_init(); /* configure the timeout values */ last_seconds = time(NULL); timeout_seconds = apdu_timeout() / 1000; diff --git a/bacnet-stack/demo/writefile/main.c b/bacnet-stack/demo/writefile/main.c index 1f4bc7a4..65d8cc0f 100644 --- a/bacnet-stack/demo/writefile/main.c +++ b/bacnet-stack/demo/writefile/main.c @@ -48,6 +48,7 @@ #include "handlers.h" #include "client.h" #include "txbuf.h" +#include "dlenv.h" /* buffer used for receive */ static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; @@ -131,6 +132,11 @@ static void LocalIAmHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); @@ -150,101 +156,6 @@ static void Init_Service_Handlers( apdu_set_reject_handler(MyRejectHandler); } -static void Init_DataLink( - void) -{ - char *pEnv = NULL; -#if defined(BACDL_BIP) && BBMD_ENABLED - long bbmd_port = 0xBAC0; - long bbmd_address = 0; - long bbmd_timetolive_seconds = 60000; -#endif - -#if defined(BACDL_ALL) - pEnv = getenv("BACNET_DATALINK"); - if (pEnv) { - datalink_set(pEnv)); - } else { - datalink_set(NULL); - } -#endif - -#if defined(BACDL_BIP) - pEnv = getenv("BACNET_IP_PORT"); - if (pEnv) { - bip_set_port(strtol(pEnv, NULL, 0)); - } else { - bip_set_port(0xBAC0); - } -#elif defined(BACDL_MSTP) - pEnv = getenv("BACNET_MAX_INFO_FRAMES"); - if (pEnv) { - dlmstp_set_max_info_frames(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_info_frames(1); - } - pEnv = getenv("BACNET_MAX_MASTER"); - if (pEnv) { - dlmstp_set_max_master(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_master(127); - } - pEnv = getenv("BACNET_MSTP_BAUD"); - if (pEnv) { - dlmstp_set_baud_rate(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_baud_rate(38400); - } - pEnv = getenv("BACNET_MSTP_MAC"); - if (pEnv) { - dlmstp_set_mac_address(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_mac_address(127); - } -#endif - pEnv = getenv("BACNET_APDU_TIMEOUT"); - if (pEnv) { - apdu_timeout_set(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); - } else { -#if defined(BACDL_MSTP) - apdu_timeout_set(60000); -#endif - } - if (!datalink_init(getenv("BACNET_IFACE"))) { - exit(1); - } -#if defined(BACDL_BIP) && BBMD_ENABLED - pEnv = getenv("BACNET_BBMD_PORT"); - if (pEnv) { - bbmd_port = strtol(pEnv, NULL, 0); - if (bbmd_port > 0xFFFF) { - bbmd_port = 0xBAC0; - } - } - pEnv = getenv("BACNET_BBMD_TIMETOLIVE"); - if (pEnv) { - bbmd_timetolive_seconds = strtol(pEnv, NULL, 0); - if (bbmd_timetolive_seconds > 0xFFFF) { - bbmd_timetolive_seconds = 0xFFFF; - } - } - pEnv = getenv("BACNET_BBMD_ADDRESS"); - if (pEnv) { - bbmd_address = bip_getaddrbyname(pEnv); - if (bbmd_address) { - struct in_addr addr; - addr.s_addr = bbmd_address; - printf - ("AtomicWriteFile: Registering with BBMD at %s:%ld for %ld seconds\n", - inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); - bvlc_register_with_bbmd(bbmd_address, bbmd_port, - bbmd_timetolive_seconds); - } - } -#endif -} - int main(int argc, char *argv[]) { BACNET_ADDRESS src = { 0}; /* address where message came from */ @@ -288,7 +199,7 @@ int main(int argc, char *argv[]) { Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); address_init(); Init_Service_Handlers(); - Init_DataLink(); + dlenv_init(); /* configure the timeout values */ last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); diff --git a/bacnet-stack/demo/writeprop/main.c b/bacnet-stack/demo/writeprop/main.c index 432e4b6e..6a668f2e 100644 --- a/bacnet-stack/demo/writeprop/main.c +++ b/bacnet-stack/demo/writeprop/main.c @@ -50,6 +50,7 @@ #include "handlers.h" #include "client.h" #include "txbuf.h" +#include "dlenv.h" #ifndef MAX_PROPERTY_VALUES #define MAX_PROPERTY_VALUES 64 @@ -129,6 +130,11 @@ void MyWritePropertySimpleAckHandler( static void Init_Service_Handlers( void) { + Device_Init(); + handler_read_property_object_set( + OBJECT_DEVICE, + Device_Encode_Property_APDU, + Device_Valid_Object_Instance_Number); /* we need to handle who-is to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); @@ -150,101 +156,6 @@ static void Init_Service_Handlers( apdu_set_reject_handler(MyRejectHandler); } -static void Init_DataLink( - void) -{ - char *pEnv = NULL; -#if defined(BACDL_BIP) && BBMD_ENABLED - long bbmd_port = 0xBAC0; - long bbmd_address = 0; - long bbmd_timetolive_seconds = 60000; -#endif - -#if defined(BACDL_ALL) - pEnv = getenv("BACNET_DATALINK"); - if (pEnv) { - datalink_set(pEnv)); - } else { - datalink_set(NULL); - } -#endif - -#if defined(BACDL_BIP) - pEnv = getenv("BACNET_IP_PORT"); - if (pEnv) { - bip_set_port(strtol(pEnv, NULL, 0)); - } else { - bip_set_port(0xBAC0); - } -#elif defined(BACDL_MSTP) - pEnv = getenv("BACNET_MAX_INFO_FRAMES"); - if (pEnv) { - dlmstp_set_max_info_frames(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_info_frames(1); - } - pEnv = getenv("BACNET_MAX_MASTER"); - if (pEnv) { - dlmstp_set_max_master(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_max_master(127); - } - pEnv = getenv("BACNET_MSTP_BAUD"); - if (pEnv) { - dlmstp_set_baud_rate(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_baud_rate(38400); - } - pEnv = getenv("BACNET_MSTP_MAC"); - if (pEnv) { - dlmstp_set_mac_address(strtol(pEnv, NULL, 0)); - } else { - dlmstp_set_mac_address(127); - } -#endif - pEnv = getenv("BACNET_APDU_TIMEOUT"); - if (pEnv) { - apdu_timeout_set(strtol(pEnv, NULL, 0)); - fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); - } else { -#if defined(BACDL_MSTP) - apdu_timeout_set(60000); -#endif - } - if (!datalink_init(getenv("BACNET_IFACE"))) { - exit(1); - } -#if defined(BACDL_BIP) && BBMD_ENABLED - pEnv = getenv("BACNET_BBMD_PORT"); - if (pEnv) { - bbmd_port = strtol(pEnv, NULL, 0); - if (bbmd_port > 0xFFFF) { - bbmd_port = 0xBAC0; - } - } - pEnv = getenv("BACNET_BBMD_TIMETOLIVE"); - if (pEnv) { - bbmd_timetolive_seconds = strtol(pEnv, NULL, 0); - if (bbmd_timetolive_seconds > 0xFFFF) { - bbmd_timetolive_seconds = 0xFFFF; - } - } - pEnv = getenv("BACNET_BBMD_ADDRESS"); - if (pEnv) { - bbmd_address = bip_getaddrbyname(pEnv); - if (bbmd_address) { - struct in_addr addr; - addr.s_addr = bbmd_address; - printf - ("WriteProperty: Registering with BBMD at %s:%ld for %ld seconds\n", - inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); - bvlc_register_with_bbmd(bbmd_address, bbmd_port, - bbmd_timetolive_seconds); - } - } -#endif -} - int main(int argc, char *argv[]) { BACNET_ADDRESS src = { 0}; /* address where message came from */ @@ -411,7 +322,7 @@ int main(int argc, char *argv[]) { Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); address_init(); Init_Service_Handlers(); - Init_DataLink(); + dlenv_init(); /* configure the timeout values */ last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); diff --git a/bacnet-stack/include/ai.h b/bacnet-stack/include/ai.h index a486146d..dfc89c8d 100644 --- a/bacnet-stack/include/ai.h +++ b/bacnet-stack/include/ai.h @@ -32,10 +32,10 @@ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - void Analog_Input_Property_Lists( - const int **pRequired, - const int **pOptional, - const int **pProprietary); + void Analog_Input_Property_Lists( + const int **pRequired, + const int **pOptional, + const int **pProprietary); bool Analog_Input_Valid_Instance( uint32_t object_instance); unsigned Analog_Input_Count( diff --git a/bacnet-stack/include/ao.h b/bacnet-stack/include/ao.h index a14174d8..1dd638cd 100644 --- a/bacnet-stack/include/ao.h +++ b/bacnet-stack/include/ao.h @@ -58,7 +58,8 @@ extern "C" { bool Analog_Output_Present_Value_Relinquish( uint32_t object_instance, unsigned priority); - + + void Analog_Output_Init(void); int Analog_Output_Encode_Property_APDU( uint8_t * apdu, diff --git a/bacnet-stack/include/bacfile.h b/bacnet-stack/include/bacfile.h index 653f1121..4756a3e1 100644 --- a/bacnet-stack/include/bacfile.h +++ b/bacnet-stack/include/bacfile.h @@ -74,6 +74,8 @@ extern "C" { bool bacfile_write_stream_data( BACNET_ATOMIC_WRITE_FILE_DATA * data); + void bacfile_init(void); + /* handling for read property service */ int bacfile_encode_property_apdu( uint8_t * apdu, diff --git a/bacnet-stack/include/bv.h b/bacnet-stack/include/bv.h index d67dcf32..8ec25694 100644 --- a/bacnet-stack/include/bv.h +++ b/bacnet-stack/include/bv.h @@ -53,6 +53,9 @@ extern "C" { char *Binary_Value_Name( uint32_t object_instance); + void Binary_Value_Init( + void); + int Binary_Value_Encode_Property_APDU( uint8_t * apdu, uint32_t object_instance, diff --git a/bacnet-stack/include/device.h b/bacnet-stack/include/device.h index f09c9b7f..9c8f2ca7 100644 --- a/bacnet-stack/include/device.h +++ b/bacnet-stack/include/device.h @@ -40,10 +40,21 @@ #include "bacenum.h" #include "wp.h" +typedef unsigned (*object_count_function) (void); +typedef uint32_t (*object_index_to_instance_function) + (unsigned index); +typedef char * (*object_name_function) + (uint32_t object_instance); + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ + void Device_Object_Function_Set( + BACNET_OBJECT_TYPE object_type, + object_count_function count_function, + object_index_to_instance_function index_function, + object_name_function name_function); void Device_Init( void); @@ -127,6 +138,7 @@ extern "C" { int Device_Encode_Property_APDU( uint8_t * apdu, + uint32_t object_instance, BACNET_PROPERTY_ID property, int32_t array_index, BACNET_ERROR_CLASS * error_class, diff --git a/bacnet-stack/include/handlers.h b/bacnet-stack/include/handlers.h index 600745ae..0e6d66e2 100644 --- a/bacnet-stack/include/handlers.h +++ b/bacnet-stack/include/handlers.h @@ -31,6 +31,9 @@ #include "bacdef.h" #include "apdu.h" #include "bacapp.h" +#include "rp.h" +#include "rpm.h" +#include "wp.h" #ifdef __cplusplus extern "C" { @@ -75,9 +78,10 @@ extern "C" { void handler_read_property_object_set( BACNET_OBJECT_TYPE object_type, - read_property_function pFunction); + read_property_function pFunction1, + object_valid_instance_function pFunction2); - void handler_read_property_ack( + void handler_read_property_ack( uint8_t * service_request, uint16_t service_len, BACNET_ADDRESS * src, @@ -144,6 +148,10 @@ extern "C" { BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data); + void handler_read_property_multiple_list_set( + BACNET_OBJECT_TYPE object_type, + rpm_property_lists_function pFunction); + void handler_read_property_multiple_ack( uint8_t * service_request, uint16_t service_len, diff --git a/bacnet-stack/include/lc.h b/bacnet-stack/include/lc.h index 84352023..3f2b67ce 100644 --- a/bacnet-stack/include/lc.h +++ b/bacnet-stack/include/lc.h @@ -51,6 +51,9 @@ extern "C" { char *Load_Control_Name( uint32_t object_instance); + void Load_Control_Init( + void); + int Load_Control_Encode_Property_APDU( uint8_t * apdu, uint32_t object_instance, diff --git a/bacnet-stack/include/lsp.h b/bacnet-stack/include/lsp.h index 78fbc86b..f36167d1 100644 --- a/bacnet-stack/include/lsp.h +++ b/bacnet-stack/include/lsp.h @@ -47,6 +47,8 @@ extern "C" { unsigned index); char *Life_Safety_Point_Name( uint32_t object_instance); + void Life_Safety_Point_Init( + void); int Life_Safety_Point_Encode_Property_APDU( uint8_t * apdu, diff --git a/bacnet-stack/include/mso.h b/bacnet-stack/include/mso.h index e34570b3..bd801324 100644 --- a/bacnet-stack/include/mso.h +++ b/bacnet-stack/include/mso.h @@ -48,6 +48,9 @@ extern "C" { char *Multistate_Output_Name( uint32_t object_instance); + void Multistate_Output_Init( + void); + int Multistate_Output_Encode_Property_APDU( uint8_t * apdu, uint32_t object_instance, diff --git a/bacnet-stack/include/rp.h b/bacnet-stack/include/rp.h index c5eebc02..8558fe5b 100644 --- a/bacnet-stack/include/rp.h +++ b/bacnet-stack/include/rp.h @@ -36,6 +36,8 @@ #include #include +#include "bacdef.h" +#include "bacenum.h" typedef struct BACnet_Read_Property_Data { BACNET_OBJECT_TYPE object_type; @@ -48,11 +50,15 @@ typedef struct BACnet_Read_Property_Data { typedef int (*read_property_function) ( uint8_t * apdu, + uint32_t object_instance, BACNET_PROPERTY_ID property, int32_t array_index, BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code); +typedef bool (*object_valid_instance_function) ( + uint32_t object_instance); + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/bacnet-stack/include/rpm.h b/bacnet-stack/include/rpm.h index de09547c..9bf61151 100644 --- a/bacnet-stack/include/rpm.h +++ b/bacnet-stack/include/rpm.h @@ -49,6 +49,10 @@ typedef struct BACnet_Read_Access_Data { struct BACnet_Read_Access_Data *next; } BACNET_READ_ACCESS_DATA; +typedef void (*rpm_property_lists_function) ( + const int **pRequired, + const int **pOptional, + const int **pProprietary); #ifdef __cplusplus extern "C" { diff --git a/bacnet-stack/include/wp.h b/bacnet-stack/include/wp.h index 77176c1c..f05dad56 100644 --- a/bacnet-stack/include/wp.h +++ b/bacnet-stack/include/wp.h @@ -55,7 +55,6 @@ typedef struct BACnet_Write_Property_Data { typedef bool (*write_property_function) ( BACNET_WRITE_PROPERTY_DATA * wp_data, - uint8_t * service_request, BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code); diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/Makefile b/bacnet-stack/ports/bdk-atxx4-mstp/Makefile index c833914a..62b23581 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/Makefile +++ b/bacnet-stack/ports/bdk-atxx4-mstp/Makefile @@ -29,9 +29,9 @@ LINT = splint # avr109 = bootloader #AVRDUDE_PROGRAMMERID = avr109 #AVRDUDE_PROGRAMMERID = jtag2fast -#AVRDUDE_PROGRAMMERID = avrispmkII +AVRDUDE_PROGRAMMERID = avrispmkII #AVRDUDE_PROGRAMMERID = dragon_isp -AVRDUDE_PROGRAMMERID = dragon_jtag +#AVRDUDE_PROGRAMMERID = dragon_jtag # # port--serial or parallel port to which your # hardware programmer is attached