Open jinyangqiao opened 6 years ago
I believe that that event is triggered by the device itself and not the server. There will be a slight delay as the message comes from the p1 => server => http but it shouldn't be 10-20 seconds
I tested it on my private cloud several times and it doesn't look like this.
The process I saw is like this:
I perform the ‘/v1/devices/:deviceID’ operation by put =>
I monitor the 'start' message from ‘spark/flash/status’ =>
I monitor the 'success' message from ‘spark/flash/status’ =>
I received a response message from the interface.
{ "id": "xxxxx......", "status": "Update finished" }
At this point my P1 device is still performing an update operation until 10 to 20 seconds after the update is successful.
@jlkalberer the event is ours and we emit it there https://github.com/Brewskey/spark-protocol/blob/dev/src/clients/Device.js#L815-L838
@jinyangqiao And as I see the way the flasher works now the event actually is not fully synchronized with flashing. spark/flash/success
emits as soon as we successfully start
flashing process, but not finish it :(
Ok, I guess I'm not sure what the proper behavior for this should be. Is there any documentation of the event from Particle?
@AntonPuko Thanks for ask! on my private cloud, spark/flash/success
emited when the flash is finished,
and the ‘/v1/devices/:deviceID’ operation by put return a result after spark/flash/success
emited.
@jlkalberer On particle ,I tested several times, and found that the ‘/v1/devices/:deviceID’ operation by put return a result after spark/flash/started
emited, and the event actually is fully synchronized with flashing,
That is, when spark/flash/success emited, the P1 finished flashing process after a second later.
I don't know if our logic is inconsistent with particle or other reasons.
Another thing to note is,my code is synchronized with your latest code. Thans very much!
Ok, sounds like a bug on our end. We'll put out a fix soon.
@jlkalberer is there a fix about the bug now? I tried to fix it but failed.
We don't check for the device to complete flashing and just assume that if all the parts of the binary were sent, then the flash worked.
I'm looking through the system firmware for how it sends the events but the code has changed quite a bit so I'm not sure where to look. I don't have a lot of time to solve this one right now so I'm not sure when I can put out a fix.
Can you watch for the reconnect event instead? What do you actually need the flash success event for?
Yes,I can watch for the reconnect event. I need the flash success event for telling the user the true upgrade status of the device!
Got it. Fixing this will take me ~8 hours and I don't have the time right now. If you have any way to track state between starting flash and the reconnect, that will probably work best (for now).
OK,I see. I will try other methods first. Thanks very much!
please,the problem is resolve?
I'm not sure if it's fixed.
I did make some changes in spark-protocol but I'm not sure if it fixed this. You can test and let me now.
Actually, I made some changes in February that should have fixed things. You'll need to check and let me know though.
Ok, I will test and inform you of the results as soon as possible.thanks.
Hi , When I perform the ‘/v1/devices/:deviceID’ operation by put and update my P1 device, I found that when I monitor the 'success' message from ‘spark/flash/status’, my P1 device is still performing the update operation and it will take a long time to succeed,about 10 to 20 seconds. I want to know whether the data of ‘spark/flash/status’ is synchronized with the real update status of the P1 device? Thanks very much!