Skip to content

Commit 4767dd5

Browse files
author
Jarkko Paso
authored
Merge pull request ARMmbed#1666 from ARMmbed/fhss_is_bc_flag_fix
Fhss is bc flag fix
2 parents 14e1597 + 6ffc81a commit 4767dd5

File tree

8 files changed

+39
-45
lines changed

8 files changed

+39
-45
lines changed

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ void mcps_sap_pd_req_queue_write(protocol_interface_rf_mac_setup_s *rf_mac_setup
16571657
bool use_bc_queue = false;
16581658

16591659
// When FHSS is enabled, broadcast buffers are pushed to own queue
1660-
if (rf_mac_setup->fhss_api) {
1660+
if (rf_mac_setup->fhss_api && (buffer->asynch_request == false)) {
16611661
if (rf_mac_setup->fhss_api->use_broadcast_queue(rf_mac_setup->fhss_api, !mac_is_ack_request_set(buffer),
16621662
mac_convert_frame_type_to_fhss(buffer->fcf_dsn.frametype)) == true) {
16631663
cur = rf_mac_setup->pd_data_request_bc_queue_to_go;

source/Service_Libs/fhss/fhss.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,20 @@ static bool fhss_is_broadcast_channel_callback(const fhss_api_t *api)
12001200
return fhss_is_current_channel_broadcast(fhss_structure);
12011201
}
12021202

1203+
static bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type)
1204+
{
1205+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
1206+
if (!fhss_structure) {
1207+
return false;
1208+
}
1209+
// Synch requests are always stored in unicast queue
1210+
if (frame_type == FHSS_SYNCH_REQUEST_FRAME) {
1211+
return false;
1212+
}
1213+
// Broadcast packets are stored in broadcast queue
1214+
return is_broadcast_addr;
1215+
}
1216+
12031217
static void fhss_superframe_handler(const fhss_api_t *fhss_api, uint16_t delay)
12041218
{
12051219
uint32_t timeout = 0;

source/Service_Libs/fhss/fhss_common.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,6 @@ int fhss_compare_with_synch_parent_address(fhss_structure_t *fhss_structure, con
239239
return ret_val;
240240
}
241241

242-
bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type)
243-
{
244-
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
245-
if (!fhss_structure) {
246-
return false;
247-
}
248-
// Synch requests are always stored in unicast queue
249-
if (frame_type == FHSS_SYNCH_REQUEST_FRAME) {
250-
return false;
251-
}
252-
// Broadcast packets are stored in broadcast queue
253-
return is_broadcast_addr;
254-
}
255-
256242
uint32_t fhss_read_timestamp_cb(const fhss_api_t *api)
257243
{
258244
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);

source/Service_Libs/fhss/fhss_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ int fhss_update_synch_parent_address(fhss_structure_t *fhss_structure);
6767
void fhss_trig_event(fhss_structure_t *fhss_structure, uint8_t event_type);
6868
int fhss_get_parent_address(fhss_structure_t *fhss_structure, uint8_t *p_addr);
6969
int fhss_compare_with_synch_parent_address(fhss_structure_t *fhss_structure, const uint8_t *source_addr);
70-
bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type);
7170
uint32_t fhss_read_timestamp_cb(const fhss_api_t *api);
7271
int fhss_init_callbacks_cb(const fhss_api_t *api, fhss_callback_t *callbacks);
7372
int fhss_failed_handle_remove(fhss_structure_t *fhss_structure, uint8_t handle);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_states
205205
if ((fhss_state == FHSS_SYNCHRONIZED) && (fhss_structure->ws->fhss_configuration.ws_channel_function != WS_FIXED_CHANNEL)) {
206206
uint32_t fhss_broadcast_interval = fhss_structure->ws->fhss_configuration.fhss_broadcast_interval;
207207
uint8_t fhss_bc_dwell_interval = fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval;
208+
208209
// Start broadcast schedule when BC intervals are known
209210
if (fhss_broadcast_interval && fhss_bc_dwell_interval) {
210211
fhss_broadcast_handler(fhss_structure->fhss_api, 0);
@@ -393,6 +394,13 @@ static void fhss_ws_data_tx_done_callback(const fhss_api_t *api, bool waiting_ac
393394
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, fhss_structure->rx_channel);
394395
}
395396
}
397+
// Buffer was successfully transmitted. Remove stored failure handle if exists.
398+
if (tx_completed == true) {
399+
fhss_failed_tx_t *fhss_failed_tx = fhss_failed_handle_find(fhss_structure, handle);
400+
if (fhss_failed_tx) {
401+
fhss_failed_handle_remove(fhss_structure, handle);
402+
}
403+
}
396404
}
397405

398406
static bool fhss_ws_data_tx_fail_callback(const fhss_api_t *api, uint8_t handle, int frame_type)
@@ -446,6 +454,21 @@ static bool fhss_ws_is_broadcast_channel_callback(const fhss_api_t *api)
446454
return fhss_structure->ws->is_on_bc_channel;
447455
}
448456

457+
static bool fhss_ws_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type)
458+
{
459+
(void) frame_type;
460+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
461+
if (!fhss_structure) {
462+
return false;
463+
}
464+
// Do not use broadcast queue when fixed channel
465+
if (fhss_structure->ws->fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
466+
return false;
467+
}
468+
// Broadcast packets are stored in broadcast queue
469+
return is_broadcast_addr;
470+
}
471+
449472
static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
450473
{
451474
uint32_t timeout = 0;
@@ -480,7 +503,7 @@ int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
480503
{
481504
// Set external API
482505
fhss_structure->fhss_api->is_broadcast_channel = &fhss_ws_is_broadcast_channel_callback;
483-
fhss_structure->fhss_api->use_broadcast_queue = &fhss_use_broadcast_queue_cb;
506+
fhss_structure->fhss_api->use_broadcast_queue = &fhss_ws_use_broadcast_queue_cb;
484507
fhss_structure->fhss_api->tx_handle = &fhss_ws_tx_handle_callback;
485508
fhss_structure->fhss_api->check_tx_conditions = &fhss_ws_check_tx_conditions_callback;
486509
fhss_structure->fhss_api->receive_frame = &fhss_ws_receive_frame_callback;

test/nanostack/unittest/service_libs/fhss_common/fhsscommontest.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ TEST(fhss_common, test_fhss_compare_with_synch_parent_address)
7171
CHECK(test_fhss_compare_with_synch_parent_address());
7272
}
7373

74-
TEST(fhss_common, test_fhss_use_broadcast_queue_cb)
75-
{
76-
CHECK(test_fhss_use_broadcast_queue_cb());
77-
}
78-
7974
TEST(fhss_common, test_fhss_read_timestamp_cb)
8075
{
8176
CHECK(test_fhss_read_timestamp_cb());

test/nanostack/unittest/service_libs/fhss_common/test_fhss_common.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -245,28 +245,6 @@ bool test_fhss_compare_with_synch_parent_address()
245245
return true;
246246
}
247247

248-
bool test_fhss_use_broadcast_queue_cb()
249-
{
250-
nsdynmemlib_stub.returnCounter = 1;
251-
// Allocate instance
252-
fhss_structure_t *fhss_ptr = fhss_allocate_instance(&fhss_api, &fhss_timer);
253-
// Test without API
254-
if (false != fhss_use_broadcast_queue_cb(NULL, true, FHSS_DATA_FRAME)) {
255-
return false;
256-
}
257-
// Test synch request frame
258-
if (false != fhss_use_broadcast_queue_cb(&fhss_api, true, FHSS_SYNCH_REQUEST_FRAME)) {
259-
return false;
260-
}
261-
// Test data frame frame with broadcast address
262-
if (true != fhss_use_broadcast_queue_cb(&fhss_api, true, FHSS_DATA_FRAME)) {
263-
return false;
264-
}
265-
// Free allocated instance
266-
fhss_free_instance(&fhss_api);
267-
return true;
268-
}
269-
270248
bool test_fhss_read_timestamp_cb()
271249
{
272250
fhss_platform_stub.timestamp_value = 100000;

test/nanostack/unittest/service_libs/fhss_common/test_fhss_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ bool test_fhss_timeout_stop();
2121
bool test_fhss_update_synch_parent_address();
2222
bool test_fhss_trig_event();
2323
bool test_fhss_compare_with_synch_parent_address();
24-
bool test_fhss_use_broadcast_queue_cb();
2524
bool test_fhss_read_timestamp_cb();
2625
bool test_fhss_init_callbacks_cb();
2726
bool test_fhss_clear_active_event();

0 commit comments

Comments
 (0)