-
Notifications
You must be signed in to change notification settings - Fork 12
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
irk_enrollment component for esphome - build issues, license etc #4
Comments
Hello! Yes, I would be happy to have this work with the HA in-built functionality. I've pushed some changes to get it to build with the latest ESPHome. I'm not going to be able to test it for a while, but you could try and give it a spin, and it hopefully will work. I don't know to what extent the ble server code has changed in esphome, but hopefully it's just surface level, and this will work now. Alternatively, you can checkout the prior commit, and use ESPHome version 2023.9, which definitely will work. |
On Arduino esp32 it is compiling but can't find any devices on my iPhone. On espidf with esp32s3 got this:
|
after fixing this error (commenting out) there is no any visible bluetooth device nearby. |
@luzik If you don't see Bluetooth device nearby try to use LightBlue or similar application to connect. |
Thx, yeah it worked. Do you have idea why iPhone do not show it before using LightBlue ? Is there any way to find it without extra app ? |
Found something like that: Maybe we can change advertising service to be heart rate ? |
I've changed
|
One more thing .. LightBlue shows no services associated with my ble device. Why is that ? |
The really fun trick of why this works to get the IRK is that I only implemented enough that the BLE handshake happens. Then, there's nothing lol. So we do enough to get the private key, but there isn't anything implemented. I haven't investigated to understand what/whether there are consequences for this. |
@luzik Here the dirty hack to advertise service (actually it's advertise 2 same services). |
Worked like a charm! With your hack and 0x180D |
While my esp is now visible in iPhone and its recover my IRK, is there a way to rename esp devices visible on bluetooth list ? It is defaults to
And this is ok for most of the cases, but If I want to change it, I have to change all the staff (DHCP, HA) |
@luzik Today it's not possible to change BLE device name in configuration. You can try another dirty hack, but name can be cached at client devices, so try to wait, enable/disable BT, etc: void IrkEnrollmentComponent::loop() {
const char *device_name = "IRK Enroll";
static bool is_device_name_set = false;
if (!is_device_name_set) {
auto dis_ = esp32_ble_server::global_ble_server->get_service(esphome::esp32_ble::ESPBTUUID::from_uint16(0x180A));
if (dis_ != nullptr) {
esp32_ble_server::BLECharacteristic *name = dis_->get_characteristic(0x2A00);
if (name == nullptr) {
name = dis_->create_characteristic(0x2A00, esp32_ble_server::BLECharacteristic::PROPERTY_READ);
name->set_value(device_name);
esp_ble_gap_set_device_name(device_name);
}
}
}
... |
Thank You again! It is working.
would be awesome |
Finally had a chance to poke this again, excited to see the work done! I wasn't able to directly include your repo as an external component, as esphome has a hard requirement that the components are in a directory named external_components:
- source: github://agittins/esphome-irk-enrollment
irk_enrollment:
latest_irk:
name: Latest IRK It builds and installs OK, and the esphome shows up in my phone's "Pair new device" listing. But pairing doesn't seem to work for me. Sometimes when I tap the device name, the phone goes to "pairing" for a few milliseconds, then back to the normal state, where I can tap it again. No logs on the esphome when that happens. Other times when I tap it, the phone (pixel 6pro) sits at the "Pairing..." state, never prompting for the pairing confirmation (the dialog that has the toggle for allowing call/contact access). After 30 seconds it times out and goes back the normal list of devices. Log entries I get at that point include:
I suspect that the above could be that the device is missing part of the request, perhaps because it's busy doing other stuff (like sending logs over wifi!). I tried after turning off Sometimes, however, when tapping the device to pair, my phone immediately goes to the pairing confirmation dialog, and when I confirm that I get log output like this:
at some point this happened, but I suspect it may have been immediately after a mac rotation or something, not sure:
I found what looked like might be a similar issue and tried adding case ESP_GAP_BLE_SEC_REQ_EVT:
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
break; to the event handler but it fails to build with (including full build so you can see IDF version etc):
At this point I'm messing with the component locally, so the config I have is: external_components:
#- source: github://agittins/esphome-irk-enrollment
#- source: github://dgrnbrg/appdaemon-configs
- source: esphome-irk-enrollment/components
irk_enrollment:
latest_irk:
name: Latest IRK Here's the full config I'm using, in case I'm doing something daft! substitutions:
devicename: ttgotest
description: TTGO-T-Display board as test platform
esphome:
name: $devicename
friendly_name: $devicename
comment: $description
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
baud_rate: 0 # disable serial uart logging
ota:
platform: esphome
password: !secret ota_password
api:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
switch:
- platform: restart
name: Reboot ${devicename}
text_sensor:
external_components:
#- source: github://agittins/esphome-irk-enrollment
#- source: github://dgrnbrg/appdaemon-configs
- source: esphome-irk-enrollment/components
irk_enrollment:
latest_irk:
name: Latest IRK
esp32_ble_tracker:
scan_parameters:
active: True
interval: 320ms # default 320ms. Time spent per adv channel
window: 300ms # default 30ms. Time spent listening during interval.
continuous: False
bluetooth_proxy:
active: True
time:
- platform: homeassistant
id: esptime
sensor:
- platform: wifi_signal
name: $devicename WiFi Signal
update_interval: 60s
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_blue
red: 0%
green: 0%
blue: 100%
- id: my_gray
red: 50%
green: 50%
blue: 50%
binary_sensor:
- platform: status
name: "Node Status"
id: system_status
- platform: gpio
pin:
number: GPIO0
inverted: true
mode:
input: true
pullup: true
name: "T-Display Button Input 0"
id: tdisplay_button_input_0
- platform: gpio
pin:
number: GPIO35
inverted: true
name: "T-Display Button Input 1"
id: tdisplay_button_input_1
|
Hi David, this is amazing stuff!
I am particularly interested in seeing if your irk_enrollment component can be used to feed IRKs to the Private BLE Device integration that is now in HA core.
I am having trouble getting it to build.
I tried using the component block in my yaml, but it seems that esphome now requires the parent directory to be named
components
for it to consider importing it.After cloning your repo locally and creating a symlink, it complained about not finding the text_sensor.h, adding an empty
text_sensor:
block to my yaml fixed that (the build setup seemed to not realise it needed to copy it in).Now I am getting:
I suspect that it's just that some things have changed in esphome since you wrote the component.
Is this component something you'd be interested in updating for the current esphome (assuming it's not just something bone-headed I'm doing on my end, which is entirely possible!), or perhaps submitting to esphome for inclusion in core? I couldn't find a license statement so thought I'd check in with you to see what you are up for before getting in too deep myself :-)
There's a feature request in the esphome tracker that I'll link to this issue as well.
The text was updated successfully, but these errors were encountered: