mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2024-07-02 14:34:13 +02:00
Added KISS flow control
This commit is contained in:
parent
8a35afbebe
commit
978800aaf9
7
Config.h
7
Config.h
@ -26,6 +26,9 @@
|
||||
const int pin_dio = 2;
|
||||
const int pin_led_rx = 5;
|
||||
const int pin_led_tx = 4;
|
||||
|
||||
#define FLOW_CONTROL_ENABLED true
|
||||
#define QUEUE_SIZE 0
|
||||
#endif
|
||||
|
||||
#if MCU_VARIANT == MCU_1284P
|
||||
@ -34,6 +37,9 @@
|
||||
const int pin_dio = 2;
|
||||
const int pin_led_rx = 12;
|
||||
const int pin_led_tx = 13;
|
||||
|
||||
#define FLOW_CONTROL_ENABLED true
|
||||
#define QUEUE_SIZE 24
|
||||
#endif
|
||||
|
||||
// MCU independent configuration parameters
|
||||
@ -42,6 +48,7 @@
|
||||
|
||||
// Default LoRa settings
|
||||
int lora_sf = 0;
|
||||
int lora_cr = 5;
|
||||
int lora_txp = 0xFF;
|
||||
uint32_t lora_bw = 0;
|
||||
uint32_t lora_freq = 0;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define CMD_SF 0x04
|
||||
#define CMD_RADIO_STATE 0x05
|
||||
#define CMD_RADIO_LOCK 0x06
|
||||
#define CMD_READY 0x0F
|
||||
|
||||
#define CMD_STAT_RX 0x21
|
||||
#define CMD_STAT_TX 0x22
|
||||
|
@ -42,6 +42,7 @@ bool startRadio() {
|
||||
setTXPower();
|
||||
setBandwidth();
|
||||
setSpreadingFactor();
|
||||
setCodingRate();
|
||||
getFrequency();
|
||||
|
||||
LoRa.enableCrc();
|
||||
@ -178,6 +179,10 @@ void transmit(size_t size) {
|
||||
LoRa.endPacket();
|
||||
led_tx_off();
|
||||
LoRa.receive();
|
||||
|
||||
if (FLOW_CONTROL_ENABLED)
|
||||
kiss_indicate_ready();
|
||||
|
||||
} else {
|
||||
kiss_indicate_error(ERROR_TXFAILED);
|
||||
led_indicate_error(5);
|
||||
|
@ -146,6 +146,13 @@ void kiss_indicate_random(uint8_t byte) {
|
||||
Serial.write(FEND);
|
||||
}
|
||||
|
||||
void kiss_indicate_ready() {
|
||||
Serial.write(FEND);
|
||||
Serial.write(CMD_READY);
|
||||
Serial.write(0x01);
|
||||
Serial.write(FEND);
|
||||
}
|
||||
|
||||
bool isSplitPacket(uint8_t header) {
|
||||
return (header & FLAG_SPLIT);
|
||||
}
|
||||
@ -165,6 +172,10 @@ void setSpreadingFactor() {
|
||||
if (radio_online) LoRa.setSpreadingFactor(lora_sf);
|
||||
}
|
||||
|
||||
void setCodingRate() {
|
||||
if (radio_online) LoRa.setCodingRate4(lora_cr);
|
||||
}
|
||||
|
||||
void setTXPower() {
|
||||
if (radio_online) LoRa.setTxPower(lora_txp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user