Feature/add who am i and you are services (#1024)
* Added Who-Am-I-Request encoding, decoding, unit tests, and command line application bacwhoami. * Added You-Are-Request encoding, decoding, unit tests, and command line application bacyouare. * Added Who-Am-I with Who-Is and You-Are handling into the example server application when run as device 4194303.
This commit is contained in:
+26
-5
@@ -174,10 +174,9 @@ static void Init_Service_Handlers(void)
|
||||
(unsigned)object_data.object_instance);
|
||||
}
|
||||
}
|
||||
/* update structured view with this device instance */
|
||||
Structured_View_Update();
|
||||
/* we need to handle who-is to support dynamic device binding */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
apdu_set_unconfirmed_handler(
|
||||
SERVICE_UNCONFIRMED_WHO_IS, handler_who_is_who_am_i_unicast);
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
|
||||
/* set the handler for all the services we don't implement */
|
||||
/* It is required to send the proper reject message... */
|
||||
@@ -206,6 +205,8 @@ static void Init_Service_Handlers(void)
|
||||
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, handler_timesync_utc);
|
||||
apdu_set_unconfirmed_handler(
|
||||
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, handler_timesync);
|
||||
apdu_set_unconfirmed_handler(
|
||||
SERVICE_UNCONFIRMED_YOU_ARE, handler_you_are_json_print);
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_SUBSCRIBE_COV, handler_cov_subscribe);
|
||||
apdu_set_unconfirmed_handler(
|
||||
@@ -292,6 +293,7 @@ int main(int argc, char *argv[])
|
||||
uint32_t elapsed_milliseconds = 0;
|
||||
uint32_t elapsed_seconds = 0;
|
||||
BACNET_CHARACTER_STRING DeviceName;
|
||||
uint32_t device_id = 0xFFFFFFFF;
|
||||
#if defined(BACNET_TIME_MASTER)
|
||||
BACNET_DATE_TIME bdatetime;
|
||||
#endif
|
||||
@@ -375,10 +377,29 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
dlenv_init();
|
||||
atexit(datalink_cleanup);
|
||||
/* broadcast an I-Am on startup */
|
||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||
#if BACNET_PROTOCOL_REVISION >= 22
|
||||
if (Device_Object_Instance_Number() == BACNET_MAX_INSTANCE) {
|
||||
apdu_set_unconfirmed_handler(
|
||||
SERVICE_UNCONFIRMED_YOU_ARE, handler_you_are_device_id_set);
|
||||
/* The Who-Am-I service is used by a sending BACnet-user
|
||||
to indicate that it requires identity configuration
|
||||
via the You-Are service. */
|
||||
Send_Who_Am_I_Broadcast(
|
||||
Device_Vendor_Identifier(), Device_Model_Name(),
|
||||
Device_Serial_Number());
|
||||
}
|
||||
#endif
|
||||
/* loop forever */
|
||||
for (;;) {
|
||||
if (device_id != Device_Object_Instance_Number()) {
|
||||
device_id = Device_Object_Instance_Number();
|
||||
/* update structured view with this device instance */
|
||||
Structured_View_Update();
|
||||
if (Device_Object_Instance_Number() != BACNET_MAX_INSTANCE) {
|
||||
/* broadcast an I-Am on startup */
|
||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||
}
|
||||
}
|
||||
/* input */
|
||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user