@@ -112,6 +112,9 @@ void HookPropertyReal(const uint32_t originalInvokeId, const uint8_t service, co
112112void HookPropertyTime (const uint32_t originalInvokeId, const uint8_t service, const uint16_t objectType, const uint32_t objectInstance, const uint32_t propertyIdentifier, const bool usePropertyArrayIndex, const uint32_t propertyArrayIndex, const uint8_t hour, const uint8_t minute, const uint8_t second, const uint8_t hundrethSecond, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint8_t networkType, const uint16_t network, const uint8_t * sourceAddress, const uint8_t sourceAddressLength);
113113void HookPropertyUInt (const uint32_t originalInvokeId, const uint8_t service, const uint16_t objectType, const uint32_t objectInstance, const uint32_t propertyIdentifier, const bool usePropertyArrayIndex, const uint32_t propertyArrayIndex, const uint32_t value, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint8_t networkType, const uint16_t network, const uint8_t * sourceAddress, const uint8_t sourceAddressLength);
114114
115+ // Hooks for device management
116+ bool HookTextMessage (const uint32_t sourceDeviceIdentifier, const bool useMessageClass, const uint32_t messageClassUnsigned, const char * messageClassString, const uint32_t messageClassStringLength, const uint8_t messagePriority, const char * message, const uint32_t messageLength, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint8_t networkType, const uint16_t sourceNetwork, const uint8_t * sourceAddress, const uint8_t sourceAddressLength, uint16_t * errorClass, uint16_t * errorCode);
117+
115118// Helper functions
116119bool DoUserInput ();
117120void WaitForResponse (unsigned int timeout=3 );
@@ -123,6 +126,7 @@ void ExampleWhoIs();
123126void ExampleReadProperty ();
124127void ExampleWriteProperty ();
125128void ExampleSubscribeCOV ();
129+ void ExampleConfirmedTextMessage ();
126130
127131int main (int argc, char ** argv )
128132{
@@ -198,6 +202,9 @@ int main(int argc, char ** argv )
198202 fpRegisterHookPropertyTime (HookPropertyTime);
199203 fpRegisterHookPropertyUInt (HookPropertyUInt);
200204
205+ // Hooks for device management
206+ fpRegisterHookTextMessage (HookTextMessage);
207+
201208 // 4. Setup the BACnet device
202209 // ---------------------------------------------------------------------------
203210 std::cout << " Setting up client device. device.instance=[" << SETTING_CLIENT_DEVICE_INSTANCE << " ]" << std::endl;
@@ -284,6 +291,10 @@ bool DoUserInput()
284291 ExampleSubscribeCOV ();
285292 break ;
286293 }
294+ case ' t' : {
295+ ExampleConfirmedTextMessage ();
296+ break ;
297+ }
287298 default : {
288299 // Print the Help
289300 std::cout << std::endl << std::endl;
@@ -299,6 +310,7 @@ bool DoUserInput()
299310 std::cout << " - R - Send Read property messages" << std::endl;
300311 std::cout << " - U - Send Write property messages" << std::endl;
301312 std::cout << " - C - Send Subscribe COV Request" << std::endl;
313+ std::cout << " - T - Send Confirmed Text Message Request" << std::endl;
302314 std::cout << std::endl;
303315 break ;
304316 }
@@ -436,6 +448,22 @@ void ExampleSubscribeCOV() {
436448 WaitForResponse ();
437449}
438450
451+ void ExampleConfirmedTextMessage () {
452+ // Text message settings
453+ bool useMessageClass = true ; // Enable or disable message class property
454+ uint32_t messageClassUnsigned = 5 ;
455+ char messageClassString[] = " " ;
456+ uint8_t messagePriority = 0 ; // 0 = normal, 1 = urgent
457+ char message[] = " Hello from the C++ client example" ;
458+
459+ // Send confirmed text message request
460+ // C++ server example configured to handle and send response (+) with default settings
461+ std::cout << " Sending Confirmed Text Message" ;
462+ fpSendConfirmedTextMessage (&invokeId, SETTING_CLIENT_DEVICE_INSTANCE, useMessageClass, messageClassUnsigned, messageClassString, strlen (messageClassString), messagePriority, message, strlen (message), downstreamConnectionString, 6 , 0 , 0 , NULL , 0 );
463+
464+ WaitForResponse ();
465+ }
466+
439467
440468// ================================================================================================
441469// Callbacks
@@ -896,3 +924,16 @@ void HookPropertyUInt(const uint32_t originalInvokeId, const uint8_t service, co
896924 HelperPrintCommonHookParameters (connectionString, connectionStringLength, networkType, network, sourceAddress, sourceAddressLength);
897925 std::cout << std::endl;
898926}
927+
928+ bool HookTextMessage (const uint32_t sourceDeviceIdentifier, const bool useMessageClass, const uint32_t messageClassUnsigned, const char * messageClassString, const uint32_t messageClassStringLength, const uint8_t messagePriority, const char * message, const uint32_t messageLength, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint8_t networkType, const uint16_t sourceNetwork, const uint8_t * sourceAddress, const uint8_t sourceAddressLength, uint16_t * errorClass, uint16_t * errorCode) {
929+ // Used to read text messages
930+ std::cout << " HookTextMessage. sourceDeviceIdentifier=[" << sourceDeviceIdentifier << " ], useMessageClass=[" << useMessageClass << " ], messageClassString=[" << messageClassString << " ], messageClassStringLength=[" << messageClassStringLength << " ], messagePriority=[" << messagePriority << " ], message=[" << message << " ], messageLength=[" << messageLength << " ], " ;
931+ std::cout << " networkType=[" << (int )networkType << " ], " ;
932+ std::cout << " connectionString=[" << (int )connectionString[0 ] << " ." << (int )connectionString[1 ] << " ." << (int )connectionString[2 ] << " ." << (int )connectionString[3 ] << " :" << ((connectionString[4 ] * 256 ) + connectionString[5 ]) << " ], " ;
933+
934+ // Errors and return value unused for unconfirmed service requests
935+ *errorClass = 0 ;
936+ *errorCode = 0 ;
937+ return true ;
938+ }
939+
0 commit comments