Fixed RSSI indication

This commit is contained in:
Mark Qvist 2018-06-27 14:08:16 +02:00
parent 03e655b3ff
commit beb17d0922
5 changed files with 22 additions and 8 deletions

View File

@ -4,7 +4,7 @@
#define CONFIG_H
#define MAJ_VERS 0x01
#define MIN_VERS 0x05
#define MIN_VERS 0x06
#define MCU_328P 0x90
#define MCU_1284P 0x91
@ -62,7 +62,7 @@
// MCU independent configuration parameters
const long serial_baudrate = 115200;
const int rssi_offset = 164;
const int rssi_offset = 292;
const int lora_rx_turnaround_ms = 50;
@ -83,7 +83,8 @@
uint8_t model = 0x00;
uint8_t hwrev = 0x00;
int last_rssi = -164;
int last_rssi = -292;
uint8_t last_rssi_raw = 0x00;
size_t read_len = 0;
uint8_t seq = 0xFF;
uint8_t pbuf[MTU];

View File

@ -66,6 +66,8 @@ class RNodeInterface():
LOG_DEBUG = 6
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):
self.serial = None
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])
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):
self.r_random = ord(byte)
elif (command == KISS.CMD_ERROR):

View File

@ -212,9 +212,18 @@ uint8_t LoRaClass::modemStatus() {
return readRegister(REG_MODEM_STAT);
}
int LoRaClass::packetRssi()
{
return (readRegister(REG_PKT_RSSI_VALUE) - (_frequency < 868E6 ? 164 : 157));
uint8_t LoRaClass::packetRssiRaw() {
uint8_t pkt_rssi_value = readRegister(REG_PKT_RSSI_VALUE);
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()

1
LoRa.h
View File

@ -26,6 +26,7 @@ public:
int parsePacket(int size = 0);
int packetRssi();
uint8_t packetRssiRaw();
float packetSnr();
long packetFrequencyError();

View File

@ -131,9 +131,10 @@ void kiss_indicate_stat_tx() {
}
void kiss_indicate_stat_rssi() {
uint8_t packet_rssi_val = (uint8_t)(last_rssi+rssi_offset);
Serial.write(FEND);
Serial.write(CMD_STAT_RSSI);
Serial.write((uint8_t)last_rssi+rssi_offset);
Serial.write(packet_rssi_val);
Serial.write(FEND);
}