Added some encoding functions for WPM. Thank you, Nikola Jelic!
This commit is contained in:
+23
-13
@@ -29,8 +29,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "bacdcode.h"
|
||||
#include "bacapp.h"
|
||||
|
||||
|
||||
#include "wp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -49,6 +48,17 @@ extern "C" {
|
||||
BACNET_WRITE_PROPERTY_DATA * wpm_data);
|
||||
|
||||
|
||||
/* encode objects */
|
||||
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id);
|
||||
int wpm_encode_apdu_object_begin (
|
||||
uint8_t * apdu,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance);
|
||||
int wpm_encode_apdu_object_end (uint8_t * apdu);
|
||||
int wpm_encode_apdu_object_property (
|
||||
uint8_t * apdu,
|
||||
BACNET_WRITE_PROPERTY_DATA * wpdata);
|
||||
|
||||
/* encode service */
|
||||
int wpm_ack_encode_apdu_init(
|
||||
uint8_t * apdu,
|
||||
@@ -66,20 +76,20 @@ extern "C" {
|
||||
/** @defgroup DSWP Data Sharing - Write Property Multiple Service (DS-WPM)
|
||||
* @ingroup DataShare
|
||||
* 15.10 WriteProperty Multiple Service <br>
|
||||
* The WritePropertyMultiple service is used by a client BACnet-user
|
||||
* to modify the value of one or more specified properties of a BACnet object.
|
||||
* This service potentially allows write access to any property of any object,
|
||||
* The WritePropertyMultiple service is used by a client BACnet-user
|
||||
* to modify the value of one or more specified properties of a BACnet object.
|
||||
* This service potentially allows write access to any property of any object,
|
||||
* whether a BACnet-defined object or not.
|
||||
* Properties shall be modified by the WritePropertyMultiple service
|
||||
* in the order specified in the 'List of Write Access Specifications' parameter,
|
||||
* and execution of the service shall continue until all of the specified
|
||||
* properties have been written to or a property is encountered that
|
||||
* Properties shall be modified by the WritePropertyMultiple service
|
||||
* in the order specified in the 'List of Write Access Specifications' parameter,
|
||||
* and execution of the service shall continue until all of the specified
|
||||
* properties have been written to or a property is encountered that
|
||||
* for some reason cannot be modified as requested.
|
||||
* Some implementors may wish to restrict write access to certain properties
|
||||
* of certain objects. In such cases, an attempt to modify a restricted property
|
||||
* Some implementors may wish to restrict write access to certain properties
|
||||
* of certain objects. In such cases, an attempt to modify a restricted property
|
||||
* shall result in the return of an error of 'Error Class' PROPERTY and 'Error Code'
|
||||
* WRITE_ACCESS_DENIED. Note that these restricted properties may be accessible
|
||||
* through the use of Virtual Terminal services or other means at the discretion
|
||||
* WRITE_ACCESS_DENIED. Note that these restricted properties may be accessible
|
||||
* through the use of Virtual Terminal services or other means at the discretion
|
||||
* of the implementor.
|
||||
*/
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2011 Krzysztof Malorny <malornykrzysztof@gmail.com>
|
||||
* Contributions by ?????? ????? 2011 <nikola.jelic@euroicc.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -134,6 +135,82 @@ int wpm_decode_object_property(
|
||||
return len;
|
||||
}
|
||||
|
||||
/* encode functions */
|
||||
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
apdu[0] = PDU_TYPE_CONFIRMED_SERVICE_REQUEST;
|
||||
apdu[1] = encode_max_segs_max_apdu (0, MAX_APDU);
|
||||
apdu[2] = invoke_id;
|
||||
apdu[3] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE; /* service choice */
|
||||
apdu_len = 4;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int wpm_encode_apdu_object_begin (
|
||||
uint8_t * apdu,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
apdu_len = encode_context_object_id (
|
||||
&apdu[0], 0, object_type, object_instance);
|
||||
/* Tag 1: sequence of WriteAccessSpecification */
|
||||
apdu_len += encode_opening_tag (&apdu[apdu_len], 1);
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int wpm_encode_apdu_object_end (uint8_t * apdu)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
apdu_len = encode_closing_tag (&apdu[0], 1);
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int wpm_encode_apdu_object_property (
|
||||
uint8_t * apdu,
|
||||
BACNET_WRITE_PROPERTY_DATA * wpdata)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
int len = 0;
|
||||
|
||||
if (apdu) {
|
||||
apdu_len = encode_context_enumerated (&apdu[0], 0,
|
||||
wpdata->object_property);
|
||||
/* optional array index */
|
||||
if (wpdata->array_index != BACNET_ARRAY_ALL) {
|
||||
apdu_len +=
|
||||
encode_context_unsigned (&apdu[apdu_len], 1,
|
||||
wpdata->array_index);
|
||||
}
|
||||
apdu_len += encode_opening_tag (&apdu[apdu_len], 2);
|
||||
for (len = 0; len < wpdata->application_data_len; len++) {
|
||||
apdu[apdu_len] = wpdata->application_data[len];
|
||||
apdu_len++;
|
||||
}
|
||||
apdu_len += encode_closing_tag (&apdu[apdu_len], 2);
|
||||
if (wpdata->priority != BACNET_NO_PRIORITY) {
|
||||
encode_context_unsigned (&apdu[apdu_len], 3,
|
||||
wpdata->priority);
|
||||
}
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int wpm_ack_encode_apdu_init(
|
||||
uint8_t * apdu,
|
||||
uint8_t invoke_id)
|
||||
|
||||
Reference in New Issue
Block a user