mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 10:12:50 +00:00
trunk roundhouse kick
This commit is contained in:
@@ -35,9 +35,9 @@ void SimRadio::setTransmitDelay()
|
||||
// So we want to make sure the other side has had a chance to reconfigure its radio.
|
||||
|
||||
/* We assume if rx_snr = 0 and rx_rssi = 0, the packet was generated locally.
|
||||
* This assumption is valid because of the offset generated by the radio to account for the noise
|
||||
* floor.
|
||||
*/
|
||||
* This assumption is valid because of the offset generated by the radio to account for the noise
|
||||
* floor.
|
||||
*/
|
||||
if (p->rx_snr == 0 && p->rx_rssi == 0) {
|
||||
startTransmitTimer(true);
|
||||
} else {
|
||||
@@ -96,7 +96,6 @@ void SimRadio::completeSending()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Could we send right now (i.e. either not actively receving or transmitting)? */
|
||||
bool SimRadio::canSendImmediately()
|
||||
{
|
||||
@@ -116,14 +115,14 @@ bool SimRadio::canSendImmediately()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimRadio::isActivelyReceiving()
|
||||
bool SimRadio::isActivelyReceiving()
|
||||
{
|
||||
return false; // TODO check how this should be simulated
|
||||
return false; // TODO check how this should be simulated
|
||||
}
|
||||
|
||||
bool SimRadio::isChannelActive()
|
||||
{
|
||||
return false; // TODO ask simulator
|
||||
return false; // TODO ask simulator
|
||||
}
|
||||
|
||||
/** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */
|
||||
@@ -138,14 +137,13 @@ bool SimRadio::cancelSending(NodeNum from, PacketId id)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void SimRadio::onNotify(uint32_t notification)
|
||||
{
|
||||
switch (notification) {
|
||||
case ISR_TX:
|
||||
handleTransmitInterrupt();
|
||||
LOG_DEBUG("tx complete - starting timer\n");
|
||||
startTransmitTimer();
|
||||
startTransmitTimer();
|
||||
break;
|
||||
case ISR_RX:
|
||||
LOG_DEBUG("rx complete - starting timer\n");
|
||||
@@ -179,25 +177,25 @@ void SimRadio::onNotify(uint32_t notification)
|
||||
} else {
|
||||
// LOG_DEBUG("done with txqueue\n");
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
assert(0); // We expected to receive a valid notification from the ISR
|
||||
}
|
||||
}
|
||||
|
||||
/** start an immediate transmit */
|
||||
void SimRadio::startSend(MeshPacket * txp)
|
||||
void SimRadio::startSend(MeshPacket *txp)
|
||||
{
|
||||
printPacket("Starting low level send", txp);
|
||||
size_t numbytes = beginSending(txp);
|
||||
MeshPacket* p = packetPool.allocCopy(*txp);
|
||||
MeshPacket *p = packetPool.allocCopy(*txp);
|
||||
perhapsDecode(p);
|
||||
Compressed c = Compressed_init_default;
|
||||
c.portnum = p->decoded.portnum;
|
||||
// LOG_DEBUG("Sending back to simulator with portNum %d\n", p->decoded.portnum);
|
||||
c.portnum = p->decoded.portnum;
|
||||
// LOG_DEBUG("Sending back to simulator with portNum %d\n", p->decoded.portnum);
|
||||
if (p->decoded.payload.size <= sizeof(c.data.bytes)) {
|
||||
memcpy(&c.data.bytes, p->decoded.payload.bytes, p->decoded.payload.size);
|
||||
c.data.size = p->decoded.payload.size;
|
||||
c.data.size = p->decoded.payload.size;
|
||||
} else {
|
||||
LOG_WARN("Payload size is larger than compressed message allows! Sending empty payload.\n");
|
||||
}
|
||||
@@ -206,8 +204,8 @@ void SimRadio::startSend(MeshPacket * txp)
|
||||
service.sendToPhone(p); // Sending back to simulator
|
||||
}
|
||||
|
||||
|
||||
void SimRadio::startReceive(MeshPacket *p) {
|
||||
void SimRadio::startReceive(MeshPacket *p)
|
||||
{
|
||||
isReceiving = true;
|
||||
size_t length = getPacketLength(p);
|
||||
uint32_t xmitMsec = getPacketTime(length);
|
||||
@@ -243,8 +241,8 @@ void SimRadio::handleReceiveInterrupt(MeshPacket *p)
|
||||
xmitMsec = getPacketTime(length);
|
||||
// LOG_DEBUG("Payload size %d vs length (includes header) %d\n", p->decoded.payload.size, length);
|
||||
|
||||
MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packtPool
|
||||
mp->which_payload_variant = MeshPacket_decoded_tag; // Mark that the payload is already decoded
|
||||
MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packtPool
|
||||
mp->which_payload_variant = MeshPacket_decoded_tag; // Mark that the payload is already decoded
|
||||
|
||||
printPacket("Lora RX", mp);
|
||||
|
||||
@@ -253,15 +251,17 @@ void SimRadio::handleReceiveInterrupt(MeshPacket *p)
|
||||
deliverToReceiver(mp);
|
||||
}
|
||||
|
||||
size_t SimRadio::getPacketLength(MeshPacket *mp) {
|
||||
size_t SimRadio::getPacketLength(MeshPacket *mp)
|
||||
{
|
||||
auto &p = mp->decoded;
|
||||
return (size_t)p.payload.size+sizeof(PacketHeader);
|
||||
return (size_t)p.payload.size + sizeof(PacketHeader);
|
||||
}
|
||||
|
||||
int16_t SimRadio::readData(uint8_t* data, size_t len) {
|
||||
int16_t SimRadio::readData(uint8_t *data, size_t len)
|
||||
{
|
||||
int16_t state = RADIOLIB_ERR_NONE;
|
||||
|
||||
if(state == RADIOLIB_ERR_NONE) {
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
// add null terminator
|
||||
data[len] = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user