Most of the scripts no longer work directly because gatttool has been removed from bluez-utils. Potential replacements for
gatttool -d <mac> -a 0x0012 -n <data e.g. e3bf>
are (the somewhat hacky):
(sleep 10; echo "write-value 0x0012 <data e.g. 0xe3 0xbf>"; sleep 1) | btgatt-client -d <mac>
or the python gattlib library, which has a nice interface via the write_by_handle method, but unfortunately segfaults on my machine.
req = GATTRequester("00:11:22:33:44:55")
req.write_by_handle(0x0012, str(bytearray([14, 4, 56])))
I got something working with node's noble library, though it's a bit more involved to use. You need to call the writeHandle method, but need to go through power, scanning, and connecting to get a peripheral you can call this method on. Roughly:
mac_addr = "xx:xx:xx:xx:xx:xx"
data = [0x12, 0xef, ... ]
noble.on('discover', function handler(peripheral) {
if (peripheral.address.toUpperCase() === mac_addr.toUpperCase()) {
noble.stopScanning()
noble.removeListener('discover', handler)
peripheral.connect(function(err) {
peripheral.writeHandle(0x0012,
Buffer.from(data),
false, // wait for response
function (err) { process.exit(0) })
})
}
})
noble.on('stateChange', function(state) {
if (state === 'poweredOn') {
noble.startScanning()
}
})
Most of the scripts no longer work directly because gatttool has been removed from bluez-utils. Potential replacements for
are (the somewhat hacky):
or the python gattlib library, which has a nice interface via the write_by_handle method, but unfortunately segfaults on my machine.
I got something working with node's noble library, though it's a bit more involved to use. You need to call the writeHandle method, but need to go through power, scanning, and connecting to get a peripheral you can call this method on. Roughly: