|
|
@ -714,6 +714,7 @@ void MyMesh::begin(FILESYSTEM *fs) { |
|
|
mesh::Mesh::begin(); |
|
|
mesh::Mesh::begin(); |
|
|
_fs = fs; |
|
|
_fs = fs; |
|
|
// load persisted prefs
|
|
|
// load persisted prefs
|
|
|
|
|
|
loadRoomPrefs(); |
|
|
_cli.loadPrefs(_fs); |
|
|
_cli.loadPrefs(_fs); |
|
|
|
|
|
|
|
|
acl.load(_fs, self_id); |
|
|
acl.load(_fs, self_id); |
|
|
@ -747,6 +748,10 @@ void MyMesh::begin(FILESYSTEM *fs) { |
|
|
updateAdvertTimer(); |
|
|
updateAdvertTimer(); |
|
|
updateFloodAdvertTimer(); |
|
|
updateFloodAdvertTimer(); |
|
|
|
|
|
|
|
|
|
|
|
if (strlen(topic) > 0) { |
|
|
|
|
|
topic_timestamp = getRTCClock()->getCurrentTimeUnique(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
board.setAdcMultiplier(_prefs.adc_multiplier); |
|
|
board.setAdcMultiplier(_prefs.adc_multiplier); |
|
|
|
|
|
|
|
|
#if ENV_INCLUDE_GPS == 1 |
|
|
#if ENV_INCLUDE_GPS == 1 |
|
|
@ -754,6 +759,45 @@ void MyMesh::begin(FILESYSTEM *fs) { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define PREFS_FILE_PATH "/room_prefs" |
|
|
|
|
|
|
|
|
|
|
|
void MyMesh::loadRoomPrefs() { |
|
|
|
|
|
#if defined(RP2040_PLATFORM) |
|
|
|
|
|
File file = _fs->open(PREFS_FILE_PATH, "r"); |
|
|
|
|
|
#else |
|
|
|
|
|
File file = _fs->open(PREFS_FILE_PATH); |
|
|
|
|
|
#endif |
|
|
|
|
|
if (file) { |
|
|
|
|
|
file.read((uint8_t *)&topic[0], sizeof(topic)); // 0
|
|
|
|
|
|
topic[MAX_TOPIC_TEXT_LEN] = '\0'; |
|
|
|
|
|
// next: 144
|
|
|
|
|
|
|
|
|
|
|
|
file.close(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MyMesh::saveRoomPrefs() { |
|
|
|
|
|
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) |
|
|
|
|
|
_fs->remove(PREFS_FILE_PATH); |
|
|
|
|
|
File file = _fs->open(PREFS_FILE_PATH, FILE_O_WRITE); |
|
|
|
|
|
#elif defined(RP2040_PLATFORM) |
|
|
|
|
|
File file = _fs->open(PREFS_FILE_PATH, "w"); |
|
|
|
|
|
#else |
|
|
|
|
|
File file = _fs->open(PREFS_FILE_PATH, "w", true); |
|
|
|
|
|
#endif |
|
|
|
|
|
if (file) { |
|
|
|
|
|
file.write((uint8_t *)&topic[0], sizeof(topic)); // 0
|
|
|
|
|
|
// next: 144
|
|
|
|
|
|
|
|
|
|
|
|
file.close(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MyMesh::savePrefs() { |
|
|
|
|
|
saveRoomPrefs(); |
|
|
|
|
|
_cli.savePrefs(_fs); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void MyMesh::sendFloodScoped(const TransportKey& scope, mesh::Packet* pkt, uint32_t delay_millis, uint8_t path_hash_size) { |
|
|
void MyMesh::sendFloodScoped(const TransportKey& scope, mesh::Packet* pkt, uint32_t delay_millis, uint8_t path_hash_size) { |
|
|
if (scope.isNull()) { |
|
|
if (scope.isNull()) { |
|
|
sendFlood(pkt, delay_millis, path_hash_size); |
|
|
sendFlood(pkt, delay_millis, path_hash_size); |
|
|
@ -964,6 +1008,8 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply |
|
|
strcpy(topic, new_topic); |
|
|
strcpy(topic, new_topic); |
|
|
topic_timestamp = getRTCClock()->getCurrentTimeUnique(); |
|
|
topic_timestamp = getRTCClock()->getCurrentTimeUnique(); |
|
|
|
|
|
|
|
|
|
|
|
saveRoomPrefs(); |
|
|
|
|
|
|
|
|
sprintf(reply, "New topic set with length %d", len); |
|
|
sprintf(reply, "New topic set with length %d", len); |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
|