Added UnconfirmedPrivateTransfer client send function.
This commit is contained in:
@@ -41,22 +41,21 @@ void handler_unconfirmed_private_transfer(
|
|||||||
uint16_t service_len,
|
uint16_t service_len,
|
||||||
BACNET_ADDRESS * src)
|
BACNET_ADDRESS * src)
|
||||||
{
|
{
|
||||||
BACNET_PRIVATE_TRANSFER_DATA data;
|
BACNET_PRIVATE_TRANSFER_DATA private_data;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int pdu_len = 0;
|
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,"Received Unconfirmed Private Transfer Request!\n");
|
fprintf(stderr,"Received Unconfirmed Private Transfer Request!\n");
|
||||||
#endif
|
#endif
|
||||||
(void) src;
|
(void) src;
|
||||||
len = ptransfer_decode_service_request(
|
len = ptransfer_decode_service_request(
|
||||||
service_request, service_len, &data);
|
service_request, service_len, &private_data);
|
||||||
if (len >= 0) {
|
if (len >= 0) {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"UnconfirmedPrivateTransfer: "
|
"UnconfirmedPrivateTransfer: "
|
||||||
"vendorID=%u serviceNumber=%u\n",
|
"vendorID=%u serviceNumber=%u\n",
|
||||||
data.vendorID, data.serviceNumber);
|
private_data.vendorID, private_data.serviceNumber);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "lso.h"
|
#include "lso.h"
|
||||||
#include "alarm_ack.h"
|
#include "alarm_ack.h"
|
||||||
|
#include "ptransfer.h"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
@@ -161,6 +162,10 @@ extern "C" {
|
|||||||
uint32_t device_id,
|
uint32_t device_id,
|
||||||
BACNET_ALARM_ACK_DATA * data);
|
BACNET_ALARM_ACK_DATA * data);
|
||||||
|
|
||||||
|
void Send_UnconfirmedPrivateTransfer(
|
||||||
|
BACNET_ADDRESS * dest,
|
||||||
|
BACNET_PRIVATE_TRANSFER_DATA *private_data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ extern "C" {
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t invoke_id,
|
uint8_t invoke_id,
|
||||||
BACNET_PRIVATE_TRANSFER_DATA * private_data);
|
BACNET_PRIVATE_TRANSFER_DATA * private_data);
|
||||||
|
int uptransfer_encode_apdu(
|
||||||
|
uint8_t * apdu,
|
||||||
|
BACNET_PRIVATE_TRANSFER_DATA * private_data);
|
||||||
int ptransfer_decode_service_request(
|
int ptransfer_decode_service_request(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
unsigned apdu_len,
|
unsigned apdu_len,
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ HANDLER_SRC = \
|
|||||||
$(BACNET_HANDLER)/s_whohas.c \
|
$(BACNET_HANDLER)/s_whohas.c \
|
||||||
$(BACNET_HANDLER)/s_whois.c \
|
$(BACNET_HANDLER)/s_whois.c \
|
||||||
$(BACNET_HANDLER)/s_router.c \
|
$(BACNET_HANDLER)/s_router.c \
|
||||||
|
$(BACNET_HANDLER)/s_upt.c \
|
||||||
$(BACNET_HANDLER)/s_wp.c
|
$(BACNET_HANDLER)/s_wp.c
|
||||||
|
|
||||||
OBJECT_SRC = \
|
OBJECT_SRC = \
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ HANDLER_SRC = \
|
|||||||
$(BACNET_HANDLER)\h_upt.c \
|
$(BACNET_HANDLER)\h_upt.c \
|
||||||
$(BACNET_HANDLER)\h_pt.c \
|
$(BACNET_HANDLER)\h_pt.c \
|
||||||
$(BACNET_HANDLER)\h_pt_a.c \
|
$(BACNET_HANDLER)\h_pt_a.c \
|
||||||
|
$(BACNET_HANDLER)\s_upt.c \
|
||||||
$(BACNET_HANDLER)\s_wp.c
|
$(BACNET_HANDLER)\s_wp.c
|
||||||
|
|
||||||
OBJECT_SRC = $(BACNET_OBJECT)\device.c \
|
OBJECT_SRC = $(BACNET_OBJECT)\device.c \
|
||||||
|
|||||||
@@ -98,17 +98,14 @@ int ptransfer_encode_apdu(
|
|||||||
|
|
||||||
int uptransfer_encode_apdu(
|
int uptransfer_encode_apdu(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t invoke_id,
|
|
||||||
BACNET_PRIVATE_TRANSFER_DATA * private_data)
|
BACNET_PRIVATE_TRANSFER_DATA * private_data)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
|
||||||
if (apdu) {
|
if (apdu) {
|
||||||
apdu[0] = PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST;
|
apdu[0] = PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST;
|
||||||
apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU);
|
apdu[1] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
|
||||||
apdu[2] = invoke_id;
|
apdu_len = 2;
|
||||||
apdu[3] = SERVICE_UNCONFIRMED_PRIVATE_TRANSFER;
|
|
||||||
apdu_len = 4;
|
|
||||||
apdu_len = pt_encode_apdu(
|
apdu_len = pt_encode_apdu(
|
||||||
&apdu[apdu_len],
|
&apdu[apdu_len],
|
||||||
MAX_APDU-apdu_len,
|
MAX_APDU-apdu_len,
|
||||||
|
|||||||
Reference in New Issue
Block a user