My humble feedback
Opened this issue · 4 comments
Hey @larsgk,
Thanks for writing https://dev.to/denladeside/creating-a-web-thermometer-2137 and sharing this demo code!
I had a look at the code and thought you may appreciate feedback ;)
In the code below, device
will always be non null when requestDevice()
resolves. So you can simply remove the if
condition and write await this.#openDevice(device);
only.
web-thermometer/src/thingy52-driver.js
Lines 118 to 120 in 80d44bb
There, you don't have to await for sensor notifications to start the battery notifications. You can use Promise.all()
for instance or something else (see below).
web-thermometer/src/thingy52-driver.js
Lines 33 to 41 in 80d44bb
// Start sensor and battery notifications
const startThermometerNotificationsPromise = this.#startThermometerNotifications(server);
const startBatteryNotificationsPromise = this.#startBatteryNotifications(server);
await startThermometerNotificationsPromise;
try {
await startBatteryNotificationsPromise;
} catch (error) {
// On Linux with earlier versions of BlueZ, there is an issue with 16bit IDs
console.log("Error with battery service: ", err);
}
It seems deviceId
can be removed below as it's not used
web-thermometer/src/thingy52-driver.js
Line 49 in 80d44bb
Once again, thanks for your work on this!
Thanks a lot François :) - I'll fix in the weekend (or maybe you wanna do a PR? :))
(gentle ping)
Any news on that front @larsgk?