unreliable rx works

1.2-legacy
geeksville 2020-02-06 16:07:50 -08:00
rodzic 61a88a343e
commit f2d7215fb3
3 zmienionych plików z 19 dodań i 8 usunięć

Wyświetl plik

@ -1,5 +1,8 @@
# High priority # High priority
* test raw device access without a manager in the way
* sim gps data for nodes that don't have hardware
* figure out what is busted with rx
* send our owner info at boot, reply if we see anyone send theirs * send our owner info at boot, reply if we see anyone send theirs
* implement regen owner and radio prefs * implement regen owner and radio prefs
* confirm second device receives that gps message and updates device db * confirm second device receives that gps message and updates device db

Wyświetl plik

@ -10,13 +10,13 @@
#include "NodeDB.h" #include "NodeDB.h"
// Change to 434.0 or other frequency, must match RX's freq! FIXME, choose a better default value // Change to 434.0 or other frequency, must match RX's freq! FIXME, choose a better default value
#define RF95_FREQ_US 915.0f #define RF95_FREQ_US 902.0f
RadioConfig radioConfig = RadioConfig_init_zero; RadioConfig radioConfig = RadioConfig_init_zero;
MeshRadio::MeshRadio(MemoryPool<MeshPacket> &_pool, PointerQueue<MeshPacket> &_rxDest) MeshRadio::MeshRadio(MemoryPool<MeshPacket> &_pool, PointerQueue<MeshPacket> &_rxDest)
: rf95(NSS_GPIO, DIO0_GPIO), : rf95(NSS_GPIO, DIO0_GPIO),
manager(rf95, nodeDB.getNodeNum()), manager(rf95),
pool(_pool), pool(_pool),
rxDest(_rxDest), rxDest(_rxDest),
txQueue(MAX_TX_QUEUE) txQueue(MAX_TX_QUEUE)
@ -38,6 +38,8 @@ bool MeshRadio::init()
delay(10); delay(10);
#endif #endif
manager.setThisAddress(nodeDB.getNodeNum()); // Note: we must do this here, because the nodenum isn't inited at constructor time.
if (!manager.init()) if (!manager.init())
{ {
DEBUG_MSG("LoRa radio init failed\n"); DEBUG_MSG("LoRa radio init failed\n");
@ -45,8 +47,6 @@ bool MeshRadio::init()
return false; return false;
} }
DEBUG_MSG("LoRa radio init OK!\n");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
if (!rf95.setFrequency(radioConfig.center_freq)) if (!rf95.setFrequency(radioConfig.center_freq))
{ {
@ -63,6 +63,8 @@ bool MeshRadio::init()
// FIXME - can we do this? It seems to be in the Heltec board. // FIXME - can we do this? It seems to be in the Heltec board.
rf95.setTxPower(radioConfig.tx_power, false); rf95.setTxPower(radioConfig.tx_power, false);
DEBUG_MSG("LoRa radio init OK!\n");
return true; return true;
} }
@ -113,10 +115,11 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
uint8_t srcaddr, destaddr, id, flags; uint8_t srcaddr, destaddr, id, flags;
// Poll to see if we've received a packet // Poll to see if we've received a packet
if (manager.recvfromAckTimeout(radiobuf, &rxlen, 0, &srcaddr, &destaddr, &id, &flags)) // if (manager.recvfromAckTimeout(radiobuf, &rxlen, 0, &srcaddr, &destaddr, &id, &flags))
if (manager.recvfrom(radiobuf, &rxlen, &srcaddr, &destaddr, &id, &flags))
{ {
// We received a packet // We received a packet
DEBUG_MSG("Received packet from mesh src=%d,dest=%d,id=%d,len=%d\n", srcaddr, destaddr, id, rxlen); DEBUG_MSG("Received packet from mesh src=0x%x,dest=0x%x,id=%d,len=%d rxGood=%d,rxBad=%d\n", srcaddr, destaddr, id, rxlen, rf95.rxGood(), rf95.rxBad());
MeshPacket *mp = pool.allocZeroed(); MeshPacket *mp = pool.allocZeroed();
assert(mp); // FIXME assert(mp); // FIXME
@ -141,7 +144,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
MeshPacket *txp = txQueue.dequeuePtr(0); // nowait MeshPacket *txp = txQueue.dequeuePtr(0); // nowait
if (txp) if (txp)
{ {
DEBUG_MSG("sending queued packet on mesh\n"); DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(),rf95.rxGood(), rf95.rxBad());
assert(txp->has_payload); assert(txp->has_payload);
size_t numbytes = pb_encode_to_bytes(radiobuf, sizeof(radiobuf), SubPacket_fields, &txp->payload); size_t numbytes = pb_encode_to_bytes(radiobuf, sizeof(radiobuf), SubPacket_fields, &txp->payload);
@ -154,5 +157,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
handleReceive(txp); handleReceive(txp);
else else
pool.release(txp); pool.release(txp);
DEBUG_MSG("Done with send\n");
} }
} }

Wyświetl plik

@ -42,7 +42,10 @@ public:
private: private:
RH_RF95 rf95; // the raw radio interface RH_RF95 rf95; // the raw radio interface
RHMesh manager;
RHDatagram manager;
// RHReliableDatagram manager; // don't use mesh yet
// RHMesh manager;
// MeshRXHandler rxHandler; // MeshRXHandler rxHandler;
MemoryPool<MeshPacket> &pool; MemoryPool<MeshPacket> &pool;