Skip to content

Commit 60dfccb

Browse files
author
Jarkko Paso
committed
FHSS: Removed unnecessary channel functions
1 parent e456662 commit 60dfccb

File tree

3 files changed

+0
-244
lines changed

3 files changed

+0
-244
lines changed

source/Service_Libs/fhss/channel_list.c

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ const int CHANNEL_LIST_SIZE_IN_BITS = 8*32;
3030
static bool channel_list_bit_test32(uint32_t word, int_fast8_t bit_number);
3131
static bool channel_list_bit_test(const uint32_t* list, int bit_number);
3232

33-
#if 0
34-
static void channel_list_bit_set32(uint32_t* word, int_fast8_t bit_number);
35-
static void channel_list_bit_set(uint32_t* list, int bit_number);
36-
#endif
37-
3833
// test bit by number
3934
static bool channel_list_bit_test32(uint32_t word, int_fast8_t bit_number)
4035
{
@@ -55,78 +50,7 @@ static bool channel_list_bit_test(const uint32_t* list, int bit_number)
5550

5651
return channel_list_bit_test32(list[word_index], bit_index);
5752
}
58-
#if 0
59-
// set bit by number
60-
static void channel_list_bit_set32(uint32_t* word, int_fast8_t bit_number)
61-
{
62-
*word |= ((uint32_t) 1 << bit_number);
63-
}
64-
65-
static void channel_list_bit_set(uint32_t* list, int bit_number)
66-
{
67-
const int_fast8_t word_index = bit_number / 32;
68-
const int_fast8_t bit_index = bit_number % 32;
69-
70-
channel_list_bit_set32(&(list[word_index]), bit_index);
71-
}
72-
73-
74-
void channel_list_print(uint8_t dlevel, const char *grp, const uint32_t* list)
75-
{
76-
77-
int temp_channel = 0;
78-
79-
#define CHANNELS_PER_LINE 32
80-
81-
uint8_t channels[CHANNELS_PER_LINE];
82-
83-
for (int line_index = 0; line_index < (CHANNEL_LIST_SIZE_IN_BITS/CHANNELS_PER_LINE); line_index++) {
84-
85-
int channels_found = 0;
86-
87-
for (int row_index = 0; row_index < CHANNELS_PER_LINE; row_index++) {
88-
89-
if (channel_list_bit_test(list, temp_channel)) {
90-
91-
channels[channels_found] = temp_channel;
92-
channels_found++;
93-
}
94-
95-
temp_channel++;
96-
}
97-
98-
tr_info("arr[%d]: %s", line_index, trace_array(channels, channels_found));
99-
}
100-
}
101-
102-
// this just avoids mistakes/copypaste on client side
103-
void channel_list_clear_mask(uint32_t* list)
104-
{
105-
const int mask_size = (sizeof(list));
106-
107-
memset(list, 0, mask_size);
108-
}
109-
110-
static int channel_list_search_in_range(const uint32_t* list, int start_index, int end_index)
111-
{
112-
int found_index = -1;
113-
for (int index = start_index; index <= end_index; index++) {
114-
115-
if (channel_list_bit_test(list, index)) {
116-
found_index = index;
117-
break;
118-
}
119-
}
120-
return found_index;
121-
}
122-
123-
// utility for getting the first channel
124-
int channel_list_get_first(const uint32_t* list)
125-
{
12653

127-
return channel_list_get_next(list, 0xff);
128-
}
129-
#endif
13054
static uint8_t channel_list_search(const uint32_t* list, int index)
13155
{
13256
uint8_t channel = 0;
@@ -163,58 +87,7 @@ uint8_t channel_list_get_channel(const uint32_t* list, int current_index)
16387

16488
return found_index;
16589
}
166-
#if 0
167-
int channel_list_get_next(const uint32_t* list, int current_index)
168-
{
169-
int found_index;
170-
171-
current_index++;
172-
173-
if (current_index >= CHANNEL_LIST_SIZE_IN_BITS) {
174-
175-
current_index = 0;
176-
}
177-
178-
// One could use a optimization here to avoid looping through masks 1..7
179-
// if page is not 9 or 10. But is it really worth it?
180-
found_index = channel_list_search_in_range(list, current_index, CHANNEL_LIST_SIZE_IN_BITS-1);
181-
182-
if ((found_index < 0) && (current_index > 0)) {
183-
184-
found_index = channel_list_search_in_range(list, 0, current_index-1);
185-
}
186-
187-
return found_index;
188-
}
189-
190-
int channel_list_get_next_broadcast(const uint32_t* list, int broadcast_channel_count, int current_index)
191-
{
192-
193-
// XXX: all these could/should be pre-calculated on configuration time.
194-
const int first_broadcast = channel_list_get_first(list);
195-
const int total_channel_count = channel_list_count_channels(list);
196-
int channels_to_loop = total_channel_count / broadcast_channel_count; // crash if broadcast is configured to zero
197-
198-
int next_broadcast = -1;
199-
200-
// If there are more than one broadcast channels and we're not yet at the last channel,
201-
// iteratively search for next broadcast channel.
202-
if ((channels_to_loop > 1) && (current_index < (CHANNEL_LIST_SIZE_IN_BITS - 1))) {
20390

204-
while (channels_to_loop > 0) {
205-
206-
current_index = channel_list_get_next(list, current_index);
207-
channels_to_loop--;
208-
}
209-
next_broadcast = current_index;
210-
}
211-
else {
212-
next_broadcast = first_broadcast;
213-
}
214-
215-
return next_broadcast;
216-
}
217-
#endif
21891
// count the amount of channels enabled in a list
21992
int channel_list_count_channels(const uint32_t* list)
22093
{
@@ -230,30 +103,3 @@ int channel_list_count_channels(const uint32_t* list)
230103

231104
return channel_count;
232105
}
233-
#if 0
234-
int channel_list_enable_channel(uint32_t* list, int channel_number)
235-
{
236-
int ret_val = -1;
237-
238-
if ((channel_number >= 0) && (channel_number < CHANNEL_LIST_SIZE_IN_BITS)) {
239-
240-
channel_list_bit_set(list, channel_number);
241-
242-
ret_val = 0;
243-
}
244-
245-
return ret_val;
246-
}
247-
248-
bool channel_list_is_channel_enabled(const uint32_t* list, int channel_number) {
249-
250-
int ret_val = false;
251-
252-
if ((channel_number >= 0) && (channel_number < CHANNEL_LIST_SIZE_IN_BITS)) {
253-
254-
ret_val = channel_list_bit_test(list, channel_number);
255-
}
256-
257-
return ret_val;
258-
}
259-
#endif

