mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Added Pi PIcoW support in the following modes:
- Companion Radio over USB Serial - Repeater - Room Server - Terminal Chat
This commit is contained in:
parent
a5f210779f
commit
99246e6b6f
13 changed files with 442 additions and 2 deletions
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#include <InternalFileSystem.h>
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
|
@ -242,7 +244,11 @@ class MyMesh : public BaseChatMesh {
|
|||
|
||||
void loadContacts() {
|
||||
if (_fs->exists("/contacts3")) {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/contacts3", "r");
|
||||
#else
|
||||
File file = _fs->open("/contacts3");
|
||||
#endif
|
||||
if (file) {
|
||||
bool full = false;
|
||||
while (!full) {
|
||||
|
|
@ -277,6 +283,8 @@ class MyMesh : public BaseChatMesh {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
File file = _fs->open("/contacts3", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/contacts3", "w+");
|
||||
#else
|
||||
File file = _fs->open("/contacts3", "w", true);
|
||||
#endif
|
||||
|
|
@ -307,7 +315,11 @@ class MyMesh : public BaseChatMesh {
|
|||
|
||||
void loadChannels() {
|
||||
if (_fs->exists("/channels2")) {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/channels2", "r");
|
||||
#else
|
||||
File file = _fs->open("/channels2");
|
||||
#endif
|
||||
if (file) {
|
||||
bool full = false;
|
||||
uint8_t channel_idx = 0;
|
||||
|
|
@ -336,6 +348,8 @@ class MyMesh : public BaseChatMesh {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
File file = _fs->open("/channels2", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/channels2", "w+");
|
||||
#else
|
||||
File file = _fs->open("/channels2", "w", true);
|
||||
#endif
|
||||
|
|
@ -366,7 +380,11 @@ class MyMesh : public BaseChatMesh {
|
|||
sprintf(path, "/bl/%s", fname);
|
||||
|
||||
if (_fs->exists(path)) {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File f = _fs->open(path, "r");
|
||||
#else
|
||||
File f = _fs->open(path);
|
||||
#endif
|
||||
if (f) {
|
||||
int len = f.read(dest_buf, 255); // currently MAX 255 byte blob len supported!!
|
||||
f.close();
|
||||
|
|
@ -387,6 +405,8 @@ class MyMesh : public BaseChatMesh {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
File f = _fs->open(path, FILE_O_WRITE);
|
||||
if (f) { f.seek(0); f.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File f = _fs->open(path, "w+");
|
||||
#else
|
||||
File f = _fs->open(path, "w", true);
|
||||
#endif
|
||||
|
|
@ -733,7 +753,11 @@ public:
|
|||
}
|
||||
|
||||
void loadPrefsInt(const char* filename) {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File file = _fs->open(filename, "r");
|
||||
#else
|
||||
File file = _fs->open(filename);
|
||||
#endif
|
||||
if (file) {
|
||||
uint8_t pad[8];
|
||||
|
||||
|
|
@ -831,6 +855,8 @@ public:
|
|||
#if defined(NRF52_PLATFORM)
|
||||
File file = _fs->open("/new_prefs", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/new_prefs", "w+");
|
||||
#else
|
||||
File file = _fs->open("/new_prefs", "w", true);
|
||||
#endif
|
||||
|
|
@ -1416,6 +1442,24 @@ public:
|
|||
#include <helpers/ArduinoSerialInterface.h>
|
||||
ArduinoSerialInterface serial_interface;
|
||||
#endif
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
//#ifdef WIFI_SSID
|
||||
// #include <helpers/rp2040/SerialWifiInterface.h>
|
||||
// SerialWifiInterface serial_interface;
|
||||
// #ifndef TCP_PORT
|
||||
// #define TCP_PORT 5000
|
||||
// #endif
|
||||
// #elif defined(BLE_PIN_CODE)
|
||||
// #include <helpers/rp2040/SerialBLEInterface.h>
|
||||
// SerialBLEInterface serial_interface;
|
||||
#if defined(SERIAL_RX)
|
||||
#include <helpers/ArduinoSerialInterface.h>
|
||||
ArduinoSerialInterface serial_interface;
|
||||
HardwareSerial companion_serial(1);
|
||||
#else
|
||||
#include <helpers/ArduinoSerialInterface.h>
|
||||
ArduinoSerialInterface serial_interface;
|
||||
#endif
|
||||
#elif defined(NRF52_PLATFORM)
|
||||
#ifdef BLE_PIN_CODE
|
||||
#include <helpers/nrf52/SerialBLEInterface.h>
|
||||
|
|
@ -1475,6 +1519,31 @@ void setup() {
|
|||
serial_interface.begin(Serial);
|
||||
#endif
|
||||
the_mesh.startInterface(serial_interface);
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
LittleFS.begin();
|
||||
the_mesh.begin(LittleFS,
|
||||
#ifdef HAS_UI
|
||||
disp != NULL
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
);
|
||||
|
||||
//#ifdef WIFI_SSID
|
||||
// WiFi.begin(WIFI_SSID, WIFI_PWD);
|
||||
// serial_interface.begin(TCP_PORT);
|
||||
// #elif defined(BLE_PIN_CODE)
|
||||
// char dev_name[32+16];
|
||||
// sprintf(dev_name, "%s%s", BLE_NAME_PREFIX, the_mesh.getNodeName());
|
||||
// serial_interface.begin(dev_name, the_mesh.getBLEPin());
|
||||
#if defined(SERIAL_RX)
|
||||
companion_serial.setPins(SERIAL_RX, SERIAL_TX);
|
||||
companion_serial.begin(115200);
|
||||
serial_interface.begin(companion_serial);
|
||||
#else
|
||||
serial_interface.begin(Serial);
|
||||
#endif
|
||||
the_mesh.startInterface(serial_interface);
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
the_mesh.begin(SPIFFS,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#include <InternalFileSystem.h>
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
|
@ -180,6 +182,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
|||
File openAppend(const char* fname) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
return _fs->open(fname, FILE_O_WRITE);
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return _fs->open(fname, "a");
|
||||
#else
|
||||
return _fs->open(fname, "a", true);
|
||||
#endif
|
||||
|
|
@ -524,10 +528,12 @@ public:
|
|||
bool formatFileSystem() override {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
return InternalFS.format();
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return LittleFS.format();
|
||||
#elif defined(ESP32)
|
||||
return SPIFFS.format();
|
||||
#else
|
||||
#error "need to implement file system erase"
|
||||
#error "need to implement file system erase"
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -563,7 +569,11 @@ public:
|
|||
}
|
||||
|
||||
void dumpLogFile() override {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File f = _fs->open(PACKET_LOG_FILE, "r");
|
||||
#else
|
||||
File f = _fs->open(PACKET_LOG_FILE);
|
||||
#endif
|
||||
if (f) {
|
||||
while (f.available()) {
|
||||
int c = f.read();
|
||||
|
|
@ -637,6 +647,10 @@ void setup() {
|
|||
SPIFFS.begin(true);
|
||||
fs = &SPIFFS;
|
||||
IdentityStore store(SPIFFS, "/identity");
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
LittleFS.begin();
|
||||
fs = &LittleFS;
|
||||
IdentityStore store(LittleFS, "/identity");
|
||||
#else
|
||||
#error "need to define filesystem"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#include <InternalFileSystem.h>
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
|
@ -259,6 +261,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
|||
File openAppend(const char* fname) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
return _fs->open(fname, FILE_O_WRITE);
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return _fs->open(fname, "a");
|
||||
#else
|
||||
return _fs->open(fname, "a", true);
|
||||
#endif
|
||||
|
|
@ -713,6 +717,8 @@ public:
|
|||
bool formatFileSystem() override {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
return InternalFS.format();
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
return LittleFS.format();
|
||||
#elif defined(ESP32)
|
||||
return SPIFFS.format();
|
||||
#else
|
||||
|
|
@ -752,7 +758,11 @@ public:
|
|||
}
|
||||
|
||||
void dumpLogFile() override {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File f = _fs->open(PACKET_LOG_FILE, "r");
|
||||
#else
|
||||
File f = _fs->open(PACKET_LOG_FILE);
|
||||
#endif
|
||||
if (f) {
|
||||
while (f.available()) {
|
||||
int c = f.read();
|
||||
|
|
@ -863,6 +873,10 @@ void setup() {
|
|||
InternalFS.begin();
|
||||
fs = &InternalFS;
|
||||
IdentityStore store(InternalFS, "");
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
LittleFS.begin();
|
||||
fs = &LittleFS;
|
||||
IdentityStore store(LittleFS, "/identity");
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
fs = &SPIFFS;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#include <InternalFileSystem.h>
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
#include <LittleFS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
|
@ -88,7 +90,11 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
|
|||
|
||||
void loadContacts() {
|
||||
if (_fs->exists("/contacts")) {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/contacts", "r");
|
||||
#else
|
||||
File file = _fs->open("/contacts");
|
||||
#endif
|
||||
if (file) {
|
||||
bool full = false;
|
||||
while (!full) {
|
||||
|
|
@ -123,6 +129,8 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
File file = _fs->open("/contacts", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/contacts", "w+");
|
||||
#else
|
||||
File file = _fs->open("/contacts", "w", true);
|
||||
#endif
|
||||
|
|
@ -309,7 +317,11 @@ public:
|
|||
|
||||
// load persisted prefs
|
||||
if (_fs->exists("/node_prefs")) {
|
||||
#if defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/node_prefs", "r");
|
||||
#else
|
||||
File file = _fs->open("/node_prefs");
|
||||
#endif
|
||||
if (file) {
|
||||
file.read((uint8_t *) &_prefs, sizeof(_prefs));
|
||||
file.close();
|
||||
|
|
@ -324,6 +336,8 @@ public:
|
|||
#if defined(NRF52_PLATFORM)
|
||||
File file = _fs->open("/node_prefs", FILE_O_WRITE);
|
||||
if (file) { file.seek(0); file.truncate(); }
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
File file = _fs->open("/node_prefs", "w+");
|
||||
#else
|
||||
File file = _fs->open("/node_prefs", "w", true);
|
||||
#endif
|
||||
|
|
@ -545,6 +559,9 @@ void setup() {
|
|||
#if defined(NRF52_PLATFORM)
|
||||
InternalFS.begin();
|
||||
the_mesh.begin(InternalFS);
|
||||
#elif defined(RP2040_PLATFORM)
|
||||
LittleFS.begin();
|
||||
the_mesh.begin(LittleFS);
|
||||
#elif defined(ESP32)
|
||||
SPIFFS.begin(true);
|
||||
the_mesh.begin(SPIFFS);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue