Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 2d01008

Browse files
author
Jarkko Paso
committed
FHSS unit tests: test setting parent BC info
1 parent 681dedd commit 2d01008

File tree

6 files changed

+69
-0
lines changed

6 files changed

+69
-0
lines changed

test/nanostack/unittest/service_libs/fhss_config/fhssconfigtest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ TEST(fhss_config, test_ns_fhss_create)
4848
{
4949
CHECK(test_ns_fhss_create());
5050
}
51+
52+
TEST(fhss_config, test_ns_fhss_ws_set_parent)
53+
{
54+
CHECK(test_ns_fhss_ws_set_parent());
55+
}

test/nanostack/unittest/service_libs/fhss_config/test_fhss_config.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,20 @@ bool test_ns_fhss_configuration_set()
118118
ns_fhss_configuration_set(NULL, NULL);
119119
return true;
120120
}
121+
122+
bool test_ns_fhss_ws_set_parent()
123+
{
124+
fhss_api_t api;
125+
uint8_t dest_address[8] = {1,2,3,4,5,6,7,8};
126+
broadcast_timing_info_t bc_timing_info;
127+
// Test without api
128+
if (-1 != ns_fhss_ws_set_parent(NULL, dest_address, &bc_timing_info)) {
129+
return false;
130+
}
131+
// Test success
132+
fhss_common_stub.bool_value = true;
133+
if (0 != ns_fhss_ws_set_parent(&api, dest_address, &bc_timing_info)) {
134+
return false;
135+
}
136+
return true;
137+
}

test/nanostack/unittest/service_libs/fhss_config/test_fhss_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ bool test_ns_fhss_ws_create();
3131
bool test_ns_fhss_delete();
3232
// Test setting synchronization time configuration
3333
bool test_ns_fhss_configuration_set();
34+
// Test setting WS parent
35+
bool test_ns_fhss_ws_set_parent();
3436

3537

3638
#ifdef __cplusplus

test/nanostack/unittest/service_libs/fhss_ws/fhsswstest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ TEST(fhssws, test_fhss_unicast_handler)
8888
{
8989
CHECK(test_fhss_unicast_handler());
9090
}
91+
92+
TEST(fhssws, test_fhss_ws_set_parent)
93+
{
94+
CHECK(test_fhss_ws_set_parent());
95+
}

test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,42 @@ bool test_fhss_unicast_handler()
418418
fhss_common_stub.callback[0](fhss_common_stub.fhss_struct.fhss_api, DEFAULT_TIMER_DELAY);
419419
return true;
420420
}
421+
422+
bool test_fhss_ws_set_parent()
423+
{
424+
uint8_t dest_address[8] = {1,2,3,4,5,6,7,8};
425+
broadcast_timing_info_t bc_timing_info;
426+
memset(&bc_timing_info, 0, sizeof(broadcast_timing_info_t));
427+
fhss_api_t *api = test_generate_fhss_api();
428+
429+
// Test without WS enabled FHSS
430+
fhss_structure_t fake_fhss_structure;
431+
memset(&fake_fhss_structure, 0, sizeof(fhss_structure_t));
432+
if (-1 != fhss_ws_set_parent(&fake_fhss_structure, dest_address, &bc_timing_info)) {
433+
return false;
434+
}
435+
// Test success
436+
bc_timing_info.broadcast_channel_function = WS_TR51CF;
437+
bc_timing_info.broadcast_dwell_interval = 250;
438+
bc_timing_info.broadcast_interval = 1000;
439+
bc_timing_info.broadcast_interval_offset = 2000;
440+
bc_timing_info.broadcast_schedule_id = 1;
441+
bc_timing_info.broadcast_slot = 10;
442+
bc_timing_info.bt_rx_timestamp = 100000;
443+
if (0 != fhss_ws_set_parent(&fhss_common_stub.fhss_struct, dest_address, &bc_timing_info)
444+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_channel_function != WS_TR51CF)
445+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_dwell_interval != 250)
446+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_interval != 1000)
447+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_interval_offset != 2000)
448+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_schedule_id != 1)
449+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_slot != 10)
450+
|| (fhss_common_stub.fhss_struct.ws->parent_bc_info->bt_rx_timestamp != 100000)) {
451+
return false;
452+
}
453+
// Test updating value
454+
bc_timing_info.broadcast_interval_offset = 5000;
455+
if (fhss_common_stub.fhss_struct.ws->parent_bc_info->broadcast_interval_offset != 5000) {
456+
return false;
457+
}
458+
return true;
459+
}

test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bool test_fhss_ws_write_synch_info_callback();
3535
bool test_fhss_broadcast_handler();
3636
bool test_fhss_ws_update_uc_channel_callback();
3737
bool test_fhss_unicast_handler();
38+
bool test_fhss_ws_set_parent();
3839

3940
#ifdef __cplusplus
4041
}

0 commit comments

Comments
 (0)