Feature/what is network number handling (#304)

* Add What-Is-Network-Number handling.

Add What-Is-Network-Number and Network-Number-Is network layer handling.
Refactor npdu_encode_npdu_network() from router specific code.
Add unit test for NDPU network message
Add app for What-Is-Network-Number
Add app for Network-Number-Is
Add send helper for What-Is-Network-Number
Add send helper for Network-Number-Is

* added sys/debug.c to ports builds for use of debug_printf() in npdu handler.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-07-14 15:34:45 -05:00
committed by GitHub
parent 38d213b47c
commit 1f41341c09
28 changed files with 1080 additions and 46 deletions
+38 -1
View File
@@ -16,6 +16,42 @@
* @{
*/
/**
* @brief Test
*/
static void test_NPDU_Network(void)
{
uint8_t pdu[480] = { 0 };
BACNET_ADDRESS dest = { 0 };
BACNET_ADDRESS src = { 0 };
BACNET_ADDRESS npdu_dest = { 0 };
BACNET_ADDRESS npdu_src = { 0 };
int len = 0;
bool data_expecting_reply = true;
BACNET_NETWORK_MESSAGE_TYPE network_message_type =
NETWORK_MESSAGE_NETWORK_NUMBER_IS;
BACNET_MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL;
BACNET_NPDU_DATA npdu_data = { 0 };
int i = 0; /* counter */
int npdu_len = 0;
bool network_layer_message = true;
uint16_t vendor_id = 0; /* optional, if net message type is > 0x80 */
npdu_encode_npdu_network(&npdu_data,
network_message_type,
data_expecting_reply, priority);
len = npdu_encode_pdu(&pdu[0], &dest, &src, &npdu_data);
zassert_not_equal(len, 0, NULL);
/* can we get the info back? */
npdu_len = npdu_decode(&pdu[0], &npdu_dest, &npdu_src, &npdu_data);
zassert_not_equal(npdu_len, 0, NULL);
zassert_equal(npdu_data.data_expecting_reply, data_expecting_reply, NULL);
zassert_equal(npdu_data.network_layer_message, network_layer_message, NULL);
zassert_equal(npdu_data.network_message_type, network_message_type, NULL);
zassert_equal(npdu_data.vendor_id, vendor_id, NULL);
zassert_equal(npdu_data.priority, priority, NULL);
}
/**
* @brief Test
*/
@@ -146,7 +182,8 @@ void test_main(void)
{
ztest_test_suite(npdu_tests,
ztest_unit_test(testNPDU1),
ztest_unit_test(testNPDU2)
ztest_unit_test(testNPDU2),
ztest_unit_test(test_NPDU_Network)
);
ztest_run_test_suite(npdu_tests);