Added implicit header mode
This commit is contained in:
parent
ab99c2abd9
commit
3cfbb0cf58
4
Config.h
4
Config.h
@ -4,7 +4,7 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#define MAJ_VERS 0x01
|
||||
#define MIN_VERS 0x10
|
||||
#define MIN_VERS 0x11
|
||||
|
||||
#define MCU_1284P 0x91
|
||||
|
||||
@ -65,6 +65,8 @@
|
||||
bool radio_online = false;
|
||||
bool hw_ready = false;
|
||||
bool promisc = false;
|
||||
bool implicit = false;
|
||||
uint8_t implicit_l = 0;
|
||||
|
||||
uint8_t op_mode = MODE_HOST;
|
||||
uint8_t model = 0x00;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define CMD_RADIO_STATE 0x06
|
||||
#define CMD_RADIO_LOCK 0x07
|
||||
#define CMD_DETECT 0x08
|
||||
#define CMD_IMPLICIT 0x09
|
||||
#define CMD_PROMISC 0x0E
|
||||
#define CMD_READY 0x0F
|
||||
|
||||
|
@ -58,6 +58,14 @@ void setup() {
|
||||
validateStatus();
|
||||
}
|
||||
|
||||
void lora_receive() {
|
||||
if (!implicit) {
|
||||
LoRa.receive();
|
||||
} else {
|
||||
LoRa.receive(implicit_l);
|
||||
}
|
||||
}
|
||||
|
||||
bool startRadio() {
|
||||
update_radio_lock();
|
||||
if (!radio_online) {
|
||||
@ -80,7 +88,7 @@ bool startRadio() {
|
||||
LoRa.enableCrc();
|
||||
LoRa.onReceive(receiveCallback);
|
||||
|
||||
LoRa.receive();
|
||||
lora_receive();
|
||||
|
||||
// Flash an info pattern to indicate
|
||||
// that the radio is now on
|
||||
@ -275,7 +283,7 @@ void transmit(size_t size) {
|
||||
LoRa.endPacket();
|
||||
led_tx_off();
|
||||
|
||||
LoRa.receive();
|
||||
lora_receive();
|
||||
} else {
|
||||
// In promiscuous mode, we only send out
|
||||
// plain raw LoRa packets with a maximum
|
||||
@ -288,7 +296,14 @@ void transmit(size_t size) {
|
||||
size = SINGLE_MTU;
|
||||
}
|
||||
|
||||
// If implicit header mode has been set,
|
||||
// set packet length to payload data length
|
||||
if (!implicit) {
|
||||
LoRa.beginPacket();
|
||||
} else {
|
||||
LoRa.beginPacket(size);
|
||||
}
|
||||
|
||||
for (size_t i; i < size; i++) {
|
||||
LoRa.write(tbuf[i]);
|
||||
|
||||
@ -297,7 +312,7 @@ void transmit(size_t size) {
|
||||
LoRa.endPacket();
|
||||
led_tx_off();
|
||||
|
||||
LoRa.receive();
|
||||
lora_receive();
|
||||
}
|
||||
} else {
|
||||
kiss_indicate_error(ERROR_TXFAILED);
|
||||
@ -435,6 +450,9 @@ void serialCallback(uint8_t sbyte) {
|
||||
if (op_mode == MODE_HOST) setCodingRate();
|
||||
kiss_indicate_codingrate();
|
||||
}
|
||||
} else if (command == CMD_IMPLICIT) {
|
||||
set_implicit_length(sbyte);
|
||||
kiss_indicate_implicit_length();
|
||||
} else if (command == CMD_RADIO_STATE) {
|
||||
if (sbyte == 0xFF) {
|
||||
kiss_indicate_radiostate();
|
||||
|
17
Utilities.h
17
Utilities.h
@ -167,6 +167,13 @@ void kiss_indicate_codingrate() {
|
||||
Serial.write(FEND);
|
||||
}
|
||||
|
||||
void kiss_indicate_implicit_length() {
|
||||
Serial.write(FEND);
|
||||
Serial.write(CMD_IMPLICIT);
|
||||
Serial.write(implicit_l);
|
||||
Serial.write(FEND);
|
||||
}
|
||||
|
||||
void kiss_indicate_txpower() {
|
||||
Serial.write(FEND);
|
||||
Serial.write(CMD_TXPOWER);
|
||||
@ -263,6 +270,15 @@ void setCodingRate() {
|
||||
if (radio_online) LoRa.setCodingRate4(lora_cr);
|
||||
}
|
||||
|
||||
void set_implicit_length(uint8_t len) {
|
||||
implicit_l = len;
|
||||
if (implicit_l != 0) {
|
||||
implicit = true;
|
||||
} else {
|
||||
implicit = false;
|
||||
}
|
||||
}
|
||||
|
||||
void setTXPower() {
|
||||
if (radio_online) {
|
||||
if (model == MODEL_A4) LoRa.setTxPower(lora_txp, PA_OUTPUT_RFO_PIN);
|
||||
@ -626,4 +642,3 @@ inline void fifo16_init(FIFOBuffer16 *f, size_t *buffer, size_t size) {
|
||||
inline size_t fifo16_len(FIFOBuffer16 *f) {
|
||||
return (f->end - f->begin);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user