Nutty Penguin Music

    @0x77/iqos.parser

    0.0.11 • Public • Published

    iQOS.parser

    A parser library for holder charge status parsing.

    Tested on iQOS 2.4+ and Chrome 76

    iQOS commmunity npm GitHub code size in bytes GitHub issues Edit iQOS.parser demo

    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));
    }

    Keywords

    none

    Install

    npm i @0x77/iqos.parser

    DownloadsWeekly Downloads

    5

    Version

    0.0.11

    License

    GPL-3.0

    Unpacked Size

    40.5 kB

    Total Files

    10

    Last publish

    Collaborators

    • 0x77