source/Service_Libs/fhss/channel_list.h

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

25-
/**
26-
* Dump the channel list object data to ns_trace using given trace level and group.
27-
*/
28-
void channel_list_print(uint8_t dlevel, const char* grp, const uint32_t* list);
29-
3025
/**
3126
* Get channel number using channel index.
3227
*
@@ -37,34 +32,6 @@ void channel_list_print(uint8_t dlevel, const char* grp, const uint32_t* list);
3732
*/
3833
uint8_t channel_list_get_channel(const uint32_t* list, int current_index);
3934

40-
/**
41-
* Clear the channel mask bitmap, does not change channel page.
42-
*
43-
* @param list list which mask is to be cleared
44-
*/
45-
void channel_list_clear_mask(uint32_t* list);
46-
47-
/**
48-
* Get next enabled channel number from given list. Channels are now taken sequentially,
49-
* starting from the index given.
50-
*
51-
* @param list to scan
52-
* @param the currently used channel index, ie. the place where search for next channel
53-
* is started
54-
* @return channel number of next channel
55-
*/
56-
int channel_list_get_next(const uint32_t* list, int current_index);
57-
58-
int channel_list_get_next_broadcast(const uint32_t* list, int broadcast_channel_count, int current_index);
59-
60-
/**
61-
* Get the first channel enabled in a list.
62-
*
63-
* @param list to scan
64-
* @return index of the first channel enabled
65-
*/
66-
int channel_list_get_first(const uint32_t* list);
67-
6835
/**
6936
* Count the amount of channels enabled in a list.
7037
*
@@ -73,31 +40,6 @@ int channel_list_get_first(const uint32_t* list);
7340
*/
7441
int channel_list_count_channels(const uint32_t* list);
7542

76-
/**
77-
* Enable channel by given channel number. This is likely to be used
78-
* from the test/application configuration side.
79-
*
80-
* Note: the channel number validity is not (yet?) verified, so one
81-
* can enable invalid channels which should not be according to channel page.
82-
*
83-
* @param list to modify
84-
* @param channel number
85-
* @return 0 on success, negative on failure (out of bounds channel)
86-
*/
87-
int channel_list_enable_channel(uint32_t* list, int channel_number);
88-
89-
/**
90-
* Check, if given channel is enabled. This is likely to be used
91-
* from the test/application configuration side.
92-
*
93-
* Note: the channel number validity is not (yet?) verified, so one
94-
* can enable invalid channels which should not be according to channel page.
95-
*
96-
* @param list to test
97-
* @param channel number
98-
* @return true, if channel is enabled on mask, false if not
99-
*/
100-
bool channel_list_is_channel_enabled(const uint32_t* list, int channel_number);
10143

10244
#ifdef __cplusplus
10345
}

test/nanostack/unittest/stub/channel_list_stub.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,46 +26,14 @@
2626

2727
channel_list_stub_def channel_list_stub;
2828

29-
void channel_list_print(uint8_t dlevel, const char *grp, const uint32_t* list)
30-
{
31-
}
32-
33-
void channel_list_clear_mask(uint32_t* list)
34-
{
35-
}
36-
37-
int channel_list_get_first(const uint32_t* list)
38-
{
39-
return 0;
40-
}
4129

4230
uint8_t channel_list_get_channel(const uint32_t* list, int current_index)
4331
{
4432
return channel_list_stub.uint8_value;
4533
}
4634

47-
int channel_list_get_next(const uint32_t* list, int current_index)
48-
{
49-
return 0;
50-
}
51-
52-
int channel_list_get_next_broadcast(const uint32_t* list, int broadcast_channel_count, int current_index)
53-
{
54-
return 0;
55-
}
56-
5735
int channel_list_count_channels(const uint32_t* list)
5836
{
5937
return channel_list_stub.uint8_value;
6038
}
6139

62-
int channel_list_enable_channel(uint32_t* list, int channel_number)
63-
{
64-
return 0;
65-
}
66-
67-
bool channel_list_is_channel_enabled(const uint32_t* list, int channel_number)
68-
{
69-
return false;
70-
}
71-

0 commit comments

Comments
 (0)