Feature/add create object service (#476)
Added BACnet CreateObject and DeleteObject services * refactored codec for BACnetPropertyValue into bacapp module * added unit tests for BACnetPropertyValue * refactored COV and Events to use BACnetPropertyValue codec API * added unit tests for COV * added overrun safe decoders for tag numbers and boolean context * added unit tests and codecs for CreateObject and DeleteObject services * added APDU service handers and senders for CreateObject and DeleteObject services * added command line apps bacco and bacdo for CreateObject and DeleteObject services * added CreateObject and DeleteObject service handling in example server app and device object * added new BACnetRejectReason, Error Class, and BACnetAbortReason enumerations and conversions --------- Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
+41
-52
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
//#include <bacnet/bacapp.h>
|
||||
// #include <bacnet/bacapp.h>
|
||||
#include <bacnet/cov.h>
|
||||
|
||||
/**
|
||||
@@ -127,24 +127,19 @@ static int cov_subscribe_property_decode_apdu(uint8_t *apdu,
|
||||
}
|
||||
|
||||
/* dummy function stubs */
|
||||
static void testCOVNotifyData(
|
||||
BACNET_COV_DATA *data, BACNET_COV_DATA *test_data)
|
||||
static void testCOVNotifyData(BACNET_COV_DATA *data, BACNET_COV_DATA *test_data)
|
||||
{
|
||||
BACNET_PROPERTY_VALUE *value = NULL;
|
||||
BACNET_PROPERTY_VALUE *test_value = NULL;
|
||||
|
||||
zassert_equal(
|
||||
test_data->subscriberProcessIdentifier,
|
||||
data->subscriberProcessIdentifier, NULL);
|
||||
zassert_equal(
|
||||
test_data->initiatingDeviceIdentifier,
|
||||
data->initiatingDeviceIdentifier, NULL);
|
||||
zassert_equal(
|
||||
test_data->monitoredObjectIdentifier.type,
|
||||
data->monitoredObjectIdentifier.type, NULL);
|
||||
zassert_equal(
|
||||
test_data->monitoredObjectIdentifier.instance,
|
||||
data->monitoredObjectIdentifier.instance, NULL);
|
||||
zassert_equal(test_data->subscriberProcessIdentifier,
|
||||
data->subscriberProcessIdentifier, NULL);
|
||||
zassert_equal(test_data->initiatingDeviceIdentifier,
|
||||
data->initiatingDeviceIdentifier, NULL);
|
||||
zassert_equal(test_data->monitoredObjectIdentifier.type,
|
||||
data->monitoredObjectIdentifier.type, NULL);
|
||||
zassert_equal(test_data->monitoredObjectIdentifier.instance,
|
||||
data->monitoredObjectIdentifier.instance, NULL);
|
||||
zassert_equal(test_data->timeRemaining, data->timeRemaining, NULL);
|
||||
/* test the listOfValues in some clever manner */
|
||||
value = data->listOfValues;
|
||||
@@ -152,10 +147,12 @@ static void testCOVNotifyData(
|
||||
while (value) {
|
||||
zassert_not_null(test_value, NULL);
|
||||
if (test_value) {
|
||||
zassert_equal(
|
||||
test_value->propertyIdentifier, value->propertyIdentifier, NULL);
|
||||
zassert_equal(
|
||||
test_value->propertyArrayIndex, value->propertyArrayIndex, NULL);
|
||||
zassert_equal(test_value->propertyIdentifier,
|
||||
value->propertyIdentifier, "property=%u test_property=%u",
|
||||
(unsigned)value->propertyIdentifier,
|
||||
(unsigned)test_value->propertyIdentifier);
|
||||
zassert_equal(test_value->propertyArrayIndex,
|
||||
value->propertyArrayIndex, NULL);
|
||||
zassert_equal(test_value->priority, value->priority, NULL);
|
||||
zassert_true(
|
||||
bacapp_same_value(&test_value->value, &value->value), NULL);
|
||||
@@ -170,14 +167,15 @@ static void testUCOVNotifyData(BACNET_COV_DATA *data)
|
||||
uint8_t apdu[480] = { 0 };
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
BACNET_COV_DATA test_data;
|
||||
BACNET_COV_DATA test_data = { 0 };
|
||||
BACNET_PROPERTY_VALUE value_list[5] = { { 0 } };
|
||||
|
||||
len = ucov_notify_encode_apdu(&apdu[0], sizeof(apdu), data);
|
||||
zassert_true(len > 0, NULL);
|
||||
apdu_len = len;
|
||||
|
||||
cov_data_value_list_link(&test_data, &value_list[0], 5);
|
||||
cov_data_value_list_link(
|
||||
&test_data, &value_list[0], ARRAY_SIZE(value_list));
|
||||
len = ucov_notify_decode_apdu(&apdu[0], apdu_len, &test_data);
|
||||
zassert_not_equal(len, -1, NULL);
|
||||
testCOVNotifyData(data, &test_data);
|
||||
@@ -188,7 +186,7 @@ static void testCCOVNotifyData(uint8_t invoke_id, BACNET_COV_DATA *data)
|
||||
uint8_t apdu[480] = { 0 };
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
BACNET_COV_DATA test_data;
|
||||
BACNET_COV_DATA test_data = { 0 };
|
||||
BACNET_PROPERTY_VALUE value_list[2] = { { 0 } };
|
||||
uint8_t test_invoke_id = 0;
|
||||
|
||||
@@ -239,42 +237,36 @@ static void testCOVNotify(void)
|
||||
}
|
||||
|
||||
static void testCOVSubscribeData(
|
||||
BACNET_SUBSCRIBE_COV_DATA *data,
|
||||
BACNET_SUBSCRIBE_COV_DATA *test_data)
|
||||
BACNET_SUBSCRIBE_COV_DATA *data, BACNET_SUBSCRIBE_COV_DATA *test_data)
|
||||
{
|
||||
zassert_equal(test_data->subscriberProcessIdentifier,
|
||||
data->subscriberProcessIdentifier, NULL);
|
||||
zassert_equal(test_data->monitoredObjectIdentifier.type,
|
||||
data->monitoredObjectIdentifier.type, NULL);
|
||||
zassert_equal(test_data->monitoredObjectIdentifier.instance,
|
||||
data->monitoredObjectIdentifier.instance, NULL);
|
||||
zassert_equal(
|
||||
test_data->subscriberProcessIdentifier,
|
||||
data->subscriberProcessIdentifier, NULL);
|
||||
zassert_equal(
|
||||
test_data->monitoredObjectIdentifier.type,
|
||||
data->monitoredObjectIdentifier.type, NULL);
|
||||
zassert_equal(
|
||||
test_data->monitoredObjectIdentifier.instance,
|
||||
data->monitoredObjectIdentifier.instance, NULL);
|
||||
zassert_equal(test_data->cancellationRequest, data->cancellationRequest, NULL);
|
||||
test_data->cancellationRequest, data->cancellationRequest, NULL);
|
||||
if (test_data->cancellationRequest != data->cancellationRequest) {
|
||||
printf("cancellation request failed!\n");
|
||||
}
|
||||
if (!test_data->cancellationRequest) {
|
||||
zassert_equal(
|
||||
test_data->issueConfirmedNotifications,
|
||||
data->issueConfirmedNotifications, NULL);
|
||||
zassert_equal(test_data->issueConfirmedNotifications,
|
||||
data->issueConfirmedNotifications, NULL);
|
||||
zassert_equal(test_data->lifetime, data->lifetime, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void testCOVSubscribePropertyData(
|
||||
BACNET_SUBSCRIBE_COV_DATA *data,
|
||||
BACNET_SUBSCRIBE_COV_DATA *test_data)
|
||||
BACNET_SUBSCRIBE_COV_DATA *data, BACNET_SUBSCRIBE_COV_DATA *test_data)
|
||||
{
|
||||
testCOVSubscribeData(data, test_data);
|
||||
zassert_equal(test_data->monitoredProperty.propertyIdentifier,
|
||||
data->monitoredProperty.propertyIdentifier, NULL);
|
||||
zassert_equal(test_data->monitoredProperty.propertyArrayIndex,
|
||||
data->monitoredProperty.propertyArrayIndex, NULL);
|
||||
zassert_equal(
|
||||
test_data->monitoredProperty.propertyIdentifier,
|
||||
data->monitoredProperty.propertyIdentifier, NULL);
|
||||
zassert_equal(
|
||||
test_data->monitoredProperty.propertyArrayIndex,
|
||||
data->monitoredProperty.propertyArrayIndex, NULL);
|
||||
zassert_equal(test_data->covIncrementPresent, data->covIncrementPresent, NULL);
|
||||
test_data->covIncrementPresent, data->covIncrementPresent, NULL);
|
||||
if (test_data->covIncrementPresent) {
|
||||
zassert_equal(test_data->covIncrement, data->covIncrement, NULL);
|
||||
}
|
||||
@@ -286,7 +278,7 @@ static void testCOVSubscribeEncoding(
|
||||
uint8_t apdu[480] = { 0 };
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
BACNET_SUBSCRIBE_COV_DATA test_data;
|
||||
BACNET_SUBSCRIBE_COV_DATA test_data = { 0 };
|
||||
uint8_t test_invoke_id = 0;
|
||||
|
||||
len = cov_subscribe_encode_apdu(&apdu[0], sizeof(apdu), invoke_id, data);
|
||||
@@ -328,7 +320,7 @@ static void testCOVSubscribe(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t invoke_id = 12;
|
||||
BACNET_SUBSCRIBE_COV_DATA data;
|
||||
BACNET_SUBSCRIBE_COV_DATA data = { 0 };
|
||||
|
||||
data.subscriberProcessIdentifier = 1;
|
||||
data.monitoredObjectIdentifier.type = OBJECT_ANALOG_INPUT;
|
||||
@@ -375,17 +367,14 @@ static void testCOVSubscribeProperty(void)
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
ZTEST_SUITE(cov_tests, NULL, NULL, NULL, NULL, NULL);
|
||||
#else
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(cov_tests,
|
||||
ztest_unit_test(testCOVNotify),
|
||||
ztest_unit_test(testCOVSubscribe),
|
||||
ztest_unit_test(testCOVSubscribeProperty)
|
||||
);
|
||||
ztest_test_suite(cov_tests, ztest_unit_test(testCOVNotify),
|
||||
ztest_unit_test(testCOVSubscribe),
|
||||
ztest_unit_test(testCOVSubscribeProperty));
|
||||
|
||||
ztest_run_test_suite(cov_tests);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user