refacto: change lora to class with ITransmitter interface
This commit is contained in:
parent
2d87381903
commit
244d1eea21
7 changed files with 225 additions and 179 deletions
47
lib/Transmitter/LoRaTransmitter.h
Normal file
47
lib/Transmitter/LoRaTransmitter.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
#include <ITransmitter.h>
|
||||
#include <SPI.h>
|
||||
#include <RadioLib.h>
|
||||
#include <Preferences.h>
|
||||
#include <config.h>
|
||||
|
||||
#define LORA_SCK 5
|
||||
#define LORA_MISO 19
|
||||
#define LORA_MOSI 27
|
||||
#define LORA_NSS 18
|
||||
#define LORA_RST 23
|
||||
#define LORA_DIO0 26
|
||||
#define LORA_DIO1 33
|
||||
|
||||
class LoRaTransmitter : public ITransmitter {
|
||||
public:
|
||||
LoRaTransmitter(
|
||||
uint64_t joinEUI,
|
||||
uint64_t devEUI,
|
||||
uint8_t* nwkKey,
|
||||
uint8_t* appKey
|
||||
);
|
||||
|
||||
void init() override;
|
||||
void join() override;
|
||||
void send(uint8_t* payload, size_t size) override;
|
||||
|
||||
private:
|
||||
uint64_t _joinEUI;
|
||||
uint64_t _devEUI;
|
||||
uint8_t _nwkKey[16];
|
||||
uint8_t _appKey[16];
|
||||
|
||||
SX1276 _radio;
|
||||
LoRaWANNode _node;
|
||||
Preferences _prefs;
|
||||
|
||||
uint8_t _noncesBuffer[RADIOLIB_LORAWAN_NONCES_BUF_SIZE];
|
||||
|
||||
void _reset();
|
||||
void _restoreDevNonce();
|
||||
void _persistDevNonce();
|
||||
int16_t _restoreSession();
|
||||
void _saveSession();
|
||||
int16_t _fullJoin();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue