-
-
Save e-neko/4a46ba7c5f41d2660efa6155a031c00d to your computer and use it in GitHub Desktop.
Nespresso coffee machine BLE experiments (get AUTH_KEY with Android BT HCI log and Wireshark)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const noble = require('noble'); | |
const SERVICE_UUID = '06aa1910f22a11e39daa0002a5d5c51b'; | |
const TEMPERATURE = {low: '01', medium: '00', high: '02'}; | |
const VOLUME = {ristretto: '00', espresso: '01', lungo: '02', americano: '04', hotwater: '05', recipe: '07'}; | |
let brew_cmd = (vol, t)=>`0305070400000000${TEMPERATURE[t]}${VOLUME[vol]}`; | |
let process_char = char=>{ | |
if (char.uuid=='06aa3a41f22a11e39daa0002a5d5c51b') | |
{ | |
char.write(Buffer.from(AUTH_KEY, 'hex')); | |
console.log('Auth done'); | |
} | |
else if (char.uuid=='06aa3a42f22a11e39daa0002a5d5c51b') | |
{ | |
char.write(Buffer.from(brew_cmd('lungo', 'high'), 'hex')); | |
console.log('Brew done'); | |
} | |
}; | |
console.log('Waiting for device'); | |
let discovered = 0; | |
noble.on('discover', machine=>{ | |
if (discovered++) | |
return; | |
console.log(`Coffee machine found: ${machine.advertisement.localName} (${machine.address}), id=${machine.id}`); | |
noble.stopScanning(); | |
machine.connect(err=>{ | |
console.log('Connected') | |
// service/char discovery not needed, just write to appropriate characteristics | |
machine.discoverServices([], (err, services)=> | |
services.forEach(srv=>srv.discoverCharacteristics([], (err, chars)=>chars.forEach(char=>process_char(char))))) | |
}); | |
}); | |
noble.on('stateChange', state=>{ | |
if (state=='poweredOn') | |
return void noble.startScanning([SERVICE_UUID], true); | |
noble.stopScanning(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment