Skip to content

Commit f794990

Browse files
author
Jarkko Paso
committed
FHSS: Implemented destination channel change in TX handle callback
1 parent d2957a1 commit f794990

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
static int fhss_ws_handle_state_set(fhss_structure_t *fhss_structure, fhss_states fhss_state, uint16_t pan_id)
3636
{
37+
(void) fhss_state;
3738
(void) pan_id;
3839
//TODO: Remove hard coded channel function
3940
fhss_structure->ws->channel_function = WS_TR51CF;
@@ -43,7 +44,7 @@ static int fhss_ws_handle_state_set(fhss_structure_t *fhss_structure, fhss_state
4344

4445
static void fhss_ws_superframe_callback(fhss_structure_t *fhss_structure)
4546
{
46-
47+
(void) fhss_structure;
4748
}
4849

4950
static void fhss_ws_update_channel_callback(fhss_structure_t *fhss_structure)
@@ -65,18 +66,50 @@ static void fhss_ws_update_channel_callback(fhss_structure_t *fhss_structure)
6566
//TODO: Callback to get channel schedule from application
6667
}
6768
#ifdef FHSS_CHANNEL_DEBUG
68-
tr_info("%"PRIu32" UC %u", fhss_structure->platform_functions.fhss_get_timestamp(fhss_structure->fhss_api), next_channel);
69+
tr_info("%"PRIu32" UC %u %u", fhss_structure->platform_functions.fhss_get_timestamp(fhss_structure->fhss_api), next_channel, fhss_structure->ws->slot);
6970
#endif /*FHSS_CHANNEL_DEBUG*/
7071
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, next_channel);
7172
}
7273

7374
static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_addr, uint8_t *destination_address, int frame_type, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length)
7475
{
76+
(void) is_broadcast_addr;
77+
(void) frame_type;
78+
(void) frame_length;
79+
(void) phy_header_length;
80+
(void) phy_tail_length;
81+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(api);
82+
if (!fhss_structure) {
83+
return -1;
84+
}
85+
if (fhss_structure->fhss_state == FHSS_SYNCHRONIZED) {
86+
int32_t tx_channel;
87+
//TODO: Compute destination slot using neighbour table
88+
uint16_t destination_slot = fhss_structure->ws->slot;
89+
if (fhss_structure->ws->channel_function == WS_TR51CF) {
90+
tx_channel = tr51_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels);
91+
} else if(fhss_structure->ws->channel_function == WS_DH1CF) {
92+
tx_channel = dh1cf_get_uc_channel_index(destination_slot, destination_address, fhss_structure->number_of_channels);
93+
} else if (fhss_structure->ws->channel_function == WS_VENDOR_DEF_CF) {
94+
95+
}
96+
#ifdef FHSS_CHANNEL_DEBUG
97+
tr_debug("TX channel: %u %u", tx_channel, destination_slot+1);
98+
#endif /*FHSS_CHANNEL_DEBUG*/
99+
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, tx_channel);
100+
}
75101
return 0;
76102
}
77103

78104
static bool fhss_ws_check_tx_conditions_callback(const fhss_api_t *api, bool is_broadcast_addr, uint8_t handle, int frame_type, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length)
79105
{
106+
(void) api;
107+
(void) is_broadcast_addr;
108+
(void) handle;
109+
(void) frame_type;
110+
(void) frame_length;
111+
(void) phy_header_length;
112+
(void) phy_tail_length;
80113
return true;
81114
}
82115

0 commit comments

Comments
 (0)