@@ -583,10 +583,19 @@ int main(int argc, char** argv)
583583 ipPortConcat[4 ] = g_database.networkPort .BACnetIPUDPPort / 256 ;
584584 ipPortConcat[5 ] = g_database.networkPort .BACnetIPUDPPort % 256 ;
585585 fpAddBDTEntry (ipPortConcat, 6 , g_database.networkPort .IPSubnetMask , 4 ); // First BDT Entry must be server device
586- fpSetBBMD (g_database. device . instance , g_database. networkPort . instance );
586+
587587
588588 std::cout << " OK" << std::endl;
589+
590+ // Add the DateTimeValue Object
591+ std::cout << " Added DateTimeValue. dateTimeValue.instance=[" << g_database.dateTimeValue .instance << " ]... " ;
592+ if (!fpAddObject (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_DATETIME_VALUE, g_database.dateTimeValue .instance )) {
593+ std::cerr << " Failed to add DateTimeValue" << std::endl;
594+ return -1 ;
595+ }
589596
597+ std::cout << " OK" << std::endl;
598+
590599 // 5. Send I-Am of this device
591600 // ---------------------------------------------------------------------------
592601 // To be a good citizen on a BACnet network. We should announce ourself when we start up.
@@ -1116,6 +1125,17 @@ bool CallbackGetPropertyDate(const uint32_t deviceInstance, const uint16_t objec
11161125 return true ;
11171126 }
11181127 }
1128+ // Example of DateTime Value Object Present Value property
1129+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_DATETIME_VALUE && objectInstance == 60 ) {
1130+ if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_PRESENT_VALUE) {
1131+ *year = g_database.dateTimeValue .presentValueYear ;
1132+ *month = g_database.dateTimeValue .presentValueMonth ;
1133+ *day = g_database.dateTimeValue .presentValueDay ;
1134+ *weekday = g_database.dateTimeValue .presentValueWeekDay ;
1135+ return true ;
1136+ }
1137+ }
1138+
11191139 return false ;
11201140}
11211141
@@ -1365,6 +1385,16 @@ bool CallbackGetPropertyTime(const uint32_t deviceInstance, const uint16_t objec
13651385 return true ;
13661386 }
13671387 }
1388+ // Example of DateTime Value Object Present Value property
1389+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_DATETIME_VALUE && objectInstance == 60 ) {
1390+ if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_PRESENT_VALUE) {
1391+ *hour = g_database.dateTimeValue .presentValueHour ;
1392+ *minute = g_database.dateTimeValue .presentValueMinute ;
1393+ *second = g_database.dateTimeValue .presentValueSecond ;
1394+ *hundrethSeconds = g_database.dateTimeValue .presentValueHundredthSeconds ;
1395+ return true ;
1396+ }
1397+ }
13681398 return false ;
13691399}
13701400
@@ -2009,6 +2039,16 @@ bool GetObjectName(const uint32_t deviceInstance, const uint16_t objectType, con
20092039 *valueElementCount = (uint32_t ) stringSize;
20102040 return true ;
20112041 }
2042+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_DATETIME_VALUE && objectInstance == g_database.dateTimeValue .instance ) {
2043+ stringSize = g_database.dateTimeValue .objectName .size ();
2044+ if (stringSize > maxElementCount) {
2045+ std::cerr << " Error - not enough space to store full name of objectType=[" << objectType << " ], objectInstance=[" << objectInstance <<" ]" << std::endl;
2046+ return false ;
2047+ }
2048+ memcpy (value, g_database.dateTimeValue .objectName .c_str (), stringSize);
2049+ *valueElementCount = (uint32_t ) stringSize;
2050+ return true ;
2051+ }
20122052 else {
20132053 // Check if the value is an Analog Value and check if it was a created object
20142054 if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_VALUE && g_database.CreatedAnalogValueData .count (objectInstance) > 0 ) {
0 commit comments