Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to advertisement in BLE manager (Mi Flora App) #117

Closed
koktaildotcom opened this issue Apr 30, 2020 · 32 comments
Closed

Cannot connect to advertisement in BLE manager (Mi Flora App) #117

koktaildotcom opened this issue Apr 30, 2020 · 32 comments
Labels
ble Bluetooth Low Energy

Comments

@koktaildotcom
Copy link

koktaildotcom commented Apr 30, 2020

With the latest firmware (v4.2.0-rc5+) i cannot connect to the advertisement anymore. It gives a timeout.

            const advertisement = await Homey.ManagerBLE.find(device.getAddress()).then(function (advertisement) {
                return advertisement;
            })

            const peripheral = await advertisement.connect();

Expect behaviour:
I get the peripheral from the advertisement.

Current behaviour
I got a BLE Timeout:

[Error: BLETimeout
at Remote IPC Process
] {
message: 'BLETimeout'
}

@koktaildotcom koktaildotcom changed the title Cannot connect to advertisement in BLE manager Cannot connect to advertisement in BLE manager (Mi Flora App) Apr 30, 2020
@koktaildotcom
Copy link
Author

Looks link the peripheral.disconnect() doesn't work and that the seconds time the connection is made the peripheral is still connected and that advertisement.connect() result in a timeout.

@WeeJeWel can you verify that?

@koktaildotcom
Copy link
Author

Ignore that.
After a reboot of homey the sensors are connected correctly the first time. Looks like Homey keep some reference to the device.

@koktaildotcom
Copy link
Author

koktaildotcom commented May 15, 2020

I've made a custom branch for tracking the issue. You can find it here: https://github.com/koktaildotcom/homey-mi-flora/tree/feature/ble-timeout-issue.

Steps to reproduce:

  1. Restart homey without any xiaomi mi flora app installed.
  2. Wait until homey is booted properly.
  3. Run the App.
  4. Install one xiaomi mi flora sensor. (the first update sequence starts)
  5. Wait until the second update sequence. (in this branch its a 5 second delay)
  6. The error occur by all the devices (it can take some while because its a timeout)

If this doesn't work some how try rebooting homey with the app and sensor installed.

This produces a log like:

─────────────── Logging stdout & stderr ───────────────
Successfully init HomeyMiFlora version: 2.1.13
[extra comment for testing] ---> This is update sequence no:1.
 
-----------------------------------------------------------------
| New update sequence 
-----------------------------------------------------------------
reduce
#########################################
# update device: Mi Flora Sensor
# firmware: 3.2.1
#########################################
call handleUpdateSequence
handleUpdateSequence
find
distance = 6.641101633089944 meter
connecting to advertisement
dataService
realtime
data
DATA_CHARACTERISTIC_UUID::read
{
  measure_temperature: 22.3,
  measure_luminance: 194,
  flora_measure_fertility: 195,
  flora_measure_moisture: 9
}
FIRMWARE_CHARACTERISTIC_UUID::read
{
  firmware_version: '3.2.1',
  last_updated: '2020-05-15T18:08:29.102Z',
  uuid: 'c47c8d661988',
  battery: 96
}
call disconnectPeripheral
try to disconnect peripheral
disconnect peripheral
[extra comment for testing] ---> Looks like it happen after the disconnect
Device sync complete in: 1.555 seconds
All devices are synced complete in: 1.64 seconds
------------------------------------------------------------------------------------------------------------------------------------------------
set timeout 2
[extra comment for testing] ---> Set the update interval to 5 seconds for testing purposes.
[extra comment for testing] ---> This is update sequence no:2.
 
-----------------------------------------------------------------
| New update sequence 
-----------------------------------------------------------------
reduce
#########################################
# update device: Mi Flora Sensor
# firmware: 3.2.1
#########################################
call handleUpdateSequence
handleUpdateSequence
find
distance = 6.641101633089944 meter
connecting to advertisement
dataService
realtime
data
DATA_CHARACTERISTIC_UUID::read
{
  measure_temperature: 22.2,
  measure_luminance: 175,
  flora_measure_fertility: 196,
  flora_measure_moisture: 9
}
FIRMWARE_CHARACTERISTIC_UUID::read
{
  firmware_version: '3.2.1',
  last_updated: '2020-05-15T18:08:38.830Z',
  uuid: 'c47c8d661988',
  battery: 96
}
call disconnectPeripheral
try to disconnect peripheral
disconnect peripheral
[extra comment for testing] ---> Looks like it happen after the disconnect
Device sync complete in: 6.59 seconds
All devices are synced complete in: 6.672 seconds
------------------------------------------------------------------------------------------------------------------------------------------------
set timeout 2
[extra comment for testing] ---> Set the update interval to 5 seconds for testing purposes.
[extra comment for testing] ---> This is update sequence no:3.
 
-----------------------------------------------------------------
| New update sequence 
-----------------------------------------------------------------
reduce
#########################################
# update device: Mi Flora Sensor
# firmware: 3.2.1
#########################################
call handleUpdateSequence
handleUpdateSequence
find
distance = 6.641101633089944 meter
connecting to advertisement
try to disconnect peripheral
disconnect peripheral
[extra comment for testing] ---> Looks like it happen after the disconnect
timeout, retry again 1
[Error: Peripheral is not connected (state is disconnected)
   at Remote IPC Process
] {
  message: 'Peripheral is not connected (state is disconnected)'
}

@koktaildotcom
Copy link
Author

At the last update sequence there is an error:
[Error: Peripheral is not connected (state is disconnected)
at Remote IPC Process
] {
message: 'Peripheral is not connected (state is disconnected)'
}

@koktaildotcom
Copy link
Author

This is still an issue. Have you test it on an Homey 2016? Looks like all complains are 2019 or Pro's.

@koktaildotcom koktaildotcom reopened this Jun 7, 2020
@robiebab
Copy link

robiebab commented Jun 7, 2020

I have a homey from 2016 and have sometimes a timeout, if i restart the app it gives a message timeout 30000. The only way foe me to fix it, is to reboot homey. Then it works for a few min or a few days. If you need more information, just ask :)

@shaarkys
Copy link

shaarkys commented Jun 7, 2020

`

nodeVersion "v12.16.1"
homeyVersion "4.2.0"
homeyModelId "homey3s"
homeyModelName "Homey (Early 2019)"

`

#########################################
# update device: Mi Flora Sensor - Strawberries
# firmware: 3.2.2
#########################################
call handleUpdateSequence
handleUpdateSequence
find
distance = 9.334850610218087 meter
connect
disconnectPeripheral not registered yet
timeout, retry again 3
[Error: BLETimeout
   at Remote IPC Process
] {
  message: 'BLETimeout'
}
Error: Error: Error: Max retries (3) exceeded, no success
    at /app.js:251:35
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async HomeyMiFlora.updateDevice (/app.js:237:16)
    at async HomeyMiFlora.updateDevices (/app.js:205:16)
reduce

This happens right after connect attempt :
const advertisement = await Homey.ManagerBLE.find(device.getAddress(), 10000).then(function (advertisement) { return advertisement; }); const peripheral = await advertisement.connect();

This somehow started with 4.2 version and get worse after each RC ... I think it stopped completely like month ago or so (RC12 maybe?)

@shaarkys
Copy link

shaarkys commented Jun 7, 2020

With the test build (tested not after reboot however)

─────────────── Logging stdout & stderr ───────────────
Successfully init HomeyMiFlora version: 2.1.13
No devices found yet.
set timeout 4
not running
No devices found yet.
set timeout 4
registeredDevice Mi Flora Sensor - Tomato
registeredDevice Mi Flora Sensor - Strawberries
registeredDevice Mi Flora Sensor - Grass
not running
[extra comment for testing] ---> This is update sequence no:1.




-----------------------------------------------------------------
| New update sequence
-----------------------------------------------------------------
reduce
#########################################
# update device: Mi Flora Sensor - Tomato
# firmware: 3.2.2
#########################################
call handleUpdateSequence
handleUpdateSequence
find
estimatedDistance = 10.1 meter
connecting to advertisement
disconnectPeripheral not registered yet
timeout, retry again 1
[Error: BLETimeout
   at Remote IPC Process
] {
  message: 'BLETimeout'
}
#########################################
# update device: Mi Flora Sensor - Tomato
# firmware: 3.2.2
#########################################
call handleUpdateSequence
handleUpdateSequence
find
estimatedDistance = 10.1 meter
connecting to advertisement
....

@koktaildotcom
Copy link
Author

@WeeJeWel would you investigate this issue with additional informatie please? Can you try to keep the app running for some time. Looks like it can work for some time. Can it be related to the node update?

Any change i can test something?

@shaarkys
Copy link

Just if that would help - here is how it behaves after daily reboot - for some time it reads values and then BLETimeout occurs.

obrazek

@koktaildotcom
Copy link
Author

