Skip to content

Commit a16ec64

Browse files
committed
Fix #677: add LMIC_queryTxReady() and more checks
1 parent 804d43e commit a16ec64

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/lmic/lmic.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2878,6 +2878,10 @@ static bit_t isTxPathBusy(void) {
28782878
return (LMIC.opmode & (OP_TXDATA|OP_JOINING)) != 0;
28792879
}
28802880

2881+
bit_t LMIC_queryTxReady (void) {
2882+
return ! isTxPathBusy();
2883+
}
2884+
28812885
static bit_t adjustDrForFrameIfNotBusy(u1_t len) {
28822886
if (isTxPathBusy()) {
28832887
return 0;
@@ -2895,6 +2899,10 @@ void LMIC_setTxData (void) {
28952899
}
28962900

28972901
void LMIC_setTxData_strict (void) {
2902+
if (isTxPathBusy()) {
2903+
return;
2904+
}
2905+
28982906
LMICOS_logEventUint32(__func__, ((u4_t)LMIC.pendTxPort << 24u) | ((u4_t)LMIC.pendTxConf << 16u) | (LMIC.pendTxLen << 0u));
28992907
LMIC.opmode |= OP_TXDATA;
29002908
if( (LMIC.opmode & OP_JOINING) == 0 ) {
@@ -2913,7 +2921,7 @@ lmic_tx_error_t LMIC_setTxData2 (u1_t port, xref2u1_t data, u1_t dlen, u1_t conf
29132921

29142922
// send a message w/o callback; do not adjust data rate
29152923
lmic_tx_error_t LMIC_setTxData2_strict (u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed) {
2916-
if ( LMIC.opmode & OP_TXDATA ) {
2924+
if (isTxPathBusy()) {
29172925
// already have a message queued
29182926
return LMIC_ERROR_TX_BUSY;
29192927
}

src/lmic/lmic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,9 @@ bit_t LMIC_selectSubBand(u1_t band);
689689
//! \brief get the number of (fixed) default channels before the progammable channels.
690690
u1_t LMIC_queryNumDefaultChannels(void);
691691

692+
//! \brief check whether the LMIC is ready for a transmit packet
693+
bit_t LMIC_queryTxReady(void);
694+
692695
void LMIC_setDrTxpow (dr_t dr, s1_t txpow); // set default/start DR/txpow
693696
void LMIC_setAdrMode (bit_t enabled); // set ADR mode (if mobile turn off)
694697

0 commit comments

Comments
 (0)