Skip to content

Commit

Permalink
FHSS: separated synch info write for FHSS and WS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Feb 13, 2018
1 parent 15d4465 commit 3e326d1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
20 changes: 19 additions & 1 deletion source/Service_Libs/fhss/fhss.c
Expand Up @@ -913,6 +913,24 @@ static void fhss_update_channel_callback(fhss_structure_t *fhss_structure)
}
}

static int16_t fhss_write_synch_info_callback(const fhss_api_t *api, uint8_t *info_ptr, int info_type, int frame_type_id, uint32_t tx_time)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
(void) frame_type_id;
(void) tx_time;
if (!fhss_structure) {
return -1;
}
if (info_type == FHSS_PLAIN_SYNCH_INFO) {
if (!info_ptr) {
return -1;
}
fhss_beacon_build(fhss_structure, info_ptr);
return FHSS_SYNCH_INFO_LENGTH;
}
return -1;
}

int fhss_set_callbacks(fhss_structure_t *fhss_structure)
{
// Set external API
Expand All @@ -926,7 +944,7 @@ int fhss_set_callbacks(fhss_structure_t *fhss_structure)
fhss_structure->fhss_api->synch_state_set = &fhss_synch_state_set_cb;
fhss_structure->fhss_api->read_timestamp = &fhss_read_timestamp_cb;
fhss_structure->fhss_api->get_retry_period = &fhss_get_retry_period_cb;
fhss_structure->fhss_api->write_synch_info = &fhss_write_synch_info_cb;
fhss_structure->fhss_api->write_synch_info = &fhss_write_synch_info_callback;
fhss_structure->fhss_api->init_callbacks = &fhss_init_callbacks_cb;
// Set internal API
fhss_structure->update_channel = fhss_update_channel_callback;
Expand Down
18 changes: 0 additions & 18 deletions source/Service_Libs/fhss/fhss_mac_interface.c
Expand Up @@ -205,24 +205,6 @@ uint16_t fhss_get_retry_period_cb(const fhss_api_t *api, uint8_t *destination_ad
return retry_period;
}

int16_t fhss_write_synch_info_cb(const fhss_api_t *api, uint8_t *info_ptr, int info_type, int frame_type_id, uint32_t tx_time)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
(void) frame_type_id;
(void) tx_time;
if (!fhss_structure) {
return -1;
}
if (info_type == FHSS_PLAIN_SYNCH_INFO) {
if (!info_ptr) {
return -1;
}
fhss_beacon_build(fhss_structure, info_ptr);
return FHSS_SYNCH_INFO_LENGTH;
}
return -1;
}


int fhss_init_callbacks_cb(const fhss_api_t *api, fhss_callback_t *callbacks)
{
Expand Down
1 change: 0 additions & 1 deletion source/Service_Libs/fhss/fhss_mac_interface.h
Expand Up @@ -26,7 +26,6 @@ bool fhss_data_tx_fail_cb(const fhss_api_t *api, uint8_t handle, int frame_type)
void fhss_synch_state_set_cb(const fhss_api_t *api, fhss_states fhss_state, uint16_t pan_id);
uint32_t fhss_read_timestamp_cb(const fhss_api_t *api);
uint16_t fhss_get_retry_period_cb(const fhss_api_t *api, uint8_t *destination_address, uint16_t phy_mtu);
int16_t fhss_write_synch_info_cb(const fhss_api_t *api, uint8_t *info_ptr, int info_type, int frame_type_id, uint32_t tx_time);
int fhss_init_callbacks_cb(const fhss_api_t *api, fhss_callback_t *callbacks);

#endif /* FHSS_MAC_INTERFACE_H_ */
19 changes: 18 additions & 1 deletion source/Service_Libs/fhss/fhss_ws.c
Expand Up @@ -170,6 +170,9 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
if (!fhss_structure) {
return -1;
}
if (is_broadcast_addr) {
return 0;
}
if (fhss_structure->fhss_state == FHSS_SYNCHRONIZED) {
int32_t tx_channel;
//TODO: Compute destination slot using neighbour table
Expand Down Expand Up @@ -201,6 +204,20 @@ static bool fhss_ws_check_tx_conditions_callback(const fhss_api_t *api, bool is_
return true;
}

static int16_t fhss_ws_write_synch_info_callback(const fhss_api_t *api, uint8_t *info_ptr, int info_type, int frame_type_id, uint32_t tx_time)
{
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
(void) frame_type_id;
(void) tx_time;
(void) info_ptr;
(void) info_type;
if (!fhss_structure) {
return -1;
}

return -1;
}

int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
{
// Set external API
Expand All @@ -214,7 +231,7 @@ int fhss_ws_set_callbacks(fhss_structure_t *fhss_structure)
fhss_structure->fhss_api->synch_state_set = &fhss_synch_state_set_cb;
fhss_structure->fhss_api->read_timestamp = &fhss_read_timestamp_cb;
fhss_structure->fhss_api->get_retry_period = &fhss_get_retry_period_cb;
fhss_structure->fhss_api->write_synch_info = &fhss_write_synch_info_cb;
fhss_structure->fhss_api->write_synch_info = &fhss_ws_write_synch_info_callback;
fhss_structure->fhss_api->init_callbacks = &fhss_init_callbacks_cb;
// Set internal API
fhss_structure->update_channel = fhss_ws_update_uc_channel_callback;
Expand Down

0 comments on commit 3e326d1

Please sign in to comment.