Skip to content

Commit c13a2fd

Browse files
committed
Fix #570: carry piggyback data for keep-alives, too
1 parent e2d6f48 commit c13a2fd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/hal/hal.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ s1_t hal_getRssiCal (void) {
8585
// Interrupt handling
8686
//--------------------
8787
static constexpr unsigned NUM_DIO_INTERRUPT = 3;
88-
static_assert(NUM_DIO_INTERRUPT <= NUM_DIO);
88+
static_assert(NUM_DIO_INTERRUPT <= NUM_DIO, "Number of interrupt-sensitive lines must be less than number of GPIOs");
8989
static ostime_t interrupt_time[NUM_DIO_INTERRUPT] = {0};
9090

9191
#if !defined(LMIC_USE_INTERRUPTS)
@@ -95,7 +95,7 @@ static void hal_interrupt_init() {
9595
pinMode(plmic_pins->dio[1], INPUT);
9696
if (plmic_pins->dio[2] != LMIC_UNUSED_PIN)
9797
pinMode(plmic_pins->dio[2], INPUT);
98-
static_assert(NUM_DIO_INTERRUPT == 3);
98+
static_assert(NUM_DIO_INTERRUPT == 3, "Number of interrupt lines must be set to 3");
9999
}
100100

101101
static bool dio_states[NUM_DIO_INTERRUPT] = {0};
@@ -131,15 +131,15 @@ static void hal_isrPin1() {
131131
}
132132
}
133133
static void hal_isrPin2() {
134-
if (interupt_time[2] == 0) {
134+
if (interrupt_time[2] == 0) {
135135
ostime_t now = os_getTime();
136136
interrupt_time[2] = now ? now : 1;
137137
}
138138
}
139139

140140
typedef void (*isr_t)();
141141
static const isr_t interrupt_fns[NUM_DIO_INTERRUPT] = {hal_isrPin0, hal_isrPin1, hal_isrPin2};
142-
static_assert(NUM_DIO_INTERRUPT == 3);
142+
static_assert(NUM_DIO_INTERRUPT == 3, "number of interrupts must be 3 for initializing interrupt_fns[]");
143143

144144
static void hal_interrupt_init() {
145145
for (uint8_t i = 0; i < NUM_DIO_INTERRUPT; ++i) {

src/lmic/lmic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,8 @@ static bit_t buildDataFrame (void) {
18611861
// highest importance are the ones in the pendMac buffer.
18621862
int end = OFF_DAT_OPTS;
18631863

1864-
if (LMIC.pendTxPort != 0 && LMIC.pendMacPiggyback && LMIC.pendMacLen != 0) {
1864+
// Send piggyback data if: !txdata or txport != 0
1865+
if ((! txdata || LMIC.pendTxPort != 0) && LMIC.pendMacPiggyback && LMIC.pendMacLen != 0) {
18651866
os_copyMem(LMIC.frame + end, LMIC.pendMacData, LMIC.pendMacLen);
18661867
end += LMIC.pendMacLen;
18671868
}

0 commit comments

Comments
 (0)