Skip to content

Commit 23a0c54

Browse files
committed
implemented zeroconf advertising
1 parent 04ff7e2 commit 23a0c54

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/hardware/bluetoothctl.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,19 @@ bool BluetoothHandler::disconnect(void) {
7474
void BluetoothHandler::discovered(BTAdvertisedDevice* device) {
7575
if (!device->haveName()) return;
7676

77-
esp_bd_addr_t* address = device->getAddress().getNative();
77+
// check for supported names
7878
std::string name = device->getName();
79+
if (name.find("Ditoo") == std::string::npos &&
80+
name.find("Pixoo") == std::string::npos &&
81+
name.find("Timebox") == std::string::npos &&
82+
name.find("Tivoo") == std::string::npos) return;
83+
84+
// pass it into zeroconf
85+
MDNS.addServiceTxt("_divoom_esp32", "_tcp", "device_mac", device->getAddress().toString().c_str());
86+
MDNS.addServiceTxt("_divoom_esp32", "_tcp", "device_name", name.c_str());
7987

8088
// pass it into the input handlers for an advertise announcement
81-
BaseInput::advertise((const uint8_t*)address, name.c_str(), name.size());
89+
BaseInput::advertise((const uint8_t*)device->getAddress().getNative(), name.c_str(), name.size());
8290
}
8391

8492
/**

src/hardware/bluetoothctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "Arduino.h"
88
#include "BluetoothSerial.h"
9+
#include "ESPmDNS.h"
910

1011
class BluetoothHandler {
1112
public:

src/hardware/wifictl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ void WifiHandler::connected(WiFiEvent_t event, WiFiEventInfo_t info) {
9494
WiFi.setAutoReconnect(true);
9595
WiFi.setHostname(WIFI_NAME);
9696
WiFi.persistent(true);
97+
98+
MDNS.begin(WIFI_NAME);
99+
MDNS.addService("_divoom_esp32", "_tcp", TCP_PORT);
97100
}
98101

99102
/**

src/hardware/wifictl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "config.h"
66

77
#include "Arduino.h"
8+
#include "ESPmDNS.h"
89
#include "WiFi.h"
910

1011
class WifiHandler {

0 commit comments

Comments
 (0)