Skip to content

Commit d04b818

Browse files
author
Jarkko Paso
committed
FHSS: Compensation callback to return timeout value
1 parent 472becb commit d04b818

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

source/Service_Libs/fhss/fhss.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ static void fhss_destroy_scramble_table(fhss_structure_t *fhss_structure)
792792
}
793793
}
794794

795-
static uint32_t fhss_get_compensation(fhss_structure_t *fhss_structure)
795+
static uint32_t fhss_get_sf_timeout_callback(fhss_structure_t *fhss_structure)
796796
{
797797
uint32_t compensation = 0;
798798
/* Drift compensation doesn't work with Linux platform */
@@ -811,7 +811,7 @@ static uint32_t fhss_get_compensation(fhss_structure_t *fhss_structure)
811811
#else
812812
(void) fhss_structure;
813813
#endif //__linux__
814-
return compensation;
814+
return (fhss_structure->synch_configuration.fhss_superframe_length) + (compensation * fhss_structure->platform_functions.fhss_resolution_divider);
815815
}
816816

817817
static void fhss_superframe_callback(fhss_structure_t *fhss_structure)
@@ -931,7 +931,7 @@ int fhss_set_callbacks(fhss_structure_t *fhss_structure)
931931
// Set internal API
932932
fhss_structure->update_channel = fhss_update_channel_callback;
933933
fhss_structure->update_superframe = fhss_superframe_callback;
934-
fhss_structure->read_compensation = fhss_get_compensation;
934+
fhss_structure->read_superframe_timeout = fhss_get_sf_timeout_callback;
935935
fhss_structure->handle_state_set = fhss_handle_state_set;
936936
return 0;
937937
}

source/Service_Libs/fhss/fhss_common.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,17 @@ int fhss_compare_with_synch_parent_address(fhss_structure_t *fhss_structure, con
257257

258258
void fhss_superframe_handler(const fhss_api_t *fhss_api, uint16_t delay)
259259
{
260-
uint32_t compensation = 0;
260+
uint32_t timeout = 0;
261261
fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api);
262262
if (!fhss_structure) {
263263
return;
264264
}
265265

266-
if (fhss_structure->current_superframe == 0) {
267-
if (fhss_structure->read_compensation) {
268-
compensation = fhss_structure->read_compensation(fhss_structure);
269-
}
266+
if (fhss_structure->read_superframe_timeout) {
267+
timeout = fhss_structure->read_superframe_timeout(fhss_structure);
270268
}
271269

272-
fhss_start_timer(fhss_structure, (fhss_structure->synch_configuration.fhss_superframe_length) - (delay * fhss_structure->platform_functions.fhss_resolution_divider) + (compensation * fhss_structure->platform_functions.fhss_resolution_divider), fhss_superframe_handler);
270+
fhss_start_timer(fhss_structure, timeout - (delay * fhss_structure->platform_functions.fhss_resolution_divider), fhss_superframe_handler);
273271

274272
if (fhss_structure->current_superframe++ >= (fhss_structure->synch_configuration.fhss_number_of_superframes - 1)) {
275273
fhss_structure->current_superframe = 0;

source/Service_Libs/fhss/fhss_common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ typedef void fhss_update_channel_cb(fhss_structure_t *fhss_structure);
3737
typedef void fhss_update_superframe_cb(fhss_structure_t *fhss_structure);
3838

3939
/**
40-
* @brief Read FHSS compensation.
40+
* @brief Read next FHSS superframe timeout length.
4141
* @param fhss_structure FHSS structure.
42-
* @return Compensation to be added to started dwell time
42+
* @return timeout (us)
4343
*/
44-
typedef uint32_t fhss_read_compensation_cb(fhss_structure_t *fhss_structure);
44+
typedef uint32_t fhss_read_superframe_timeout_cb(fhss_structure_t *fhss_structure);
4545

4646
/**
4747
* @brief Set FHSS state.
@@ -120,7 +120,7 @@ struct fhss_structure
120120
struct fhss_ws *ws;
121121
fhss_update_channel_cb *update_channel; /**< Update listening channel */
122122
fhss_update_superframe_cb *update_superframe; /**< Update superframe */
123-
fhss_read_compensation_cb *read_compensation; /**< Read FHSS compensation */
123+
fhss_read_superframe_timeout_cb *read_superframe_timeout; /**< Read next FHSS superframe timeout length */
124124
fhss_handle_state_set_cb *handle_state_set; /**< Set FHSS state */
125125
};
126126

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configurati
3737
return NULL;
3838
}
3939

40+
static uint32_t fhss_ws_get_sf_timeout_callback(fhss_structure_t *fhss_structure)
41+
{
42+
return fhss_structure->fhss_conf.fhss_ws_configuration.fhss_uc_dwell_interval * 1000;
43+
}
44+
4045
static int fhss_ws_handle_state_set(fhss_structure_t *fhss_structure, fhss_states fhss_state, uint16_t pan_id)
4146
{
4247
(void) fhss_state;
4348
(void) pan_id;
4449
//TODO: Remove hard coded channel function
4550
fhss_structure->ws->channel_function = WS_TR51CF;
46-
fhss_start_timer(fhss_structure, fhss_structure->synch_configuration.fhss_superframe_length, fhss_superframe_handler);
51+
fhss_start_timer(fhss_structure, fhss_structure->fhss_conf.fhss_ws_configuration.fhss_uc_dwell_interval*1000, fhss_superframe_handler);
4752
return 0;
4853
}
4954

@@ -136,7 +141,7 @@ int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
136141
// Set internal API
137142
fhss_structure->update_channel = fhss_ws_update_channel_callback;
138143
fhss_structure->update_superframe = fhss_ws_superframe_callback;
139-
fhss_structure->read_compensation = NULL;
144+
fhss_structure->read_superframe_timeout = fhss_ws_get_sf_timeout_callback;
140145
fhss_structure->handle_state_set = fhss_ws_handle_state_set;
141146
fhss_structure->ws = ns_dyn_mem_alloc(sizeof(fhss_ws_t));
142147
if (!fhss_structure->ws) {

0 commit comments

Comments
 (0)