Skip to content

Commit 84bd8a4

Browse files
Jarkko Pasojuhhei01
authored andcommitted
FHSS: Synchronization must be done in critical state
(cherry picked from commit 60c02049ae56d3381e750cd2d21ce26ca71789b4)
1 parent fb1b163 commit 84bd8a4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/Service_Libs/fhss/fhss_mac_interface.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Service_Libs/fhss/fhss.h"
2323
#include "Service_Libs/fhss/fhss_channel.h"
2424
#include "Service_Libs/fhss/fhss_beacon.h"
25+
#include "platform/arm_hal_interrupt.h"
2526
#include "randLIB.h"
2627
#include "ns_trace.h"
2728

@@ -124,10 +125,12 @@ void fhss_receive_frame_cb(const fhss_api_t *api, uint16_t pan_id, uint8_t *sour
124125
if (!fhss_compare_with_synch_parent_address(fhss_structure, source_address)) {
125126
// Synch parent address needs to be updated in case parent has changed
126127
fhss_update_synch_parent_address(fhss_structure);
128+
platform_enter_critical();
127129
// Calculate time since the Beacon was received
128130
uint32_t elapsed_time = api->read_timestamp(api) - timestamp;
129131
// Synchronize to given PAN
130132
fhss_beacon_received(fhss_structure, synch_info, elapsed_time);
133+
platform_exit_critical();
131134
}
132135
}
133136
} else if (FHSS_SYNCH_REQUEST_FRAME == frame_type) {
@@ -220,10 +223,12 @@ void fhss_synch_state_set_cb(const fhss_api_t *api, fhss_states fhss_state, uint
220223
fhss_beacon_info_t *beacon_info = fhss_get_beacon_info(fhss_structure, pan_id);
221224
if (beacon_info) {
222225
memcpy(fhss_structure->synch_parent, beacon_info->source_address, 8);
226+
platform_enter_critical();
223227
// Calculate time since the Beacon was received
224228
uint32_t elapsed_time = api->read_timestamp(api) - beacon_info->timestamp;
225229
// Synchronize to given PAN
226230
fhss_beacon_received(fhss_structure, beacon_info->synch_info, elapsed_time);
231+
platform_exit_critical();
227232
// Delete stored Beacon infos
228233
fhss_flush_beacon_info_storage(fhss_structure);
229234
fhss_structure->synch_panid = pan_id;

0 commit comments

Comments
 (0)