Skip to content

Commit c6cfb6c

Browse files
author
Jarkko Paso
authored
Merge pull request ARMmbed#1544 from ARMmbed/fhss_headers_refactored
FHSS: refactoring FHSS header files
2 parents e047723 + 1b4e203 commit c6cfb6c

26 files changed

+69
-60
lines changed

source/Service_Libs/fhss/channel_functions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
17+
#ifndef CHANNEL_FUNC_H_
18+
#define CHANNEL_FUNC_H_
1819
/**
1920
* @brief Calculate channel table based on TR51 channel function.
2021
* @param number_of_channels Number of channels in table.
@@ -62,3 +63,5 @@ int32_t dh1cf_get_uc_channel_index(uint16_t slot_number, uint8_t *mac, int16_t n
6263
* @return Channel index.
6364
*/
6465
int32_t dh1cf_get_bc_channel_index(uint16_t slot_number, uint16_t bsi, int16_t number_of_channels);
66+
67+
#endif /*CHANNEL_FUNC_H_*/

source/Service_Libs/fhss/fhss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "ns_types.h"
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
21-
#include "fhss_common.h"
2221
#include "fhss.h"
22+
#include "fhss_common.h"
2323
#include "fhss_channel.h"
2424
#include "channel_list.h"
2525
#include "nsdynmemLIB.h"

source/Service_Libs/fhss/fhss.h

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,46 @@
1616
*/
1717
#ifndef FHSS_H_
1818
#define FHSS_H_
19-
19+
#include "ns_list.h"
2020
#define MAX_SCRAMBLE_TABLE_INDEXES 20
2121
// Lifetime is given as seconds
2222
#define BEACON_INFO_LIFETIME 600
2323
// Limits the number of synchronization info messages sent on broadcast channels
2424
#define MAX_SYNCH_INFOS_PER_CHANNEL_LIST 2
2525
// FHSS randomly selects the starting superframe for broadcast channel. This defines how many superframes are used for randomization.
2626
#define NUMBER_OF_BC_START_SUPERFRAMES 3
27+
#define MAX_FHSS_TIMER_DIVIDER 100
28+
#define SYNCH_MONITOR_AVG_SAMPLES 5
29+
30+
typedef struct fhss_structure fhss_structure_t;
31+
typedef struct fhss_beacon_info fhss_beacon_info_t;
32+
typedef struct fhss_synch_monitor fhss_synch_monitor_s;
33+
typedef struct fhss_failed_tx fhss_failed_tx_t;
34+
35+
struct fhss_beacon_info
36+
{
37+
uint16_t pan_id;
38+
uint8_t source_address[8];
39+
uint32_t timestamp;
40+
uint8_t synch_info[FHSS_SYNCH_INFO_LENGTH];
41+
struct fhss_beacon_info *next;
42+
};
2743

28-
struct fhss_callback;
44+
struct fhss_synch_monitor
45+
{
46+
int32_t avg_synch_fix;
47+
int avg_synch_fix_counter;
48+
int drift_compensation;
49+
int channel_counter;
50+
};
51+
52+
struct fhss_failed_tx
53+
{
54+
uint8_t handle;
55+
uint8_t bad_channel;
56+
uint8_t retries_done;
57+
ns_list_link_t link;
58+
};
2959

3060
bool fhss_is_synch_root(fhss_structure_t *fhss_structure);
3161
bool fhss_check_bad_channel(fhss_structure_t *fhss_structure, uint8_t handle);
@@ -43,9 +73,6 @@ void fhss_failed_list_free(fhss_structure_t *fhss_structure);
4373
int fhss_reset_synch_monitor(fhss_synch_monitor_s *synch_monitor);
4474
int fhss_set_internal_callbacks(fhss_structure_t *fhss_structure);
4575

46-
#define MAX_FHSS_TIMER_DIVIDER 100
47-
#define SYNCH_MONITOR_AVG_SAMPLES 5
48-
4976
/**
5077
* Calculate time in microseconds to start of next superframe.
5178
*

source/Service_Libs/fhss/fhss_beacon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "nsconfig.h"
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
22-
#include "fhss_common.h"
2322
#include "fhss.h"
23+
#include "fhss_common.h"
2424
#include "fhss_beacon.h"
2525
#include "common_functions.h"
2626
#include <string.h> // memcpy

source/Service_Libs/fhss/fhss_beacon_tasklet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include "ns_trace.h"
2424
#include "fhss_api.h"
2525
#include "fhss_config.h"
26-
#include "fhss_common.h"
2726
#include "fhss.h"
27+
#include "fhss_common.h"
2828
#include "fhss_beacon.h"
2929
#include "fhss_statistics.h"
3030
#include "fhss_mac_interface.h"

source/Service_Libs/fhss/fhss_channel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "ns_types.h"
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
21-
#include "fhss_common.h"
2221
#include "fhss.h"
22+
#include "fhss_common.h"
2323
#include "fhss_channel.h"
2424
#include "fhss_beacon.h"
2525
#include "channel_list.h"

source/Service_Libs/fhss/fhss_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "ns_trace.h"
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
22-
#include "fhss_common.h"
2322
#include "fhss.h"
23+
#include "fhss_common.h"
2424
#include "fhss_ws.h"
2525
#include "fhss_beacon.h"
2626
#include "fhss_statistics.h"

source/Service_Libs/fhss/fhss_common.h

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,16 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#include "ns_list.h"
17+
#ifndef FHSS_COMMON_H_
18+
#define FHSS_COMMON_H_
1819
#define FHSS_TASKLET_INIT_EVENT 0
1920
#define FHSS_TIMER_EVENT 1
2021
#define FHSS_COMPARE_SYNCH_PARENT 2
2122
#define FHSS_BROADCAST_CHANNEL 3
2223
#define FHSS_UPDATE_SYNCH_INFO_STORAGE 4
2324

24-
typedef struct fhss_structure fhss_structure_t;
25-
struct fhss_ws;
26-
27-
typedef struct fhss_beacon_info
28-
{
29-
uint16_t pan_id;
30-
uint8_t source_address[8];
31-
uint32_t timestamp;
32-
uint8_t synch_info[FHSS_SYNCH_INFO_LENGTH];
33-
struct fhss_beacon_info *next;
34-
}fhss_beacon_info_t;
35-
36-
typedef struct fhss_failed_tx
37-
{
38-
uint8_t handle;
39-
uint8_t bad_channel;
40-
uint8_t retries_done;
41-
ns_list_link_t link;
42-
}fhss_failed_tx_t;
43-
4425
typedef NS_LIST_HEAD(fhss_failed_tx_t, link) fhss_failed_tx_list_t;
4526

46-
typedef struct
47-
{
48-
int32_t avg_synch_fix;
49-
int avg_synch_fix_counter;
50-
int drift_compensation;
51-
int channel_counter;
52-
} fhss_synch_monitor_s;
53-
5427
/**
5528
* @brief Update listening channel.
5629
* @param fhss_structure FHSS structure.
@@ -120,7 +93,7 @@ struct fhss_structure
12093
/*Indexes in this table will be used to extend the repeated channel sequence*/
12194
uint8_t *fhss_scramble_table;
12295
/** Used to monitor and fix synchronization drift*/
123-
fhss_synch_monitor_s synch_monitor;
96+
struct fhss_synch_monitor synch_monitor;
12497
/** Used to drop multiple synch info messages on same broadcast channel*/
12598
bool beacon_received_on_this_bc_channel;
12699
/** Timer used for events other than synchronization.*/
@@ -135,7 +108,7 @@ struct fhss_structure
135108
/* Bit mask for FHSS events pushed to event queue. Prevents pushing same event to queue multiple times*/
136109
uint8_t active_fhss_events;
137110
struct fhss_callback callbacks;
138-
fhss_beacon_info_t *fhss_beacon_info_store;
111+
struct fhss_beacon_info *fhss_beacon_info_store;
139112
fhss_failed_tx_list_t fhss_failed_tx_list;
140113
fhss_statistics_t *fhss_stats_ptr;
141114

@@ -146,8 +119,7 @@ struct fhss_structure
146119
fhss_handle_state_set_cb *handle_state_set; /**< Set FHSS state */
147120
};
148121

149-
150-
fhss_structure_t * fhss_enable(fhss_api_t *fhss_api, const fhss_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer, fhss_statistics_t *fhss_statistics);
122+
fhss_structure_t *fhss_enable(fhss_api_t *fhss_api, const fhss_configuration_t *fhss_configuration, const fhss_timer_t *fhss_timer, fhss_statistics_t *fhss_statistics);
151123
int fhss_down(fhss_structure_t *fhss_structure);
152124
int8_t fhss_set_datarate(fhss_structure_t *fhss_structure, uint32_t datarate);
153125
int8_t fhss_set_synch_configuration(fhss_structure_t *fhss_structure, const fhss_synch_configuration_t *fhss_synch_configuration);
@@ -161,4 +133,6 @@ int fhss_update_synch_parent_address(fhss_structure_t *fhss_structure);
161133
void fhss_trig_event(fhss_structure_t *fhss_structure, uint8_t event_type);
162134
int fhss_get_parent_address(fhss_structure_t *fhss_structure, uint8_t *p_addr);
163135
int fhss_compare_with_synch_parent_address(fhss_structure_t *fhss_structure, const uint8_t *source_addr);
136+
164137
void fhss_superframe_handler(const fhss_api_t *fhss_api, uint16_t delay);
138+
#endif /*FHSS_COMMON_H_*/

source/Service_Libs/fhss/fhss_configuration_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include "fhss_config.h"
2222
#include "net_fhss.h"
2323
#include "nsdynmemLIB.h"
24-
#include "Service_Libs/fhss/fhss_common.h"
2524
#include "Service_Libs/fhss/fhss.h"
25+
#include "Service_Libs/fhss/fhss_common.h"
2626
#include "Service_Libs/fhss/fhss_ws.h"
2727
#include "Service_Libs/fhss/fhss_mac_interface.h"
2828
#include "ns_trace.h"

source/Service_Libs/fhss/fhss_mac_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "ns_types.h"
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "Service_Libs/fhss/fhss_ws.h"
2525
#include "Service_Libs/fhss/fhss_channel.h"
2626
#include "Service_Libs/fhss/fhss_beacon.h"

source/Service_Libs/fhss/fhss_statistics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "ns_types.h"
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
21-
#include "fhss_common.h"
2221
#include "fhss.h"
22+
#include "fhss_common.h"
2323
#include "fhss_statistics.h"
2424

2525
void fhss_stats_update(fhss_structure_t *fhss_structure, fhss_stats_type_t type, uint32_t update_val)

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "ns_types.h"
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
21+
#include "fhss.h"
2122
#include "fhss_common.h"
2223
#include "channel_functions.h"
2324
#include "fhss_ws.h"

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
#ifndef FHSS_WS_H_
18+
#define FHSS_WS_H_
1719
typedef struct fhss_ws fhss_ws_t;
1820

1921
#define WS_FIXED_CHANNEL 0
@@ -28,3 +30,5 @@ struct fhss_ws
2830
};
2931

3032
int fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure);
33+
34+
#endif /*FHSS_WS_H_*/

test/nanostack/unittest/service_libs/fhss/test_fhss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "nsconfig.h"
1818
#include "fhss_api.h"
1919
#include "fhss_config.h"
20-
#include "Service_Libs/fhss/fhss_common.h"
2120
#include "Service_Libs/fhss/fhss.h"
21+
#include "Service_Libs/fhss/fhss_common.h"
2222
#include "Service_Libs/fhss/fhss_beacon.h"
2323
#include "MAC/IEEE802_15_4/mac_fhss_callbacks.h"
2424
#include "test_fhss.h"

test/nanostack/unittest/service_libs/fhss_beacon/test_fhss_beacon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "nsconfig.h"
1818
#include "fhss_api.h"
1919
#include "fhss_config.h"
20-
#include "Service_Libs/fhss/fhss_common.h"
2120
#include "Service_Libs/fhss/fhss.h"
21+
#include "Service_Libs/fhss/fhss_common.h"
2222
#include "Service_Libs/fhss/fhss_beacon.h"
2323

2424
uint16_t common_read_16_bit(const uint8_t data_buf[__static 2])

