mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Initial commit
This commit is contained in:
commit
6c7efdd0f6
59 changed files with 8604 additions and 0 deletions
42
src/helpers/RadioLibWrappers.h
Normal file
42
src/helpers/RadioLibWrappers.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include <Mesh.h>
|
||||
#include <RadioLib.h>
|
||||
|
||||
class RadioLibWrapper : public mesh::Radio {
|
||||
protected:
|
||||
PhysicalLayer* _radio;
|
||||
mesh::MainBoard* _board;
|
||||
uint32_t n_recv, n_sent;
|
||||
|
||||
public:
|
||||
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board) { n_recv = n_sent = 0; }
|
||||
|
||||
void begin() override;
|
||||
int recvRaw(uint8_t* bytes, int sz) override;
|
||||
uint32_t getEstAirtimeFor(int len_bytes) override;
|
||||
void startSendRaw(const uint8_t* bytes, int len) override;
|
||||
bool isSendComplete() override;
|
||||
void onSendFinished() override;
|
||||
|
||||
uint32_t getPacketsRecv() const { return n_recv; }
|
||||
uint32_t getPacketsSent() const { return n_sent; }
|
||||
virtual float getLastRSSI() const;
|
||||
virtual float getLastSNR() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief an RNG impl using the noise from the LoRa radio as entropy.
|
||||
* NOTE: this is VERY SLOW! Use only for things like creating new LocalIdentity
|
||||
*/
|
||||
class RadioNoiseListener : public mesh::RNG {
|
||||
PhysicalLayer* _radio;
|
||||
public:
|
||||
RadioNoiseListener(PhysicalLayer& radio): _radio(&radio) { }
|
||||
|
||||
void random(uint8_t* dest, size_t sz) override {
|
||||
for (int i = 0; i < sz; i++) {
|
||||
dest[i] = _radio->randomByte() ^ (::random(0, 256) & 0xFF);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue