Fixed line endings and SVN props with fixup.sh script
This commit is contained in:
+185
-185
@@ -1,185 +1,185 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "access_rule.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
int bacapp_encode_access_rule(
|
||||
uint8_t * apdu,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[0], 0, rule->time_range_specifier);
|
||||
apdu_len += len;
|
||||
|
||||
if (rule->time_range_specifier == TIME_RANGE_SPECIFIER_SPECIFIED) {
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu[apdu_len], 1,
|
||||
&rule->time_range);
|
||||
if (len > 0)
|
||||
apdu_len += len;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 2,
|
||||
rule->location_specifier);
|
||||
apdu_len += len;
|
||||
|
||||
if (rule->location_specifier == LOCATION_SPECIFIER_SPECIFIED) {
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu[apdu_len], 3,
|
||||
&rule->location);
|
||||
if (len > 0)
|
||||
apdu_len += len;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = encode_context_boolean(&apdu[apdu_len], 4, rule->enable);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_access_rule(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_access_rule(&apdu[apdu_len], rule);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_access_rule(
|
||||
uint8_t * apdu,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 0,
|
||||
&rule->time_range_specifier);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (rule->time_range_specifier == TIME_RANGE_SPECIFIER_SPECIFIED) {
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len =
|
||||
bacapp_decode_context_device_obj_property_ref(&apdu[apdu_len],
|
||||
1, &rule->time_range);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 2,
|
||||
&rule->location_specifier);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (rule->location_specifier == LOCATION_SPECIFIER_SPECIFIED) {
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 3)) {
|
||||
len =
|
||||
bacapp_decode_context_device_obj_property_ref(&apdu[apdu_len],
|
||||
3, &rule->location);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 4)) {
|
||||
len = decode_context_boolean2(&apdu[apdu_len], 4, &rule->enable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_access_rule(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||
len++;
|
||||
section_length = bacapp_decode_access_rule(&apdu[len], rule);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "access_rule.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
int bacapp_encode_access_rule(
|
||||
uint8_t * apdu,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[0], 0, rule->time_range_specifier);
|
||||
apdu_len += len;
|
||||
|
||||
if (rule->time_range_specifier == TIME_RANGE_SPECIFIER_SPECIFIED) {
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu[apdu_len], 1,
|
||||
&rule->time_range);
|
||||
if (len > 0)
|
||||
apdu_len += len;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
len =
|
||||
encode_context_enumerated(&apdu[apdu_len], 2,
|
||||
rule->location_specifier);
|
||||
apdu_len += len;
|
||||
|
||||
if (rule->location_specifier == LOCATION_SPECIFIER_SPECIFIED) {
|
||||
len =
|
||||
bacapp_encode_context_device_obj_property_ref(&apdu[apdu_len], 3,
|
||||
&rule->location);
|
||||
if (len > 0)
|
||||
apdu_len += len;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = encode_context_boolean(&apdu[apdu_len], 4, rule->enable);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_access_rule(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_access_rule(&apdu[apdu_len], rule);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_access_rule(
|
||||
uint8_t * apdu,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 0,
|
||||
&rule->time_range_specifier);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (rule->time_range_specifier == TIME_RANGE_SPECIFIER_SPECIFIED) {
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len =
|
||||
bacapp_decode_context_device_obj_property_ref(&apdu[apdu_len],
|
||||
1, &rule->time_range);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 2,
|
||||
&rule->location_specifier);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (rule->location_specifier == LOCATION_SPECIFIER_SPECIFIED) {
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 3)) {
|
||||
len =
|
||||
bacapp_decode_context_device_obj_property_ref(&apdu[apdu_len],
|
||||
3, &rule->location);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 4)) {
|
||||
len = decode_context_boolean2(&apdu[apdu_len], 4, &rule->enable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_access_rule(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_ACCESS_RULE * rule)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||
len++;
|
||||
section_length = bacapp_decode_access_rule(&apdu[len], rule);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -1,131 +1,131 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "assigned_access_rights.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
|
||||
int bacapp_encode_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len =
|
||||
bacapp_encode_context_device_obj_ref(&apdu[apdu_len], 0,
|
||||
&aar->assigned_access_rights);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_boolean(&apdu[apdu_len], 1, aar->enable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_assigned_access_rights(&apdu[apdu_len], aar);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len =
|
||||
bacapp_decode_context_device_obj_ref(&apdu[apdu_len], 0,
|
||||
&aar->assigned_access_rights);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len = decode_context_boolean2(&apdu[apdu_len], 1, &aar->enable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length = bacapp_decode_assigned_access_rights(&apdu[len], aar);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "assigned_access_rights.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
|
||||
int bacapp_encode_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len =
|
||||
bacapp_encode_context_device_obj_ref(&apdu[apdu_len], 0,
|
||||
&aar->assigned_access_rights);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_boolean(&apdu[apdu_len], 1, aar->enable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_assigned_access_rights(&apdu[apdu_len], aar);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len =
|
||||
bacapp_decode_context_device_obj_ref(&apdu[apdu_len], 0,
|
||||
&aar->assigned_access_rights);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len = decode_context_boolean2(&apdu[apdu_len], 1, &aar->enable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_assigned_access_rights(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_ASSIGNED_ACCESS_RIGHTS * aar)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length = bacapp_decode_assigned_access_rights(&apdu[len], aar);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -1,142 +1,142 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "authentication_factor.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
|
||||
int bacapp_encode_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0, af->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 1, af->format_class);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_octet_string(&apdu[apdu_len], 2, &af->value);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_authentication_factor(&apdu[apdu_len], af);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len = decode_context_enumerated(&apdu[apdu_len], 0, &af->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 1, &af->format_class);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = decode_context_octet_string(&apdu[apdu_len], 2, &af->value);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length = bacapp_decode_authentication_factor(&apdu[len], af);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "authentication_factor.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
|
||||
int bacapp_encode_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0, af->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 1, af->format_class);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_octet_string(&apdu[apdu_len], 2, &af->value);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_authentication_factor(&apdu[apdu_len], af);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len = decode_context_enumerated(&apdu[apdu_len], 0, &af->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 1, &af->format_class);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = decode_context_octet_string(&apdu[apdu_len], 2, &af->value);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR * af)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length = bacapp_decode_authentication_factor(&apdu[len], af);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -1,151 +1,151 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "bacdcode.h"
|
||||
#include "authentication_factor_format.h"
|
||||
|
||||
|
||||
int bacapp_encode_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0, aff->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
if (aff->format_type == AUTHENTICATION_FACTOR_CUSTOM) {
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 1, aff->vendor_id);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 2, aff->vendor_format);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
}
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_authentication_factor_format(&apdu[apdu_len], aff);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 0,
|
||||
&aff->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 1, &aff->vendor_id);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
if ((aff->format_type != AUTHENTICATION_FACTOR_CUSTOM)
|
||||
&& (aff->vendor_id != 0))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 2, &aff->vendor_format);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
if ((aff->format_type != AUTHENTICATION_FACTOR_CUSTOM)
|
||||
&& (aff->vendor_format != 0))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length =
|
||||
bacapp_decode_authentication_factor_format(&apdu[len], aff);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "bacdcode.h"
|
||||
#include "authentication_factor_format.h"
|
||||
|
||||
|
||||
int bacapp_encode_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0, aff->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
if (aff->format_type == AUTHENTICATION_FACTOR_CUSTOM) {
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 1, aff->vendor_id);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 2, aff->vendor_format);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
}
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_authentication_factor_format(&apdu[apdu_len], aff);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 0,
|
||||
&aff->format_type);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 1, &aff->vendor_id);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
if ((aff->format_type != AUTHENTICATION_FACTOR_CUSTOM)
|
||||
&& (aff->vendor_id != 0))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = decode_context_unsigned(&apdu[apdu_len], 2, &aff->vendor_format);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
if ((aff->format_type != AUTHENTICATION_FACTOR_CUSTOM)
|
||||
&& (aff->vendor_format != 0))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_authentication_factor_format(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_AUTHENTICATION_FACTOR_FORMAT * aff)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length =
|
||||
bacapp_decode_authentication_factor_format(&apdu[len], aff);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
+117
-117
@@ -1,117 +1,117 @@
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2015 Nikola Jelic
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "bacdcode.h"
|
||||
#include "bactimevalue.h"
|
||||
|
||||
int bacapp_encode_time_value(uint8_t * apdu,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_application_time(&apdu[apdu_len], &value->Time);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_application_data(&apdu[apdu_len], &value->Value);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_time_value(uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_time_value(&apdu[apdu_len], value);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_time_value(uint8_t * apdu,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = decode_application_time(&apdu[apdu_len], &value->Time);
|
||||
if (len <= 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_decode_application_data(&apdu[apdu_len], 2048, &value->Value);
|
||||
if (len <= 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_time_value(uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag_number))
|
||||
len++;
|
||||
else
|
||||
return -1;
|
||||
|
||||
section_length = bacapp_decode_time_value(&apdu[len], value);
|
||||
if (section_length > 0)
|
||||
len += section_length;
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag_number))
|
||||
len++;
|
||||
else
|
||||
return -1;
|
||||
|
||||
return len;
|
||||
}
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2015 Nikola Jelic
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "bacdcode.h"
|
||||
#include "bactimevalue.h"
|
||||
|
||||
int bacapp_encode_time_value(uint8_t * apdu,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_application_time(&apdu[apdu_len], &value->Time);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_application_data(&apdu[apdu_len], &value->Value);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_time_value(uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_time_value(&apdu[apdu_len], value);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_time_value(uint8_t * apdu,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = decode_application_time(&apdu[apdu_len], &value->Time);
|
||||
if (len <= 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_decode_application_data(&apdu[apdu_len], 2048, &value->Value);
|
||||
if (len <= 0)
|
||||
return -1;
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_time_value(uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_TIME_VALUE * value)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag_number))
|
||||
len++;
|
||||
else
|
||||
return -1;
|
||||
|
||||
section_length = bacapp_decode_time_value(&apdu[len], value);
|
||||
if (section_length > 0)
|
||||
len += section_length;
|
||||
else
|
||||
return -1;
|
||||
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag_number))
|
||||
len++;
|
||||
else
|
||||
return -1;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -1,132 +1,132 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "credential_authentication_factor.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
|
||||
int bacapp_encode_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0, caf->disable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
bacapp_encode_context_authentication_factor(&apdu[apdu_len], 1,
|
||||
&caf->authentication_factor);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_credential_authentication_factor(&apdu[apdu_len], caf);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len = decode_context_enumerated(&apdu[apdu_len], 0, &caf->disable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len =
|
||||
bacapp_decode_context_authentication_factor(&apdu[apdu_len], 1,
|
||||
&caf->authentication_factor);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length =
|
||||
bacapp_decode_credential_authentication_factor(&apdu[len], caf);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Nikola Jelic <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
|
||||
* "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 "credential_authentication_factor.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
|
||||
int bacapp_encode_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0, caf->disable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
len =
|
||||
bacapp_encode_context_authentication_factor(&apdu[apdu_len], 1,
|
||||
&caf->authentication_factor);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_encode_context_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
len = bacapp_encode_credential_authentication_factor(&apdu[apdu_len], caf);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag);
|
||||
apdu_len += len;
|
||||
|
||||
return apdu_len;
|
||||
|
||||
}
|
||||
|
||||
int bacapp_decode_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 0)) {
|
||||
len = decode_context_enumerated(&apdu[apdu_len], 0, &caf->disable);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len =
|
||||
bacapp_decode_context_authentication_factor(&apdu[apdu_len], 1,
|
||||
&caf->authentication_factor);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
else
|
||||
apdu_len += len;
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_credential_authentication_factor(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag,
|
||||
BACNET_CREDENTIAL_AUTHENTICATION_FACTOR * caf)
|
||||
{
|
||||
int len = 0;
|
||||
int section_length;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
section_length =
|
||||
bacapp_decode_credential_authentication_factor(&apdu[len], caf);
|
||||
|
||||
if (section_length == -1) {
|
||||
len = -1;
|
||||
} else {
|
||||
len += section_length;
|
||||
if (decode_is_closing_tag_number(&apdu[len], tag)) {
|
||||
len++;
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
+385
-385
@@ -1,385 +1,385 @@
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2013 Steve Karg <skarg@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "lighting.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
/** @file lighting.c Manipulate BACnet lighting command values */
|
||||
|
||||
|
||||
/**
|
||||
* Encodes into bytes from the lighting-command structure
|
||||
*
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param value - lighting command value to encode
|
||||
*
|
||||
* @return number of bytes encoded, or 0 if unable to encode.
|
||||
*/
|
||||
int lighting_command_encode(
|
||||
uint8_t * apdu,
|
||||
BACNET_LIGHTING_COMMAND * data)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
int len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
data->operation);
|
||||
apdu_len += len;
|
||||
/* optional target-level */
|
||||
if (data->use_target_level) {
|
||||
len = encode_context_real(&apdu[apdu_len], 1,
|
||||
data->target_level);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional ramp-rate */
|
||||
if (data->use_ramp_rate) {
|
||||
len = encode_context_real(&apdu[apdu_len], 2,
|
||||
data->ramp_rate);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional step increment */
|
||||
if (data->use_step_increment) {
|
||||
len = encode_context_real(&apdu[apdu_len], 3,
|
||||
data->step_increment);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional fade time */
|
||||
if (data->use_fade_time) {
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 4,
|
||||
data->fade_time);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional priority */
|
||||
if (data->use_priority) {
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 5,
|
||||
data->priority);
|
||||
apdu_len += len;
|
||||
}
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes into bytes from the lighting-command structure
|
||||
* a context tagged chunk (opening and closing tag)
|
||||
*
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param tag_number - tag number to encode this chunk
|
||||
* @param value - lighting command value to encode
|
||||
*
|
||||
* @return number of bytes encoded, or 0 if unable to encode.
|
||||
*/
|
||||
int lighting_command_encode_context(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_LIGHTING_COMMAND * value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
|
||||
apdu_len += encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += lighting_command_encode(&apdu[apdu_len], value);
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes from bytes into the lighting-command structure
|
||||
*
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param apdu_max_len - number of bytes in the buffer to decode
|
||||
* @param value - lighting command value to place the decoded values
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int lighting_command_decode(
|
||||
uint8_t * apdu,
|
||||
unsigned apdu_max_len,
|
||||
BACNET_LIGHTING_COMMAND * data)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
uint8_t tag_number = 0;
|
||||
uint32_t len_value_type = 0;
|
||||
uint32_t unsigned_value = 0;
|
||||
float real_value = 0.0;
|
||||
|
||||
apdu_max_len = apdu_max_len;
|
||||
/* check for value pointers */
|
||||
if (apdu_max_len && data) {
|
||||
/* Tag 0: operation */
|
||||
if (!decode_is_context_tag(&apdu[apdu_len], 0))
|
||||
return BACNET_STATUS_ERROR;
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len =
|
||||
decode_enumerated(&apdu[apdu_len], len_value_type, &unsigned_value);
|
||||
if (len > 0) {
|
||||
data->operation = unsigned_value;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* Tag 1: target-level - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_real(&apdu[apdu_len], &real_value);
|
||||
data->target_level = real_value;
|
||||
apdu_len += len;
|
||||
data->use_target_level = true;
|
||||
} else {
|
||||
data->use_target_level = false;
|
||||
}
|
||||
/* Tag 2: ramp-rate - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_real(&apdu[apdu_len], &real_value);
|
||||
data->ramp_rate = real_value;
|
||||
data->use_ramp_rate = true;
|
||||
} else {
|
||||
data->use_ramp_rate = false;
|
||||
}
|
||||
/* Tag 3: step-increment - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 3)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_real(&apdu[apdu_len], &real_value);
|
||||
data->step_increment = real_value;
|
||||
data->use_step_increment = true;
|
||||
} else {
|
||||
data->use_step_increment = false;
|
||||
}
|
||||
/* Tag 4: fade-time - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 4)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_unsigned(&apdu[apdu_len], len_value_type,
|
||||
&unsigned_value);
|
||||
data->fade_time = unsigned_value;
|
||||
data->use_fade_time = true;
|
||||
} else {
|
||||
data->use_fade_time = false;
|
||||
}
|
||||
/* Tag 5: priority - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 4)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_unsigned(&apdu[apdu_len], len_value_type,
|
||||
&unsigned_value);
|
||||
data->priority = unsigned_value;
|
||||
data->use_priority = true;
|
||||
} else {
|
||||
data->use_priority = false;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies one lighting-command structure to another
|
||||
*
|
||||
* @param dst - lighting command value target
|
||||
* @param src - lighting command value source
|
||||
*
|
||||
* @return true if copy succeeded
|
||||
*/
|
||||
bool lighting_command_copy(
|
||||
BACNET_LIGHTING_COMMAND * dst,
|
||||
BACNET_LIGHTING_COMMAND * src)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if (dst && src) {
|
||||
dst->operation = src->operation;
|
||||
dst->use_target_level = src->use_target_level;
|
||||
dst->use_ramp_rate = src->use_ramp_rate;
|
||||
dst->use_step_increment = src->use_step_increment;
|
||||
dst->use_fade_time = src->use_fade_time;
|
||||
dst->use_priority = src->use_priority;
|
||||
dst->target_level = src->target_level;
|
||||
dst->ramp_rate = src->ramp_rate;
|
||||
dst->step_increment = src->step_increment;
|
||||
dst->fade_time = src->fade_time;
|
||||
dst->priority = src->priority;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare one lighting-command structure to another
|
||||
*
|
||||
* @param dst - lighting command value target
|
||||
* @param src - lighting command value source
|
||||
*
|
||||
* @return true if lighting-commands are the same for values in-use
|
||||
*/
|
||||
bool lighting_command_same(
|
||||
BACNET_LIGHTING_COMMAND * dst,
|
||||
BACNET_LIGHTING_COMMAND * src)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if (dst && src) {
|
||||
if ((dst->operation == src->operation) &&
|
||||
(dst->use_target_level == src->use_target_level) &&
|
||||
(dst->use_ramp_rate == src->use_ramp_rate) &&
|
||||
(dst->use_step_increment == src->use_step_increment) &&
|
||||
(dst->use_fade_time == src->use_fade_time) &&
|
||||
(dst->use_priority == src->use_priority)) {
|
||||
status = true;
|
||||
if ((dst->use_target_level) &&
|
||||
(dst->target_level != src->target_level)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_ramp_rate) &&
|
||||
(dst->ramp_rate != src->ramp_rate)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_step_increment) &&
|
||||
(dst->step_increment != src->step_increment)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_fade_time) &&
|
||||
(dst->fade_time != src->fade_time)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_priority) &&
|
||||
(dst->priority != src->priority)) {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "ctest.h"
|
||||
|
||||
void testBACnetLightingCommand(
|
||||
Test * pTest,
|
||||
BACNET_LIGHTING_COMMAND *data)
|
||||
{
|
||||
bool status = false;
|
||||
BACNET_LIGHTING_COMMAND test_data;
|
||||
int len, apdu_len;
|
||||
uint8_t apdu[MAX_APDU] = {0};
|
||||
|
||||
status = lighting_command_copy(&test_data, NULL);
|
||||
ct_test(pTest, status == false);
|
||||
status = lighting_command_copy(NULL, data);
|
||||
ct_test(pTest, status == false);
|
||||
status = lighting_command_copy(&test_data, data);
|
||||
ct_test(pTest, status == true);
|
||||
status = lighting_command_same(&test_data, data);
|
||||
ct_test(pTest, status == true);
|
||||
len = lighting_command_encode(apdu, data);
|
||||
apdu_len = lighting_command_decode(apdu, sizeof(apdu), &test_data);
|
||||
ct_test(pTest, len > 0);
|
||||
ct_test(pTest, apdu_len > 0);
|
||||
status = lighting_command_same(&test_data, data);
|
||||
}
|
||||
|
||||
void testBACnetLightingCommandAll(
|
||||
Test * pTest)
|
||||
{
|
||||
BACNET_LIGHTING_COMMAND data;
|
||||
|
||||
data.operation = BACNET_LIGHTS_NONE;
|
||||
data.use_target_level = false;
|
||||
data.use_ramp_rate = false;
|
||||
data.use_step_increment = false;
|
||||
data.use_fade_time = false;
|
||||
data.use_priority = false;
|
||||
data.target_level = 0.0;
|
||||
data.ramp_rate = 100.0;
|
||||
data.step_increment = 1.0;
|
||||
data.fade_time = 100;
|
||||
data.priority = 1;
|
||||
testBACnetLightingCommand(pTest, &data);
|
||||
data.operation = BACNET_LIGHTS_STOP;
|
||||
data.use_target_level = true;
|
||||
data.use_ramp_rate = true;
|
||||
data.use_step_increment = true;
|
||||
data.use_fade_time = true;
|
||||
data.use_priority = true;
|
||||
testBACnetLightingCommand(pTest, &data);
|
||||
}
|
||||
|
||||
#ifdef TEST_LIGHTING_COMMAND
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
|
||||
pTest = ct_create("BACnet Lighting Command", NULL);
|
||||
/* individual tests */
|
||||
rc = ct_addTestFunction(pTest, testBACnetLightingCommandAll);
|
||||
assert(rc);
|
||||
|
||||
ct_setStream(pTest, stdout);
|
||||
ct_run(pTest);
|
||||
(void) ct_report(pTest);
|
||||
ct_destroy(pTest);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* TEST */
|
||||
/*####COPYRIGHTBEGIN####
|
||||
-------------------------------------------
|
||||
Copyright (C) 2013 Steve Karg <skarg@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
The Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if other files instantiate templates or
|
||||
use macros or inline functions from this file, or you compile
|
||||
this file and link it with other works to produce a work based
|
||||
on this file, this file does not by itself cause the resulting
|
||||
work to be covered by the GNU General Public License. However
|
||||
the source code for this file must still be made available in
|
||||
accordance with section (3) of the GNU General Public License.
|
||||
|
||||
This exception does not invalidate any other reasons why a work
|
||||
based on this file might be covered by the GNU General Public
|
||||
License.
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "lighting.h"
|
||||
#include "bacdcode.h"
|
||||
|
||||
/** @file lighting.c Manipulate BACnet lighting command values */
|
||||
|
||||
|
||||
/**
|
||||
* Encodes into bytes from the lighting-command structure
|
||||
*
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param value - lighting command value to encode
|
||||
*
|
||||
* @return number of bytes encoded, or 0 if unable to encode.
|
||||
*/
|
||||
int lighting_command_encode(
|
||||
uint8_t * apdu,
|
||||
BACNET_LIGHTING_COMMAND * data)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
int len = 0; /* total length of the apdu, return value */
|
||||
|
||||
if (apdu) {
|
||||
len = encode_context_enumerated(&apdu[apdu_len], 0,
|
||||
data->operation);
|
||||
apdu_len += len;
|
||||
/* optional target-level */
|
||||
if (data->use_target_level) {
|
||||
len = encode_context_real(&apdu[apdu_len], 1,
|
||||
data->target_level);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional ramp-rate */
|
||||
if (data->use_ramp_rate) {
|
||||
len = encode_context_real(&apdu[apdu_len], 2,
|
||||
data->ramp_rate);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional step increment */
|
||||
if (data->use_step_increment) {
|
||||
len = encode_context_real(&apdu[apdu_len], 3,
|
||||
data->step_increment);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional fade time */
|
||||
if (data->use_fade_time) {
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 4,
|
||||
data->fade_time);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* optional priority */
|
||||
if (data->use_priority) {
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 5,
|
||||
data->priority);
|
||||
apdu_len += len;
|
||||
}
|
||||
}
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes into bytes from the lighting-command structure
|
||||
* a context tagged chunk (opening and closing tag)
|
||||
*
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param tag_number - tag number to encode this chunk
|
||||
* @param value - lighting command value to encode
|
||||
*
|
||||
* @return number of bytes encoded, or 0 if unable to encode.
|
||||
*/
|
||||
int lighting_command_encode_context(
|
||||
uint8_t * apdu,
|
||||
uint8_t tag_number,
|
||||
BACNET_LIGHTING_COMMAND * value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
|
||||
apdu_len += encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += lighting_command_encode(&apdu[apdu_len], value);
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes from bytes into the lighting-command structure
|
||||
*
|
||||
* @param apdu - buffer to hold the bytes
|
||||
* @param apdu_max_len - number of bytes in the buffer to decode
|
||||
* @param value - lighting command value to place the decoded values
|
||||
*
|
||||
* @return number of bytes encoded
|
||||
*/
|
||||
int lighting_command_decode(
|
||||
uint8_t * apdu,
|
||||
unsigned apdu_max_len,
|
||||
BACNET_LIGHTING_COMMAND * data)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
uint8_t tag_number = 0;
|
||||
uint32_t len_value_type = 0;
|
||||
uint32_t unsigned_value = 0;
|
||||
float real_value = 0.0;
|
||||
|
||||
apdu_max_len = apdu_max_len;
|
||||
/* check for value pointers */
|
||||
if (apdu_max_len && data) {
|
||||
/* Tag 0: operation */
|
||||
if (!decode_is_context_tag(&apdu[apdu_len], 0))
|
||||
return BACNET_STATUS_ERROR;
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len =
|
||||
decode_enumerated(&apdu[apdu_len], len_value_type, &unsigned_value);
|
||||
if (len > 0) {
|
||||
data->operation = unsigned_value;
|
||||
}
|
||||
apdu_len += len;
|
||||
/* Tag 1: target-level - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_real(&apdu[apdu_len], &real_value);
|
||||
data->target_level = real_value;
|
||||
apdu_len += len;
|
||||
data->use_target_level = true;
|
||||
} else {
|
||||
data->use_target_level = false;
|
||||
}
|
||||
/* Tag 2: ramp-rate - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_real(&apdu[apdu_len], &real_value);
|
||||
data->ramp_rate = real_value;
|
||||
data->use_ramp_rate = true;
|
||||
} else {
|
||||
data->use_ramp_rate = false;
|
||||
}
|
||||
/* Tag 3: step-increment - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 3)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_real(&apdu[apdu_len], &real_value);
|
||||
data->step_increment = real_value;
|
||||
data->use_step_increment = true;
|
||||
} else {
|
||||
data->use_step_increment = false;
|
||||
}
|
||||
/* Tag 4: fade-time - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 4)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_unsigned(&apdu[apdu_len], len_value_type,
|
||||
&unsigned_value);
|
||||
data->fade_time = unsigned_value;
|
||||
data->use_fade_time = true;
|
||||
} else {
|
||||
data->use_fade_time = false;
|
||||
}
|
||||
/* Tag 5: priority - OPTIONAL */
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 4)) {
|
||||
len =
|
||||
decode_tag_number_and_value(&apdu[apdu_len], &tag_number,
|
||||
&len_value_type);
|
||||
apdu_len += len;
|
||||
len = decode_unsigned(&apdu[apdu_len], len_value_type,
|
||||
&unsigned_value);
|
||||
data->priority = unsigned_value;
|
||||
data->use_priority = true;
|
||||
} else {
|
||||
data->use_priority = false;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies one lighting-command structure to another
|
||||
*
|
||||
* @param dst - lighting command value target
|
||||
* @param src - lighting command value source
|
||||
*
|
||||
* @return true if copy succeeded
|
||||
*/
|
||||
bool lighting_command_copy(
|
||||
BACNET_LIGHTING_COMMAND * dst,
|
||||
BACNET_LIGHTING_COMMAND * src)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if (dst && src) {
|
||||
dst->operation = src->operation;
|
||||
dst->use_target_level = src->use_target_level;
|
||||
dst->use_ramp_rate = src->use_ramp_rate;
|
||||
dst->use_step_increment = src->use_step_increment;
|
||||
dst->use_fade_time = src->use_fade_time;
|
||||
dst->use_priority = src->use_priority;
|
||||
dst->target_level = src->target_level;
|
||||
dst->ramp_rate = src->ramp_rate;
|
||||
dst->step_increment = src->step_increment;
|
||||
dst->fade_time = src->fade_time;
|
||||
dst->priority = src->priority;
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare one lighting-command structure to another
|
||||
*
|
||||
* @param dst - lighting command value target
|
||||
* @param src - lighting command value source
|
||||
*
|
||||
* @return true if lighting-commands are the same for values in-use
|
||||
*/
|
||||
bool lighting_command_same(
|
||||
BACNET_LIGHTING_COMMAND * dst,
|
||||
BACNET_LIGHTING_COMMAND * src)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
if (dst && src) {
|
||||
if ((dst->operation == src->operation) &&
|
||||
(dst->use_target_level == src->use_target_level) &&
|
||||
(dst->use_ramp_rate == src->use_ramp_rate) &&
|
||||
(dst->use_step_increment == src->use_step_increment) &&
|
||||
(dst->use_fade_time == src->use_fade_time) &&
|
||||
(dst->use_priority == src->use_priority)) {
|
||||
status = true;
|
||||
if ((dst->use_target_level) &&
|
||||
(dst->target_level != src->target_level)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_ramp_rate) &&
|
||||
(dst->ramp_rate != src->ramp_rate)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_step_increment) &&
|
||||
(dst->step_increment != src->step_increment)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_fade_time) &&
|
||||
(dst->fade_time != src->fade_time)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_priority) &&
|
||||
(dst->priority != src->priority)) {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "ctest.h"
|
||||
|
||||
void testBACnetLightingCommand(
|
||||
Test * pTest,
|
||||
BACNET_LIGHTING_COMMAND *data)
|
||||
{
|
||||
bool status = false;
|
||||
BACNET_LIGHTING_COMMAND test_data;
|
||||
int len, apdu_len;
|
||||
uint8_t apdu[MAX_APDU] = {0};
|
||||
|
||||
status = lighting_command_copy(&test_data, NULL);
|
||||
ct_test(pTest, status == false);
|
||||
status = lighting_command_copy(NULL, data);
|
||||
ct_test(pTest, status == false);
|
||||
status = lighting_command_copy(&test_data, data);
|
||||
ct_test(pTest, status == true);
|
||||
status = lighting_command_same(&test_data, data);
|
||||
ct_test(pTest, status == true);
|
||||
len = lighting_command_encode(apdu, data);
|
||||
apdu_len = lighting_command_decode(apdu, sizeof(apdu), &test_data);
|
||||
ct_test(pTest, len > 0);
|
||||
ct_test(pTest, apdu_len > 0);
|
||||
status = lighting_command_same(&test_data, data);
|
||||
}
|
||||
|
||||
void testBACnetLightingCommandAll(
|
||||
Test * pTest)
|
||||
{
|
||||
BACNET_LIGHTING_COMMAND data;
|
||||
|
||||
data.operation = BACNET_LIGHTS_NONE;
|
||||
data.use_target_level = false;
|
||||
data.use_ramp_rate = false;
|
||||
data.use_step_increment = false;
|
||||
data.use_fade_time = false;
|
||||
data.use_priority = false;
|
||||
data.target_level = 0.0;
|
||||
data.ramp_rate = 100.0;
|
||||
data.step_increment = 1.0;
|
||||
data.fade_time = 100;
|
||||
data.priority = 1;
|
||||
testBACnetLightingCommand(pTest, &data);
|
||||
data.operation = BACNET_LIGHTS_STOP;
|
||||
data.use_target_level = true;
|
||||
data.use_ramp_rate = true;
|
||||
data.use_step_increment = true;
|
||||
data.use_fade_time = true;
|
||||
data.use_priority = true;
|
||||
testBACnetLightingCommand(pTest, &data);
|
||||
}
|
||||
|
||||
#ifdef TEST_LIGHTING_COMMAND
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
|
||||
pTest = ct_create("BACnet Lighting Command", NULL);
|
||||
/* individual tests */
|
||||
rc = ct_addTestFunction(pTest, testBACnetLightingCommandAll);
|
||||
assert(rc);
|
||||
|
||||
ct_setStream(pTest, stdout);
|
||||
ct_run(pTest);
|
||||
(void) ct_report(pTest);
|
||||
ct_destroy(pTest);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* TEST */
|
||||
|
||||
Reference in New Issue
Block a user