mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* new target: RAK_4631_Repeater
This commit is contained in:
parent
eb685db693
commit
515285e3c9
5 changed files with 143 additions and 9 deletions
|
|
@ -17,7 +17,13 @@ bool IdentityStore::load(const char *name, mesh::LocalIdentity& id) {
|
|||
bool IdentityStore::save(const char *name, const mesh::LocalIdentity& id) {
|
||||
char filename[40];
|
||||
sprintf(filename, "%s/%s.id", _dir, name);
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
File file = _fs->open(filename, FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#else
|
||||
File file = _fs->open(filename, "w", true);
|
||||
#endif
|
||||
if (file) {
|
||||
id.writeTo(file);
|
||||
file.close();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <FS.h>
|
||||
#if defined(ESP32)
|
||||
#include <FS.h>
|
||||
#define FILESYSTEM fs::FS
|
||||
#elif defined(NRF52_PLATFORM)
|
||||
#include <Adafruit_LittleFS.h>
|
||||
#define FILESYSTEM Adafruit_LittleFS
|
||||
|
||||
using namespace Adafruit_LittleFS_Namespace;
|
||||
#endif
|
||||
|
||||
#include <Identity.h>
|
||||
|
||||
class IdentityStore {
|
||||
fs::FS* _fs;
|
||||
FILESYSTEM* _fs;
|
||||
const char* _dir;
|
||||
public:
|
||||
IdentityStore(fs::FS& fs, const char* dir): _fs(&fs), _dir(dir) { }
|
||||
IdentityStore(FILESYSTEM& fs, const char* dir): _fs(&fs), _dir(dir) { }
|
||||
|
||||
void begin() { _fs->mkdir(_dir); }
|
||||
bool load(const char *name, mesh::LocalIdentity& id);
|
||||
|
|
|
|||
63
src/helpers/RAK4631Board.h
Normal file
63
src/helpers/RAK4631Board.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
|
||||
// LoRa radio module pins for RAK4631
|
||||
#define P_LORA_DIO_1 47
|
||||
#define P_LORA_NSS 42
|
||||
#define P_LORA_RESET RADIOLIB_NC // 38
|
||||
#define P_LORA_BUSY 46
|
||||
#define P_LORA_SCLK 43
|
||||
#define P_LORA_MISO 45
|
||||
#define P_LORA_MOSI 44
|
||||
#define SX126X_POWER_EN 37
|
||||
|
||||
#define SX126X_DIO2_AS_RF_SWITCH true
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
|
||||
// built-ins
|
||||
#define PIN_VBAT_READ 1
|
||||
#define ADC_MULTIPLIER 6.17
|
||||
|
||||
class RAK4631Board : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
|
||||
public:
|
||||
void begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
|
||||
pinMode(SX126X_POWER_EN, OUTPUT);
|
||||
digitalWrite(SX126X_POWER_EN, HIGH);
|
||||
}
|
||||
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
#define BATTERY_SAMPLES 10
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
analogReadResolution(12);
|
||||
|
||||
uint32_t raw = 0;
|
||||
for (int i = 0; i < BATTERY_SAMPLES; i++) {
|
||||
raw += analogRead(PIN_VBAT_READ);
|
||||
}
|
||||
raw = raw / BATTERY_SAMPLES;
|
||||
|
||||
return (ADC_MULTIPLIER * raw) / 4096;
|
||||
}
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "RAK 4631";
|
||||
}
|
||||
|
||||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue