Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Pair? #196

Open
erenoglu opened this issue Mar 24, 2024 · 1 comment
Open

How to Pair? #196

erenoglu opened this issue Mar 24, 2024 · 1 comment
Labels

Comments

@erenoglu
Copy link

Question
I have a madoka thermostat using BLE and first thing you need to do is to pair. to pair it, it displays a 5 digit code and you need to click a button on the thermostat and do the same on the initiating side. The code changes each time it's paired.

How can I achieve the same in esp32-ble2mqtt? I tried the below json but it did not work. It sees the thermostat and connects but thermostat doesn't show any code as if it's not attempting any pairing/authentication.

"ble": {
"whitelist": [
"F4:93:1C:90:B9:FB", ---> This is the thermostat
"00:11:22:??:??:??" --> this one is dummy, disregard
],
"passkeys": {
"F4:93:1C:90:B9:FB": "?????", ---> I put this ????? to try to make it accept all codes but no pairing attempted
"00:11:22:??:??:??": "123456" --> this one is dummy, disregard
}
}

Additional context
I expect the esp32-ble2mqtt to attempt pairing to the whitelisted thermostat, and accept any code that it gets to complete pairing. Then normal operations can resume.

@shmuelzon
Copy link
Owner

I think the issue here is the bonding capabilities this project exposes. It currently only states that it has a keyboard (to enter a pairing code). It sound like, in this case, the pairing is expected to be done by displaying a code on both sides and clicking yes/no.

The current IO capability is set to ESP_IO_CAP_IN (which is KeyboardOnly) while it sound like we might need ESP_IO_CAP_IO (which is DisplayYesNo) or ESP_IO_CAP_KBDISP (which is Keyboard display).

If you're up for it, you can try to apply the following changes and see how it works for you:

diff --git a/main/ble.c b/main/ble.c
index db35bd8..36946bf 100644
--- a/main/ble.c
+++ b/main/ble.c
@@ -1036,7 +1036,7 @@ int ble_initialize(void)
     ESP_ERROR_CHECK(esp_ble_gattc_app_register(0));
     ESP_ERROR_CHECK(esp_ble_gatt_set_local_mtu(200));
     /* Set security IO capability to KeyboardOnly */
-    esp_ble_io_cap_t iocap = ESP_IO_CAP_IN;
+    esp_ble_io_cap_t iocap = ESP_IO_CAP_IO;
     esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap,
         sizeof(iocap));

or

diff --git a/main/ble.c b/main/ble.c
index db35bd8..36946bf 100644
--- a/main/ble.c
+++ b/main/ble.c
@@ -1036,7 +1036,7 @@ int ble_initialize(void)
     ESP_ERROR_CHECK(esp_ble_gattc_app_register(0));
     ESP_ERROR_CHECK(esp_ble_gatt_set_local_mtu(200));
     /* Set security IO capability to KeyboardOnly */
-    esp_ble_io_cap_t iocap = ESP_IO_CAP_IN;
+    esp_ble_io_cap_t iocap = ESP_IO_CAP_KBDISP;
     esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap,
         sizeof(iocap));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants