@0x77/iqos.parser 中文文档教程
iQOS.parser
用于持有人收费状态解析的解析器库。
在 iQOS 2.4+ 和 Chrome 76 上测试
Q&A
TODO
- Add charger support
- Test on iQOS 3.0
- Write connection library
- etc… (P.S.: purpose your features on issues)
Where I can ask the question or bug report?
What is this?
- This library contains simple function that parse the iQOS holder charge status
How to know that holder is not inside charger?
- It will return
-1
What i need to test it out?
- Chrome that supports BLE.
- Bluetooth-enabled iQOS (not tested on iQOS 3)
- A simple code for access ble and display the status:
import HolderChargeEventHandler from '@0x77/iqos.parser';
let optionalServices = ["daebb240-b041-11e4-9e45-0002a5d5c51b"];
//f8a54120-b041-11e4-9be7-0002a5d5c51b battery status characteristic
console.log('Requesting any Bluetooth Device...');
navigator.bluetooth.requestDevice({
acceptAllDevices: true,
optionalServices: optionalServices
})
.then(device => {
console.log('Connecting to GATT Server...');
return device.gatt.connect();
})
.then(server => {
console.log('Getting Services...');
return server.getPrimaryServices();
})
.then(services => {
console.log('Getting Characteristics...');
let queue = Promise.resolve();
services.forEach(service => {
queue = queue.then(_ => service.getCharacteristics().then(characteristics => {
console.log('> Service: ' + service.uuid);
characteristics.forEach(characteristic => {
// log('> C: ', characteristic.uuid.uuid);
console.log(characteristic.uuid);
if (characteristic.uuid == "f8a54120-b041-11e4-9be7-0002a5d5c51b") {
console.log("characteristic of battery found");
characteristic.startNotifications().then(characteristic => {
characteristic.addEventListener(
'characteristicvaluechanged', handleCharacteristicValueChanged
);
})
.catch(error => { console.log(error); });
}
console.log("Reinsert holder to begin...");
});
}));
});
return queue;
})
.catch(error => {
console.log('Argh! ' + error);
});
const handleCharacteristicValueChanged = (event) => {
console.log(HolderChargeEventHandler(event));
}
iQOS.parser
A parser library for holder charge status parsing.
Tested on iQOS 2.4+ and Chrome 76
Q&A
TODO
- Add charger support
- Test on iQOS 3.0
- Write connection library
- etc… (P.S.: purpose your features on issues)
Where I can ask the question or bug report?
What is this?
- This library contains simple function that parse the iQOS holder charge status
How to know that holder is not inside charger?
- It will return
-1
What i need to test it out?
- Chrome that supports BLE.
- Bluetooth-enabled iQOS (not tested on iQOS 3)
- A simple code for access ble and display the status:
import HolderChargeEventHandler from '@0x77/iqos.parser';
let optionalServices = ["daebb240-b041-11e4-9e45-0002a5d5c51b"];
//f8a54120-b041-11e4-9be7-0002a5d5c51b battery status characteristic
console.log('Requesting any Bluetooth Device...');
navigator.bluetooth.requestDevice({
acceptAllDevices: true,
optionalServices: optionalServices
})
.then(device => {
console.log('Connecting to GATT Server...');
return device.gatt.connect();
})
.then(server => {
console.log('Getting Services...');
return server.getPrimaryServices();
})
.then(services => {
console.log('Getting Characteristics...');
let queue = Promise.resolve();
services.forEach(service => {
queue = queue.then(_ => service.getCharacteristics().then(characteristics => {
console.log('> Service: ' + service.uuid);
characteristics.forEach(characteristic => {
// log('> C: ', characteristic.uuid.uuid);
console.log(characteristic.uuid);
if (characteristic.uuid == "f8a54120-b041-11e4-9be7-0002a5d5c51b") {
console.log("characteristic of battery found");
characteristic.startNotifications().then(characteristic => {
characteristic.addEventListener(
'characteristicvaluechanged', handleCharacteristicValueChanged
);
})
.catch(error => { console.log(error); });
}
console.log("Reinsert holder to begin...");
});
}));
});
return queue;
})
.catch(error => {
console.log('Argh! ' + error);
});
const handleCharacteristicValueChanged = (event) => {
console.log(HolderChargeEventHandler(event));
}