Commit bf1f2fae authored by Reto Da Forno's avatar Reto Da Forno
Browse files

Merge remote-tracking branch 'origin/fix-flood-stop'

parents 194eeb95 08af1e24
......@@ -143,7 +143,11 @@ void gloria_update()
void gloria_process_slot()
{
if (gloria_is_not_finished(current_flood) && !current_flood->stop) {
if (current_flood->stop) {
// finish flood without callback (calling callback could lead to executing gloria_stop() two times)
return;
}
else if (gloria_is_not_finished(current_flood)) {
if (gloria_is_ack_slot(current_flood)) {
if (current_flood->acked) {
// flood ack received or node is flood destination -> send ack
......
......@@ -191,7 +191,7 @@ uint8_t gloria_stop(void)
#if GLORIA_INTERFACE_WAIT_TX_FINISHED
// if a transmission is ongoing, wait for it to complete
flood.stop = true;
uint64_t timeout = hs_timer_get_current_timestamp() + gloria_calculate_slot_time(GLORIA_INTERFACE_MODULATION, 0, 0, GLORIA_INTERFACE_MAX_PAYLOAD_LEN);
uint64_t timeout = hs_timer_get_current_timestamp() + gloria_calculate_slot_time(internal_modulation, 0, 0, GLORIA_INTERFACE_MAX_PAYLOAD_LEN);
while ((radio_get_status() == RF_TX_RUNNING) && !flood_completed && (hs_timer_get_current_timestamp() < timeout));
#endif /* GLORIA_INTERFACE_WAIT_TX_FINISHED */
......
......@@ -301,7 +301,12 @@ void hs_timer_generic_start(uint64_t timestamp, hs_timer_cb_t callback)
{
if (callback) {
uint64_t now = hs_timer_get_current_timestamp();
if ((timestamp - now) < HS_TIMER_GUARD_TIME || (timestamp - now) > (uint64_t) INT64_MAX) {
if ((timestamp - now) < HS_TIMER_GUARD_TIME) {
LOG_WARNING("Generic too late!");
callback();
}
else if ((timestamp - now) > (uint64_t) INT64_MAX) {
LOG_WARNING("Generic strange condition");
callback();
}
else {
......@@ -388,4 +393,3 @@ void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment