May 4, 2020

I keep buying dumb Bluetooth devices and hooking them up to websites, but there’s just enough boilerplate to make integrating them a hassle. So, I made a little Custom Element to help automate some of the boilerplate.

You’d use <bt-device> like any other HTML element:

<!-- Connects to a Thermos Smart Lid water bottle -->
<bt-device
service="40fc0000-8a8d-4a32-a455-c1148e24a9f1"
characteristic="40fc0001-8a8d-4a32-a455-c1148e24a9f1"
notifications="true"
></bt-device>

And then grab the element and connect up to receive notifications:

const device = document.querySelector('bt-device');
await device.connect();
device.addEventListener('data', evt => {
console.log(evt.detai...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help