Merge upstream dev and reconcile NV3001B SPI support
This commit is contained in:
commit
a72a75cd08
51 files changed
+1226
-818
No files matched your search
@@ -2154,6 +2154,30 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
||||
sprintf(reply, "> pin is now %06d", _prefs.ble_pin);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "set ble.name") == 0) {
|
||||
_prefs.ble_name[0] = 0;
|
||||
savePrefs();
|
||||
sprintf(reply, "> BLE name reset to %s%s (reboot to apply)", BLE_NAME_PREFIX, _prefs.node_name);
|
||||
return true;
|
||||
}
|
||||
if (memcmp(command, "set ble.name ", 13) == 0) {
|
||||
if (AdvertDataParser::isValidName(&command[13])) {
|
||||
StrHelper::strncpy(_prefs.ble_name, &command[13], sizeof(_prefs.ble_name));
|
||||
savePrefs();
|
||||
sprintf(reply, "> BLE name is now %s (reboot to apply)", _prefs.ble_name);
|
||||
} else {
|
||||
strcpy(reply, "Error, bad chars");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (strcmp(command, "get ble.name") == 0) {
|
||||
if (_prefs.ble_name[0]) {
|
||||
sprintf(reply, "> %s", _prefs.ble_name);
|
||||
} else {
|
||||
sprintf(reply, "> %s%s", BLE_NAME_PREFIX, _prefs.node_name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WIFI_INTERFACE
|
||||
if (memcmp(command, "set wifi.ssid ", 14) == 0) {
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
float tx_delay_factor = 0;
|
||||
float direct_tx_delay_factor = 0;
|
||||
uint32_t ble_pin = 0;
|
||||
char ble_name[32] = {0};
|
||||
uint8_t advert_loc_policy = 0;
|
||||
uint8_t buzzer_quiet = 0;
|
||||
uint8_t vibe_quiet = 0;
|
||||
@@ -38,6 +39,7 @@ public:
|
||||
uint32_t gps_interval = 0; // GPS read interval in seconds
|
||||
uint32_t gps_period = 0; // periodic acquisition interval in seconds
|
||||
int32_t gps_fence = -1; // GPS_GUARD fence in metres, 0 = off, -1 = build default
|
||||
int32_t gps_first_fix = -1; // first-fix timeout in seconds, 0 = no limit, -1 = build default
|
||||
uint8_t gps_guard = 1; // GPS_GUARD on/off
|
||||
uint8_t autoadd_config = 0; // bitmask for auto-add contacts config
|
||||
uint8_t rx_boosted_gain = 0; // SX126x RX boosted gain mode (0=power saving, 1=boosted)
|
||||
@@ -169,6 +171,7 @@ private:
|
||||
def("int", _parent->gps_interval); // interval in seconds
|
||||
def("period", _parent->gps_period); // periodic acquisition interval in seconds
|
||||
def("adv_loc", _parent->advert_loc_policy);
|
||||
def("ffix", _parent->gps_first_fix);
|
||||
#ifdef GPS_GUARD
|
||||
def("fence", _parent->gps_fence);
|
||||
def("guard", _parent->gps_guard);
|
||||
@@ -180,6 +183,12 @@ private:
|
||||
void setGpsEnabled(bool enabled) override { _parent->gps_enabled = enabled; markDirty(); }
|
||||
uint32_t getGpsPeriod() const override { return _parent->gps_period; }
|
||||
void setGpsPeriod(uint32_t seconds) override { _parent->gps_period = seconds; markDirty(); }
|
||||
bool getFirstFixTimeout(uint32_t& seconds) const override {
|
||||
if (_parent->gps_first_fix < 0) return false;
|
||||
seconds = (uint32_t)_parent->gps_first_fix;
|
||||
return true;
|
||||
}
|
||||
void setFirstFixTimeout(uint32_t seconds) override { _parent->gps_first_fix = (int32_t)seconds; markDirty(); }
|
||||
bool getGuardFence(uint32_t& metres) const override {
|
||||
if (_parent->gps_fence < 0) return false;
|
||||
metres = (uint32_t)_parent->gps_fence;
|
||||
@@ -216,6 +225,7 @@ private:
|
||||
def("defs_nm", _parent->default_scope_name, sizeof(_parent->default_scope_name));
|
||||
def("defs_key", (void *) _parent->default_scope_key, sizeof(_parent->default_scope_key));
|
||||
def("pin", _parent->ble_pin);
|
||||
def("ble_name", _parent->ble_name, sizeof(_parent->ble_name));
|
||||
def("buzz_q", _parent->buzzer_quiet);
|
||||
def("vibe_q", _parent->vibe_quiet);
|
||||
def("auto_add", _parent->autoadd_config); // bitmask for auto-add contacts config
|
||||
|
||||
@@ -215,7 +215,13 @@ void setup() {
|
||||
|
||||
// add bluetooth interface
|
||||
#if defined(BLE_PIN_CODE)
|
||||
bluetooth_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
|
||||
char *prefix = BLE_NAME_PREFIX;
|
||||
char *ble_name = the_mesh.getNodePrefs()->node_name;
|
||||
if (the_mesh.getNodePrefs()->ble_name[0]) {
|
||||
prefix = "";
|
||||
ble_name = the_mesh.getNodePrefs()->ble_name;
|
||||
}
|
||||
bluetooth_interface.begin((const char *) prefix, ble_name, the_mesh.getBLEPin());
|
||||
interface_manager.addInterface(InterfaceType::Bluetooth, &bluetooth_interface);
|
||||
#endif
|
||||
|
||||
@@ -276,27 +282,30 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ESP_MDNS
|
||||
String nodeName = the_mesh.getNodeName();
|
||||
String sanitizedNodeName;
|
||||
sanitizedNodeName.reserve(nodeName.length());
|
||||
for (size_t i = 0; i < nodeName.length(); ++i) {
|
||||
const char* nodeName = the_mesh.getNodeName();
|
||||
|
||||
// "meshcore_" prefix + sanitized node name, capped at 63 chars (max DNS label length)
|
||||
char mdnsName[64];
|
||||
const size_t prefixLen = snprintf(mdnsName, sizeof(mdnsName), "meshcore_");
|
||||
size_t pos = prefixLen;
|
||||
for (size_t i = 0; nodeName[i] != '\0' && pos < sizeof(mdnsName) - 1; ++i) {
|
||||
const char c = nodeName[i];
|
||||
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') || c == '-' || c == '_') {
|
||||
sanitizedNodeName += c;
|
||||
mdnsName[pos++] = c;
|
||||
}
|
||||
}
|
||||
mdnsName[pos] = '\0';
|
||||
|
||||
String mdnsName = "meshcore_";
|
||||
mdnsName += sanitizedNodeName;
|
||||
if (!MDNS.begin(mdnsName.c_str())) {
|
||||
if (!MDNS.begin(mdnsName)) {
|
||||
WIFI_DEBUG_PRINTLN("mDNS failed to start!");
|
||||
} else {
|
||||
MDNS.addService("meshcore", "tcp", TCP_PORT);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "node-name", the_mesh.getNodeName());
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "node-name", nodeName);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "firmware-version", FIRMWARE_VERSION);
|
||||
String protocol; protocol+=FIRMWARE_VER_CODE;
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "protocol-version", protocol.c_str());
|
||||
char protocol[12];
|
||||
snprintf(protocol, sizeof(protocol), "%d", (int)FIRMWARE_VER_CODE);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "protocol-version", (const char*)protocol);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "build-date", __DATE__);
|
||||
MDNS.addServiceTxt("meshcore", "tcp", "build-time", __TIME__);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user