5 seconds delay for ble.discover or ble.find with Uuid

5 seconds is to long for my project to get a advertisement.
I experimented with timeout parms on this functions, but it did not affected anything.
Please help?

Too long or too short? Can you show the code where you pass the timeout value?

Older Homey’s have a 30 second delay, so HP2023 is an improvement, and I think the actual delay was 10 seconds.
All you can do is contact Athom and explain the issue.
The problem is Homey is no constantly listening and tracking BLE notifications, so they have to choose a period to listen for when you request a discovery to be able to detect anything.
I did put in a request a long time ago to be able to register for notifications when a BLE device broadcast a new message. I was informed it would never happen for old Homey’s but would be considered for HP2023. That doesn’t mean it will happen, but if enough developers request it, then maybe it will take a higher priority.
I feel the intention was only to ever connect to devices and register for notifications, but it seems most devices don’t allow permanent connections, which makes that useless.

// 1, 10, 1000, 20000, -1000 etc

const advertisements = await this.homey.ble.discover([‘0000fd3000001000800000805f9b34fb’], 1000);

const advertisement = await this.homey.ble.find(‘c904dd7b51df’, 1000);

Timeout is in milliseconds, so 1000 is one second.

I know, but it stays 5 seconds.

Ah yes, the documentation is broken, there’s a hardcoded timeout of 5 seconds in Homey’s core :face_with_raised_eyebrow:

1 Like

https://apps.developer.homey.app/wireless/bluetooth
image

Yes found the note, thanks robertklep.
I use the Eufycan with bold smartlock, but 5 seconds aditional after face recognition is to mutch :frowning:

WebSocket call: 42/devkit,7[“event”,{“sessionId”:“devkit-nl.domain.test1-1.0.0-cc266abe”,“type”:“request”,“uri”:“homey:manager:ble”,“event”:“connect”,“data”:{“peripheralUuid”:“f905dd7b61df”}}]

I am not a javascript expert and i dont know how to debug it, but when Uuid is known then it is must be possible to create adverticement from scratch?

var advertisement = new Homey.BleAdvertisement();
advertisement.uuid = ‘f905dd7b61df’
var peripheral = advertisement.connect();
// Work to do
(await peripheral).disconnect();

That’s not a JS question per se, but a Homey SDK question.

In short: you can’t create BLE Advertisement objects manually, you have to use either .discover() or .find(): BleAdvertisement - Homey Apps SDK v3

The advertisement.connect() creates the websocket call, and the only property to get the peripheral is the Uuid, advertisement is not needed, my problem is that i dont know witch props needed to create advertisement from scratch.

The WebSocket message is internal to the SDK, you can’t (or shouldn’t) use it manually. Same as with advertisements: you can’t (or shouldn’t) instantiate them manually.