aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/Transceiver.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-06-28 13:27:24 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-07-01 16:13:10 +0200
commit778b30a530020b84987eb283ed8db4f98f1ed839 (patch)
treea1ccd4a8f69383aa448e32eb379eb521d9548e11 /Transceiver52M/Transceiver.cpp
parente9ce77b87159397015cf368e87b8b21f3318abbc (diff)
Introduce structs to encode TRXD packets
This will ease adding new protocol versions in the future. Related: OS#4006 Change-Id: I67ffede171eddde436f9057191ed76015a8ea6eb
Diffstat (limited to 'Transceiver52M/Transceiver.cpp')
-rw-r--r--Transceiver52M/Transceiver.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 0aa4ff5..5441745 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -29,6 +29,9 @@
extern "C" {
#include "osmo_signal.h"
+#include "proto_trxd.h"
+
+#include <osmocom/core/bits.h>
}
#ifdef HAVE_CONFIG_H
@@ -950,22 +953,24 @@ void Transceiver::driveReceiveFIFO(size_t chan)
TOAint = (int) (TOA * 256.0 + 0.5); // round to closest integer
- char burstString[nbits + 10];
- burstString[0] = burstTime.TN();
- for (int i = 0; i < 4; i++)
- burstString[1+i] = (burstTime.FN() >> ((3-i)*8)) & 0x0ff;
- burstString[5] = (int)dBm;
- burstString[6] = (TOAint >> 8) & 0x0ff;
- burstString[7] = TOAint & 0x0ff;
+ char burstString[sizeof(struct trxd_hdr_v0) + nbits + 2];
+ struct trxd_hdr_v0* pkt = (struct trxd_hdr_v0*)burstString;
+ pkt->common.version = 0;
+ pkt->common.reserved = 0;
+ pkt->common.tn = burstTime.TN();
+ osmo_store32be(burstTime.FN(), &pkt->common.fn);
+ pkt->v0.rssi = dBm;
+ osmo_store16be(TOAint, &pkt->v0.toa);
SoftVector::iterator burstItr = rxBurst->begin();
for (unsigned i = 0; i < nbits; i++)
- burstString[8 + i] = (char) round((*burstItr++) * 255.0);
+ pkt->soft_bits[i] = (char) round((*burstItr++) * 255.0);
- burstString[nbits + 9] = '\0';
+ /* +1: Historical reason. There's an uninitizalied byte in there: pkt->soft_bits[bi.nbits] */
+ pkt->soft_bits[nbits + 1] = '\0';
delete rxBurst;
- mDataSockets[chan]->write(burstString, nbits + 10);
+ mDataSockets[chan]->write(burstString, sizeof(struct trxd_hdr_v0) + nbits + 2);
}
void Transceiver::driveTxFIFO()