Added time properties and missing revision properties to the Device Object.

This commit is contained in:
skarg
2006-05-05 19:53:50 +00:00
parent a17336780b
commit fb6fbe630e
+42 -26
View File
@@ -67,10 +67,11 @@ static char Description[16] = "server";
/* static uint8_t Max_Segments_Accepted = 0; */ /* static uint8_t Max_Segments_Accepted = 0; */
/* VT_Classes_Supported */ /* VT_Classes_Supported */
/* Active_VT_Sessions */ /* Active_VT_Sessions */
/* Local_Time - rely on OS, if there is one */ BACNET_TIME Local_Time; /* rely on OS, if there is one */
/* Local_Date - rely on OS, if there is one */ BACNET_DATE Local_Date; /* rely on OS, if there is one */
/* UTC_Offset - rely on OS, if there is one */ /* BACnet UTC is inverse of standard offset - i.e. relative to local */
/* Daylight_Savings_Status - rely on OS, if there is one */ static int UTC_Offset = 5;
static bool Daylight_Savings_Status = false; /* rely on OS */
/* APDU_Segment_Timeout */ /* APDU_Segment_Timeout */
static uint16_t APDU_Timeout = 3000; static uint16_t APDU_Timeout = 3000;
static uint8_t Number_Of_APDU_Retries = 3; static uint8_t Number_Of_APDU_Retries = 3;
@@ -270,7 +271,7 @@ uint8_t Device_Protocol_Version(void)
uint8_t Device_Protocol_Revision(void) uint8_t Device_Protocol_Revision(void)
{ {
return 4; return 5;
} }
uint16_t Device_Max_APDU_Length_Accepted(void) uint16_t Device_Max_APDU_Length_Accepted(void)
@@ -540,30 +541,41 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
Application_Software_Version); Application_Software_Version);
apdu_len = encode_tagged_character_string(&apdu[0], &char_string); apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break; break;
/* if you support time */ /* FIXME: if you support time */
/*case PROP_LOCAL_TIME: */ case PROP_LOCAL_TIME:
/*t = time(NULL); */ /* FIXME: get the actual value */
/*my_tm = localtime(&t); */ Local_Time.hour = 7;
/*apdu_len = */ Local_Time.min = 0;
/* encode_tagged_time(&apdu[0], my_tm->tm_hour, my_tm->tm_min, */ Local_Time.sec = 3;
/* my_tm->tm_sec, 0); */ Local_Time.hundredths = 1;
/*break; */ apdu_len =
/* if you support date */ encode_tagged_time(&apdu[0], &Local_Time);
/*case PROP_LOCAL_DATE: */ break;
/*t = time(NULL); */ /* FIXME: if you support time */
/*my_tm = localtime(&t); */ case PROP_UTC_OFFSET:
/* month 1=Jan */ /* NOTE: if your UTC offset is -5, then BACnet UTC offset is 5 */
/* day = day of month */ apdu_len = encode_tagged_signed(&apdu[0], UTC_Offset);
/* wday 1=Monday...7=Sunday */ break;
/*apdu_len = encode_tagged_date(&apdu[0], */ /* FIXME: if you support date */
/* my_tm->tm_year+1900, */ case PROP_LOCAL_DATE:
/* my_tm->tm_mon + 1, */ /* FIXME: get the actual value instead of April Fool's Day */
/* my_tm->tm_mday, ((my_tm->tm_wday == 0) ? 7 : my_tm->tm_wday)); */ Local_Date.year = 2006; /* AD */
/*break; */ Local_Date.month = 4; /* 1=Jan */
Local_Date.day = 1; /* 1..31 */
Local_Date.wday = 6; /* 1=Monday */
apdu_len = encode_tagged_date(&apdu[0],&Local_Date);
break;
case PROP_DAYLIGHT_SAVINGS_STATUS:
apdu_len = encode_tagged_boolean(&apdu[0], Daylight_Savings_Status);
break;
case PROP_PROTOCOL_VERSION: case PROP_PROTOCOL_VERSION:
apdu_len = apdu_len =
encode_tagged_unsigned(&apdu[0], Device_Protocol_Version()); encode_tagged_unsigned(&apdu[0], Device_Protocol_Version());
break; break;
case PROP_PROTOCOL_REVISION:
apdu_len =
encode_tagged_unsigned(&apdu[0], Device_Protocol_Revision());
break;
/* BACnet Legacy Support */ /* BACnet Legacy Support */
case PROP_PROTOCOL_CONFORMANCE_CLASS: case PROP_PROTOCOL_CONFORMANCE_CLASS:
apdu_len = encode_tagged_unsigned(&apdu[0], 1); apdu_len = encode_tagged_unsigned(&apdu[0], 1);
@@ -666,7 +678,11 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
encode_tagged_unsigned(&apdu[0], Number_Of_APDU_Retries); encode_tagged_unsigned(&apdu[0], Number_Of_APDU_Retries);
break; break;
case PROP_DEVICE_ADDRESS_BINDING: case PROP_DEVICE_ADDRESS_BINDING:
/* encode the list here, if it exists */ /* FIXME: encode the list here, if it exists */
break;
case PROP_DATABASE_REVISION:
apdu_len =
encode_tagged_unsigned(&apdu[0], Database_Revision);
break; break;
default: default:
*error_class = ERROR_CLASS_PROPERTY; *error_class = ERROR_CLASS_PROPERTY;