Skip to content

Commit a7c2e13

Browse files
committed
LoRa non-blocking endPacket from sandeepmistry/arduino-LoRa#62
1 parent 7e9f0fd commit a7c2e13

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

crossbow.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// #define DEVICE_MODE_TX
2-
#define DEVICE_MODE_RX
1+
#define DEVICE_MODE_TX
2+
// #define DEVICE_MODE_RX
33

4-
// #define FEATURE_TX_OLED
4+
#define FEATURE_TX_OLED
55
// #define FORCE_TX_WITHOUT_INPUT
66

77
// #define DEBUG_SERIAL

lora.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,29 @@ int LoRaClass::endPacket()
153153
return 1;
154154
}
155155

156+
//https://github.com/sandeepmistry/arduino-LoRa/pull/62/files
157+
void LoRaClass::endPacketAsync()
158+
{
159+
// put in TX mode
160+
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
161+
162+
// apparently this grace time is required for the radio
163+
delayMicroseconds(150);
164+
}
165+
166+
//https://github.com/sandeepmistry/arduino-LoRa/pull/62/files
167+
bool LoRaClass::isTransmitting()
168+
{
169+
if ((readRegister(REG_OP_MODE) & MODE_TX) == MODE_TX)
170+
return true;
171+
172+
if (!(readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0)
173+
// clear IRQ's
174+
writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);
175+
176+
return false;
177+
}
178+
156179
int LoRaClass::parsePacket(int size)
157180
{
158181
int packetLength = 0;

lora.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class LoRaClass {
2626
int beginPacket(int implicitHeader = false);
2727
int endPacket();
2828

29+
void endPacketAsync();
30+
bool isTransmitting()
31+
2932
int parsePacket(int size = 0);
3033
int packetRssi();
3134
float packetSnr();

0 commit comments

Comments
 (0)