Skip to content

Commit 5e70ec1

Browse files
author
Jarkko Paso
committed
FHSS: ws struct to hold ws specific parameters
1 parent f2d7558 commit 5e70ec1

File tree

8 files changed

+44
-9
lines changed

8 files changed

+44
-9
lines changed

source/Service_Libs/fhss/fhss.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,11 @@ static void fhss_update_channel_callback(fhss_structure_t *fhss_structure)
780780
}
781781
}
782782

783-
void fhss_set_internal_callbacks(fhss_structure_t *fhss_structure)
783+
int fhss_set_internal_callbacks(fhss_structure_t *fhss_structure)
784784
{
785785
fhss_structure->update_channel = fhss_update_channel_callback;
786786
fhss_structure->update_superframe = fhss_superframe_callback;
787787
fhss_structure->read_compensation = fhss_get_compensation;
788788
fhss_structure->handle_state_set = fhss_handle_state_set;
789+
return 0;
789790
}

source/Service_Libs/fhss/fhss.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int fhss_failed_handle_add(fhss_structure_t *fhss_structure, uint8_t handle);
4141
int fhss_failed_handle_remove(fhss_structure_t *fhss_structure, uint8_t handle);
4242
void fhss_failed_list_free(fhss_structure_t *fhss_structure);
4343
int fhss_reset_synch_monitor(fhss_synch_monitor_s *synch_monitor);
44-
void fhss_set_internal_callbacks(fhss_structure_t *fhss_structure);
44+
int fhss_set_internal_callbacks(fhss_structure_t *fhss_structure);
4545

4646
#define MAX_FHSS_TIMER_DIVIDER 100
4747
#define SYNCH_MONITOR_AVG_SAMPLES 5

source/Service_Libs/fhss/fhss_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ int8_t fhss_disable(fhss_structure_t *fhss_structure)
232232
return -1;
233233
}
234234
fhss_destroy_scramble_table(fhss_structure);
235+
ns_dyn_mem_free(fhss_structure->ws);
235236
ns_dyn_mem_free(fhss_structure);
236237
fhss_structure = 0;
237238
fhss_struct = 0;

source/Service_Libs/fhss/fhss_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define FHSS_UPDATE_SYNCH_INFO_STORAGE 4
2323

2424
typedef struct fhss_structure fhss_structure_t;
25+
struct fhss_ws;
2526

2627
typedef struct fhss_beacon_info
2728
{
@@ -137,6 +138,8 @@ struct fhss_structure
137138
fhss_beacon_info_t *fhss_beacon_info_store;
138139
fhss_failed_tx_list_t fhss_failed_tx_list;
139140
fhss_statistics_t *fhss_stats_ptr;
141+
142+
struct fhss_ws *ws;
140143
fhss_update_channel_cb *update_channel; /**< Update listening channel */
141144
fhss_update_superframe_cb *update_superframe; /**< Update superframe */
142145
fhss_read_compensation_cb *read_compensation; /**< Read FHSS compensation */

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
#include "fhss_config.h"
2121
#include "fhss_common.h"
2222
#include "channel_functions.h"
23+
#include "fhss_ws.h"
24+
#include "nsdynmemLIB.h"
2325
#include "ns_trace.h"
26+
#include <string.h>
2427

2528
#define TRACE_GROUP "fhss"
2629

@@ -42,19 +45,34 @@ static void fhss_ws_superframe_callback(fhss_structure_t *fhss_structure)
4245
static void fhss_ws_update_channel_callback(fhss_structure_t *fhss_structure)
4346
{
4447
uint8_t mac_address[8];
48+
int32_t next_channel;
4549
fhss_structure->callbacks.read_mac_address(fhss_structure->fhss_api, mac_address);
46-
int32_t next_channel = fhss_structure->rx_channel = dh1cf_get_uc_channel_index(fhss_structure->uc_channel_index, mac_address, fhss_structure->number_of_channels);
47-
fhss_structure->uc_channel_index++;
50+
if (fhss_structure->ws->channel_function == WS_FIXED_CHANNEL) {
51+
52+
} else if (fhss_structure->ws->channel_function == WS_TR51CF) {
53+
54+
} else if (fhss_structure->ws->channel_function == WS_DH1CF) {
55+
next_channel = fhss_structure->rx_channel = dh1cf_get_uc_channel_index(fhss_structure->ws->slot, mac_address, fhss_structure->number_of_channels);
56+
} else if (fhss_structure->ws->channel_function == WS_VENDOR_DEF_CF) {
57+
//TODO: Callback to get channel schedule from application
58+
}
59+
fhss_structure->ws->slot++;
4860
#ifdef FHSS_CHANNEL_DEBUG
49-
tr_info("%"PRIu32" UC %u %u", fhss_structure->platform_functions.fhss_get_timestamp(fhss_structure->fhss_api), fhss_structure->uc_channel_index-1, next_channel);
61+
tr_info("%"PRIu32" UC %u", fhss_structure->platform_functions.fhss_get_timestamp(fhss_structure->fhss_api), next_channel);
5062
#endif /*FHSS_CHANNEL_DEBUG*/
5163
fhss_structure->callbacks.change_channel(fhss_structure->fhss_api, next_channel);
5264
}
5365

54-
void fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure)
66+
int fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure)
5567
{
5668
fhss_structure->update_channel = fhss_ws_update_channel_callback;
5769
fhss_structure->update_superframe = fhss_ws_superframe_callback;
5870
fhss_structure->read_compensation = NULL;
5971
fhss_structure->handle_state_set = fhss_ws_handle_state_set;
72+
fhss_structure->ws = ns_dyn_mem_alloc(sizeof(fhss_ws_t));
73+
if (!fhss_structure->ws) {
74+
return -1;
75+
}
76+
memset(fhss_structure->ws, 0, sizeof(fhss_ws_t));
77+
return 0;
6078
}

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,17 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
typedef struct fhss_ws fhss_ws_t;
1718

18-
void fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure);
19+
#define WS_FIXED_CHANNEL 0
20+
#define WS_TR51CF 1
21+
#define WS_DH1CF 2
22+
#define WS_VENDOR_DEF_CF 3
23+
24+
struct fhss_ws
25+
{
26+
uint8_t channel_function;
27+
uint16_t slot;
28+
};
29+
30+
int fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure);

test/nanostack/unittest/stub/fhss_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ int fhss_handle_state_set(fhss_structure_t *fhss_structure, fhss_states fhss_sta
200200
return 0;
201201
}
202202

203-
void fhss_set_internal_callbacks(fhss_structure_t *fhss_structure)
203+
int fhss_set_internal_callbacks(fhss_structure_t *fhss_structure)
204204
{
205205

206206
}

test/nanostack/unittest/stub/fhss_ws_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "Service_Libs/fhss/fhss.h"
2424
#include "Service_Libs/fhss/fhss_beacon.h"
2525

26-
void fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure)
26+
int fhss_ws_set_internal_callbacks(fhss_structure_t *fhss_structure)
2727
{
2828

2929
}

0 commit comments

Comments
 (0)