Oral-B电动牙刷Bluetooth 4.1低功耗蓝牙数据读取与智能功能集成问询
Hey there! Awesome work getting the connection up and running with noble—reading dynamic services and characteristics is a huge win, so pat yourself on the back. Let’s dive into the key technical challenges you’ll likely face next, along with practical solutions:
Parsing Real-Time Clean Data
Oral-B’s BLE characteristics send data as raw binary, so your first task is decoding that into usable values (like clean time, pressure, mode, or brush head status).
- Start by logging the raw buffer from each characteristic update to spot patterns:
characteristic.on('data', (data) => { console.log('Raw hex data:', data.toString('hex')); // Add parsing logic here }); - Community reverse-engineering has uncovered common formats: for example, a 4-byte buffer might include a mode ID (1 byte), pressure level (2 bytes little-endian), and elapsed time (1 byte). Use Node.js
Buffermethods likereadUInt8()orreadUInt16LE()to extract these values.
Handling Disconnections & Reliable Reconnection
BLE connections can drop unexpectedly (especially if the toothbrush goes to sleep), so you need robust reconnection logic:
- Listen for the
disconnectevent on your device instance, then trigger a re-scan for the device’s UUID:device.on('disconnect', () => { console.log('Toothbrush disconnected—reconnecting...'); noble.startScanning([targetServiceUuid], false, (error) => { if (error) console.error('Scan error:', error); }); }); - Add a retry limit to avoid infinite scanning, and handle cases where the user presses the toothbrush’s Bluetooth button to re-pair.
Syncing with the Oral-B App (Optional)
If you want to mirror the app’s functionality or pull additional data (like brush head usage history), you’ll need to replicate the app’s BLE handshake:
- Use a BLE sniffer (or tools like Wireshark with a compatible adapter) to capture the app’s communication with the toothbrush. Look for write operations to authentication or configuration characteristics.
- For example, some models require sending a specific handshake packet to unlock access to extended data features—you can replicate this in your code with
characteristic.write().
Controlling the Toothbrush’s Small Display
To push data to the toothbrush’s built-in screen, locate the GATT characteristic with WRITE permissions (usually part of a display-specific service):
- Once identified, format your data into the binary format the toothbrush expects. For example, to show a "Deep Clean" mode indicator:
const displayChar = await device.getCharacteristic(displayServiceUuid, displayCharUuid); await displayChar.write(Buffer.from([0x02, 0x04])); // Example command for deep clean mode - Test small payloads first and observe the screen’s response to refine your formatting.
Power & Adapter Management
If you’re running this on an embedded device (like a Raspberry Pi), ensure your BLE adapter stays active:
- Disable power-saving for the adapter using
bluetoothctl:sudo bluetoothctl power on sudo bluetoothctl discoverable on - Listen for noble’s
stateChangeevent to handle cases where the adapter is turned off unexpectedly:noble.on('stateChange', (state) => { if (state === 'poweredOn') { console.log('BLE adapter ready—starting scan'); noble.startScanning([targetServiceUuid]); } else { console.log('BLE adapter offline'); noble.stopScanning(); } });
内容的提问来源于stack exchange,提问作者DorNickie

