diff --git a/html/locales/de.json b/html/locales/de.json
index 7235f5c6..c0212477 100644
--- a/html/locales/de.json
+++ b/html/locales/de.json
@@ -18,6 +18,7 @@
"wifi": "WLAN",
"mqtt": "MQTT",
"ftp": "FTP",
+ "bluetooth": "Bluetooth",
"general": "Allgemein",
"tools": "Tools",
"forum": "Forum"
@@ -144,8 +145,8 @@
"111":"Wiederhole Titel (endlos)",
"120":"Dimme LEDs (Nachtmodus)",
"130":"Aktiviere/deaktive WLAN",
- "140":"Bluetooth Lautsprecher aktivieren/deaktivieren",
- "141":"Bluetooth Kopfhörer aktivieren/deaktivieren",
+ "140":"Bluetooth-Lautsprecher aktivieren/deaktivieren",
+ "141":"Bluetooth-Kopfhörer aktivieren/deaktivieren",
"150":"Aktiviere FTP",
"0":"Lösche Zuordnung",
"170":"Play/Pause",
@@ -204,6 +205,27 @@
"button": "FTP-Server starten"
}
},
+ "bt": {
+ "sink": {
+ "title": "ESPuino als Bluetooth-Lautsprecher",
+ "desc": "ESPuino wird als Bluetooth-Lautsprecher gestartet. Nach dem Wechsel in diesen Modus wird die Web-Schnittstelle nicht mehr zur Verfügung stehen, bis das System im normalen Modus neu gestartet wird.",
+ "button": "Als Bluetooth-Lautsprecher starten"
+ },
+ "source": {
+ "configtitle": "Bluetooth-Kopfhörer Einstellungen",
+ "title": "Mit Bluetooth-Kopfhörer verbinden",
+ "desc": "Das Gerät verbindet sich mit dem angegebenen Bluetooth-Kopfhörer. Nach dem Wechsel in diesen Modus wird die Web-Schnittstelle nicht mehr zur Verfügung stehen, bis das System im normalen Modus neu gestartet wird.",
+ "button": "Im Kopfhörer-Modus starten"
+ },
+ "device": {
+ "title": "Bluetooth-Gerät (Kopfhörer)",
+ "placeholder": "z.B. My POGS Wireless Headphone"
+ },
+ "pincode": {
+ "title": "Pairing PIN-Code",
+ "placeholder": "z.B. 0000"
+ }
+ },
"general": {
"volume": {
"title": "Lautstärke",
diff --git a/html/locales/en.json b/html/locales/en.json
index e4faaa82..ef514667 100644
--- a/html/locales/en.json
+++ b/html/locales/en.json
@@ -18,6 +18,7 @@
"wifi": "WiFi",
"mqtt": "MQTT",
"ftp": "FTP",
+ "bluetooth": "Bluetooth",
"general": "General",
"tools": "Tools",
"forum": "Forum"
@@ -65,7 +66,7 @@
"voldown": "Volume Down",
"volup": "Volume Up",
"current": "Current track",
- "command": "Excecute Modification"
+ "command": "Execute Modification"
},
"files": {
"title": "Files",
@@ -91,7 +92,7 @@
"desc": "Start Upload",
"selectFolder": "Please select the upload location!",
"selectFile": "Please select files to upload!",
- "success": "Upload successfull ({{elapsed}}, {{speed}} KB/s)",
+ "success": "Upload successful ({{elapsed}}, {{speed}} KB/s)",
"error": "Upload error",
"timeCalc": "Remaining time is being calculated..",
"minutes_one": "minute",
@@ -144,7 +145,7 @@
"111":"Loop track",
"120":"Dimm LEDs (nightmode)",
"130":"Toggle WiFi",
- "140":"Toggle Bluetooth Speeker",
+ "140":"Toggle Bluetooth Speaker",
"141":"Toggle Bluetooth Headphones",
"150":"Enable FTP",
"0":"Remove assignment",
@@ -204,6 +205,27 @@
"button": "Start FTP-server"
}
},
+ "bt": {
+ "sink": {
+ "title": "ESPuino as Bluetooth speaker",
+ "desc": "ESPuino is started as a Bluetooth speaker. After switching to this mode, the web interface will no longer be available until the system is restarted in normal mode.",
+ "button": "Start as Bluetooth speaker"
+ },
+ "source": {
+ "configtitle": "Bluetooth headphone settings",
+ "title": "Connect with Bluetooth headphone",
+ "desc": "The device connects to the specified Bluetooth headset. After switching to this mode, the web interface will no longer be available until the system is restarted in normal mode.",
+ "button": "Start in headphone mode"
+ },
+ "device": {
+ "title": "Bluetooth device (headphone)",
+ "placeholder": "e.g. My POGS Wireless Headphone"
+ },
+ "pincode": {
+ "title": "Pairing PIN-Code",
+ "placeholder": "e.g. 0000"
+ }
+ },
"general": {
"volume": {
"title": "Volume",
diff --git a/html/management.html b/html/management.html
index 10a04c79..921ca616 100644
--- a/html/management.html
+++ b/html/management.html
@@ -166,6 +166,7 @@
WiFi
%SHOW_MQTT_TAB%
%SHOW_FTP_TAB%
+ %SHOW_BLUETOOTH_TAB%
General
Tools
Forum
@@ -487,6 +488,45 @@
+
@@ -1460,6 +1500,18 @@
socket.send(myJSON);
}
+ function btSettings(clickedId) {
+ lastIdclicked = clickedId;
+ var myObj = {
+ "bluetooth": {
+ deviceName: document.getElementById('btDeviceName').value,
+ pinCode: document.getElementById('btPinCode').value
+ }
+ };
+ var myJSON = JSON.stringify(myObj);
+ socket.send(myJSON);
+ }
+
function removeTrSlash(str) {
if (str.substr(-1) === '/') {
return str.substr(0, str.length - 1);
diff --git a/src/Bluetooth.cpp b/src/Bluetooth.cpp
index 354d5b9e..4d4febb9 100644
--- a/src/Bluetooth.cpp
+++ b/src/Bluetooth.cpp
@@ -207,15 +207,20 @@ void Bluetooth_Init(void) {
//a2dp_source->set_task_core(1); // task core
//a2dp_source->set_nvs_init(true); // erase/initialize NVS
//a2dp_source->set_ssp_enabled(true); // enable secure simple pairing
- //a2dp_source->set_pin_code("0000"); // set pin code if needed, see https://forum.espuino.de/t/neues-feature-bluetooth-kopfhoerer/1293/30
+ // pairing pin-code, see https://forum.espuino.de/t/neues-feature-bluetooth-kopfhoerer/1293/30
+ String btPinCode = gPrefsSettings.getString("btPinCode", "");
+ if (btPinCode != "") {
+ a2dp_source->set_ssp_enabled(true);
+ a2dp_source->set_pin_code(btPinCode.c_str());
+ }
// start bluetooth source
a2dp_source->set_ssid_callback(scan_bluetooth_device_callback);
a2dp_source->start(get_data_channels);
// get device name
- btDeviceName = nameBluetoothSourceDevice;
+ btDeviceName = "";
if (gPrefsSettings.isKey("btDeviceName")) {
- btDeviceName = gPrefsSettings.getString("btDeviceName", nameBluetoothSourceDevice);
+ btDeviceName = gPrefsSettings.getString("btDeviceName", "");
}
Log_Printf(LOGLEVEL_INFO, "Bluetooth source started, connect to device: '%s'", (btDeviceName == "") ? "connect to first device found" : btDeviceName.c_str());
// connect events after startup
diff --git a/src/Web.cpp b/src/Web.cpp
index 537a3aea..a04efe57 100644
--- a/src/Web.cpp
+++ b/src/Web.cpp
@@ -39,6 +39,7 @@ typedef struct {
const char mqttTab[] = "
";
const char ftpTab[] = "
";
+const char bluetoothTab[] = "
";
AsyncWebServer wServer(80);
AsyncWebSocket ws("/ws");
@@ -494,6 +495,12 @@ String templateProcessor(const String &templ) {
#else
return String();
#endif
+ } else if (templ == "SHOW_BLUETOOTH_TAB") { // Only show Bluetooth-tab if Bluetooth-support was compiled
+ #ifdef BLUETOOTH_ENABLE
+ return bluetoothTab;
+ #else
+ return String();
+ #endif
} else if (templ == "INIT_LED_BRIGHTNESS") {
return String(gPrefsSettings.getUChar("iLedBrightness", 0));
} else if (templ == "NIGHT_LED_BRIGHTNESS") {
@@ -574,10 +581,14 @@ String templateProcessor(const String &templ) {
#ifdef MQTT_ENABLE
return String(gMqttPort);
#endif
- } else if (templ == "BT_SOURCE_NAME") {
+ } else if (templ == "BT_DEVICE_NAME") {
if (gPrefsSettings.isKey("btDeviceName")) {
return gPrefsSettings.getString("btDeviceName", "");
}
+ } else if (templ == "BT_PIN_CODE") {
+ if (gPrefsSettings.isKey("btPinCode")) {
+ return gPrefsSettings.getString("btPinCode", "");
+ }
} else if (templ == "IPv4") {
return WiFi.localIP().toString();
} else if (templ == "RFID_TAG_ID") {
@@ -682,6 +693,12 @@ bool processJsonRequest(char *_serialJson) {
(!String(_mqttServer).equals(gPrefsSettings.getString("mqttServer", "-1")))) {
return false;
}
+ } else if (doc.containsKey("bluetooth")) {
+ // bluetooth settings
+ const char *_btDeviceName = doc["bluetooth"]["deviceName"];
+ gPrefsSettings.putString("btDeviceName", (String)_btDeviceName);
+ const char *btPinCode = doc["bluetooth"]["pinCode"];
+ gPrefsSettings.putString("btPinCode", (String)btPinCode);
} else if (doc.containsKey("rfidMod")) {
const char *_rfidIdModId = object["rfidMod"]["rfidIdMod"];
uint8_t _modId = object["rfidMod"]["modId"];
diff --git a/src/settings-override.h.sample b/src/settings-override.h.sample
index 380935ad..9a14d378 100644
--- a/src/settings-override.h.sample
+++ b/src/settings-override.h.sample
@@ -175,7 +175,6 @@
// Bluetooth
constexpr const char nameBluetoothSinkDevice[] = "ESPuino"; // Name of your ESPuino as Bluetooth-device
- constexpr const char nameBluetoothSourceDevice[] = "My POGS Wireless Headphone"; // Name of Bluetooth-device to connect to (BT-Headset name) (https://forum.espuino.de/t/neues-feature-bluetooth-kopfhoerer/1293/)
// Where to store the backup-file for NVS-records
constexpr const char backupFile[] = "/backup.txt"; // File is written every time a (new) RFID-assignment via GUI is done
diff --git a/src/settings.h b/src/settings.h
index 0e400991..5254e695 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -195,7 +195,6 @@
// Bluetooth
constexpr const char nameBluetoothSinkDevice[] = "ESPuino"; // Name of your ESPuino as Bluetooth-device
- constexpr const char nameBluetoothSourceDevice[] = "My POGS Wireless Headphone"; // Name of Bluetooth-device to connect to (BT-Headset name) (https://forum.espuino.de/t/neues-feature-bluetooth-kopfhoerer/1293/)
// Where to store the backup-file for NVS-records
constexpr const char backupFile[] = "/backup.txt"; // File is written every time a (new) RFID-assignment via GUI is done