cf77abac9b
* Added BACnet Secure Connect datalink. * Added BACnet/SC hub application --------- Co-authored-by: Kirill Neznamov <kirill.neznamov@dsr-corporation.com> Co-authored-by: Mikhail Antropov <michail.antropov@dsr-corporation.com> Co-authored-by: Ondřej Hruška <ondra@ondrovo.com> Co-authored-by: Patrick Grimm <patrick@lunatiki.de>
86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
/**
|
|
* @file
|
|
* @brief Test for BACnet File object
|
|
* @author Steve Karg <skarg@users.sourceforge.net>
|
|
* @date January 2023
|
|
* @section LICENSE
|
|
*
|
|
* Copyright (C) 2022 Steve Karg <skarg@users.sourceforge.net>
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
#include <zephyr/ztest.h>
|
|
#include <bacnet/basic/object/bacfile.h>
|
|
|
|
/**
|
|
* @addtogroup bacnet_tests
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @brief Test
|
|
*/
|
|
#if defined(CONFIG_ZTEST_NEW_API)
|
|
ZTEST(bacfile_tests, test_BACnet_File_Object)
|
|
#else
|
|
static void test_BACnet_File_Object(void)
|
|
#endif
|
|
{
|
|
uint8_t apdu[MAX_APDU] = { 0 };
|
|
int len = 0, test_len = 0;
|
|
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
|
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
|
const int *required_property = NULL;
|
|
const uint32_t instance = 1;
|
|
|
|
bacfile_init();
|
|
bacfile_create(1);
|
|
rpdata.application_data = &apdu[0];
|
|
rpdata.application_data_len = sizeof(apdu);
|
|
rpdata.object_type = OBJECT_FILE;
|
|
rpdata.object_instance = instance;
|
|
rpdata.array_index = BACNET_ARRAY_ALL;
|
|
|
|
BACfile_Property_Lists(&required_property, NULL, NULL);
|
|
while ((*required_property) >= 0) {
|
|
rpdata.object_property = *required_property;
|
|
len = bacfile_read_property(&rpdata);
|
|
if (len < 0) {
|
|
printf(
|
|
"property %u: failed to read!\n",
|
|
(unsigned)rpdata.object_property);
|
|
}
|
|
zassert_true(len >= 0, NULL);
|
|
if (len >= 0) {
|
|
test_len = bacapp_decode_known_property(
|
|
rpdata.application_data, len, &value, rpdata.object_type,
|
|
rpdata.object_property);
|
|
if (len != test_len) {
|
|
printf(
|
|
"property %u: failed to decode!\n",
|
|
(unsigned)rpdata.object_property);
|
|
}
|
|
zassert_equal(len, test_len, NULL);
|
|
}
|
|
required_property++;
|
|
}
|
|
|
|
bacfile_cleanup();
|
|
|
|
return;
|
|
}
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
#if defined(CONFIG_ZTEST_NEW_API)
|
|
ZTEST_SUITE(bacfile_tests, NULL, NULL, NULL, NULL, NULL);
|
|
#else
|
|
void test_main(void)
|
|
{
|
|
ztest_test_suite(bacfile_tests, ztest_unit_test(test_BACnet_File_Object));
|
|
|
|
ztest_run_test_suite(bacfile_tests);
|
|
}
|
|
#endif
|