kopia lustrzana https://github.com/meshtastic/firmware
Merge pull request #1425 from holdenk/sketch
Configure bluetooth name based on owner's short namepull/1522/head
commit
d726ed6e7c
10
src/main.cpp
10
src/main.cpp
|
@ -101,9 +101,15 @@ const char *getDeviceName()
|
|||
|
||||
getMacAddr(dmac);
|
||||
|
||||
// Meshtastic_ab3c
|
||||
// Meshtastic_ab3c or Shortname_abcd
|
||||
static char name[20];
|
||||
sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]);
|
||||
sprintf(name, "%02x%02x", dmac[4], dmac[5]);
|
||||
// if the shortname exists and is NOT the new default of ab3c, use it for BLE name.
|
||||
if ((owner.short_name != NULL) && (owner.short_name != name)) {
|
||||
sprintf(name, "%s_%02x%02x", owner.short_name, dmac[4], dmac[5]);
|
||||
} else {
|
||||
sprintf(name, "Meshtastic_%02x%02x", dmac[4], dmac[5]);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -225,6 +225,11 @@ void NRF52Bluetooth::setup()
|
|||
Bluefruit.autoConnLed(false);
|
||||
Bluefruit.begin();
|
||||
|
||||
// Clear existing data.
|
||||
Bluefruit.Advertising.stop();
|
||||
Bluefruit.Advertising.clearData();
|
||||
Bluefruit.ScanResponse.clearData();
|
||||
|
||||
// Set the advertised device name (keep it short!)
|
||||
Bluefruit.setName(getDeviceName());
|
||||
|
||||
|
@ -276,4 +281,4 @@ void NRF52Bluetooth::clearBonds()
|
|||
|
||||
Bluefruit.Periph.clearBonds();
|
||||
Bluefruit.Central.clearBonds();
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue