mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 19:02:00 +00:00
* MyMesh::begin() refactor, removing last display concepts
This commit is contained in:
@@ -911,7 +911,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyMesh::begin(bool has_display) {
|
void MyMesh::begin() {
|
||||||
BaseChatMesh::begin();
|
BaseChatMesh::begin();
|
||||||
|
|
||||||
if (!_store->loadMainIdentity(self_id)) {
|
if (!_store->loadMainIdentity(self_id)) {
|
||||||
@@ -963,24 +963,7 @@ void MyMesh::begin(bool has_display) {
|
|||||||
_prefs.gps_enabled = constrain(_prefs.gps_enabled, 0, 1); // Ensure boolean 0 or 1
|
_prefs.gps_enabled = constrain(_prefs.gps_enabled, 0, 1); // Ensure boolean 0 or 1
|
||||||
_prefs.gps_interval = constrain(_prefs.gps_interval, 0, 86400); // Max 24 hours
|
_prefs.gps_interval = constrain(_prefs.gps_interval, 0, 86400); // Max 24 hours
|
||||||
|
|
||||||
#ifdef BLE_PIN_CODE // 123456 by default
|
|
||||||
if (_prefs.ble_pin == 0) {
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
if (has_display && BLE_PIN_CODE == 123456) {
|
|
||||||
StdRNG rng;
|
|
||||||
_active_ble_pin = rng.nextInt(100000, 999999); // random pin each session
|
|
||||||
} else {
|
|
||||||
_active_ble_pin = BLE_PIN_CODE; // otherwise static pin
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
_active_ble_pin = BLE_PIN_CODE; // otherwise static pin
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
_active_ble_pin = _prefs.ble_pin;
|
_active_ble_pin = _prefs.ble_pin;
|
||||||
}
|
|
||||||
#else
|
|
||||||
_active_ble_pin = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
resetContacts();
|
resetContacts();
|
||||||
_store->loadContacts(this);
|
_store->loadContacts(this);
|
||||||
@@ -1007,6 +990,9 @@ NodePrefs *MyMesh::getNodePrefs() {
|
|||||||
uint32_t MyMesh::getBLEPin() {
|
uint32_t MyMesh::getBLEPin() {
|
||||||
return _active_ble_pin;
|
return _active_ble_pin;
|
||||||
}
|
}
|
||||||
|
void MyMesh::setBLEPin(uint32_t active_pin) {
|
||||||
|
_active_ble_pin = active_pin;
|
||||||
|
}
|
||||||
|
|
||||||
struct FreqRange {
|
struct FreqRange {
|
||||||
uint32_t lower_freq, upper_freq;
|
uint32_t lower_freq, upper_freq;
|
||||||
|
|||||||
@@ -100,13 +100,14 @@ public:
|
|||||||
|
|
||||||
MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store);
|
MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store);
|
||||||
|
|
||||||
void begin(bool has_display);
|
void begin();
|
||||||
void startInterface(BaseSerialInterface &serial);
|
void startInterface(BaseSerialInterface &serial);
|
||||||
void setListener(Listener* listener) { _listener = listener; }
|
void setListener(Listener* listener) { _listener = listener; }
|
||||||
|
|
||||||
const char *getNodeName();
|
const char *getNodeName();
|
||||||
NodePrefs *getNodePrefs();
|
NodePrefs *getNodePrefs();
|
||||||
uint32_t getBLEPin();
|
uint32_t getBLEPin();
|
||||||
|
void setBLEPin(uint32_t active_pin);
|
||||||
|
|
||||||
void loop();
|
void loop();
|
||||||
void handleCmdFrame(size_t len);
|
void handleCmdFrame(size_t len);
|
||||||
|
|||||||
@@ -172,37 +172,38 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
store.begin();
|
store.begin();
|
||||||
the_mesh.begin(
|
the_mesh.begin();
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
disp != NULL
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
#elif defined(RP2040_PLATFORM)
|
#elif defined(RP2040_PLATFORM)
|
||||||
LittleFS.begin();
|
LittleFS.begin();
|
||||||
store.begin();
|
store.begin();
|
||||||
the_mesh.begin(
|
the_mesh.begin();
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
disp != NULL
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
SPIFFS.begin(true);
|
SPIFFS.begin(true);
|
||||||
store.begin();
|
store.begin();
|
||||||
the_mesh.begin(
|
the_mesh.begin();
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
disp != NULL
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
#error "need to define filesystem"
|
#error "need to define filesystem"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BLE_PIN_CODE // 123456 by default
|
||||||
|
if (the_mesh.getNodePrefs()->ble_pin == 0) {
|
||||||
|
#ifdef DISPLAY_CLASS
|
||||||
|
if (disp != NULL && BLE_PIN_CODE == 123456) {
|
||||||
|
StdRNG rng;
|
||||||
|
the_mesh.setBLEPin(rng.nextInt(100000, 999999)); // random pin each session
|
||||||
|
} else {
|
||||||
|
the_mesh.setBLEPin(BLE_PIN_CODE); // otherwise static pin
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
the_mesh.setBLEPin(BLE_PIN_CODE); // otherwise static pin
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
the_mesh.setBLEPin(the_mesh.getNodePrefs()->ble_pin);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
the_mesh.setBLEPin(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
// add bluetooth interface
|
// add bluetooth interface
|
||||||
#if defined(BLE_PIN_CODE)
|
#if defined(BLE_PIN_CODE)
|
||||||
bluetooth_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
|
bluetooth_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
|
||||||
|
|||||||
Reference in New Issue
Block a user