Skip to content

Commit 585d9d3

Browse files
authored
Merge pull request #8432 from korbinianbauer/develop
Don't use unsigned integer type for negative SNR value
2 parents b682ab3 + 49b9d51 commit 585d9d3

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/mesh/RadioInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ uint32_t RadioInterface::getTxDelayMsec()
272272
uint8_t RadioInterface::getCWsize(float snr)
273273
{
274274
// The minimum value for a LoRa SNR
275-
const uint32_t SNR_MIN = -20;
275+
const int32_t SNR_MIN = -20;
276276

277277
// The maximum value for a LoRa SNR
278-
const uint32_t SNR_MAX = 10;
278+
const int32_t SNR_MAX = 10;
279279

280280
return map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
281281
}

src/mesh/RadioLibInterface.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,7 @@ void RadioLibInterface::onNotify(uint32_t notification)
289289
// actual transmission as short as possible
290290
txp = txQueue.dequeue();
291291
assert(txp);
292-
bool sent = startSend(txp);
293-
if (sent) {
294-
// Packet has been sent, count it toward our TX airtime utilization.
295-
uint32_t xmitMsec = getPacketTime(txp);
296-
airTime->logAirtime(TX_LOG, xmitMsec);
297-
}
292+
startSend(txp);
298293
LOG_DEBUG("%d packets remain in the TX queue", txQueue.getMaxLen() - txQueue.getFree());
299294
}
300295
}
@@ -413,6 +408,10 @@ void RadioLibInterface::completeSending()
413408
sendingPacket = NULL;
414409

415410
if (p) {
411+
// Packet has been sent, count it toward our TX airtime utilization.
412+
uint32_t xmitMsec = getPacketTime(p);
413+
airTime->logAirtime(TX_LOG, xmitMsec);
414+
416415
txGood++;
417416
if (!isFromUs(p))
418417
txRelay++;

src/modules/RangeTestModule.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ ProcessMessage RangeTestModuleRadio::handleReceived(const meshtastic_MeshPacket
159159
LOG_DEBUG("---- Received Packet:");
160160
LOG_DEBUG("mp.from %d", mp.from);
161161
LOG_DEBUG("mp.rx_snr %f", mp.rx_snr);
162+
LOG_DEBUG("mp.rx_rssi %f", mp.rx_rssi);
162163
LOG_DEBUG("mp.hop_limit %d", mp.hop_limit);
163164
LOG_DEBUG("---- Node Information of Received Packet (mp.from):");
164165
LOG_DEBUG("n->user.long_name %s", n->user.long_name);
@@ -234,8 +235,8 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
234235
}
235236

236237
// Print the CSV header
237-
if (fileToWrite.println(
238-
"time,from,sender name,sender lat,sender long,rx lat,rx long,rx elevation,rx snr,distance,hop limit,payload")) {
238+
if (fileToWrite.println("time,from,sender name,sender lat,sender long,rx lat,rx long,rx elevation,rx "
239+
"snr,distance,hop limit,payload,rx rssi")) {
239240
LOG_INFO("File was written");
240241
} else {
241242
LOG_ERROR("File write failed");
@@ -297,6 +298,8 @@ bool RangeTestModuleRadio::appendFile(const meshtastic_MeshPacket &mp)
297298

298299
// TODO: If quotes are found in the payload, it has to be escaped.
299300
fileToAppend.printf("\"%s\"\n", p.payload.bytes);
301+
fileToAppend.printf("%i,", mp.rx_rssi); // RX RSSI
302+
300303
fileToAppend.flush();
301304
fileToAppend.close();
302305

0 commit comments

Comments
 (0)