Closed johnnyman727 closed 8 years ago
After talking with @rwaldron, option 3 might be best in this case. Not only do we need to run the command to turn on the BLE dongle, but we need to force the download of optional npm
dependencies (bluetooth-hci-socket
). If we make a wrapper around noble
, we will be able to do both of these things. @sandeepmistry - do you have thoughts about this?
Is having BlueZ's bluetoothd
daemon installed and running an option? It would take care of this, and also enable classic Bluetooth features (audio, serial, etc).
One gotcha is a one line patch is needed to make it compatible with bleno
currently (see https://github.com/sandeepmistry/bleno/issues/24).
@sandeepmistry ah cool! I didn't know such a daemon exists. I checked and it is installed on Tessel's OpenWRT image but the added patch makes it a bit more painful than the option of wrapping noble
/bleno
in a Tessel specific package, IMO.
As a variant of option 1, OpenWrt procd runs scripts in /etc/hotplug.d/usb/
when a USB device is added or removed.
@johnnyman727 fair enough.
@kevinmehall's hot plug idea sounds good.
Briefly looking at udev
rules might be worthwhile as well.
OpenWrt uses procd
instead of udev
, but it might be beneficial to use the more-standard udev (#36).
Thanks @kevinmehall and @sandeepmistry. I was able to get a semi-functional implementation with hotplug
. The biggest limitation I see currently is that the hotplug
scripts don't get if a USB device is plugged in on bootup.
Resolved with https://github.com/tessel/openwrt-tessel/pull/37.
After working out a few kinks in how we manage binary dependencies, one should, in theory, be able to just run either
noble
orbleno
to control your USB BLE dongle on T2. However, there is currently one hurdle that we don't have a solid plan for: before using the device, you must initialize it with the command:I have a couple ideas of how we can make this automatically work, but they aren't necessarily ideal. I also imagine that this might not be a one-off case - we may need to create a mechanism for a node package to run arbitrary shell commands (scary!) prior to initializing a script.
ubus
output for new USB devices. When it detects the USB device, it checks what kind of device it is and if it's a BLE device, we initialize it. We can generalize this a bit more so you can register a script/command for particular types of detected devices.package.json
that documents shell scripts that need to be run on Tessel prior to starting the module. Have the CLI find extract those and run them just before running the actual script.noble
andbleno
and spawns a child process to initialize any interfaces before running the actualnoble
code (not scalable/generalizable).@kevinmehall you may have opinions/suggestions about this.