Fixed RSSI indication
This commit is contained in:
parent
03e655b3ff
commit
beb17d0922
7
Config.h
7
Config.h
|
@ -4,7 +4,7 @@
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define MAJ_VERS 0x01
|
#define MAJ_VERS 0x01
|
||||||
#define MIN_VERS 0x05
|
#define MIN_VERS 0x06
|
||||||
|
|
||||||
#define MCU_328P 0x90
|
#define MCU_328P 0x90
|
||||||
#define MCU_1284P 0x91
|
#define MCU_1284P 0x91
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
// MCU independent configuration parameters
|
// MCU independent configuration parameters
|
||||||
const long serial_baudrate = 115200;
|
const long serial_baudrate = 115200;
|
||||||
const int rssi_offset = 164;
|
const int rssi_offset = 292;
|
||||||
|
|
||||||
const int lora_rx_turnaround_ms = 50;
|
const int lora_rx_turnaround_ms = 50;
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@
|
||||||
uint8_t model = 0x00;
|
uint8_t model = 0x00;
|
||||||
uint8_t hwrev = 0x00;
|
uint8_t hwrev = 0x00;
|
||||||
|
|
||||||
int last_rssi = -164;
|
int last_rssi = -292;
|
||||||
|
uint8_t last_rssi_raw = 0x00;
|
||||||
size_t read_len = 0;
|
size_t read_len = 0;
|
||||||
uint8_t seq = 0xFF;
|
uint8_t seq = 0xFF;
|
||||||
uint8_t pbuf[MTU];
|
uint8_t pbuf[MTU];
|
||||||
|
|
|
@ -66,6 +66,8 @@ class RNodeInterface():
|
||||||
LOG_DEBUG = 6
|
LOG_DEBUG = 6
|
||||||
LOG_EXTREME = 7
|
LOG_EXTREME = 7
|
||||||
|
|
||||||
|
RSSI_OFFSET = 292
|
||||||
|
|
||||||
def __init__(self, callback, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, loglevel = -1, flow_control = True):
|
def __init__(self, callback, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, loglevel = -1, flow_control = True):
|
||||||
self.serial = None
|
self.serial = None
|
||||||
self.loglevel = loglevel
|
self.loglevel = loglevel
|
||||||
|
@ -410,7 +412,7 @@ class RNodeInterface():
|
||||||
self.r_stat_tx = ord(command_buffer[0]) << 24 | ord(command_buffer[1]) << 16 | ord(command_buffer[2]) << 8 | ord(command_buffer[3])
|
self.r_stat_tx = ord(command_buffer[0]) << 24 | ord(command_buffer[1]) << 16 | ord(command_buffer[2]) << 8 | ord(command_buffer[3])
|
||||||
|
|
||||||
elif (command == KISS.CMD_STAT_RSSI):
|
elif (command == KISS.CMD_STAT_RSSI):
|
||||||
self.r_stat_rssi = ord(byte)
|
self.r_stat_rssi = ord(byte)-RSSI_OFFSET
|
||||||
elif (command == KISS.CMD_RANDOM):
|
elif (command == KISS.CMD_RANDOM):
|
||||||
self.r_random = ord(byte)
|
self.r_random = ord(byte)
|
||||||
elif (command == KISS.CMD_ERROR):
|
elif (command == KISS.CMD_ERROR):
|
||||||
|
|
15
LoRa.cpp
15
LoRa.cpp
|
@ -212,9 +212,18 @@ uint8_t LoRaClass::modemStatus() {
|
||||||
return readRegister(REG_MODEM_STAT);
|
return readRegister(REG_MODEM_STAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoRaClass::packetRssi()
|
uint8_t LoRaClass::packetRssiRaw() {
|
||||||
{
|
uint8_t pkt_rssi_value = readRegister(REG_PKT_RSSI_VALUE);
|
||||||
return (readRegister(REG_PKT_RSSI_VALUE) - (_frequency < 868E6 ? 164 : 157));
|
return pkt_rssi_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LoRaClass::packetRssi() {
|
||||||
|
int pkt_rssi = (int)readRegister(REG_PKT_RSSI_VALUE);
|
||||||
|
// TODO: change this to look at the actual model code
|
||||||
|
if (_frequency < 820E6) pkt_rssi -= 7;
|
||||||
|
pkt_rssi -= 157;
|
||||||
|
|
||||||
|
return pkt_rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
float LoRaClass::packetSnr()
|
float LoRaClass::packetSnr()
|
||||||
|
|
1
LoRa.h
1
LoRa.h
|
@ -26,6 +26,7 @@ public:
|
||||||
|
|
||||||
int parsePacket(int size = 0);
|
int parsePacket(int size = 0);
|
||||||
int packetRssi();
|
int packetRssi();
|
||||||
|
uint8_t packetRssiRaw();
|
||||||
float packetSnr();
|
float packetSnr();
|
||||||
long packetFrequencyError();
|
long packetFrequencyError();
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,10 @@ void kiss_indicate_stat_tx() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void kiss_indicate_stat_rssi() {
|
void kiss_indicate_stat_rssi() {
|
||||||
|
uint8_t packet_rssi_val = (uint8_t)(last_rssi+rssi_offset);
|
||||||
Serial.write(FEND);
|
Serial.write(FEND);
|
||||||
Serial.write(CMD_STAT_RSSI);
|
Serial.write(CMD_STAT_RSSI);
|
||||||
Serial.write((uint8_t)last_rssi+rssi_offset);
|
Serial.write(packet_rssi_val);
|
||||||
Serial.write(FEND);
|
Serial.write(FEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue