@@ -79,7 +79,7 @@ std::string downstream_Device_ip_address;
7979
8080// Callback Functions to Register to the DLL
8181// Message Functions
82- uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * receivedConnectionString, const uint8_t maxConnectionStringLength , uint8_t * receivedConnectionStringLength , uint8_t * networkType);
82+ uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * sourceConnectionString, uint8_t * sourceConnectionStringLength, uint8_t * destinationConnectionString , uint8_t * destinationConnectionStringLength, const uint8_t maxConnectionStringLength , uint8_t * networkType);
8383uint16_t CallbackSendMessage (const uint8_t * message, const uint16_t messageLength, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint8_t networkType, bool broadcast);
8484
8585// System Functions
@@ -126,6 +126,7 @@ void ExampleWhoIs();
126126void ExampleReadProperty ();
127127void ExampleWriteProperty ();
128128void ExampleSubscribeCOV ();
129+ void ExampleSubscribeCOVProperty ();
129130void ExampleConfirmedTextMessage ();
130131
131132int main (int argc, char ** argv )
@@ -242,7 +243,7 @@ int main(int argc, char ** argv )
242243 std::cout << " FYI: Entering main loop..." << std::endl;
243244 for (;;) {
244245 // Call the DLLs loop function which checks for messages and processes them.
245- fpLoop ();
246+ fpTick ();
246247
247248 // Handle any user input.
248249 if (!DoUserInput ()) {
@@ -291,6 +292,10 @@ bool DoUserInput()
291292 ExampleSubscribeCOV ();
292293 break ;
293294 }
295+ case ' p' : {
296+ ExampleSubscribeCOVProperty ();
297+ break ;
298+ }
294299 case ' t' : {
295300 ExampleConfirmedTextMessage ();
296301 break ;
@@ -325,7 +330,7 @@ bool DoUserInput()
325330void WaitForResponse (unsigned int timeout /* =3*/ ) {
326331 time_t expireTime = time (0 ) + timeout;
327332 while (time (0 ) < expireTime) {
328- fpLoop ();
333+ fpTick ();
329334 }
330335}
331336
@@ -437,7 +442,7 @@ void ExampleSubscribeCOV() {
437442
438443 // Subscribe to the analog input and analog value objects in the server example
439444
440- std::cout << " Sending Subscribe COV Request. Analog Input, INSTANCE=[0], timeToLive = " << timeToLive << " , processIdentifier = " << analogValueProcessIdentifier << std::endl;
445+ std::cout << " Sending Subscribe COV Request. Analog Input, INSTANCE=[0], timeToLive = " << timeToLive << " , processIdentifier = " << analogInputProcessIdentifier << std::endl;
441446 fpSendSubscribeCOV (&invokeId, analogInputProcessIdentifier, CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, 0 , false , timeToLive, downstreamConnectionString, 6 , 0 , 0 , NULL , 0 );
442447
443448 WaitForResponse ();
@@ -448,6 +453,18 @@ void ExampleSubscribeCOV() {
448453 WaitForResponse ();
449454}
450455
456+ void ExampleSubscribeCOVProperty () {
457+ const uint16_t timeToLive = 60 * 5 ; // 5 Min subscription time
458+
459+ // Local process identifier, must be unique for each subscribe COV request
460+ const uint16_t analogValueProcessIdentifier = 0 ;
461+
462+ // Subscribe to the analog input and analog value objects in the server example
463+
464+ std::cout << " Sending Subscribe COV Property Request. Analog Value, INSTANCE=[2], timeToLive = " << timeToLive << " , processIdentifier = " << analogValueProcessIdentifier << std::endl;
465+ fpSendSubscribeCOVProperty (&invokeId, analogValueProcessIdentifier, CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_VALUE, 2 , CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_PRESENT_VALUE, false , 0 , true , 5 .0f , false , timeToLive, downstreamConnectionString, 6 , 0 , 0 , NULL , 0 );
466+ }
467+
451468void ExampleConfirmedTextMessage () {
452469 // Text message settings
453470 bool useMessageClass = true ; // Enable or disable message class property
@@ -471,14 +488,14 @@ void ExampleConfirmedTextMessage() {
471488
472489
473490// Callback used by the BACnet Stack to check if there is a message to process
474- uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * receivedConnectionString, const uint8_t maxConnectionStringLength , uint8_t * receivedConnectionStringLength , uint8_t * networkType)
491+ uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * sourceConnectionString, uint8_t * sourceConnectionStringLength, uint8_t * destinationConnectionString , uint8_t * destinationConnectionStringLength, const uint8_t maxConnectionStringLength , uint8_t * networkType)
475492{
476493 // Check parameters
477494 if (message == NULL || maxMessageLength == 0 ) {
478495 std::cerr << " Invalid input buffer" << std::endl;
479496 return 0 ;
480497 }
481- if (receivedConnectionString == NULL || maxConnectionStringLength == 0 ) {
498+ if (sourceConnectionString == NULL || maxConnectionStringLength == 0 ) {
482499 std::cerr << " Invalid connection string buffer" << std::endl;
483500 return 0 ;
484501 }
@@ -497,14 +514,14 @@ uint16_t CallbackReceiveMessage(uint8_t* message, const uint16_t maxMessageLengt
497514 std::cout << " FYI: Received message from [" << ipAddress << " :" << port << " ], length [" << bytesRead << " ]" << std::endl;
498515
499516 // Convert the IP Address to the connection string
500- if (!ChipkinCommon::ChipkinConvert::IPAddressToBytes (ipAddress, receivedConnectionString , maxConnectionStringLength)) {
517+ if (!ChipkinCommon::ChipkinConvert::IPAddressToBytes (ipAddress, sourceConnectionString , maxConnectionStringLength)) {
501518 std::cerr << " Failed to convert the ip address into a connectionString" << std::endl;
502519 return 0 ;
503520 }
504- receivedConnectionString [4 ] = port / 256 ;
505- receivedConnectionString [5 ] = port % 256 ;
521+ sourceConnectionString [4 ] = port / 256 ;
522+ sourceConnectionString [5 ] = port % 256 ;
506523
507- *receivedConnectionStringLength = 6 ;
524+ *sourceConnectionStringLength = 6 ;
508525 *networkType = CASBACnetStackExampleConstants::NETWORK_TYPE_IP;
509526
510527 // Process the message as XML
@@ -568,7 +585,7 @@ uint16_t CallbackSendMessage(const uint8_t* message, const uint16_t messageLengt
568585
569586 // Get the XML rendered version of the just sent message
570587 static char xmlRenderBuffer[MAX_XML_RENDER_BUFFER_LENGTH];
571- if (fpDecodeAsXML ((char *)message, messageLength, xmlRenderBuffer, MAX_XML_RENDER_BUFFER_LENGTH, networkType ) > 0 ) {
588+ if (fpDecodeAsXML ((char *)message, messageLength, xmlRenderBuffer, MAX_XML_RENDER_BUFFER_LENGTH, CASBACnetStackExampleConstants::NETWORK_TYPE_IP ) > 0 ) {
572589 std::cout << xmlRenderBuffer << std::endl << std::endl;
573590 memset (xmlRenderBuffer, 0 , MAX_XML_RENDER_BUFFER_LENGTH);
574591 }
0 commit comments