Added UnconfirmedPrivateTransfer client send function.

This commit is contained in:
skarg
2009-10-20 21:48:38 +00:00
parent af30d31a6c
commit d8b6557641
7 changed files with 91 additions and 9 deletions
+3 -4
View File
@@ -41,22 +41,21 @@ void handler_unconfirmed_private_transfer(
uint16_t service_len,
BACNET_ADDRESS * src)
{
BACNET_PRIVATE_TRANSFER_DATA data;
BACNET_PRIVATE_TRANSFER_DATA private_data;
int len = 0;
int pdu_len = 0;
#if PRINT_ENABLED
fprintf(stderr,"Received Unconfirmed Private Transfer Request!\n");
#endif
(void) src;
len = ptransfer_decode_service_request(
service_request, service_len, &data);
service_request, service_len, &private_data);
if (len >= 0) {
#if PRINT_ENABLED
fprintf(stderr,
"UnconfirmedPrivateTransfer: "
"vendorID=%u serviceNumber=%u\n",
data.vendorID, data.serviceNumber);
private_data.vendorID, private_data.serviceNumber);
#endif
}
}
+76
View File
@@ -0,0 +1,76 @@
/**************************************************************************
*
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
*
* 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 <string.h>
#include "config.h"
#include "config.h"
#include "txbuf.h"
#include "bacdef.h"
#include "bacdcode.h"
#include "address.h"
#include "tsm.h"
#include "npdu.h"
#include "apdu.h"
#include "device.h"
#include "datalink.h"
#include "dcc.h"
#include "ptransfer.h"
/* some demo stuff needed */
#include "handlers.h"
#include "txbuf.h"
void Send_UnconfirmedPrivateTransfer(
BACNET_ADDRESS * dest,
BACNET_PRIVATE_TRANSFER_DATA *private_data)
{
int len = 0;
int pdu_len = 0;
int bytes_sent = 0;
BACNET_NPDU_DATA npdu_data;
if (!dcc_communication_enabled())
return;
/* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, NULL, &npdu_data);
/* encode the APDU portion of the packet */
len = uptransfer_encode_apdu(
&Handler_Transmit_Buffer[pdu_len],
private_data);
pdu_len += len;
bytes_sent =
datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send UnconfirmedPrivateTransfer Request (%s)!\n",
strerror(errno));
#endif
}
+5
View File
@@ -38,6 +38,7 @@
#include "event.h"
#include "lso.h"
#include "alarm_ack.h"
#include "ptransfer.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -161,6 +162,10 @@ extern "C" {
uint32_t device_id,
BACNET_ALARM_ACK_DATA * data);
void Send_UnconfirmedPrivateTransfer(
BACNET_ADDRESS * dest,
BACNET_PRIVATE_TRANSFER_DATA *private_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
+3
View File
@@ -52,6 +52,9 @@ extern "C" {
uint8_t * apdu,
uint8_t invoke_id,
BACNET_PRIVATE_TRANSFER_DATA * private_data);
int uptransfer_encode_apdu(
uint8_t * apdu,
BACNET_PRIVATE_TRANSFER_DATA * private_data);
int ptransfer_decode_service_request(
uint8_t * apdu,
unsigned apdu_len,
+1
View File
@@ -113,6 +113,7 @@ HANDLER_SRC = \
$(BACNET_HANDLER)/s_whohas.c \
$(BACNET_HANDLER)/s_whois.c \
$(BACNET_HANDLER)/s_router.c \
$(BACNET_HANDLER)/s_upt.c \
$(BACNET_HANDLER)/s_wp.c
OBJECT_SRC = \
+1
View File
@@ -115,6 +115,7 @@ HANDLER_SRC = \
$(BACNET_HANDLER)\h_upt.c \
$(BACNET_HANDLER)\h_pt.c \
$(BACNET_HANDLER)\h_pt_a.c \
$(BACNET_HANDLER)\s_upt.c \
$(BACNET_HANDLER)\s_wp.c
OBJECT_SRC = $(BACNET_OBJECT)\device.c \
+2 -5
View File
@@ -98,17 +98,14 @@ int ptransfer_encode_apdu(
int uptransfer_encode_apdu(
uint8_t * apdu,
uint8_t invoke_id,
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int apdu_len = 0; /* total length of the apdu, return value */
if (apdu) {
apdu[0] = PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST;
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
apdu[2] = invoke_id;
apdu[3] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
apdu_len = 4;
apdu[1] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
apdu_len = 2;
apdu_len = pt_encode_apdu(
&apdu[apdu_len],
MAX_APDU-apdu_len,