[SX126x] Moved standby call to readData
This commit is contained in:
parent
f3ba8cf86a
commit
b8128c15a6
2 changed files with 8 additions and 10 deletions
|
@ -77,6 +77,7 @@ void setup() {
|
||||||
// lora.sleep()
|
// lora.sleep()
|
||||||
// lora.transmit();
|
// lora.transmit();
|
||||||
// lora.receive();
|
// lora.receive();
|
||||||
|
// lora.readData();
|
||||||
// lora.scanChannel();
|
// lora.scanChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +111,6 @@ void loop() {
|
||||||
// reset flag
|
// reset flag
|
||||||
receivedFlag = false;
|
receivedFlag = false;
|
||||||
|
|
||||||
// put module to standby while reading data
|
|
||||||
lora.standby();
|
|
||||||
|
|
||||||
// you can read received data as an Arduino String
|
// you can read received data as an Arduino String
|
||||||
String str;
|
String str;
|
||||||
int state = lora.readData(str);
|
int state = lora.readData(str);
|
||||||
|
|
|
@ -256,12 +256,6 @@ int16_t SX126x::receive(uint8_t* data, size_t len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// put radio to standby
|
|
||||||
state = standby();
|
|
||||||
if(state != ERR_NONE) {
|
|
||||||
return(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// read the received data
|
// read the received data
|
||||||
return(readData(data, len));
|
return(readData(data, len));
|
||||||
}
|
}
|
||||||
|
@ -446,6 +440,12 @@ int16_t SX126x::startReceive(uint32_t timeout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX126x::readData(uint8_t* data, size_t len) {
|
int16_t SX126x::readData(uint8_t* data, size_t len) {
|
||||||
|
// set mode to standby
|
||||||
|
int16_t state = standby();
|
||||||
|
if(state != ERR_NONE) {
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
|
||||||
// check integrity CRC
|
// check integrity CRC
|
||||||
uint16_t irq = getIrqStatus();
|
uint16_t irq = getIrqStatus();
|
||||||
if((irq & SX126X_IRQ_CRC_ERR) || (irq & SX126X_IRQ_HEADER_ERR)) {
|
if((irq & SX126X_IRQ_CRC_ERR) || (irq & SX126X_IRQ_HEADER_ERR)) {
|
||||||
|
@ -460,7 +460,7 @@ int16_t SX126x::readData(uint8_t* data, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// read packet data
|
// read packet data
|
||||||
int16_t state = readBuffer(data, length);
|
state = readBuffer(data, length);
|
||||||
if(state != ERR_NONE) {
|
if(state != ERR_NONE) {
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue