Skip to content

Commit 04ae3c3

Browse files
author
Jarkko Paso
committed
FHSS: separated is_bc_callback to FHSS and WS
1 parent 59fe586 commit 04ae3c3

File tree

7 files changed

+24
-53
lines changed

7 files changed

+24
-53
lines changed

source/Service_Libs/fhss/fhss.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,19 @@ static uint16_t fhss_get_retry_period_callback(const fhss_api_t *api, uint8_t *d
10761076
return retry_period;
10771077
}
10781078

1079+
static bool fhss_is_broadcast_channel_callback(const fhss_api_t *api)
1080+
{
1081+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
1082+
if (!fhss_structure) {
1083+
return false;
1084+
}
1085+
// FHSS is unsynchronized, broadcasts allowed
1086+
if (fhss_structure->fhss_state == FHSS_UNSYNCHRONIZED) {
1087+
return true;
1088+
}
1089+
return fhss_is_current_channel_broadcast(fhss_structure);
1090+
}
1091+
10791092
static void fhss_superframe_handler(const fhss_api_t *fhss_api, uint16_t delay)
10801093
{
10811094
uint32_t timeout = 0;
@@ -1141,7 +1154,7 @@ int8_t fhss_set_synch_configuration(fhss_structure_t *fhss_structure, const fhss
11411154
int fhss_set_callbacks(fhss_structure_t *fhss_structure)
11421155
{
11431156
// Set external API
1144-
fhss_structure->fhss_api->is_broadcast_channel = &fhss_is_broadcast_channel_cb;
1157+
fhss_structure->fhss_api->is_broadcast_channel = &fhss_is_broadcast_channel_callback;
11451158
fhss_structure->fhss_api->use_broadcast_queue = &fhss_use_broadcast_queue_cb;
11461159
fhss_structure->fhss_api->tx_handle = &fhss_tx_handle_callback;
11471160
fhss_structure->fhss_api->check_tx_conditions = &fhss_check_tx_conditions_callback;

source/Service_Libs/fhss/fhss_mac_interface.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,6 @@
3030

3131
#define TRACE_GROUP "fhss"
3232

33-
34-
bool fhss_is_broadcast_channel_cb(const fhss_api_t *api)
35-
{
36-
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
37-
if (!fhss_structure) {
38-
return false;
39-
}
40-
// FHSS is unsynchronized, broadcasts allowed
41-
if (fhss_structure->fhss_state == FHSS_UNSYNCHRONIZED) {
42-
return true;
43-
}
44-
return fhss_is_current_channel_broadcast(fhss_structure);
45-
}
46-
4733
bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type)
4834
{
4935
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);

source/Service_Libs/fhss/fhss_mac_interface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef FHSS_MAC_INTERFACE_H_
1919
#define FHSS_MAC_INTERFACE_H_
2020

21-
bool fhss_is_broadcast_channel_cb(const fhss_api_t *api);
2221
bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type);
2322
uint32_t fhss_read_timestamp_cb(const fhss_api_t *api);
2423
int fhss_init_callbacks_cb(const fhss_api_t *api, fhss_callback_t *callbacks);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ static void fhss_ws_receive_frame_callback(const fhss_api_t *api, uint16_t pan_i
300300
(void) frame_type;
301301
}
302302

303+
static bool fhss_ws_is_broadcast_channel_callback(const fhss_api_t *api)
304+
{
305+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
306+
if (!fhss_structure) {
307+
return true;
308+
}
309+
return fhss_structure->ws->is_on_bc_channel;
310+
}
311+
303312
static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
304313
{
305314
uint32_t timeout = 0;
@@ -315,7 +324,7 @@ static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
315324
int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
316325
{
317326
// Set external API
318-
fhss_structure->fhss_api->is_broadcast_channel = &fhss_is_broadcast_channel_cb;
327+
fhss_structure->fhss_api->is_broadcast_channel = &fhss_ws_is_broadcast_channel_callback;
319328
fhss_structure->fhss_api->use_broadcast_queue = &fhss_use_broadcast_queue_cb;
320329
fhss_structure->fhss_api->tx_handle = &fhss_ws_tx_handle_callback;
321330
fhss_structure->fhss_api->check_tx_conditions = &fhss_ws_check_tx_conditions_callback;

test/nanostack/unittest/service_libs/fhss_mac_interface/fhssmaciftest.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ TEST_GROUP(fhss_mac_if)
2929
}
3030
};
3131

32-
TEST(fhss_mac_if, test_fhss_is_broadcast_channel_cb)
33-
{
34-
CHECK(test_fhss_is_broadcast_channel_cb());
35-
}
36-
3732
TEST(fhss_mac_if, test_fhss_use_broadcast_queue_cb)
3833
{
3934
CHECK(test_fhss_use_broadcast_queue_cb());

test/nanostack/unittest/service_libs/fhss_mac_interface/test_fhss_mac_interface.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,6 @@
2929
#include "fhss_channel_stub.h"
3030
#include "fhss_platform_stub.h"
3131

32-
bool test_fhss_is_broadcast_channel_cb()
33-
{
34-
fhss_api_t fhss_api;
35-
36-
// By setting bool value false, fhss_struct can not be found
37-
fhss_stub.bool_value = false;
38-
if (fhss_is_broadcast_channel_cb(&fhss_api) == true) {
39-
return false;
40-
}
41-
// By setting bool value true, fhss_struct can be found
42-
fhss_stub.bool_value = true;
43-
// Should return true
44-
fhss_channel_stub.channel_bool_value = true;
45-
if (fhss_is_broadcast_channel_cb(&fhss_api) == false) {
46-
return false;
47-
}
48-
// Should return false
49-
fhss_channel_stub.channel_bool_value = false;
50-
fhss_stub.fhss_struct.fhss_state = FHSS_SYNCHRONIZED;
51-
if (fhss_is_broadcast_channel_cb(&fhss_api) == true) {
52-
return false;
53-
}
54-
// Should return true when unsynchronized
55-
fhss_stub.fhss_struct.fhss_state = FHSS_UNSYNCHRONIZED;
56-
if (fhss_is_broadcast_channel_cb(&fhss_api) == false) {
57-
return false;
58-
}
59-
return true;
60-
}
6132
bool test_fhss_use_broadcast_queue_cb()
6233
{
6334
fhss_api_t fhss_api;

test/nanostack/unittest/service_libs/fhss_mac_interface/test_fhss_mac_interface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ extern "C" {
2222
#endif
2323

2424
#include <stdbool.h>
25-
// Test broadcast channel check callback
26-
bool test_fhss_is_broadcast_channel_cb();
2725
// Test broadcast queue check callback
2826
bool test_fhss_use_broadcast_queue_cb();
2927
// Test timestamp callback

0 commit comments

Comments
 (0)