Converted device object test to use common read-write property test. Extended the basic BACnet device object example API. (#1106)
* Converted device object test to use common read-write property test. Extended the basic BACnet device object example API. * Created BACnet/IP and COV test mocks to enable device object testing with less dependencies.
This commit is contained in:
@@ -81,16 +81,12 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/basic/object/structured_view.c
|
||||
${SRC_DIR}/bacnet/basic/object/time_value.c
|
||||
${SRC_DIR}/bacnet/basic/object/trendlog.c
|
||||
${SRC_DIR}/bacnet/basic/service/h_apdu.c
|
||||
${SRC_DIR}/bacnet/basic/service/h_cov.c
|
||||
${SRC_DIR}/bacnet/basic/service/h_wp.c
|
||||
${SRC_DIR}/bacnet/basic/sys/bigend.c
|
||||
${SRC_DIR}/bacnet/basic/sys/days.c
|
||||
${SRC_DIR}/bacnet/basic/sys/debug.c
|
||||
${SRC_DIR}/bacnet/basic/sys/keylist.c
|
||||
${SRC_DIR}/bacnet/basic/sys/lighting_command.c
|
||||
${SRC_DIR}/bacnet/basic/sys/linear.c
|
||||
${SRC_DIR}/bacnet/basic/tsm/tsm.c
|
||||
${SRC_DIR}/bacnet/datalink/bvlc.c
|
||||
${SRC_DIR}/bacnet/datalink/bvlc6.c
|
||||
${SRC_DIR}/bacnet/cov.c
|
||||
@@ -112,9 +108,14 @@ add_executable(${PROJECT_NAME}
|
||||
${SRC_DIR}/bacnet/special_event.c
|
||||
${SRC_DIR}/bacnet/channel_value.c
|
||||
${SRC_DIR}/bacnet/secure_connect.c
|
||||
./stubs.c
|
||||
# Test and test library files
|
||||
./src/main.c
|
||||
${TST_DIR}/bacnet/basic/object/test/apdu_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/test/bip_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/test/cov_mock.c
|
||||
${TST_DIR}/bacnet/basic/object/test/property_test.c
|
||||
${TST_DIR}/bacnet/basic/object/test/datetime_local.c
|
||||
${TST_DIR}/bacnet/basic/object/test/tsm_mock.c
|
||||
${ZTST_DIR}/ztest_mock.c
|
||||
${ZTST_DIR}/ztest.c
|
||||
)
|
||||
|
||||
@@ -9,6 +9,34 @@
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/service/h_apdu.h>
|
||||
|
||||
bool apdu_service_supported(BACNET_SERVICES_SUPPORTED service_supported)
|
||||
{
|
||||
(void)service_supported;
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint16_t Timeout_Milliseconds = 1000;
|
||||
uint16_t apdu_timeout(void)
|
||||
{
|
||||
return Timeout_Milliseconds;
|
||||
}
|
||||
|
||||
void apdu_timeout_set(uint16_t milliseconds)
|
||||
{
|
||||
Timeout_Milliseconds = milliseconds;
|
||||
}
|
||||
|
||||
static uint8_t Number_Of_Retries = 3;
|
||||
uint8_t apdu_retries(void)
|
||||
{
|
||||
return Number_Of_Retries;
|
||||
}
|
||||
|
||||
void apdu_retries_set(uint8_t value)
|
||||
{
|
||||
Number_Of_Retries = value;
|
||||
}
|
||||
|
||||
uint16_t apdu_decode_confirmed_service_request(
|
||||
uint8_t *apdu,
|
||||
uint16_t apdu_len,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief mock BACnet/IP datalink functions
|
||||
* @author Steve Karg
|
||||
* @date September 2025
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/basic/tsm/tsm.h>
|
||||
|
||||
void bip_get_my_address(BACNET_ADDRESS *my_address)
|
||||
{
|
||||
(void)my_address;
|
||||
}
|
||||
|
||||
int bip_send_pdu(
|
||||
BACNET_ADDRESS *dest,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *pdu,
|
||||
unsigned pdu_len)
|
||||
{
|
||||
(void)dest;
|
||||
(void)npdu_data;
|
||||
(void)pdu;
|
||||
(void)pdu_len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief mock for COV functions
|
||||
* @author Steve Karg
|
||||
* @date September 2025
|
||||
* @copyright SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <zephyr/ztest.h>
|
||||
#include <bacnet/bacdef.h>
|
||||
#include <bacnet/basic/services.h>
|
||||
|
||||
int handler_cov_encode_subscriptions(uint8_t *apdu, int max_apdu)
|
||||
{
|
||||
(void)apdu;
|
||||
(void)max_apdu;
|
||||
return 0;
|
||||
}
|
||||
@@ -284,14 +284,14 @@ void bacnet_object_properties_read_write_test(
|
||||
rpdata.object_type = object_type;
|
||||
rpdata.object_instance = object_instance;
|
||||
property_list(&pRequired, &pOptional, &pProprietary);
|
||||
/* detect properties that are not in the property lists */
|
||||
/* detect properties that are missing from the property lists */
|
||||
for (property = 0; property < MAX_BACNET_PROPERTY_ID; property++) {
|
||||
if (property_lists_member(
|
||||
pRequired, pOptional, pProprietary, property)) {
|
||||
continue;
|
||||
}
|
||||
if ((property == PROP_ALL) || (property == PROP_REQUIRED) ||
|
||||
(property == PROP_OPTIONAL)) {
|
||||
(property == PROP_OPTIONAL) || (property == PROP_PROPERTY_LIST)) {
|
||||
continue;
|
||||
}
|
||||
rpdata.object_property = property;
|
||||
|
||||
Reference in New Issue
Block a user