Got rid of the handler-set functions for RP,RPM,WP,RD. Just referencing the device object functions directly.

This commit is contained in:
skarg
2010-02-18 03:06:03 +00:00
parent 2b2077a329
commit 1f9c13d37b
10 changed files with 196 additions and 237 deletions
+35 -52
View File
@@ -53,6 +53,12 @@ static char My_Object_Name[32] = "ARM7 Device";
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
static BACNET_REINITIALIZED_STATE_OF_DEVICE Reinitialize_State =
REINITIALIZED_STATE_IDLE;
/* forward prototypes */
int Device_Read_Property_Local(
BACNET_READ_PROPERTY_DATA *rpdata);
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data);
static struct object_functions {
BACNET_OBJECT_TYPE Object_Type;
@@ -72,8 +78,8 @@ static struct object_functions {
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Name,
Device_Read_Property,
Device_Write_Property,
Device_Read_Property_Local,
Device_Write_Property_Local,
Device_Property_Lists},
{OBJECT_ANALOG_INPUT,
Analog_Input_Init,
@@ -169,7 +175,7 @@ void Device_Property_Lists(
/* Encodes the property APDU and returns the length,
or sets the error, and returns -1 */
int Device_Objects_Read_Property(
int Device_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = -1;
@@ -207,7 +213,7 @@ int Device_Objects_Read_Property(
return apdu_len;
}
bool Device_Objects_Write_Property(
bool Device_Write_Property(
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
int apdu_len = -1;
@@ -264,7 +270,7 @@ static unsigned property_list_count(
}
/* for a given object type, returns the special property list */
static void Device_Objects_Property_List(
void Device_Objects_Property_List(
BACNET_OBJECT_TYPE object_type,
struct special_property_list_t *pPropertyList)
{
@@ -431,46 +437,6 @@ char *Device_Valid_Object_Id(
return name;
}
bool Device_Reinitialize(
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
{
bool status = false;
if (characterstring_ansi_same(&rd_data->password, "Jesus")) {
switch (rd_data->state) {
case REINITIALIZED_STATE_COLD_START:
break;
case REINITIALIZED_STATE_WARM_START:
break;
case REINITIALIZED_STATE_START_BACKUP:
break;
case REINITIALIZED_STATE_END_BACKUP:
break;
case REINITIALIZED_STATE_START_RESTORE:
break;
case REINITIALIZED_STATE_END_RESTORE:
break;
case REINITIALIZED_STATE_ABORT_RESTORE:
break;
default:
break;
}
Reinitialize_State = rd_data->state;
/* Note: you could use a mix of state
and password to multiple things */
/* note: you probably want to restart *after* the
simple ack has been sent from the return handler
so just set a flag from here */
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
status = true;
} else {
rd_data->error_class = ERROR_CLASS_SECURITY;
rd_data->error_code = ERROR_CODE_PASSWORD_FAILURE;
}
return status;
}
unsigned Device_Count(void)
{
return 1;
@@ -492,6 +458,28 @@ char *Device_Name(
return NULL;
}
bool Device_Reinitialize(
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
{
bool status = false;
if (characterstring_ansi_same(&rd_data->password, "filister")) {
Reinitialize_State = rd_data->state;
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
/* Note: you could use a mix of state
and password to multiple things */
/* note: you probably want to restart *after* the
simple ack has been sent from the return handler
so just set a flag from here */
status = true;
} else {
rd_data->error_class = ERROR_CLASS_SECURITY;
rd_data->error_code = ERROR_CODE_PASSWORD_FAILURE;
}
return status;
}
void Device_Init(
void)
{
@@ -505,11 +493,6 @@ void Device_Init(
(char *)&Object_Instance_Number,
sizeof(Object_Instance_Number),
EEPROM_BACNET_ID_ADDR); */
handler_read_property_function_set(Device_Objects_Read_Property);
handler_rpm_function_set(Device_Objects_Read_Property);
handler_rpm_list_set(Device_Objects_Property_List);
handler_write_property_function_set(Device_Objects_Write_Property);
handler_reinitialize_device_function_set(Device_Reinitialize);
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Init) {
@@ -604,7 +587,7 @@ uint32_t Device_Database_Revision(
}
/* return the length of the apdu encoded or -1 for error */
int Device_Read_Property(
int Device_Read_Property_Local(
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = 0; /* return value */
@@ -853,7 +836,7 @@ int Device_Read_Property(
return apdu_len;
}
bool Device_Write_Property(
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
bool status = false; /* return value */
+4 -4
View File
@@ -59,7 +59,6 @@ CSRC = main.c \
eeprom.c \
seeprom.c \
dlmstp.c \
h_rd.c \
device.c \
ai.c \
av.c \
@@ -68,13 +67,14 @@ CSRC = main.c \
# common demo files needed
DEMOSRC = $(BACNET_DEMO)/handler/txbuf.c \
$(BACNET_DEMO)/handler/h_npdu.c \
$(BACNET_DEMO)/handler/h_whois.c \
$(BACNET_DEMO)/handler/h_dcc.c \
$(BACNET_DEMO)/handler/h_wp.c \
$(BACNET_DEMO)/handler/h_npdu.c \
$(BACNET_DEMO)/handler/h_rd.c \
$(BACNET_DEMO)/handler/h_rp.c \
$(BACNET_DEMO)/handler/h_rpm.c \
$(BACNET_DEMO)/handler/h_whohas.c \
$(BACNET_DEMO)/handler/h_whois.c \
$(BACNET_DEMO)/handler/h_wp.c \
$(BACNET_DEMO)/handler/s_iam.c \
$(BACNET_DEMO)/handler/s_ihave.c \
$(BACNET_DEMO)/handler/noserv.c
+31 -19
View File
@@ -46,6 +46,11 @@
#include "bi.h"
#include "bo.h"
/* forward prototype */
int Device_Read_Property_Local(
BACNET_READ_PROPERTY_DATA *rpdata);
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data);
static struct object_functions {
BACNET_OBJECT_TYPE Object_Type;
@@ -65,8 +70,8 @@ static struct object_functions {
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Name,
Device_Read_Property,
Device_Write_Property,
Device_Read_Property_Local,
Device_Write_Property_Local,
Device_Property_Lists},
{OBJECT_ANALOG_INPUT,
Analog_Input_Init,
@@ -225,7 +230,7 @@ static int Read_Property_Common(
/* Encodes the property APDU and returns the length,
or sets the error, and returns -1 */
int Device_Objects_Read_Property(
int Device_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = -1;
@@ -249,7 +254,7 @@ int Device_Objects_Read_Property(
return apdu_len;
}
bool Device_Objects_Write_Property(
bool Device_Write_Property(
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
int apdu_len = -1;
@@ -294,7 +299,7 @@ static unsigned property_list_count(
}
/* for a given object type, returns the special property list */
static void Device_Objects_Property_List(
void Device_Objects_Property_List(
BACNET_OBJECT_TYPE object_type,
struct special_property_list_t *pPropertyList)
{
@@ -366,11 +371,26 @@ char *Device_Name(
return NULL;
}
void Device_Reinit(
void)
bool Device_Reinitialize(
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
{
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
bool status = false;
if (characterstring_ansi_same(&rd_data->password, "rehmite")) {
Reinitialize_State = rd_data->state;
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
/* Note: you could use a mix of state
and password to multiple things */
/* note: you probably want to restart *after* the
simple ack has been sent from the return handler
so just set a flag from here */
status = true;
} else {
rd_data->error_class = ERROR_CLASS_SECURITY;
rd_data->error_code = ERROR_CODE_PASSWORD_FAILURE;
}
return status;
}
void Device_Init(
@@ -378,11 +398,6 @@ void Device_Init(
{
struct object_functions *pObject = NULL;
handler_read_property_function_set(Device_Objects_Read_Property);
handler_rpm_function_set(Device_Objects_Read_Property);
handler_rpm_list_set(Device_Objects_Property_List);
handler_write_property_function_set(Device_Objects_Write_Property);
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Init) {
@@ -390,9 +405,6 @@ void Device_Init(
}
pObject++;
}
Reinitialize_State = REINITIALIZED_STATE_IDLE;
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
/* Get the data from the eeprom */
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & Object_Instance_Number,
@@ -598,7 +610,7 @@ char *Device_Valid_Object_Id(
}
/* return the length of the apdu encoded or -1 for error */
int Device_Read_Property(
int Device_Read_Property_Local(
BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = 0; /* return value */
@@ -796,7 +808,7 @@ int Device_Read_Property(
return apdu_len;
}
bool Device_Write_Property(
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
bool status = false; /* return value */