diff --git a/bacnet-stack/demo/readrange/main.c b/bacnet-stack/demo/readrange/main.c index 8b6ffbb5..e9403478 100644 --- a/bacnet-stack/demo/readrange/main.c +++ b/bacnet-stack/demo/readrange/main.c @@ -22,6 +22,8 @@ * *********************************************************************/ +#define PRINT_ENABLED 1 + /* command line tool that sends a BACnet service, and displays the reply */ #include #include @@ -52,6 +54,19 @@ #include "dlenv.h" #include "mydata.h" #include "readrange.h" +#include "bactext.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" #if defined(__BORLANDC__) #define _kbhit kbhit @@ -120,6 +135,159 @@ void MyRejectHandler( /* Error_Detected = true; */ } +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_MULTI_STATE_OUTPUT, + 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) { @@ -127,14 +295,18 @@ static void Init_Service_Handlers( to support dynamic device binding to us */ apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is); /* handle i-am to support binding to other devices */ +#if 0 apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_bind); +#else + apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_add); +#endif /* set the handler for all the services we don't implement It is required to send the proper reject message... */ apdu_set_unrecognized_service_handler_handler (handler_unrecognized_service); /* we must implement read property - it's required! */ apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property); - + apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE, handler_read_property_multiple); apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_RANGE, handler_read_range); apdu_set_confirmed_handler(SERVICE_CONFIRMED_PRIVATE_TRANSFER, handler_conf_private_trans); /* handle the data coming back from confirmed requests */ @@ -210,6 +382,7 @@ int main( else Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE); + Init_Objects(); address_init(); Init_Service_Handlers(); dlenv_init();