diff --git a/bacnet-stack/demo/handler/s_uevent.c b/bacnet-stack/demo/handler/s_uevent.c new file mode 100644 index 00000000..79a134aa --- /dev/null +++ b/bacnet-stack/demo/handler/s_uevent.c @@ -0,0 +1,51 @@ +/************************************************************************** +* +* Copyright (C) 2008 John Minack +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +* +*********************************************************************/ +#include +#include +#include +#include "event.h" +#include "datalink.h" + +int Send_UEvent_Notify( + uint8_t * buffer, + BACNET_EVENT_NOTIFICATION_DATA * data, + BACNET_ADDRESS * dest) +{ + int len = 0; + int pdu_len = 0; + int bytes_sent = 0; + BACNET_NPDU_DATA npdu_data; + + /* encode the NPDU portion of the packet */ + npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); + pdu_len = npdu_encode_pdu(buffer, dest, NULL, &npdu_data); + /* encode the APDU portion of the packet */ + len = uevent_notify_encode_apdu(&buffer[pdu_len], data); + pdu_len += len; + /* send the data */ + bytes_sent = datalink_send_pdu(dest, &npdu_data, &buffer[0], pdu_len); + + return bytes_sent; +} diff --git a/bacnet-stack/include/client.h b/bacnet-stack/include/client.h index 87c107fd..4da021cf 100644 --- a/bacnet-stack/include/client.h +++ b/bacnet-stack/include/client.h @@ -35,6 +35,7 @@ #include "bacenum.h" #include "rpm.h" #include "cov.h" +#include "event.h" #ifdef __cplusplus extern "C" { @@ -132,6 +133,11 @@ extern "C" { int fileStartPosition, BACNET_OCTET_STRING * fileData); + int Send_UEvent_Notify( + uint8_t * buffer, + BACNET_EVENT_NOTIFICATION_DATA * data, + BACNET_ADDRESS * dest); + void Send_Who_Is_Router_To_Network( BACNET_ADDRESS * dst, int dnet); diff --git a/bacnet-stack/lib/Makefile b/bacnet-stack/lib/Makefile index 4498ced0..afe6a31d 100644 --- a/bacnet-stack/lib/Makefile +++ b/bacnet-stack/lib/Makefile @@ -104,6 +104,7 @@ HANDLER_SRC = \ $(BACNET_HANDLER)/s_rp.c \ $(BACNET_HANDLER)/s_rpm.c \ $(BACNET_HANDLER)/s_ts.c \ + $(BACNET_HANDLER)/s_uevent.c \ $(BACNET_HANDLER)/s_whohas.c \ $(BACNET_HANDLER)/s_whois.c \ $(BACNET_HANDLER)/s_router.c \ diff --git a/bacnet-stack/lib/bacnet.cbp b/bacnet-stack/lib/bacnet.cbp index 9a22cf67..1d955778 100644 --- a/bacnet-stack/lib/bacnet.cbp +++ b/bacnet-stack/lib/bacnet.cbp @@ -115,9 +115,9 @@ - - + + @@ -133,6 +133,9 @@ + + diff --git a/bacnet-stack/lib/makefile.b32 b/bacnet-stack/lib/makefile.b32 index 48e02e12..a5d44691 100644 --- a/bacnet-stack/lib/makefile.b32 +++ b/bacnet-stack/lib/makefile.b32 @@ -102,6 +102,7 @@ HANDLER_SRC = $(BACNET_HANDLER)\txbuf.c \ $(BACNET_HANDLER)\s_rp.c \ $(BACNET_HANDLER)\s_rpm.c \ $(BACNET_HANDLER)\s_ts.c \ + $(BACNET_HANDLER)\s_uevent.c \ $(BACNET_HANDLER)\s_whohas.c \ $(BACNET_HANDLER)\s_whois.c \ $(BACNET_HANDLER)\s_wp.c diff --git a/bacnet-stack/src/event.c b/bacnet-stack/src/event.c index 336b0f56..4ae756e1 100644 --- a/bacnet-stack/src/event.c +++ b/bacnet-stack/src/event.c @@ -106,14 +106,14 @@ int event_notify_encode_service_request( /* tag 1 - initiatingObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 1, - data->initiatingObjectIdentifier.type, + (int)data->initiatingObjectIdentifier.type, data->initiatingObjectIdentifier.instance); apdu_len += len; /* tag 2 - eventObjectIdentifier */ len = encode_context_object_id(&apdu[apdu_len], 2, - data->eventObjectIdentifier.type, + (int)data->eventObjectIdentifier.type, data->eventObjectIdentifier.instance); apdu_len += len; @@ -860,32 +860,6 @@ int event_notify_decode_service_request( return len; } -#ifndef TEST - -int uevent_notify_send( - uint8_t * buffer, - BACNET_EVENT_NOTIFICATION_DATA * data, - BACNET_ADDRESS * dest) -{ - int len = 0; - int pdu_len = 0; - int bytes_sent = 0; - BACNET_NPDU_DATA npdu_data; - - /* encode the NPDU portion of the packet */ - npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); - pdu_len = npdu_encode_pdu(buffer, dest, NULL, &npdu_data); - /* encode the APDU portion of the packet */ - len = uevent_notify_encode_apdu(&buffer[pdu_len], data); - pdu_len += len; - /* send the data */ - bytes_sent = datalink_send_pdu(dest, &npdu_data, &buffer[0], pdu_len); - - return bytes_sent; -} -#endif - - #ifdef TEST #include