diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce2933f..381505c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ The git repositories are hosted at the following sites: ### Fixed +* Fixed unit test stack corruption from using stack based message text + characterstring pointer in multiple functions and setting the value + in the global event and test event data structures. (#1154) * Fix timesync recipient encoding to check for OBJECT_DEVICE type before encoding. (#1153) * Fixed segmented ComplexACK in MS/TP by adding postpone reply because diff --git a/test/bacnet/event/src/main.c b/test/bacnet/event/src/main.c index 2c28e59c..77ca206e 100644 --- a/test/bacnet/event/src/main.c +++ b/test/bacnet/event/src/main.c @@ -14,93 +14,96 @@ * @{ */ -static BACNET_EVENT_NOTIFICATION_DATA data; -static BACNET_EVENT_NOTIFICATION_DATA data2; +static BACNET_EVENT_NOTIFICATION_DATA Data; +static BACNET_CHARACTER_STRING Message_Text; +static BACNET_EVENT_NOTIFICATION_DATA Test_Data; +static BACNET_CHARACTER_STRING Test_Message_Text; /** * @brief Helper test to BACnet event handlers */ static void verifyBaseEventState(void) { - zassert_equal(data.processIdentifier, data2.processIdentifier, NULL); + zassert_equal(Data.processIdentifier, Test_Data.processIdentifier, NULL); zassert_equal( - data.initiatingObjectIdentifier.instance, - data2.initiatingObjectIdentifier.instance, NULL); + Data.initiatingObjectIdentifier.instance, + Test_Data.initiatingObjectIdentifier.instance, NULL); zassert_equal( - data.initiatingObjectIdentifier.type, - data2.initiatingObjectIdentifier.type, NULL); + Data.initiatingObjectIdentifier.type, + Test_Data.initiatingObjectIdentifier.type, NULL); zassert_equal( - data.eventObjectIdentifier.instance, - data2.eventObjectIdentifier.instance, NULL); + Data.eventObjectIdentifier.instance, + Test_Data.eventObjectIdentifier.instance, NULL); zassert_equal( - data.eventObjectIdentifier.type, data2.eventObjectIdentifier.type, + Data.eventObjectIdentifier.type, Test_Data.eventObjectIdentifier.type, NULL); - zassert_equal(data.notificationClass, data2.notificationClass, NULL); - zassert_equal(data.priority, data2.priority, NULL); - zassert_equal(data.notifyType, data2.notifyType, NULL); - zassert_equal(data.fromState, data2.fromState, NULL); - zassert_equal(data.toState, data2.toState, NULL); - zassert_equal(data.toState, data2.toState, NULL); + zassert_equal(Data.notificationClass, Test_Data.notificationClass, NULL); + zassert_equal(Data.priority, Test_Data.priority, NULL); + zassert_equal(Data.notifyType, Test_Data.notifyType, NULL); + zassert_equal(Data.fromState, Test_Data.fromState, NULL); + zassert_equal(Data.toState, Test_Data.toState, NULL); + zassert_equal(Data.toState, Test_Data.toState, NULL); - if (data.messageText != NULL && data2.messageText != NULL) { + if (Data.messageText != NULL && Test_Data.messageText != NULL) { zassert_equal( - data.messageText->encoding, data2.messageText->encoding, NULL); + Data.messageText->encoding, Test_Data.messageText->encoding, NULL); zassert_equal( - data.messageText->length, data2.messageText->length, NULL); + Data.messageText->length, Test_Data.messageText->length, NULL); zassert_equal( - strcmp(data.messageText->value, data2.messageText->value), 0, NULL); + strcmp(Data.messageText->value, Test_Data.messageText->value), 0, + NULL); } - zassert_equal(data.timeStamp.tag, data2.timeStamp.tag, NULL); + zassert_equal(Data.timeStamp.tag, Test_Data.timeStamp.tag, NULL); - switch (data.timeStamp.tag) { + switch (Data.timeStamp.tag) { case TIME_STAMP_SEQUENCE: zassert_equal( - data.timeStamp.value.sequenceNum, - data2.timeStamp.value.sequenceNum, NULL); + Data.timeStamp.value.sequenceNum, + Test_Data.timeStamp.value.sequenceNum, NULL); break; case TIME_STAMP_DATETIME: zassert_equal( - data.timeStamp.value.dateTime.time.hour, - data2.timeStamp.value.dateTime.time.hour, NULL); + Data.timeStamp.value.dateTime.time.hour, + Test_Data.timeStamp.value.dateTime.time.hour, NULL); zassert_equal( - data.timeStamp.value.dateTime.time.min, - data2.timeStamp.value.dateTime.time.min, NULL); + Data.timeStamp.value.dateTime.time.min, + Test_Data.timeStamp.value.dateTime.time.min, NULL); zassert_equal( - data.timeStamp.value.dateTime.time.sec, - data2.timeStamp.value.dateTime.time.sec, NULL); + Data.timeStamp.value.dateTime.time.sec, + Test_Data.timeStamp.value.dateTime.time.sec, NULL); zassert_equal( - data.timeStamp.value.dateTime.time.hundredths, - data2.timeStamp.value.dateTime.time.hundredths, NULL); + Data.timeStamp.value.dateTime.time.hundredths, + Test_Data.timeStamp.value.dateTime.time.hundredths, NULL); zassert_equal( - data.timeStamp.value.dateTime.date.day, - data2.timeStamp.value.dateTime.date.day, NULL); + Data.timeStamp.value.dateTime.date.day, + Test_Data.timeStamp.value.dateTime.date.day, NULL); zassert_equal( - data.timeStamp.value.dateTime.date.month, - data2.timeStamp.value.dateTime.date.month, NULL); + Data.timeStamp.value.dateTime.date.month, + Test_Data.timeStamp.value.dateTime.date.month, NULL); zassert_equal( - data.timeStamp.value.dateTime.date.wday, - data2.timeStamp.value.dateTime.date.wday, NULL); + Data.timeStamp.value.dateTime.date.wday, + Test_Data.timeStamp.value.dateTime.date.wday, NULL); zassert_equal( - data.timeStamp.value.dateTime.date.year, - data2.timeStamp.value.dateTime.date.year, NULL); + Data.timeStamp.value.dateTime.date.year, + Test_Data.timeStamp.value.dateTime.date.year, NULL); break; case TIME_STAMP_TIME: zassert_equal( - data.timeStamp.value.time.hour, data2.timeStamp.value.time.hour, - NULL); + Data.timeStamp.value.time.hour, + Test_Data.timeStamp.value.time.hour, NULL); zassert_equal( - data.timeStamp.value.time.min, data2.timeStamp.value.time.min, - NULL); + Data.timeStamp.value.time.min, + Test_Data.timeStamp.value.time.min, NULL); zassert_equal( - data.timeStamp.value.time.sec, data2.timeStamp.value.time.sec, - NULL); + Data.timeStamp.value.time.sec, + Test_Data.timeStamp.value.time.sec, NULL); zassert_equal( - data.timeStamp.value.time.hundredths, - data2.timeStamp.value.time.hundredths, NULL); + Data.timeStamp.value.time.hundredths, + Test_Data.timeStamp.value.time.hundredths, NULL); break; default: @@ -113,302 +116,307 @@ static void testEventBufferReady(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_BUFFER_READY; - data.notificationParams.bufferReady.previousNotification = 1234; - data.notificationParams.bufferReady.currentNotification = 2345; - data.notificationParams.bufferReady.bufferProperty.deviceIdentifier.type = + Data.eventType = EVENT_BUFFER_READY; + Data.notificationParams.bufferReady.previousNotification = 1234; + Data.notificationParams.bufferReady.currentNotification = 2345; + Data.notificationParams.bufferReady.bufferProperty.deviceIdentifier.type = OBJECT_DEVICE; - data.notificationParams.bufferReady.bufferProperty.deviceIdentifier + Data.notificationParams.bufferReady.bufferProperty.deviceIdentifier .instance = 500; - data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type = + Data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type = OBJECT_ANALOG_INPUT; - data.notificationParams.bufferReady.bufferProperty.objectIdentifier + Data.notificationParams.bufferReady.bufferProperty.objectIdentifier .instance = 100; - data.notificationParams.bufferReady.bufferProperty.propertyIdentifier = + Data.notificationParams.bufferReady.bufferProperty.propertyIdentifier = PROP_PRESENT_VALUE; - data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0; + Data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0; memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.bufferReady.previousNotification, - data2.notificationParams.bufferReady.previousNotification, NULL); + Data.notificationParams.bufferReady.previousNotification, + Test_Data.notificationParams.bufferReady.previousNotification, NULL); zassert_equal( - data.notificationParams.bufferReady.currentNotification, - data2.notificationParams.bufferReady.currentNotification, NULL); + Data.notificationParams.bufferReady.currentNotification, + Test_Data.notificationParams.bufferReady.currentNotification, NULL); zassert_equal( - data.notificationParams.bufferReady.bufferProperty.deviceIdentifier + Data.notificationParams.bufferReady.bufferProperty.deviceIdentifier .type, - data2.notificationParams.bufferReady.bufferProperty.deviceIdentifier + Test_Data.notificationParams.bufferReady.bufferProperty.deviceIdentifier .type, NULL); zassert_equal( - data.notificationParams.bufferReady.bufferProperty.deviceIdentifier + Data.notificationParams.bufferReady.bufferProperty.deviceIdentifier .instance, - data2.notificationParams.bufferReady.bufferProperty.deviceIdentifier + Test_Data.notificationParams.bufferReady.bufferProperty.deviceIdentifier .instance, NULL); zassert_equal( - data.notificationParams.bufferReady.bufferProperty.objectIdentifier + Data.notificationParams.bufferReady.bufferProperty.objectIdentifier .instance, - data2.notificationParams.bufferReady.bufferProperty.objectIdentifier + Test_Data.notificationParams.bufferReady.bufferProperty.objectIdentifier .instance, NULL); zassert_equal( - data.notificationParams.bufferReady.bufferProperty.objectIdentifier + Data.notificationParams.bufferReady.bufferProperty.objectIdentifier .type, - data2.notificationParams.bufferReady.bufferProperty.objectIdentifier + Test_Data.notificationParams.bufferReady.bufferProperty.objectIdentifier .type, NULL); zassert_equal( - data.notificationParams.bufferReady.bufferProperty.propertyIdentifier, - data2.notificationParams.bufferReady.bufferProperty.propertyIdentifier, + Data.notificationParams.bufferReady.bufferProperty.propertyIdentifier, + Test_Data.notificationParams.bufferReady.bufferProperty + .propertyIdentifier, NULL); zassert_equal( - data.notificationParams.bufferReady.bufferProperty.arrayIndex, - data2.notificationParams.bufferReady.bufferProperty.arrayIndex, NULL); + Data.notificationParams.bufferReady.bufferProperty.arrayIndex, + Test_Data.notificationParams.bufferReady.bufferProperty.arrayIndex, + NULL); } static void testEventAccessEvent(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; // OPTIONAL authenticationFactor omitted - data.eventType = EVENT_ACCESS_EVENT; - data.notificationParams.accessEvent.accessEvent = + Data.eventType = EVENT_ACCESS_EVENT; + Data.notificationParams.accessEvent.accessEvent = ACCESS_EVENT_LOCKED_BY_HIGHER_AUTHORITY; - data.notificationParams.accessEvent.accessEventTag = 7; - data.notificationParams.accessEvent.accessEventTime.tag = + Data.notificationParams.accessEvent.accessEventTag = 7; + Data.notificationParams.accessEvent.accessEventTime.tag = TIME_STAMP_SEQUENCE; - data.notificationParams.accessEvent.accessEventTime.value.sequenceNum = 17; - data.notificationParams.accessEvent.accessCredential.deviceIdentifier + Data.notificationParams.accessEvent.accessEventTime.value.sequenceNum = 17; + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier .instance = 1234; - data.notificationParams.accessEvent.accessCredential.deviceIdentifier.type = + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier.type = OBJECT_DEVICE; - data.notificationParams.accessEvent.accessCredential.objectIdentifier + Data.notificationParams.accessEvent.accessCredential.objectIdentifier .instance = 17; - data.notificationParams.accessEvent.accessCredential.objectIdentifier.type = + Data.notificationParams.accessEvent.accessCredential.objectIdentifier.type = OBJECT_ACCESS_POINT; - data.notificationParams.accessEvent.authenticationFactor.format_type = + Data.notificationParams.accessEvent.authenticationFactor.format_type = AUTHENTICATION_FACTOR_MAX; // omit authenticationFactor - bitstring_init(&data.notificationParams.accessEvent.statusFlags); + bitstring_init(&Data.notificationParams.accessEvent.statusFlags); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_IN_ALARM, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.accessEvent.accessEvent, - data2.notificationParams.accessEvent.accessEvent, NULL); + Data.notificationParams.accessEvent.accessEvent, + Test_Data.notificationParams.accessEvent.accessEvent, NULL); zassert_true( bitstring_same( - &data.notificationParams.accessEvent.statusFlags, - &data2.notificationParams.accessEvent.statusFlags), + &Data.notificationParams.accessEvent.statusFlags, + &Test_Data.notificationParams.accessEvent.statusFlags), NULL); zassert_equal( - data.notificationParams.accessEvent.accessEventTag, - data2.notificationParams.accessEvent.accessEventTag, NULL); + Data.notificationParams.accessEvent.accessEventTag, + Test_Data.notificationParams.accessEvent.accessEventTag, NULL); zassert_equal( - data.notificationParams.accessEvent.accessEventTime.tag, - data2.notificationParams.accessEvent.accessEventTime.tag, NULL); + Data.notificationParams.accessEvent.accessEventTime.tag, + Test_Data.notificationParams.accessEvent.accessEventTime.tag, NULL); zassert_equal( - data.notificationParams.accessEvent.accessEventTime.value.sequenceNum, - data2.notificationParams.accessEvent.accessEventTime.value.sequenceNum, + Data.notificationParams.accessEvent.accessEventTime.value.sequenceNum, + Test_Data.notificationParams.accessEvent.accessEventTime.value + .sequenceNum, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.deviceIdentifier - .instance, - data2.notificationParams.accessEvent.accessCredential.deviceIdentifier + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier .instance, + Test_Data.notificationParams.accessEvent.accessCredential + .deviceIdentifier.instance, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.deviceIdentifier - .type, - data2.notificationParams.accessEvent.accessCredential.deviceIdentifier + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier .type, + Test_Data.notificationParams.accessEvent.accessCredential + .deviceIdentifier.type, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.objectIdentifier - .instance, - data2.notificationParams.accessEvent.accessCredential.objectIdentifier + Data.notificationParams.accessEvent.accessCredential.objectIdentifier .instance, + Test_Data.notificationParams.accessEvent.accessCredential + .objectIdentifier.instance, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.objectIdentifier - .type, - data2.notificationParams.accessEvent.accessCredential.objectIdentifier + Data.notificationParams.accessEvent.accessCredential.objectIdentifier .type, + Test_Data.notificationParams.accessEvent.accessCredential + .objectIdentifier.type, NULL); // OPTIONAL authenticationFactor included - data.eventType = EVENT_ACCESS_EVENT; - data.notificationParams.accessEvent.accessEvent = + Data.eventType = EVENT_ACCESS_EVENT; + Data.notificationParams.accessEvent.accessEvent = ACCESS_EVENT_LOCKED_BY_HIGHER_AUTHORITY; - data.notificationParams.accessEvent.accessEventTag = 7; - data.notificationParams.accessEvent.accessEventTime.tag = + Data.notificationParams.accessEvent.accessEventTag = 7; + Data.notificationParams.accessEvent.accessEventTime.tag = TIME_STAMP_SEQUENCE; - data.notificationParams.accessEvent.accessEventTime.value.sequenceNum = 17; - data.notificationParams.accessEvent.accessCredential.deviceIdentifier + Data.notificationParams.accessEvent.accessEventTime.value.sequenceNum = 17; + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier .instance = 1234; - data.notificationParams.accessEvent.accessCredential.deviceIdentifier.type = + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier.type = OBJECT_DEVICE; - data.notificationParams.accessEvent.accessCredential.objectIdentifier + Data.notificationParams.accessEvent.accessCredential.objectIdentifier .instance = 17; - data.notificationParams.accessEvent.accessCredential.objectIdentifier.type = + Data.notificationParams.accessEvent.accessCredential.objectIdentifier.type = OBJECT_ACCESS_POINT; - data.notificationParams.accessEvent.authenticationFactor.format_type = + Data.notificationParams.accessEvent.authenticationFactor.format_type = AUTHENTICATION_FACTOR_SIMPLE_NUMBER16; - data.notificationParams.accessEvent.authenticationFactor.format_class = 215; + Data.notificationParams.accessEvent.authenticationFactor.format_class = 215; uint8_t octetstringValue[2] = { 0x00, 0x10 }; octetstring_init( - &data.notificationParams.accessEvent.authenticationFactor.value, + &Data.notificationParams.accessEvent.authenticationFactor.value, octetstringValue, 2); - bitstring_init(&data.notificationParams.accessEvent.statusFlags); + bitstring_init(&Data.notificationParams.accessEvent.statusFlags); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_IN_ALARM, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.accessEvent.statusFlags, + &Data.notificationParams.accessEvent.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.accessEvent.accessEvent, - data2.notificationParams.accessEvent.accessEvent, NULL); + Data.notificationParams.accessEvent.accessEvent, + Test_Data.notificationParams.accessEvent.accessEvent, NULL); zassert_true( bitstring_same( - &data.notificationParams.accessEvent.statusFlags, - &data2.notificationParams.accessEvent.statusFlags), + &Data.notificationParams.accessEvent.statusFlags, + &Test_Data.notificationParams.accessEvent.statusFlags), NULL); zassert_equal( - data.notificationParams.accessEvent.accessEventTag, - data2.notificationParams.accessEvent.accessEventTag, NULL); + Data.notificationParams.accessEvent.accessEventTag, + Test_Data.notificationParams.accessEvent.accessEventTag, NULL); zassert_equal( - data.notificationParams.accessEvent.accessEventTime.tag, - data2.notificationParams.accessEvent.accessEventTime.tag, NULL); + Data.notificationParams.accessEvent.accessEventTime.tag, + Test_Data.notificationParams.accessEvent.accessEventTime.tag, NULL); zassert_equal( - data.notificationParams.accessEvent.accessEventTime.value.sequenceNum, - data2.notificationParams.accessEvent.accessEventTime.value.sequenceNum, + Data.notificationParams.accessEvent.accessEventTime.value.sequenceNum, + Test_Data.notificationParams.accessEvent.accessEventTime.value + .sequenceNum, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.deviceIdentifier + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier .instance, - data2.notificationParams.accessEvent.accessCredential.deviceIdentifier + Test_Data.notificationParams.accessEvent.accessCredential + .deviceIdentifier.instance, + NULL); + + zassert_equal( + Data.notificationParams.accessEvent.accessCredential.deviceIdentifier + .type, + Test_Data.notificationParams.accessEvent.accessCredential + .deviceIdentifier.type, + NULL); + + zassert_equal( + Data.notificationParams.accessEvent.accessCredential.objectIdentifier .instance, + Test_Data.notificationParams.accessEvent.accessCredential + .objectIdentifier.instance, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.deviceIdentifier - .type, - data2.notificationParams.accessEvent.accessCredential.deviceIdentifier + Data.notificationParams.accessEvent.accessCredential.objectIdentifier .type, + Test_Data.notificationParams.accessEvent.accessCredential + .objectIdentifier.type, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.objectIdentifier - .instance, - data2.notificationParams.accessEvent.accessCredential.objectIdentifier - .instance, + Data.notificationParams.accessEvent.authenticationFactor.format_type, + Test_Data.notificationParams.accessEvent.authenticationFactor + .format_type, NULL); zassert_equal( - data.notificationParams.accessEvent.accessCredential.objectIdentifier - .type, - data2.notificationParams.accessEvent.accessCredential.objectIdentifier - .type, - NULL); - - zassert_equal( - data.notificationParams.accessEvent.authenticationFactor.format_type, - data2.notificationParams.accessEvent.authenticationFactor.format_type, - NULL); - - zassert_equal( - data.notificationParams.accessEvent.authenticationFactor.format_class, - data2.notificationParams.accessEvent.authenticationFactor.format_class, + Data.notificationParams.accessEvent.authenticationFactor.format_class, + Test_Data.notificationParams.accessEvent.authenticationFactor + .format_class, NULL); zassert_true( octetstring_value_same( - &data.notificationParams.accessEvent.authenticationFactor.value, - &data2.notificationParams.accessEvent.authenticationFactor.value), + &Data.notificationParams.accessEvent.authenticationFactor.value, + &Test_Data.notificationParams.accessEvent.authenticationFactor + .value), NULL); } @@ -416,55 +424,54 @@ static void testEventDoubleOutOfRange(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_DOUBLE_OUT_OF_RANGE; - data.notificationParams.doubleOutOfRange.exceedingValue = 3.45; - data.notificationParams.doubleOutOfRange.deadband = 2.34; - data.notificationParams.doubleOutOfRange.exceededLimit = 1.23; - bitstring_init(&data.notificationParams.doubleOutOfRange.statusFlags); + Data.eventType = EVENT_DOUBLE_OUT_OF_RANGE; + Data.notificationParams.doubleOutOfRange.exceedingValue = 3.45; + Data.notificationParams.doubleOutOfRange.deadband = 2.34; + Data.notificationParams.doubleOutOfRange.exceededLimit = 1.23; + bitstring_init(&Data.notificationParams.doubleOutOfRange.statusFlags); bitstring_set_bit( - &data.notificationParams.doubleOutOfRange.statusFlags, + &Data.notificationParams.doubleOutOfRange.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.doubleOutOfRange.statusFlags, + &Data.notificationParams.doubleOutOfRange.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.doubleOutOfRange.statusFlags, + &Data.notificationParams.doubleOutOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.doubleOutOfRange.statusFlags, + &Data.notificationParams.doubleOutOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_false( islessgreater( - data.notificationParams.doubleOutOfRange.deadband, - data2.notificationParams.doubleOutOfRange.deadband), + Data.notificationParams.doubleOutOfRange.deadband, + Test_Data.notificationParams.doubleOutOfRange.deadband), NULL); zassert_false( islessgreater( - data.notificationParams.doubleOutOfRange.exceededLimit, - data2.notificationParams.doubleOutOfRange.exceededLimit), + Data.notificationParams.doubleOutOfRange.exceededLimit, + Test_Data.notificationParams.doubleOutOfRange.exceededLimit), NULL); zassert_false( islessgreater( - data.notificationParams.doubleOutOfRange.exceedingValue, - data2.notificationParams.doubleOutOfRange.exceedingValue), + Data.notificationParams.doubleOutOfRange.exceedingValue, + Test_Data.notificationParams.doubleOutOfRange.exceedingValue), NULL); zassert_true( bitstring_same( - &data.notificationParams.doubleOutOfRange.statusFlags, - &data2.notificationParams.doubleOutOfRange.statusFlags), + &Data.notificationParams.doubleOutOfRange.statusFlags, + &Test_Data.notificationParams.doubleOutOfRange.statusFlags), NULL); } @@ -472,49 +479,48 @@ static void testEventSignedOutOfRange(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_SIGNED_OUT_OF_RANGE; - data.notificationParams.signedOutOfRange.exceedingValue = -345; - data.notificationParams.signedOutOfRange.deadband = 234; - data.notificationParams.signedOutOfRange.exceededLimit = -123; - bitstring_init(&data.notificationParams.signedOutOfRange.statusFlags); + Data.eventType = EVENT_SIGNED_OUT_OF_RANGE; + Data.notificationParams.signedOutOfRange.exceedingValue = -345; + Data.notificationParams.signedOutOfRange.deadband = 234; + Data.notificationParams.signedOutOfRange.exceededLimit = -123; + bitstring_init(&Data.notificationParams.signedOutOfRange.statusFlags); bitstring_set_bit( - &data.notificationParams.signedOutOfRange.statusFlags, + &Data.notificationParams.signedOutOfRange.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.signedOutOfRange.statusFlags, + &Data.notificationParams.signedOutOfRange.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.signedOutOfRange.statusFlags, + &Data.notificationParams.signedOutOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.signedOutOfRange.statusFlags, + &Data.notificationParams.signedOutOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.signedOutOfRange.deadband, - data2.notificationParams.signedOutOfRange.deadband, NULL); + Data.notificationParams.signedOutOfRange.deadband, + Test_Data.notificationParams.signedOutOfRange.deadband, NULL); zassert_equal( - data.notificationParams.signedOutOfRange.exceededLimit, - data2.notificationParams.signedOutOfRange.exceededLimit, NULL); + Data.notificationParams.signedOutOfRange.exceededLimit, + Test_Data.notificationParams.signedOutOfRange.exceededLimit, NULL); zassert_equal( - data.notificationParams.signedOutOfRange.exceedingValue, - data2.notificationParams.signedOutOfRange.exceedingValue, NULL); + Data.notificationParams.signedOutOfRange.exceedingValue, + Test_Data.notificationParams.signedOutOfRange.exceedingValue, NULL); zassert_true( bitstring_same( - &data.notificationParams.signedOutOfRange.statusFlags, - &data2.notificationParams.signedOutOfRange.statusFlags), + &Data.notificationParams.signedOutOfRange.statusFlags, + &Test_Data.notificationParams.signedOutOfRange.statusFlags), NULL); } @@ -522,37 +528,36 @@ static void testEventProprietary(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_PROPRIETARY_MIN; - data.notificationParams.complexEventType.values[0].propertyIdentifier = + Data.eventType = EVENT_PROPRIETARY_MIN; + Data.notificationParams.complexEventType.values[0].propertyIdentifier = PROP_PRESENT_VALUE; - data.notificationParams.complexEventType.values[0].priority = 1; - data.notificationParams.complexEventType.values[0].propertyArrayIndex = + Data.notificationParams.complexEventType.values[0].priority = 1; + Data.notificationParams.complexEventType.values[0].propertyArrayIndex = BACNET_ARRAY_ALL; - data.notificationParams.complexEventType.values[0].value.tag = + Data.notificationParams.complexEventType.values[0].value.tag = BACNET_APPLICATION_TAG_REAL; - data.notificationParams.complexEventType.values[0].value.type.Real = 1.0f; - data.notificationParams.complexEventType.values[0].value.context_specific = + Data.notificationParams.complexEventType.values[0].value.type.Real = 1.0f; + Data.notificationParams.complexEventType.values[0].value.context_specific = false; - data.notificationParams.complexEventType.values[0].value.context_tag = 0; - data.notificationParams.complexEventType.values[0].value.next = NULL; - data.notificationParams.complexEventType.values[0].next = NULL; + Data.notificationParams.complexEventType.values[0].value.context_tag = 0; + Data.notificationParams.complexEventType.values[0].value.next = NULL; + Data.notificationParams.complexEventType.values[0].next = NULL; memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_true( bacapp_same_value( - &data.notificationParams.complexEventType.values[0].value, - &data2.notificationParams.complexEventType.values[0].value), + &Data.notificationParams.complexEventType.values[0].value, + &Test_Data.notificationParams.complexEventType.values[0].value), NULL); } @@ -560,49 +565,48 @@ static void testEventUnsignedOutOfRange(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_UNSIGNED_OUT_OF_RANGE; - data.notificationParams.unsignedOutOfRange.exceedingValue = 345; - data.notificationParams.unsignedOutOfRange.deadband = 234; - data.notificationParams.unsignedOutOfRange.exceededLimit = 123; - bitstring_init(&data.notificationParams.unsignedOutOfRange.statusFlags); + Data.eventType = EVENT_UNSIGNED_OUT_OF_RANGE; + Data.notificationParams.unsignedOutOfRange.exceedingValue = 345; + Data.notificationParams.unsignedOutOfRange.deadband = 234; + Data.notificationParams.unsignedOutOfRange.exceededLimit = 123; + bitstring_init(&Data.notificationParams.unsignedOutOfRange.statusFlags); bitstring_set_bit( - &data.notificationParams.unsignedOutOfRange.statusFlags, + &Data.notificationParams.unsignedOutOfRange.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.unsignedOutOfRange.statusFlags, + &Data.notificationParams.unsignedOutOfRange.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.unsignedOutOfRange.statusFlags, + &Data.notificationParams.unsignedOutOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.unsignedOutOfRange.statusFlags, + &Data.notificationParams.unsignedOutOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.unsignedOutOfRange.deadband, - data2.notificationParams.unsignedOutOfRange.deadband, NULL); + Data.notificationParams.unsignedOutOfRange.deadband, + Test_Data.notificationParams.unsignedOutOfRange.deadband, NULL); zassert_equal( - data.notificationParams.unsignedOutOfRange.exceededLimit, - data2.notificationParams.unsignedOutOfRange.exceededLimit, NULL); + Data.notificationParams.unsignedOutOfRange.exceededLimit, + Test_Data.notificationParams.unsignedOutOfRange.exceededLimit, NULL); zassert_equal( - data.notificationParams.unsignedOutOfRange.exceedingValue, - data2.notificationParams.unsignedOutOfRange.exceedingValue, NULL); + Data.notificationParams.unsignedOutOfRange.exceedingValue, + Test_Data.notificationParams.unsignedOutOfRange.exceedingValue, NULL); zassert_true( bitstring_same( - &data.notificationParams.unsignedOutOfRange.statusFlags, - &data2.notificationParams.unsignedOutOfRange.statusFlags), + &Data.notificationParams.unsignedOutOfRange.statusFlags, + &Test_Data.notificationParams.unsignedOutOfRange.statusFlags), NULL); } @@ -610,52 +614,51 @@ static void testEventChangeOfCharacterstring(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; BACNET_CHARACTER_STRING changed_value = { 0 }; BACNET_CHARACTER_STRING alarm_value = { 0 }; - data.eventType = EVENT_CHANGE_OF_CHARACTERSTRING; - data.notificationParams.changeOfCharacterstring.changedValue = + Data.eventType = EVENT_CHANGE_OF_CHARACTERSTRING; + Data.notificationParams.changeOfCharacterstring.changedValue = &changed_value; - data.notificationParams.changeOfCharacterstring.alarmValue = &alarm_value; + Data.notificationParams.changeOfCharacterstring.alarmValue = &alarm_value; bitstring_init( - &data.notificationParams.changeOfCharacterstring.statusFlags); + &Data.notificationParams.changeOfCharacterstring.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfCharacterstring.statusFlags, + &Data.notificationParams.changeOfCharacterstring.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfCharacterstring.statusFlags, + &Data.notificationParams.changeOfCharacterstring.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfCharacterstring.statusFlags, + &Data.notificationParams.changeOfCharacterstring.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfCharacterstring.statusFlags, + &Data.notificationParams.changeOfCharacterstring.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_true( characterstring_same( - data.notificationParams.changeOfCharacterstring.changedValue, - data2.notificationParams.changeOfCharacterstring.changedValue), + Data.notificationParams.changeOfCharacterstring.changedValue, + Test_Data.notificationParams.changeOfCharacterstring.changedValue), NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfCharacterstring.statusFlags, - &data2.notificationParams.changeOfCharacterstring.statusFlags), + &Data.notificationParams.changeOfCharacterstring.statusFlags, + &Test_Data.notificationParams.changeOfCharacterstring.statusFlags), NULL); zassert_true( characterstring_same( - data.notificationParams.changeOfCharacterstring.alarmValue, - data2.notificationParams.changeOfCharacterstring.alarmValue), + Data.notificationParams.changeOfCharacterstring.alarmValue, + Test_Data.notificationParams.changeOfCharacterstring.alarmValue), NULL); } @@ -663,7 +666,6 @@ static void testEventChangeOfStatusFlags(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; BACNET_OCTET_STRING extended_ostring = { 0 }; BACNET_CHARACTER_STRING extended_cstring = { 0 }; BACNET_BIT_STRING extended_bstring = { 0 }; @@ -706,45 +708,45 @@ static void testEventChangeOfStatusFlags(void) { .tag = MAX_BACNET_APPLICATION_TAG, .type.Unsigned_Int = 0 }, }; - data.eventType = EVENT_CHANGE_OF_STATUS_FLAGS; + Data.eventType = EVENT_CHANGE_OF_STATUS_FLAGS; bitstring_init( - &data.notificationParams.changeOfStatusFlags.referencedFlags); + &Data.notificationParams.changeOfStatusFlags.referencedFlags); bitstring_set_bit( - &data.notificationParams.changeOfStatusFlags.referencedFlags, + &Data.notificationParams.changeOfStatusFlags.referencedFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfStatusFlags.referencedFlags, + &Data.notificationParams.changeOfStatusFlags.referencedFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfStatusFlags.referencedFlags, + &Data.notificationParams.changeOfStatusFlags.referencedFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfStatusFlags.referencedFlags, + &Data.notificationParams.changeOfStatusFlags.referencedFlags, STATUS_FLAG_OUT_OF_SERVICE, false); i = 0; while (present_value[i].tag != MAX_BACNET_APPLICATION_TAG) { memcpy( - &data.notificationParams.changeOfStatusFlags.presentValue, + &Data.notificationParams.changeOfStatusFlags.presentValue, &present_value[i], sizeof(present_value[i])); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; + memset(&Test_Data, 0, sizeof(Test_Data)); test_len = - event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "tag=%s apdu_len=%d test_len=%d", bactext_application_tag_name( - data.notificationParams.changeOfStatusFlags.presentValue.tag), + Data.notificationParams.changeOfStatusFlags.presentValue.tag), apdu_len, test_len); verifyBaseEventState(); zassert_true( bitstring_same( - &data.notificationParams.changeOfStatusFlags.referencedFlags, - &data2.notificationParams.changeOfStatusFlags.referencedFlags), + &Data.notificationParams.changeOfStatusFlags.referencedFlags, + &Test_Data.notificationParams.changeOfStatusFlags + .referencedFlags), NULL); i++; } @@ -752,7 +754,7 @@ static void testEventChangeOfStatusFlags(void) static void testEventchangeOfReliability(void) { - uint8_t apdu[MAX_APDU]; + uint8_t apdu[MAX_APDU] = { 0 }; int apdu_len, test_len, null_len; BACNET_PROPERTY_VALUE property_values = { .priority = 1, @@ -767,42 +769,43 @@ static void testEventchangeOfReliability(void) }; BACNET_PROPERTY_VALUE test_property_values = { 0 }; - data.eventType = EVENT_CHANGE_OF_RELIABILITY; - data.notificationParams.changeOfReliability.reliability = + Data.eventType = EVENT_CHANGE_OF_RELIABILITY; + Data.notificationParams.changeOfReliability.reliability = RELIABILITY_NO_FAULT_DETECTED; - data.notificationParams.changeOfReliability.propertyValues = + Data.notificationParams.changeOfReliability.propertyValues = &property_values; - bitstring_init(&data.notificationParams.changeOfReliability.statusFlags); + bitstring_init(&Data.notificationParams.changeOfReliability.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfReliability.statusFlags, + &Data.notificationParams.changeOfReliability.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfReliability.statusFlags, + &Data.notificationParams.changeOfReliability.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfReliability.statusFlags, + &Data.notificationParams.changeOfReliability.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfReliability.statusFlags, + &Data.notificationParams.changeOfReliability.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - data2.notificationParams.changeOfReliability.propertyValues = + Test_Data.notificationParams.changeOfReliability.propertyValues = &test_property_values; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.changeOfReliability.reliability, - data2.notificationParams.changeOfReliability.reliability, NULL); + Data.notificationParams.changeOfReliability.reliability, + Test_Data.notificationParams.changeOfReliability.reliability, NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfReliability.statusFlags, - &data2.notificationParams.changeOfReliability.statusFlags), + &Data.notificationParams.changeOfReliability.statusFlags, + &Test_Data.notificationParams.changeOfReliability.statusFlags), NULL); /* property_values vs test_property_values*/ zassert_equal( @@ -814,7 +817,9 @@ static void testEventchangeOfReliability(void) property_values.propertyArrayIndex, test_property_values.propertyArrayIndex, NULL); zassert_equal( - property_values.priority, test_property_values.priority, NULL); + property_values.priority, test_property_values.priority, + "priority=%u test_priority=%u", (unsigned)property_values.priority, + (unsigned)test_property_values.priority); zassert_true( bacapp_same_value(&property_values.value, &test_property_values.value), NULL); @@ -826,12 +831,13 @@ static void testEventNone(void) uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - data.eventType = EVENT_NONE; - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + Data.eventType = EVENT_NONE; + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); @@ -841,147 +847,147 @@ static void testEventChangeOfState(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_CHANGE_OF_STATE; - data.notificationParams.changeOfState.newState.tag = PROP_STATE_UNITS; - data.notificationParams.changeOfState.newState.state.units = + Data.eventType = EVENT_CHANGE_OF_STATE; + Data.notificationParams.changeOfState.newState.tag = PROP_STATE_UNITS; + Data.notificationParams.changeOfState.newState.state.units = UNITS_SQUARE_METERS; - bitstring_init(&data.notificationParams.changeOfState.statusFlags); + bitstring_init(&Data.notificationParams.changeOfState.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfState.statusFlags, + &Data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfState.statusFlags, + &Data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfState.statusFlags, + &Data.notificationParams.changeOfState.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.changeOfState.newState.tag, - data2.notificationParams.changeOfState.newState.tag, NULL); + Data.notificationParams.changeOfState.newState.tag, + Test_Data.notificationParams.changeOfState.newState.tag, NULL); zassert_equal( - data.notificationParams.changeOfState.newState.state.units, - data2.notificationParams.changeOfState.newState.state.units, NULL); + Data.notificationParams.changeOfState.newState.state.units, + Test_Data.notificationParams.changeOfState.newState.state.units, NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfState.statusFlags, - &data2.notificationParams.changeOfState.statusFlags), + &Data.notificationParams.changeOfState.statusFlags, + &Test_Data.notificationParams.changeOfState.statusFlags), NULL); /* ** Same, but timestamp of */ - data.timeStamp.tag = TIME_STAMP_DATETIME; - data.timeStamp.value.dateTime.time.hour = 1; - data.timeStamp.value.dateTime.time.min = 2; - data.timeStamp.value.dateTime.time.sec = 3; - data.timeStamp.value.dateTime.time.hundredths = 4; + Data.timeStamp.tag = TIME_STAMP_DATETIME; + Data.timeStamp.value.dateTime.time.hour = 1; + Data.timeStamp.value.dateTime.time.min = 2; + Data.timeStamp.value.dateTime.time.sec = 3; + Data.timeStamp.value.dateTime.time.hundredths = 4; - data.timeStamp.value.dateTime.date.day = 1; - data.timeStamp.value.dateTime.date.month = 1; - data.timeStamp.value.dateTime.date.wday = 1; - data.timeStamp.value.dateTime.date.year = 1945; + Data.timeStamp.value.dateTime.date.day = 1; + Data.timeStamp.value.dateTime.date.month = 1; + Data.timeStamp.value.dateTime.date.wday = 1; + Data.timeStamp.value.dateTime.date.year = 1945; memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.changeOfState.newState.tag, - data2.notificationParams.changeOfState.newState.tag, NULL); + Data.notificationParams.changeOfState.newState.tag, + Test_Data.notificationParams.changeOfState.newState.tag, NULL); zassert_equal( - data.notificationParams.changeOfState.newState.state.units, - data2.notificationParams.changeOfState.newState.state.units, NULL); + Data.notificationParams.changeOfState.newState.state.units, + Test_Data.notificationParams.changeOfState.newState.state.units, NULL); } static void testEventChangeOfBitstring(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.timeStamp.value.sequenceNum = 1234; - data.timeStamp.tag = TIME_STAMP_SEQUENCE; + Data.timeStamp.value.sequenceNum = 1234; + Data.timeStamp.tag = TIME_STAMP_SEQUENCE; - data.eventType = EVENT_CHANGE_OF_BITSTRING; + Data.eventType = EVENT_CHANGE_OF_BITSTRING; bitstring_init( - &data.notificationParams.changeOfBitstring.referencedBitString); + &Data.notificationParams.changeOfBitstring.referencedBitString); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.referencedBitString, 0, + &Data.notificationParams.changeOfBitstring.referencedBitString, 0, true); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.referencedBitString, 1, + &Data.notificationParams.changeOfBitstring.referencedBitString, 1, false); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.referencedBitString, 2, + &Data.notificationParams.changeOfBitstring.referencedBitString, 2, true); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.referencedBitString, 2, + &Data.notificationParams.changeOfBitstring.referencedBitString, 2, false); - bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags); + bitstring_init(&Data.notificationParams.changeOfBitstring.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.statusFlags, + &Data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.statusFlags, + &Data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.statusFlags, + &Data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfBitstring.statusFlags, + &Data.notificationParams.changeOfBitstring.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_true( bitstring_same( - &data.notificationParams.changeOfBitstring.referencedBitString, - &data2.notificationParams.changeOfBitstring.referencedBitString), + &Data.notificationParams.changeOfBitstring.referencedBitString, + &Test_Data.notificationParams.changeOfBitstring + .referencedBitString), NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfBitstring.statusFlags, - &data2.notificationParams.changeOfBitstring.statusFlags), + &Data.notificationParams.changeOfBitstring.statusFlags, + &Test_Data.notificationParams.changeOfBitstring.statusFlags), NULL); } @@ -989,93 +995,92 @@ static void testEventChangeOfValue(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_CHANGE_OF_VALUE; - data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_REAL; - data.notificationParams.changeOfValue.newValue.changeValue = 1.23f; + Data.eventType = EVENT_CHANGE_OF_VALUE; + Data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_REAL; + Data.notificationParams.changeOfValue.newValue.changeValue = 1.23f; - bitstring_init(&data.notificationParams.changeOfValue.statusFlags); + bitstring_init(&Data.notificationParams.changeOfValue.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfValue.statusFlags, + &Data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfValue.statusFlags, + &Data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfValue.statusFlags, + &Data.notificationParams.changeOfValue.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_true( bitstring_same( - &data.notificationParams.changeOfValue.statusFlags, - &data2.notificationParams.changeOfValue.statusFlags), + &Data.notificationParams.changeOfValue.statusFlags, + &Test_Data.notificationParams.changeOfValue.statusFlags), NULL); zassert_equal( - data.notificationParams.changeOfValue.tag, - data2.notificationParams.changeOfValue.tag, NULL); + Data.notificationParams.changeOfValue.tag, + Test_Data.notificationParams.changeOfValue.tag, NULL); zassert_false( islessgreater( - data.notificationParams.changeOfValue.newValue.changeValue, - data2.notificationParams.changeOfValue.newValue.changeValue), + Data.notificationParams.changeOfValue.newValue.changeValue, + Test_Data.notificationParams.changeOfValue.newValue.changeValue), NULL); /* ** Event Type = EVENT_CHANGE_OF_VALUE - bitstring value */ - data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS; - bitstring_init(&data.notificationParams.changeOfValue.newValue.changedBits); + Data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS; + bitstring_init(&Data.notificationParams.changeOfValue.newValue.changedBits); bitstring_set_bit( - &data.notificationParams.changeOfValue.newValue.changedBits, 0, true); + &Data.notificationParams.changeOfValue.newValue.changedBits, 0, true); bitstring_set_bit( - &data.notificationParams.changeOfValue.newValue.changedBits, 1, false); + &Data.notificationParams.changeOfValue.newValue.changedBits, 1, false); bitstring_set_bit( - &data.notificationParams.changeOfValue.newValue.changedBits, 2, false); + &Data.notificationParams.changeOfValue.newValue.changedBits, 2, false); bitstring_set_bit( - &data.notificationParams.changeOfValue.newValue.changedBits, 3, false); + &Data.notificationParams.changeOfValue.newValue.changedBits, 3, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_true( bitstring_same( - &data.notificationParams.changeOfValue.statusFlags, - &data2.notificationParams.changeOfValue.statusFlags), + &Data.notificationParams.changeOfValue.statusFlags, + &Test_Data.notificationParams.changeOfValue.statusFlags), NULL); zassert_equal( - data.notificationParams.changeOfValue.tag, - data2.notificationParams.changeOfValue.tag, NULL); + Data.notificationParams.changeOfValue.tag, + Test_Data.notificationParams.changeOfValue.tag, NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfValue.newValue.changedBits, - &data2.notificationParams.changeOfValue.newValue.changedBits), + &Data.notificationParams.changeOfValue.newValue.changedBits, + &Test_Data.notificationParams.changeOfValue.newValue.changedBits), NULL); } @@ -1083,108 +1088,108 @@ static void testEventCommandFailure(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; /* ** commandValue = enumerated */ - data.eventType = EVENT_COMMAND_FAILURE; - data.notificationParams.commandFailure.tag = COMMAND_FAILURE_BINARY_PV; - data.notificationParams.commandFailure.commandValue.binaryValue = + Data.eventType = EVENT_COMMAND_FAILURE; + Data.notificationParams.commandFailure.tag = COMMAND_FAILURE_BINARY_PV; + Data.notificationParams.commandFailure.commandValue.binaryValue = BINARY_INACTIVE; - data.notificationParams.commandFailure.feedbackValue.binaryValue = + Data.notificationParams.commandFailure.feedbackValue.binaryValue = BINARY_ACTIVE; - bitstring_init(&data.notificationParams.commandFailure.statusFlags); + bitstring_init(&Data.notificationParams.commandFailure.statusFlags); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.commandFailure.commandValue.binaryValue, - data2.notificationParams.commandFailure.commandValue.binaryValue, NULL); + Data.notificationParams.commandFailure.commandValue.binaryValue, + Test_Data.notificationParams.commandFailure.commandValue.binaryValue, + NULL); zassert_equal( - data.notificationParams.commandFailure.feedbackValue.binaryValue, - data2.notificationParams.commandFailure.feedbackValue.binaryValue, + Data.notificationParams.commandFailure.feedbackValue.binaryValue, + Test_Data.notificationParams.commandFailure.feedbackValue.binaryValue, NULL); zassert_true( bitstring_same( - &data.notificationParams.commandFailure.statusFlags, - &data2.notificationParams.commandFailure.statusFlags), + &Data.notificationParams.commandFailure.statusFlags, + &Test_Data.notificationParams.commandFailure.statusFlags), NULL); /* ** commandValue = unsigned */ - data.eventType = EVENT_COMMAND_FAILURE; - data.notificationParams.commandFailure.tag = COMMAND_FAILURE_UNSIGNED; - data.notificationParams.commandFailure.commandValue.unsignedValue = 10; - data.notificationParams.commandFailure.feedbackValue.unsignedValue = 2; + Data.eventType = EVENT_COMMAND_FAILURE; + Data.notificationParams.commandFailure.tag = COMMAND_FAILURE_UNSIGNED; + Data.notificationParams.commandFailure.commandValue.unsignedValue = 10; + Data.notificationParams.commandFailure.feedbackValue.unsignedValue = 2; - bitstring_init(&data.notificationParams.commandFailure.statusFlags); + bitstring_init(&Data.notificationParams.commandFailure.statusFlags); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.commandFailure.statusFlags, + &Data.notificationParams.commandFailure.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.commandFailure.commandValue.unsignedValue, - data2.notificationParams.commandFailure.commandValue.unsignedValue, + Data.notificationParams.commandFailure.commandValue.unsignedValue, + Test_Data.notificationParams.commandFailure.commandValue.unsignedValue, NULL); zassert_equal( - data.notificationParams.commandFailure.feedbackValue.unsignedValue, - data2.notificationParams.commandFailure.feedbackValue.unsignedValue, + Data.notificationParams.commandFailure.feedbackValue.unsignedValue, + Test_Data.notificationParams.commandFailure.feedbackValue.unsignedValue, NULL); zassert_true( bitstring_same( - &data.notificationParams.commandFailure.statusFlags, - &data2.notificationParams.commandFailure.statusFlags), + &Data.notificationParams.commandFailure.statusFlags, + &Test_Data.notificationParams.commandFailure.statusFlags), NULL); } @@ -1192,59 +1197,58 @@ static void testEventFloatingLimit(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_FLOATING_LIMIT; - data.notificationParams.floatingLimit.referenceValue = 1.23f; - data.notificationParams.floatingLimit.setPointValue = 2.34f; - data.notificationParams.floatingLimit.errorLimit = 3.45f; + Data.eventType = EVENT_FLOATING_LIMIT; + Data.notificationParams.floatingLimit.referenceValue = 1.23f; + Data.notificationParams.floatingLimit.setPointValue = 2.34f; + Data.notificationParams.floatingLimit.errorLimit = 3.45f; - bitstring_init(&data.notificationParams.floatingLimit.statusFlags); + bitstring_init(&Data.notificationParams.floatingLimit.statusFlags); bitstring_set_bit( - &data.notificationParams.floatingLimit.statusFlags, + &Data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.floatingLimit.statusFlags, + &Data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.floatingLimit.statusFlags, + &Data.notificationParams.floatingLimit.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_false( islessgreater( - data.notificationParams.floatingLimit.referenceValue, - data2.notificationParams.floatingLimit.referenceValue), + Data.notificationParams.floatingLimit.referenceValue, + Test_Data.notificationParams.floatingLimit.referenceValue), NULL); zassert_false( islessgreater( - data.notificationParams.floatingLimit.setPointValue, - data2.notificationParams.floatingLimit.setPointValue), + Data.notificationParams.floatingLimit.setPointValue, + Test_Data.notificationParams.floatingLimit.setPointValue), NULL); zassert_false( islessgreater( - data.notificationParams.floatingLimit.errorLimit, - data2.notificationParams.floatingLimit.errorLimit), + Data.notificationParams.floatingLimit.errorLimit, + Test_Data.notificationParams.floatingLimit.errorLimit), NULL); zassert_true( bitstring_same( - &data.notificationParams.floatingLimit.statusFlags, - &data2.notificationParams.floatingLimit.statusFlags), + &Data.notificationParams.floatingLimit.statusFlags, + &Test_Data.notificationParams.floatingLimit.statusFlags), NULL); } @@ -1252,62 +1256,61 @@ static void testEventOutOfRange(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_OUT_OF_RANGE; - data.notificationParams.outOfRange.exceedingValue = 3.45f; - data.notificationParams.outOfRange.deadband = 2.34f; - data.notificationParams.outOfRange.exceededLimit = 1.23f; + Data.eventType = EVENT_OUT_OF_RANGE; + Data.notificationParams.outOfRange.exceedingValue = 3.45f; + Data.notificationParams.outOfRange.deadband = 2.34f; + Data.notificationParams.outOfRange.exceededLimit = 1.23f; - bitstring_init(&data.notificationParams.outOfRange.statusFlags); + bitstring_init(&Data.notificationParams.outOfRange.statusFlags); bitstring_set_bit( - &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_IN_ALARM, + &Data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, + &Data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.outOfRange.statusFlags, + &Data.notificationParams.outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_false( islessgreater( - data.notificationParams.outOfRange.deadband, - data2.notificationParams.outOfRange.deadband), + Data.notificationParams.outOfRange.deadband, + Test_Data.notificationParams.outOfRange.deadband), NULL); zassert_false( islessgreater( - data.notificationParams.outOfRange.exceededLimit, - data2.notificationParams.outOfRange.exceededLimit), + Data.notificationParams.outOfRange.exceededLimit, + Test_Data.notificationParams.outOfRange.exceededLimit), NULL); zassert_false( islessgreater( - data.notificationParams.outOfRange.exceedingValue, - data2.notificationParams.outOfRange.exceedingValue), + Data.notificationParams.outOfRange.exceedingValue, + Test_Data.notificationParams.outOfRange.exceedingValue), NULL); zassert_true( bitstring_same( - &data.notificationParams.outOfRange.statusFlags, - &data2.notificationParams.outOfRange.statusFlags), + &Data.notificationParams.outOfRange.statusFlags, + &Test_Data.notificationParams.outOfRange.statusFlags), NULL); } @@ -1315,59 +1318,59 @@ static void testEventChangeOfLifeSafety(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_CHANGE_OF_LIFE_SAFETY; - data.notificationParams.changeOfLifeSafety.newState = + Data.eventType = EVENT_CHANGE_OF_LIFE_SAFETY; + Data.notificationParams.changeOfLifeSafety.newState = LIFE_SAFETY_STATE_ALARM; - data.notificationParams.changeOfLifeSafety.newMode = LIFE_SAFETY_MODE_ARMED; - data.notificationParams.changeOfLifeSafety.operationExpected = + Data.notificationParams.changeOfLifeSafety.newMode = LIFE_SAFETY_MODE_ARMED; + Data.notificationParams.changeOfLifeSafety.operationExpected = LIFE_SAFETY_OP_RESET; - bitstring_init(&data.notificationParams.changeOfLifeSafety.statusFlags); + bitstring_init(&Data.notificationParams.changeOfLifeSafety.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfLifeSafety.statusFlags, + &Data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfLifeSafety.statusFlags, + &Data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfLifeSafety.statusFlags, + &Data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfLifeSafety.statusFlags, + &Data.notificationParams.changeOfLifeSafety.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.changeOfLifeSafety.newMode, - data2.notificationParams.changeOfLifeSafety.newMode, NULL); + Data.notificationParams.changeOfLifeSafety.newMode, + Test_Data.notificationParams.changeOfLifeSafety.newMode, NULL); zassert_equal( - data.notificationParams.changeOfLifeSafety.newState, - data2.notificationParams.changeOfLifeSafety.newState, NULL); + Data.notificationParams.changeOfLifeSafety.newState, + Test_Data.notificationParams.changeOfLifeSafety.newState, NULL); zassert_equal( - data.notificationParams.changeOfLifeSafety.operationExpected, - data2.notificationParams.changeOfLifeSafety.operationExpected, NULL); + Data.notificationParams.changeOfLifeSafety.operationExpected, + Test_Data.notificationParams.changeOfLifeSafety.operationExpected, + NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfLifeSafety.statusFlags, - &data2.notificationParams.changeOfLifeSafety.statusFlags), + &Data.notificationParams.changeOfLifeSafety.statusFlags, + &Test_Data.notificationParams.changeOfLifeSafety.statusFlags), NULL); } @@ -1375,52 +1378,51 @@ static void testEventUnsignedRange(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_UNSIGNED_RANGE; - data.notificationParams.unsignedRange.exceedingValue = 1234; - data.notificationParams.unsignedRange.exceededLimit = 2345; + Data.eventType = EVENT_UNSIGNED_RANGE; + Data.notificationParams.unsignedRange.exceedingValue = 1234; + Data.notificationParams.unsignedRange.exceededLimit = 2345; - bitstring_init(&data.notificationParams.unsignedRange.statusFlags); + bitstring_init(&Data.notificationParams.unsignedRange.statusFlags); bitstring_set_bit( - &data.notificationParams.unsignedRange.statusFlags, + &Data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.unsignedRange.statusFlags, + &Data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.unsignedRange.statusFlags, + &Data.notificationParams.unsignedRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal(apdu_len, test_len, NULL); verifyBaseEventState(); zassert_equal( - data.notificationParams.unsignedRange.exceedingValue, - data2.notificationParams.unsignedRange.exceedingValue, NULL); + Data.notificationParams.unsignedRange.exceedingValue, + Test_Data.notificationParams.unsignedRange.exceedingValue, NULL); zassert_equal( - data.notificationParams.unsignedRange.exceededLimit, - data2.notificationParams.unsignedRange.exceededLimit, NULL); + Data.notificationParams.unsignedRange.exceededLimit, + Test_Data.notificationParams.unsignedRange.exceededLimit, NULL); zassert_true( bitstring_same( - &data.notificationParams.unsignedRange.statusFlags, - &data2.notificationParams.unsignedRange.statusFlags), + &Data.notificationParams.unsignedRange.statusFlags, + &Test_Data.notificationParams.unsignedRange.statusFlags), NULL); } @@ -1428,7 +1430,6 @@ static void testEventExtended(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; BACNET_OCTET_STRING extended_ostring = { 0 }; BACNET_CHARACTER_STRING extended_cstring = { 0 }; BACNET_BIT_STRING extended_bstring = { 0 }; @@ -1470,38 +1471,37 @@ static void testEventExtended(void) { .tag = MAX_BACNET_APPLICATION_TAG, .type.Unsigned_Int = 0 }, }; - data.eventType = EVENT_EXTENDED; - data.notificationParams.extended.vendorID = 1234; - data.notificationParams.extended.extendedEventType = 4321; + Data.eventType = EVENT_EXTENDED; + Data.notificationParams.extended.vendorID = 1234; + Data.notificationParams.extended.extendedEventType = 4321; i = 0; while (extended_parameters[i].tag != MAX_BACNET_APPLICATION_TAG) { memcpy( - &data.notificationParams.extended.parameters, + &Data.notificationParams.extended.parameters, &extended_parameters[i], sizeof(extended_parameters[i])); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; + memset(&Test_Data, 0, sizeof(Test_Data)); test_len = - event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "tag=%s apdu_len=%d test_len=%d", bactext_application_tag_name( - data.notificationParams.extended.parameters.tag), + Data.notificationParams.extended.parameters.tag), apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.extended.vendorID, - data2.notificationParams.extended.vendorID, NULL); + Data.notificationParams.extended.vendorID, + Test_Data.notificationParams.extended.vendorID, NULL); zassert_equal( - data.notificationParams.extended.extendedEventType, - data2.notificationParams.extended.extendedEventType, NULL); + Data.notificationParams.extended.extendedEventType, + Test_Data.notificationParams.extended.extendedEventType, NULL); zassert_equal( - data.notificationParams.extended.parameters.tag, - data2.notificationParams.extended.parameters.tag, NULL); + Data.notificationParams.extended.parameters.tag, + Test_Data.notificationParams.extended.parameters.tag, NULL); i++; } } @@ -1510,7 +1510,6 @@ static void testEventChangeOfDiscreteValue(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; BACNET_OCTET_STRING extended_ostring = { 0 }; BACNET_CHARACTER_STRING extended_cstring = { 0 }; unsigned i; @@ -1539,51 +1538,51 @@ static void testEventChangeOfDiscreteValue(void) { .tag = MAX_BACNET_APPLICATION_TAG, .type.Unsigned_Int = 0 }, }; - data.eventType = EVENT_CHANGE_OF_DISCRETE_VALUE; - bitstring_init(&data.notificationParams.changeOfDiscreteValue.statusFlags); + Data.eventType = EVENT_CHANGE_OF_DISCRETE_VALUE; + bitstring_init(&Data.notificationParams.changeOfDiscreteValue.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfDiscreteValue.statusFlags, + &Data.notificationParams.changeOfDiscreteValue.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfDiscreteValue.statusFlags, + &Data.notificationParams.changeOfDiscreteValue.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfDiscreteValue.statusFlags, + &Data.notificationParams.changeOfDiscreteValue.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfDiscreteValue.statusFlags, + &Data.notificationParams.changeOfDiscreteValue.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); i = 0; while (discrete_values[i].tag != MAX_BACNET_APPLICATION_TAG) { memcpy( - &data.notificationParams.changeOfDiscreteValue.newValue, + &Data.notificationParams.changeOfDiscreteValue.newValue, &discrete_values[i], sizeof(discrete_values[i])); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; + memset(&Test_Data, 0, sizeof(Test_Data)); test_len = - event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "tag[%u]=%s apdu_len=%d test_len=%d", (unsigned) - data.notificationParams.changeOfDiscreteValue.newValue.tag, + Data.notificationParams.changeOfDiscreteValue.newValue.tag, bactext_application_tag_name( - data.notificationParams.changeOfDiscreteValue.newValue.tag), + Data.notificationParams.changeOfDiscreteValue.newValue.tag), apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.changeOfDiscreteValue.newValue.tag, - data2.notificationParams.changeOfDiscreteValue.newValue.tag, NULL); + Data.notificationParams.changeOfDiscreteValue.newValue.tag, + Test_Data.notificationParams.changeOfDiscreteValue.newValue.tag, + NULL); i++; } zassert_true( bitstring_same( - &data.notificationParams.changeOfDiscreteValue.statusFlags, - &data2.notificationParams.changeOfDiscreteValue.statusFlags), + &Data.notificationParams.changeOfDiscreteValue.statusFlags, + &Test_Data.notificationParams.changeOfDiscreteValue.statusFlags), NULL); } @@ -1591,66 +1590,65 @@ static void testEventChangeOfTimer(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText2 = { 0 }; - data.eventType = EVENT_CHANGE_OF_TIMER; - data.notificationParams.changeOfTimer.newState = TIMER_STATE_IDLE; - data.notificationParams.changeOfTimer.initialTimeout = 1500; + Data.eventType = EVENT_CHANGE_OF_TIMER; + Data.notificationParams.changeOfTimer.newState = TIMER_STATE_IDLE; + Data.notificationParams.changeOfTimer.initialTimeout = 1500; datetime_init_ascii( - &data.notificationParams.changeOfTimer.expirationTime, + &Data.notificationParams.changeOfTimer.expirationTime, "2025/12/31-23:59:59.99"); datetime_init_ascii( - &data.notificationParams.changeOfTimer.updateTime, + &Data.notificationParams.changeOfTimer.updateTime, "2025/11/04-16:42:01.01"); - data.notificationParams.changeOfTimer.lastStateChange = + Data.notificationParams.changeOfTimer.lastStateChange = TIMER_TRANSITION_NONE; - bitstring_init(&data.notificationParams.changeOfTimer.statusFlags); + bitstring_init(&Data.notificationParams.changeOfTimer.statusFlags); bitstring_set_bit( - &data.notificationParams.changeOfTimer.statusFlags, + &Data.notificationParams.changeOfTimer.statusFlags, STATUS_FLAG_IN_ALARM, true); bitstring_set_bit( - &data.notificationParams.changeOfTimer.statusFlags, STATUS_FLAG_FAULT, + &Data.notificationParams.changeOfTimer.statusFlags, STATUS_FLAG_FAULT, false); bitstring_set_bit( - &data.notificationParams.changeOfTimer.statusFlags, + &Data.notificationParams.changeOfTimer.statusFlags, STATUS_FLAG_OVERRIDDEN, false); bitstring_set_bit( - &data.notificationParams.changeOfTimer.statusFlags, + &Data.notificationParams.changeOfTimer.statusFlags, STATUS_FLAG_OUT_OF_SERVICE, false); memset(apdu, 0, MAX_APDU); - null_len = event_notify_encode_service_request(NULL, &data); - apdu_len = event_notify_encode_service_request(&apdu[0], &data); + null_len = event_notify_encode_service_request(NULL, &Data); + apdu_len = event_notify_encode_service_request(&apdu[0], &Data); zassert_equal( apdu_len, null_len, "apdu_len=%d null_len=%d", apdu_len, null_len); - memset(&data2, 0, sizeof(data2)); - data2.messageText = &messageText2; - test_len = event_notify_decode_service_request(&apdu[0], apdu_len, &data2); + memset(&Test_Data, 0, sizeof(Test_Data)); + test_len = + event_notify_decode_service_request(&apdu[0], apdu_len, &Test_Data); zassert_equal( apdu_len, test_len, "apdu_len=%d test_len=%d", apdu_len, test_len); verifyBaseEventState(); zassert_equal( - data.notificationParams.changeOfTimer.newState, - data2.notificationParams.changeOfTimer.newState, NULL); + Data.notificationParams.changeOfTimer.newState, + Test_Data.notificationParams.changeOfTimer.newState, NULL); zassert_equal( - data.notificationParams.changeOfTimer.initialTimeout, - data2.notificationParams.changeOfTimer.initialTimeout, NULL); + Data.notificationParams.changeOfTimer.initialTimeout, + Test_Data.notificationParams.changeOfTimer.initialTimeout, NULL); zassert_equal( - data.notificationParams.changeOfTimer.lastStateChange, - data2.notificationParams.changeOfTimer.lastStateChange, NULL); + Data.notificationParams.changeOfTimer.lastStateChange, + Test_Data.notificationParams.changeOfTimer.lastStateChange, NULL); zassert_equal( datetime_compare( - &data.notificationParams.changeOfTimer.expirationTime, - &data2.notificationParams.changeOfTimer.expirationTime), + &Data.notificationParams.changeOfTimer.expirationTime, + &Test_Data.notificationParams.changeOfTimer.expirationTime), 0, NULL); zassert_equal( datetime_compare( - &data.notificationParams.changeOfTimer.updateTime, - &data2.notificationParams.changeOfTimer.updateTime), + &Data.notificationParams.changeOfTimer.updateTime, + &Test_Data.notificationParams.changeOfTimer.updateTime), 0, NULL); zassert_true( bitstring_same( - &data.notificationParams.changeOfTimer.statusFlags, - &data2.notificationParams.changeOfTimer.statusFlags), + &Data.notificationParams.changeOfTimer.statusFlags, + &Test_Data.notificationParams.changeOfTimer.statusFlags), NULL); } @@ -1665,27 +1663,25 @@ static void testEventNotification(void) { uint8_t apdu[MAX_APDU]; int apdu_len, test_len, null_len; - BACNET_CHARACTER_STRING messageText = { 0 }; - BACNET_CHARACTER_STRING messageText2 = { 0 }; uint8_t invoke_id = 2; /* common to all the notification types */ characterstring_init_ansi( - &messageText, "This is a test of the message text\n"); - data.messageText = &messageText; - data2.messageText = &messageText2; - data.processIdentifier = 1234; - data.initiatingObjectIdentifier.type = OBJECT_ANALOG_INPUT; - data.initiatingObjectIdentifier.instance = 100; - data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT; - data.eventObjectIdentifier.instance = 200; - data.timeStamp.value.sequenceNum = 1234; - data.timeStamp.tag = TIME_STAMP_SEQUENCE; - data.notificationClass = 50; - data.priority = 50; - data.notifyType = NOTIFY_ALARM; - data.fromState = EVENT_STATE_NORMAL; - data.toState = EVENT_STATE_OFFNORMAL; + &Message_Text, "This is a test of the message text\n"); + Data.messageText = &Message_Text; + Test_Data.messageText = &Test_Message_Text; + Data.processIdentifier = 1234; + Data.initiatingObjectIdentifier.type = OBJECT_ANALOG_INPUT; + Data.initiatingObjectIdentifier.instance = 100; + Data.eventObjectIdentifier.type = OBJECT_ANALOG_INPUT; + Data.eventObjectIdentifier.instance = 200; + Data.timeStamp.value.sequenceNum = 1234; + Data.timeStamp.tag = TIME_STAMP_SEQUENCE; + Data.notificationClass = 50; + Data.priority = 50; + Data.notifyType = NOTIFY_ALARM; + Data.fromState = EVENT_STATE_NORMAL; + Data.toState = EVENT_STATE_OFFNORMAL; /* ** Event Type = EVENT_CHANGE_OF_BITSTRING */ @@ -1771,30 +1767,30 @@ static void testEventNotification(void) */ testEventProprietary(); /* function coverage: Confirmed and Unconfirmed Event Notifications */ - null_len = cevent_notify_encode_apdu(NULL, invoke_id, &data); - apdu_len = cevent_notify_encode_apdu(apdu, invoke_id, &data); + null_len = cevent_notify_encode_apdu(NULL, invoke_id, &Data); + apdu_len = cevent_notify_encode_apdu(apdu, invoke_id, &Data); zassert_true(apdu_len > 0, NULL); zassert_equal(apdu_len, null_len, NULL); zassert_equal(apdu[0], PDU_TYPE_CONFIRMED_SERVICE_REQUEST, NULL); zassert_equal(apdu[2], invoke_id, NULL); zassert_equal(apdu[3], SERVICE_CONFIRMED_EVENT_NOTIFICATION, NULL); - null_len = uevent_notify_encode_apdu(NULL, &data); - apdu_len = uevent_notify_encode_apdu(apdu, &data); + null_len = uevent_notify_encode_apdu(NULL, &Data); + apdu_len = uevent_notify_encode_apdu(apdu, &Data); zassert_true(apdu_len > 0, NULL); zassert_equal(apdu_len, null_len, NULL); zassert_equal(apdu[0], PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST, NULL); zassert_equal(apdu[1], SERVICE_UNCONFIRMED_EVENT_NOTIFICATION, NULL); null_len = - event_notification_service_request_encode(NULL, sizeof(apdu), &data); + event_notification_service_request_encode(NULL, sizeof(apdu), &Data); apdu_len = - event_notification_service_request_encode(apdu, sizeof(apdu), &data); + event_notification_service_request_encode(apdu, sizeof(apdu), &Data); zassert_true(apdu_len > 0, NULL); zassert_equal(apdu_len, null_len, NULL); while (apdu_len > 0) { apdu_len--; test_len = - event_notification_service_request_encode(apdu, apdu_len, &data); + event_notification_service_request_encode(apdu, apdu_len, &Data); zassert_equal(test_len, 0, NULL); } }