The community did some testing. If you disable all flows (“when value is below set value”) it looks like the BLE timeout isn't kicking in that quick. However with some tests after 21 updates with an interval of 15 minutes the BLE timeout kicks in again.

@koktaildotcom
Copy link
Author

When do this issue get some love? I've got a lot of complains here. I cannot do anything about it.

@homeyjoenka
Copy link

Hi

every day homey loses contact with the flower, we restart homey en dan connect he for couple of hours

@WeeJeWel WeeJeWel added the ble Bluetooth Low Energy label Jul 15, 2020
@akrug42
Copy link

akrug42 commented Jul 24, 2020

Hi
Any Progress on this issue. I have the same issue. After couple updates from the sensor the update process seams to be stuck.
Is there anything I can do to help speeding up the bug fixing process?

@davidhalford
Copy link

davidhalford commented Jul 30, 2020

Just installed the app and have 1 unit (not the pot, the other thing). Same issue; initial connect works, nothing after that. If you need any info from my side, please let me know, as I'd like to keep my plant alive :)

@CyborgNL
Copy link

CyborgNL commented Aug 5, 2020

I am using a Homey Pro and not able to read the sensor data anymore. Reboot Homey several times and also the app. 1 sensor is working sometimes and from the 2nd sensor I do not receive any data. It is also not possible to add new sensors (received today) 😔

@homeyjoenka
Copy link

We have to same problem its not fine

@Raycokes2000
Copy link

Raycokes2000 commented Aug 7, 2020

Same here too, sensor status looks frozen even after several reboots of homey early19 pro, Flora app and even battery change of sensors do not work

@niekvugteveen
Copy link

Same here. After restart I get one reading, then nothing. This is taking too long. It makes devices unusable.

@fmvdb
Copy link

fmvdb commented Aug 13, 2020

Just received 3 Mi Flora Sensors today and ran into this issue. Data is update in Homey one time. On the smartphone the data is read flawless with the app from Mi (Flower Care).

Looking forward to a fix!

@tilcoating
Copy link

Three sensors, once updated upon install... Please solve, Athom. Bluetooth is quite useless in this way.

@dbuekenh
Copy link

dbuekenh commented Sep 1, 2020

Same problem here with 2 sensors on a homey with latest release

😕

@koktaildotcom
Copy link
Author

@WeeJeWel is there any progress on this issue? It's been there for half a year. I still get a lot of complains about it.

@shaarkys
Copy link

shaarkys commented Oct 2, 2020

Btw, I can confirm the same happening as well on v5.0.0-rc.34 (which is understandable as Bluetooth stack hasn't been touched), yet just for the record.

@geurti64
Copy link

F597670B-D907-4406-B3F6-A8CAF8A5A4AF
My Homey 2018 got every week a reboot to make sure I get the plant updated again. As you can see in the screenshot not all the updates are 6 days old. Some are much older and one last update is even two months old.
I wonder if it's only a BLE problem. But I've not enough knowledge about it to say why. What surprises me is that out of four I get two updates. Why are the other two updates so much older?

@flits
Copy link

flits commented Oct 24, 2020

Worked without any problem. But looks like it stopped working 4 days ago. Status is not being updated. Only one synch after a Homey reboot and then it stops updating.

@koktaildotcom
Copy link
Author

koktaildotcom commented Nov 22, 2020

In the Homey v5.0.0-rc.41 release:

[Core] Fixed an issue with managing BLE connections

I've tested it on the SDK3 and i don't get timeouts anymore. Many thanks for solving this issue. Can you give us some insights what happened?

@shaarkys
Copy link

shaarkys commented Nov 22, 2020

For me it is still the same, I'm on v5 38 since release... :-( After reboot it reads values and then nothing.

@geurti64
Copy link

For me it is still the same, I'm on v5 38 since release... :-( After reboot it reads values and then nothing.

So still no reason for me to get v5 🤓

@koktaildotcom
Copy link
Author

koktaildotcom commented Nov 23, 2020

I misinformed you, my development Homey is on v5.0.0-rc41 and is not stable for experimental release yet. We have to wait a little longer.

@shaarkys
Copy link

No problem, it's great they fixed it, no matter which RC :-) Thank you for sharing.

@mrlukasbos
Copy link

The BLE connection issue should be resolved in V5.0.0-rc.41 and will be shipped with the next beta release. Feel free to reopen this thread if any problems still occur.

Thank you very much for reporting the issue and for providing the detailed information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ble Bluetooth Low Energy
Development

No branches or pull requests