Skip to content

Commit

Permalink
FHSS: separated is_bc_callback to FHSS and WS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Feb 16, 2018
1 parent 59fe586 commit 04ae3c3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 53 deletions.
15 changes: 14 additions & 1 deletion source/Service_Libs/fhss/fhss.c
Expand Up @@ -1076,6 +1076,19 @@ static uint16_t fhss_get_retry_period_callback(const fhss_api_t *api, uint8_t *d
return retry_period;
}

static bool fhss_is_broadcast_channel_callback(const fhss_api_t *api)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
if (!fhss_structure) {
return false;
}
// FHSS is unsynchronized, broadcasts allowed
if (fhss_structure->fhss_state == FHSS_UNSYNCHRONIZED) {
return true;
}
return fhss_is_current_channel_broadcast(fhss_structure);
}

static void fhss_superframe_handler(const fhss_api_t *fhss_api, uint16_t delay)
{
uint32_t timeout = 0;
Expand Down Expand Up @@ -1141,7 +1154,7 @@ int8_t fhss_set_synch_configuration(fhss_structure_t *fhss_structure, const fhss
int fhss_set_callbacks(fhss_structure_t *fhss_structure)
{
// Set external API
fhss_structure->fhss_api->is_broadcast_channel = &fhss_is_broadcast_channel_cb;
fhss_structure->fhss_api->is_broadcast_channel = &fhss_is_broadcast_channel_callback;
fhss_structure->fhss_api->use_broadcast_queue = &fhss_use_broadcast_queue_cb;
fhss_structure->fhss_api->tx_handle = &fhss_tx_handle_callback;
fhss_structure->fhss_api->check_tx_conditions = &fhss_check_tx_conditions_callback;
Expand Down
14 changes: 0 additions & 14 deletions source/Service_Libs/fhss/fhss_mac_interface.c
Expand Up @@ -30,20 +30,6 @@

#define TRACE_GROUP "fhss"


bool fhss_is_broadcast_channel_cb(const fhss_api_t *api)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
if (!fhss_structure) {
return false;
}
// FHSS is unsynchronized, broadcasts allowed
if (fhss_structure->fhss_state == FHSS_UNSYNCHRONIZED) {
return true;
}
return fhss_is_current_channel_broadcast(fhss_structure);
}

bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
Expand Down
1 change: 0 additions & 1 deletion source/Service_Libs/fhss/fhss_mac_interface.h
Expand Up @@ -18,7 +18,6 @@
#ifndef FHSS_MAC_INTERFACE_H_
#define FHSS_MAC_INTERFACE_H_

bool fhss_is_broadcast_channel_cb(const fhss_api_t *api);
bool fhss_use_broadcast_queue_cb(const fhss_api_t *api, bool is_broadcast_addr, int frame_type);
uint32_t fhss_read_timestamp_cb(const fhss_api_t *api);
int fhss_init_callbacks_cb(const fhss_api_t *api, fhss_callback_t *callbacks);
Expand Down
11 changes: 10 additions & 1 deletion source/Service_Libs/fhss/fhss_ws.c
Expand Up @@ -300,6 +300,15 @@ static void fhss_ws_receive_frame_callback(const fhss_api_t *api, uint16_t pan_i
(void) frame_type;
}

static bool fhss_ws_is_broadcast_channel_callback(const fhss_api_t *api)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
if (!fhss_structure) {
return true;
}
return fhss_structure->ws->is_on_bc_channel;
}

static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
{
uint32_t timeout = 0;
Expand All @@ -315,7 +324,7 @@ static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
{
// Set external API
fhss_structure->fhss_api->is_broadcast_channel = &fhss_is_broadcast_channel_cb;
fhss_structure->fhss_api->is_broadcast_channel = &fhss_ws_is_broadcast_channel_callback;
fhss_structure->fhss_api->use_broadcast_queue = &fhss_use_broadcast_queue_cb;
fhss_structure->fhss_api->tx_handle = &fhss_ws_tx_handle_callback;
fhss_structure->fhss_api->check_tx_conditions = &fhss_ws_check_tx_conditions_callback;
Expand Down
Expand Up @@ -29,11 +29,6 @@ TEST_GROUP(fhss_mac_if)
}
};

TEST(fhss_mac_if, test_fhss_is_broadcast_channel_cb)
{
CHECK(test_fhss_is_broadcast_channel_cb());
}

TEST(fhss_mac_if, test_fhss_use_broadcast_queue_cb)
{
CHECK(test_fhss_use_broadcast_queue_cb());
Expand Down
Expand Up @@ -29,35 +29,6 @@
#include "fhss_channel_stub.h"
#include "fhss_platform_stub.h"

bool test_fhss_is_broadcast_channel_cb()
{
fhss_api_t fhss_api;

// By setting bool value false, fhss_struct can not be found
fhss_stub.bool_value = false;
if (fhss_is_broadcast_channel_cb(&fhss_api) == true) {
return false;
}
// By setting bool value true, fhss_struct can be found
fhss_stub.bool_value = true;
// Should return true
fhss_channel_stub.channel_bool_value = true;
if (fhss_is_broadcast_channel_cb(&fhss_api) == false) {
return false;
}
// Should return false
fhss_channel_stub.channel_bool_value = false;
fhss_stub.fhss_struct.fhss_state = FHSS_SYNCHRONIZED;
if (fhss_is_broadcast_channel_cb(&fhss_api) == true) {
return false;
}
// Should return true when unsynchronized
fhss_stub.fhss_struct.fhss_state = FHSS_UNSYNCHRONIZED;
if (fhss_is_broadcast_channel_cb(&fhss_api) == false) {
return false;
}
return true;
}
bool test_fhss_use_broadcast_queue_cb()
{
fhss_api_t fhss_api;
Expand Down
Expand Up @@ -22,8 +22,6 @@ extern "C" {
#endif

#include <stdbool.h>
// Test broadcast channel check callback
bool test_fhss_is_broadcast_channel_cb();
// Test broadcast queue check callback
bool test_fhss_use_broadcast_queue_cb();
// Test timestamp callback
Expand Down

0 comments on commit 04ae3c3

Please sign in to comment.