@@ -583,10 +583,19 @@ int main(int argc, char** argv)
583
583
ipPortConcat[4 ] = g_database.networkPort .BACnetIPUDPPort / 256 ;
584
584
ipPortConcat[5 ] = g_database.networkPort .BACnetIPUDPPort % 256 ;
585
585
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
+
587
587
588
588
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
+ }
589
596
597
+ std::cout << " OK" << std::endl;
598
+
590
599
// 5. Send I-Am of this device
591
600
// ---------------------------------------------------------------------------
592
601
// 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
1116
1125
return true ;
1117
1126
}
1118
1127
}
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
+
1119
1139
return false ;
1120
1140
}
1121
1141
@@ -1365,6 +1385,16 @@ bool CallbackGetPropertyTime(const uint32_t deviceInstance, const uint16_t objec
1365
1385
return true ;
1366
1386
}
1367
1387
}
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
+ }
1368
1398
return false ;
1369
1399
}
1370
1400
@@ -2009,6 +2039,16 @@ bool GetObjectName(const uint32_t deviceInstance, const uint16_t objectType, con
2009
2039
*valueElementCount = (uint32_t ) stringSize;
2010
2040
return true ;
2011
2041
}
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
+ }
2012
2052
else {
2013
2053
// Check if the value is an Analog Value and check if it was a created object
2014
2054
if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_VALUE && g_database.CreatedAnalogValueData .count (objectInstance) > 0 ) {
0 commit comments