Skip to content

Commit

Permalink
FHSS: Removed unnecessary channel functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Jan 17, 2018
1 parent e456662 commit 60dfccb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 244 deletions.
154 changes: 0 additions & 154 deletions source/Service_Libs/fhss/channel_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ const int CHANNEL_LIST_SIZE_IN_BITS = 8*32;
static bool channel_list_bit_test32(uint32_t word, int_fast8_t bit_number);
static bool channel_list_bit_test(const uint32_t* list, int bit_number);

#if 0
static void channel_list_bit_set32(uint32_t* word, int_fast8_t bit_number);
static void channel_list_bit_set(uint32_t* list, int bit_number);
#endif

// test bit by number
static bool channel_list_bit_test32(uint32_t word, int_fast8_t bit_number)
{
Expand All @@ -55,78 +50,7 @@ static bool channel_list_bit_test(const uint32_t* list, int bit_number)

return channel_list_bit_test32(list[word_index], bit_index);
}
#if 0
// set bit by number
static void channel_list_bit_set32(uint32_t* word, int_fast8_t bit_number)
{
*word |= ((uint32_t) 1 << bit_number);
}

static void channel_list_bit_set(uint32_t* list, int bit_number)
{
const int_fast8_t word_index = bit_number / 32;
const int_fast8_t bit_index = bit_number % 32;

channel_list_bit_set32(&(list[word_index]), bit_index);
}


void channel_list_print(uint8_t dlevel, const char *grp, const uint32_t* list)
{

int temp_channel = 0;

#define CHANNELS_PER_LINE 32

uint8_t channels[CHANNELS_PER_LINE];

for (int line_index = 0; line_index < (CHANNEL_LIST_SIZE_IN_BITS/CHANNELS_PER_LINE); line_index++) {

int channels_found = 0;

for (int row_index = 0; row_index < CHANNELS_PER_LINE; row_index++) {

if (channel_list_bit_test(list, temp_channel)) {

channels[channels_found] = temp_channel;
channels_found++;
}

temp_channel++;
}

tr_info("arr[%d]: %s", line_index, trace_array(channels, channels_found));
}
}

// this just avoids mistakes/copypaste on client side
void channel_list_clear_mask(uint32_t* list)
{
const int mask_size = (sizeof(list));

memset(list, 0, mask_size);
}

static int channel_list_search_in_range(const uint32_t* list, int start_index, int end_index)
{
int found_index = -1;
for (int index = start_index; index <= end_index; index++) {

if (channel_list_bit_test(list, index)) {
found_index = index;
break;
}
}
return found_index;
}

// utility for getting the first channel
int channel_list_get_first(const uint32_t* list)
{

return channel_list_get_next(list, 0xff);
}
#endif
static uint8_t channel_list_search(const uint32_t* list, int index)
{
uint8_t channel = 0;
Expand Down Expand Up @@ -163,58 +87,7 @@ uint8_t channel_list_get_channel(const uint32_t* list, int current_index)

return found_index;
}
#if 0
int channel_list_get_next(const uint32_t* list, int current_index)
{
int found_index;

current_index++;

if (current_index >= CHANNEL_LIST_SIZE_IN_BITS) {

current_index = 0;
}

// One could use a optimization here to avoid looping through masks 1..7
// if page is not 9 or 10. But is it really worth it?
found_index = channel_list_search_in_range(list, current_index, CHANNEL_LIST_SIZE_IN_BITS-1);

if ((found_index < 0) && (current_index > 0)) {

found_index = channel_list_search_in_range(list, 0, current_index-1);
}

return found_index;
}

int channel_list_get_next_broadcast(const uint32_t* list, int broadcast_channel_count, int current_index)
{

// XXX: all these could/should be pre-calculated on configuration time.
const int first_broadcast = channel_list_get_first(list);
const int total_channel_count = channel_list_count_channels(list);
int channels_to_loop = total_channel_count / broadcast_channel_count; // crash if broadcast is configured to zero

int next_broadcast = -1;

// If there are more than one broadcast channels and we're not yet at the last channel,
// iteratively search for next broadcast channel.
if ((channels_to_loop > 1) && (current_index < (CHANNEL_LIST_SIZE_IN_BITS - 1))) {

while (channels_to_loop > 0) {

current_index = channel_list_get_next(list, current_index);
channels_to_loop--;
}
next_broadcast = current_index;
}
else {
next_broadcast = first_broadcast;
}

return next_broadcast;
}
#endif
// count the amount of channels enabled in a list
int channel_list_count_channels(const uint32_t* list)
{
Expand All @@ -230,30 +103,3 @@ int channel_list_count_channels(const uint32_t* list)

return channel_count;
}
#if 0
int channel_list_enable_channel(uint32_t* list, int channel_number)
{
int ret_val = -1;

if ((channel_number >= 0) && (channel_number < CHANNEL_LIST_SIZE_IN_BITS)) {

channel_list_bit_set(list, channel_number);

ret_val = 0;
}

return ret_val;
}

bool channel_list_is_channel_enabled(const uint32_t* list, int channel_number) {

int ret_val = false;

if ((channel_number >= 0) && (channel_number < CHANNEL_LIST_SIZE_IN_BITS)) {

ret_val = channel_list_bit_test(list, channel_number);
}

return ret_val;
}
#endif
58 changes: 0 additions & 58 deletions source/Service_Libs/fhss/channel_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
extern "C" {
#endif

/**
* Dump the channel list object data to ns_trace using given trace level and group.
*/
void channel_list_print(uint8_t dlevel, const char* grp, const uint32_t* list);

/**
* Get channel number using channel index.
*
Expand All @@ -37,34 +32,6 @@ void channel_list_print(uint8_t dlevel, const char* grp, const uint32_t* list);
*/
uint8_t channel_list_get_channel(const uint32_t* list, int current_index);

/**
* Clear the channel mask bitmap, does not change channel page.
*
* @param list list which mask is to be cleared
*/
void channel_list_clear_mask(uint32_t* list);

/**
* Get next enabled channel number from given list. Channels are now taken sequentially,
* starting from the index given.
*
* @param list to scan
* @param the currently used channel index, ie. the place where search for next channel
* is started
* @return channel number of next channel
*/
int channel_list_get_next(const uint32_t* list, int current_index);

int channel_list_get_next_broadcast(const uint32_t* list, int broadcast_channel_count, int current_index);

/**
* Get the first channel enabled in a list.
*
* @param list to scan
* @return index of the first channel enabled
*/
int channel_list_get_first(const uint32_t* list);

/**
* Count the amount of channels enabled in a list.
*
Expand All @@ -73,31 +40,6 @@ int channel_list_get_first(const uint32_t* list);
*/
int channel_list_count_channels(const uint32_t* list);

/**
* Enable channel by given channel number. This is likely to be used
* from the test/application configuration side.
*
* Note: the channel number validity is not (yet?) verified, so one
* can enable invalid channels which should not be according to channel page.
*
* @param list to modify
* @param channel number
* @return 0 on success, negative on failure (out of bounds channel)
*/
int channel_list_enable_channel(uint32_t* list, int channel_number);

/**
* Check, if given channel is enabled. This is likely to be used
* from the test/application configuration side.
*
* Note: the channel number validity is not (yet?) verified, so one
* can enable invalid channels which should not be according to channel page.
*
* @param list to test
* @param channel number
* @return true, if channel is enabled on mask, false if not
*/
bool channel_list_is_channel_enabled(const uint32_t* list, int channel_number);

#ifdef __cplusplus
}
Expand Down
32 changes: 0 additions & 32 deletions test/nanostack/unittest/stub/channel_list_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,14 @@

channel_list_stub_def channel_list_stub;

void channel_list_print(uint8_t dlevel, const char *grp, const uint32_t* list)
{
}

void channel_list_clear_mask(uint32_t* list)
{
}

int channel_list_get_first(const uint32_t* list)
{
return 0;
}

uint8_t channel_list_get_channel(const uint32_t* list, int current_index)
{
return channel_list_stub.uint8_value;
}

int channel_list_get_next(const uint32_t* list, int current_index)
{
return 0;
}

int channel_list_get_next_broadcast(const uint32_t* list, int broadcast_channel_count, int current_index)
{
return 0;
}

int channel_list_count_channels(const uint32_t* list)
{
return channel_list_stub.uint8_value;
}

int channel_list_enable_channel(uint32_t* list, int channel_number)
{
return 0;
}

bool channel_list_is_channel_enabled(const uint32_t* list, int channel_number)
{
return false;
}

0 comments on commit 60dfccb

Please sign in to comment.