test/nanostack/unittest/service_libs/fhss_beacon_tasklet/test_fhss_beacon_tasklet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "nsconfig.h"
1818
#include "fhss_api.h"
1919
#include "fhss_config.h"
20-
#include "Service_Libs/fhss/fhss_common.h"
2120
#include "Service_Libs/fhss/fhss.h"
21+
#include "Service_Libs/fhss/fhss_common.h"
2222
#include "Service_Libs/fhss/fhss_beacon.h"
2323
#include "MAC/IEEE802_15_4/mac_fhss_callbacks.h"
2424
#include "fhss_platform_stub.h"

test/nanostack/unittest/service_libs/fhss_channel/test_fhss_channel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "nsconfig.h"
1818
#include "fhss_api.h"
1919
#include "fhss_config.h"
20-
#include "Service_Libs/fhss/fhss_common.h"
2120
#include "Service_Libs/fhss/fhss.h"
21+
#include "Service_Libs/fhss/fhss_common.h"
2222
#include "MAC/IEEE802_15_4/mac_fhss_callbacks.h"
2323
#include "test_fhss_channel.h"
2424
#include "nsdynmemLIB_stub.h"

test/nanostack/unittest/service_libs/fhss_config/test_fhss_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
2121
#include "net_fhss.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "test_fhss_config.h"
2525
#include "nsdynmemLIB_stub.h"
2626
#include "fhss_mac_interface_stub.h"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
2121
#include "net_fhss.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "Service_Libs/fhss/fhss_mac_interface.h"
2525
#include "MAC/IEEE802_15_4/mac_fhss_callbacks.h"
2626
#include "test_fhss_mac_interface.h"

test/nanostack/unittest/service_libs/fhss_statistics/test_fhss_statistics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
2121
#include "net_fhss.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "Service_Libs/fhss/fhss_statistics.h"
2525

2626

test/nanostack/unittest/stub/fhss_beacon_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
2222
#include "fhss_channel_stub.h"
23-
#include "Service_Libs/fhss/fhss_common.h"
2423
#include "Service_Libs/fhss/fhss.h"
24+
#include "Service_Libs/fhss/fhss_common.h"
2525
#include "Service_Libs/fhss/fhss_beacon.h"
2626

2727
uint8_t fhss_calculate_uc_index(uint8_t channel_index, uint16_t number_of_channels, uint8_t number_of_broadcast_channels)

test/nanostack/unittest/stub/fhss_beacon_tasklet_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include "fhss_config.h"
2222
#include "fhss_channel_stub.h"
2323
#include "fhss_beacon_tasklet_stub.h"
24-
#include "Service_Libs/fhss/fhss_common.h"
2524
#include "Service_Libs/fhss/fhss.h"
25+
#include "Service_Libs/fhss/fhss_common.h"
2626

2727
fhss_beacon_tasklet_stub_def fhss_beacon_tasklet_stub;
2828

test/nanostack/unittest/stub/fhss_channel_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
2222
#include "fhss_channel_stub.h"
23-
#include "Service_Libs/fhss/fhss_common.h"
2423
#include "Service_Libs/fhss/fhss.h"
24+
#include "Service_Libs/fhss/fhss_common.h"
2525

2626
fhss_channel_stub_def fhss_channel_stub;
2727

test/nanostack/unittest/stub/fhss_statistics_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "fhss_api.h"
2020
#include "fhss_config.h"
2121
#include "fhss_channel_stub.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "Service_Libs/fhss/fhss_statistics.h"
2525

2626
void fhss_stats_update(fhss_structure_t *fhss_structure, fhss_stats_type_t type, uint32_t update_val)

test/nanostack/unittest/stub/fhss_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "nsdynmemLIB.h"
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "Service_Libs/fhss/fhss_beacon.h"
2525
#include "fhss_stub.h"
2626

test/nanostack/unittest/stub/fhss_ws_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "nsdynmemLIB.h"
2020
#include "fhss_api.h"
2121
#include "fhss_config.h"
22-
#include "Service_Libs/fhss/fhss_common.h"
2322
#include "Service_Libs/fhss/fhss.h"
23+
#include "Service_Libs/fhss/fhss_common.h"
2424
#include "Service_Libs/fhss/fhss_beacon.h"
2525

2626
int fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure)

0 commit comments

Comments
 (0)