Skip to content

Commit 237b3d4

Browse files
committed
Fhss info print (ARMmbed#1486)
* Added FHSS synch info state and error print's * Added more print for debug. * Corrected FHSS timestamp value for timeout synchinfo eventhandling. * Fix thread commercial stub definition. (cherry picked from commit 414267d19c41e3a07d5f6646f3519b608b140173) Change-Id: Ibe0c3a5cb4bdb0b580a494d38499153847610372
1 parent 0f39a47 commit 237b3d4

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

source/Service_Libs/fhss/fhss.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ static fhss_beacon_info_t *fhss_create_beacon_info(fhss_structure_t *fhss_struct
949949

950950
static int fhss_remove_beacon_info(fhss_structure_t *fhss_structure, uint16_t pan_id)
951951
{
952+
tr_debug("Remove synch info %u", pan_id);
952953
if (!fhss_structure || !fhss_structure->fhss_beacon_info_store) {
953954
return -1;
954955
}
@@ -1001,6 +1002,7 @@ int fhss_add_beacon_info(fhss_structure_t *fhss_structure, uint16_t pan_id, uint
10011002
beacon_info = fhss_create_beacon_info(fhss_structure);
10021003
}
10031004
if (!beacon_info) {
1005+
tr_error("Beacon data not allocated");
10041006
return -2;
10051007
}
10061008
fhss_write_beacon_info(beacon_info, pan_id, source_address, timestamp, synch_info);
@@ -1015,6 +1017,10 @@ void fhss_update_beacon_info_lifetimes(fhss_structure_t *fhss_structure, uint32_
10151017
uint32_t time_since_added = timestamp - beacon_info->timestamp;
10161018
// timestamp is microseconds, lifetime is seconds
10171019
if (time_since_added >= ((uint32_t)BEACON_INFO_LIFETIME * 1000000)) {
1020+
tr_debug("Remove synch info by timeout");
1021+
tr_debug("time_since_added: %"PRIu32"", time_since_added);
1022+
tr_debug("beacon_info->timestamp: %"PRIu32"", beacon_info->timestamp);
1023+
tr_debug("timestamp: %"PRIu32"", timestamp);
10181024
if (fhss_remove_beacon_info(fhss_structure, beacon_info->pan_id) == 0) {
10191025
return;
10201026
}

source/Service_Libs/fhss/fhss_beacon_tasklet.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "fhss.h"
2727
#include "fhss_beacon.h"
2828
#include "fhss_statistics.h"
29+
#include "fhss_mac_interface.h"
2930
#include "platform/arm_hal_interrupt.h"
3031

3132
#include <string.h> // memset
@@ -122,7 +123,7 @@ static void fhss_beacon_tasklet_func(arm_event_s* event)
122123
// Update Beacon info lifetimes
123124
else if(event->event_type == FHSS_UPDATE_SYNCH_INFO_STORAGE)
124125
{
125-
fhss_update_beacon_info_lifetimes(fhss_structure, fhss_structure->platform_functions.fhss_get_timestamp(fhss_structure->fhss_api));
126+
fhss_update_beacon_info_lifetimes(fhss_structure, fhss_read_timestamp_cb(fhss_structure->fhss_api));
126127
}
127128
}
128129

source/Service_Libs/fhss/fhss_mac_interface.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,17 @@ void fhss_synch_state_set_cb(const fhss_api_t *api, fhss_states fhss_state, uint
204204

205205
// State is already set
206206
if (fhss_structure->fhss_state == fhss_state) {
207+
tr_debug("Synch same state %u", fhss_state);
207208
return;
208209
}
209210

210211
if (fhss_state == FHSS_UNSYNCHRONIZED) {
212+
tr_debug("FHSS down");
211213
fhss_down(fhss_structure);
212214
} else {
213215
// Do not synchronize to current pan
214216
if (fhss_structure->synch_panid == pan_id) {
217+
tr_debug("Synch same panid %u", pan_id);
215218
return;
216219
}
217220
uint32_t datarate = fhss_structure->callbacks.read_datarate(api);
@@ -222,6 +225,7 @@ void fhss_synch_state_set_cb(const fhss_api_t *api, fhss_states fhss_state, uint
222225
// Get Beacon info from storage
223226
fhss_beacon_info_t *beacon_info = fhss_get_beacon_info(fhss_structure, pan_id);
224227
if (beacon_info) {
228+
tr_debug("Synch to storaged value");
225229
memcpy(fhss_structure->synch_parent, beacon_info->source_address, 8);
226230
platform_enter_critical();
227231
// Calculate time since the Beacon was received
@@ -230,11 +234,14 @@ void fhss_synch_state_set_cb(const fhss_api_t *api, fhss_states fhss_state, uint
230234
fhss_beacon_received(fhss_structure, beacon_info->synch_info, elapsed_time);
231235
platform_exit_critical();
232236
// Delete stored Beacon infos
237+
tr_debug("Flush storaged Beacon's");
233238
fhss_flush_beacon_info_storage(fhss_structure);
234239
fhss_structure->synch_panid = pan_id;
235240
} else if (fhss_is_synch_root(fhss_structure) == true) {
236241
// Synch root will start new network
237242
fhss_start_timer(fhss_structure, fhss_structure->synch_configuration.fhss_superframe_length, fhss_superframe_handler);
243+
} else {
244+
tr_error("Synch info not find");
238245
}
239246
}
240247
fhss_structure->fhss_state = fhss_state;

test/nanostack/unittest/service_libs/fhss_beacon_tasklet/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ TEST_SRC_FILES = \
1717
../../stub/fhss_statistics_stub.c \
1818
../../stub/fhss_callbacks_stub.c \
1919
../../stub/fhss_platform_stub.c \
20+
../../stub/fhss_mac_interface_stub.c \
2021
../../stub/event_stub.c \
2122

2223
include ../../MakefileWorker.mk

0 commit comments

Comments
 (0)