Skip to content

Commit 875f6a5

Browse files
Jordan Yatesnashif
authored andcommitted
lorawan: fix premature return in lorawan_send
Fixes an issue where `lorawan_send` would return prematurely when `LORAWAN_MSG_CONFIRMED` is mixed with unconfirmed messages. All calls to `LoRaMacMcpsRequest` result in `McpsConfirm` being run, where the semaphore `mcps_confirm_sem` is given. However this semaphore is only taken when `LORAWAN_MSG_CONFIRMED` is set. Therefore if an unconfirmed message is sent, any following confirmed messages will return from `lorawan_send` immediately as the semaphore will be available from the previous send. The return value would also be wrong for the same reasons. Fixed by only giving the semaphore in situations when it is being blocked on. Signed-off-by: Jordan Yates <[email protected]>
1 parent f862972 commit 875f6a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

subsys/lorawan/lorawan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ static void McpsConfirm(McpsConfirm_t *mcpsConfirm)
8585
}
8686

8787
last_mcps_confirm_status = mcpsConfirm->Status;
88-
k_sem_give(&mcps_confirm_sem);
88+
/* mcps_confirm_sem is only blocked on in the MCPS_CONFIRMED case */
89+
if (mcpsConfirm->McpsRequest == MCPS_CONFIRMED) {
90+
k_sem_give(&mcps_confirm_sem);
91+
}
8992
}
9093

9194
static void McpsIndication(McpsIndication_t *mcpsIndication)

0 commit comments

Comments
 (0)