Moved send_uevent to demo/handler/s_uevent.c. Cleaned up event.c after splint review.

This commit is contained in:
skarg
2009-04-18 15:28:35 +00:00
parent 51845ed4fd
commit 4530915459
6 changed files with 67 additions and 31 deletions
+51
View File
@@ -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 <stddef.h>
#include <stdint.h>
#include <errno.h>
#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;
}
+6
View File
@@ -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);
+1
View File
@@ -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 \
+6 -3
View File
@@ -115,9 +115,9 @@
<Unit filename="..\demo\handler\s_iam.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\demo\handler\s_cov.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\demo\handler\s_cov.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\demo\handler\s_ihave.c">
<Option compilerVar="CC" />
</Unit>
@@ -133,6 +133,9 @@
<Unit filename="..\demo\handler\s_ts.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\demo\handler\s_uevent.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\demo\handler\s_whohas.c">
<Option compilerVar="CC" />
</Unit>
+1
View File
@@ -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
+2 -28
View File
@@ -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 <assert.h>