ChrisScheffler/miflora

Doubt about automatic disconnection (after 10 seconds)

crbertoldo opened this issue · 5 comments

@ChrisScheffler, in Wiki worklog about the blink command you meant that accidentally mixed up the byte order and the device had changed its behavior. One of these change was "it won't automatically disconnect connections after 10 seconds". I need it. It cannot disconnect in my project. Do you know how to reproduce, please?

@crbertoldo I encountered the behavior when i wrote 0xFFFD to the command characteristic (00001a0000001000800000805f9b34fb). I didn't play around much with the device after that, but I think it won't work as expected.
I could reset it by writing 0xD0AA to the same characteristic.

Try at you own risk ;)

@ChrisScheffler, thank you very much. It has worked as expected.

I also managed to inadvertently reverse the bits and wrote 0xFFFD to two of my sensors. I have found that writing 0xD0AA will cause those sensors to disconnect but when I next connect to the sensors they're still in the "will not auto-disconnect" state, and the battery reads 0% at all times. Also, the light is continuously blinking.

While I absolutely acknowledge that this is my own fault I'm wondering if you encountered this particular behaviour at all?

No, I didn't get a sensor in this state, fortunately. Did you try to remove the battery for some time, insert it again and retry writing 0xD0AA to the sensor?

garo commented

Thank you for this. If somebody else reads this here's a code snippet which I used to reset my device. This also fixes the issue that the device led was constantly glowing white, draining the battery.


async function discover() {
    const devices = await miflora.discover();
    console.log("Discovered", devices.length, "devices");
    console.log(devices);
    return devices;
}

discover().then(async (devices) => {
    const device = devices[0];
    console.log("Connecting to device", device.address);
    await device.connect();
    console.log("Connection done. Current state of the device", device);
    console.log("Will reset device so that it identifies as 'Flower care' again:");
    await device._setDeviceMode(Buffer.from('d0aa', 'hex'));
    const ret = await device.query();
    console.log("query done", ret);
});