Skip to content

Commit 19c4be6

Browse files
author
Jarkko Paso
committed
FHSS: Separated tx done cb for FHSS and WS
1 parent 3e326d1 commit 19c4be6

File tree

7 files changed

+31
-46
lines changed

7 files changed

+31
-46
lines changed

source/Service_Libs/fhss/fhss.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,24 @@ static int16_t fhss_write_synch_info_callback(const fhss_api_t *api, uint8_t *in
931931
return -1;
932932
}
933933

934+
static void fhss_data_tx_done_callback(const fhss_api_t *api, bool waiting_ack, bool tx_completed, uint8_t handle)
935+
{
936+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
937+
if (!fhss_structure) {
938+
return;
939+
}
940+
if (waiting_ack == false) {
941+
fhss_change_to_rx_channel(fhss_structure);
942+
}
943+
// Buffer was successfully transmitted. Remove stored failure handle if exists.
944+
if (tx_completed == true) {
945+
fhss_failed_tx_t *fhss_failed_tx = fhss_failed_handle_find(fhss_structure, handle);
946+
if (fhss_failed_tx) {
947+
fhss_failed_handle_remove(fhss_structure, handle);
948+
}
949+
}
950+
}
951+
934952
int fhss_set_callbacks(fhss_structure_t *fhss_structure)
935953
{
936954
// Set external API
@@ -939,7 +957,7 @@ int fhss_set_callbacks(fhss_structure_t *fhss_structure)
939957
fhss_structure->fhss_api->tx_handle = &fhss_tx_handle_callback;
940958
fhss_structure->fhss_api->check_tx_conditions = &fhss_check_tx_conditions_callback;
941959
fhss_structure->fhss_api->receive_frame = &fhss_receive_frame_cb;
942-
fhss_structure->fhss_api->data_tx_done = &fhss_data_tx_done_cb;
960+
fhss_structure->fhss_api->data_tx_done = &fhss_data_tx_done_callback;
943961
fhss_structure->fhss_api->data_tx_fail = &fhss_data_tx_fail_cb;
944962
fhss_structure->fhss_api->synch_state_set = &fhss_synch_state_set_cb;
945963
fhss_structure->fhss_api->read_timestamp = &fhss_read_timestamp_cb;

source/Service_Libs/fhss/fhss_mac_interface.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,6 @@ void fhss_receive_frame_cb(const fhss_api_t *api, uint16_t pan_id, uint8_t *sour
8989
}
9090
}
9191

92-
void fhss_data_tx_done_cb(const fhss_api_t *api, bool waiting_ack, bool tx_completed, uint8_t handle)
93-
{
94-
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
95-
if (!fhss_structure) {
96-
return;
97-
}
98-
if (waiting_ack == false) {
99-
fhss_change_to_rx_channel(fhss_structure);
100-
}
101-
// Buffer was successfully transmitted. Remove stored failure handle if exists.
102-
if (tx_completed == true) {
103-
fhss_failed_tx_t *fhss_failed_tx = fhss_failed_handle_find(fhss_structure, handle);
104-
if (fhss_failed_tx) {
105-
fhss_failed_handle_remove(fhss_structure, handle);
106-
}
107-
}
108-
}
109-
11092
bool fhss_data_tx_fail_cb(const fhss_api_t *api, uint8_t handle, int frame_type)
11193
{
11294
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
@@ -21,7 +21,6 @@
2121
bool fhss_is_broadcast_channel_cb(const fhss_api_t *api);
2222
bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type);
2323
void fhss_receive_frame_cb(const fhss_api_t *api, uint16_t pan_id, uint8_t *source_address, uint32_t timestamp, uint8_t *synch_info, int frame_type);
24-
void fhss_data_tx_done_cb(const fhss_api_t *api, bool waiting_ack, bool tx_completed, uint8_t handle);
2524
bool fhss_data_tx_fail_cb(const fhss_api_t *api, uint8_t handle, int frame_type);
2625
void fhss_synch_state_set_cb(const fhss_api_t *api, fhss_states fhss_state, uint16_t pan_id);
2726
uint32_t fhss_read_timestamp_cb(const fhss_api_t *api);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,17 @@ static int16_t fhss_ws_write_synch_info_callback(const fhss_api_t *api, uint8_t
218218
return -1;
219219
}
220220

221+
static void fhss_ws_data_tx_done_callback(const fhss_api_t *api, bool waiting_ack, bool tx_completed, uint8_t handle)
222+
{
223+
(void) waiting_ack;
224+
(void) tx_completed;
225+
(void) handle;
226+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
227+
if (!fhss_structure) {
228+
return;
229+
}
230+
}
231+
221232
int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
222233
{
223234
// Set external API
@@ -226,7 +237,7 @@ int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
226237
fhss_structure->fhss_api->tx_handle = &fhss_ws_tx_handle_callback;
227238
fhss_structure->fhss_api->check_tx_conditions = &fhss_ws_check_tx_conditions_callback;
228239
fhss_structure->fhss_api->receive_frame = &fhss_receive_frame_cb;
229-
fhss_structure->fhss_api->data_tx_done = &fhss_data_tx_done_cb;
240+
fhss_structure->fhss_api->data_tx_done = &fhss_ws_data_tx_done_callback;
230241
fhss_structure->fhss_api->data_tx_fail = &fhss_data_tx_fail_cb;
231242
fhss_structure->fhss_api->synch_state_set = &fhss_synch_state_set_cb;
232243
fhss_structure->fhss_api->read_timestamp = &fhss_read_timestamp_cb;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ TEST(fhss_mac_if, test_fhss_receive_frame_cb)
4444
CHECK(test_fhss_receive_frame_cb());
4545
}
4646

47-
TEST(fhss_mac_if, test_fhss_data_tx_done_cb)
48-
{
49-
CHECK(test_fhss_data_tx_done_cb());
50-
}
51-
5247
TEST(fhss_mac_if, test_fhss_data_tx_fail_cb)
5348
{
5449
CHECK(test_fhss_data_tx_fail_cb());

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,7 @@ bool test_fhss_receive_frame_cb()
119119

120120
return true;
121121
}
122-
bool test_fhss_data_tx_done_cb()
123-
{
124-
fhss_api_t fhss_api;
125122

126-
// By setting bool value false, fhss_struct can not be found
127-
fhss_stub.bool_value = false;
128-
fhss_data_tx_done_cb(&fhss_api, true, true, 0);
129-
// By setting bool value true, fhss_struct can be found
130-
fhss_stub.bool_value = true;
131-
fhss_data_tx_done_cb(&fhss_api, false, true, 0);
132-
// Should find failed TX handle
133-
fhss_stub.fhss_failed_tx.handle = 10;
134-
fhss_data_tx_done_cb(&fhss_api, false, true, 10);
135-
// Verify removed handle (255 means removed in this test)
136-
if (fhss_stub.fhss_failed_tx.handle != 255) {
137-
return false;
138-
}
139-
return true;
140-
}
141123
bool test_fhss_data_tx_fail_cb()
142124
{
143125
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
@@ -28,8 +28,6 @@ bool test_fhss_is_broadcast_channel_cb();
2828
bool test_fhss_use_broadcast_queue_cb();
2929
// Test frame receive callback
3030
bool test_fhss_receive_frame_cb();
31-
// Test TX done callback
32-
bool test_fhss_data_tx_done_cb();
3331
// Test TX fail callback
3432
bool test_fhss_data_tx_fail_cb();
3533
// Test state set callback

0 commit comments

Comments
 (0)