Brewskey / spark-protocol

Node.JS module for hosting direct encrypted CoAP socket connections
GNU Lesser General Public License v3.0
9 stars 16 forks source link

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. #140

Open jinyangqiao opened 6 years ago

jinyangqiao commented 6 years ago

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!

jlkalberer commented 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

jinyangqiao commented 6 years ago

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.

AntonPuko commented 6 years ago

@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 :(

jlkalberer commented 6 years ago

Ok, I guess I'm not sure what the proper behavior for this should be. Is there any documentation of the event from Particle?

jinyangqiao commented 6 years ago

@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!

jlkalberer commented 6 years ago

Ok, sounds like a bug on our end. We'll put out a fix soon.

jinyangqiao commented 6 years ago

@jlkalberer is there a fix about the bug now? I tried to fix it but failed.

jlkalberer commented 6 years ago

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?

jinyangqiao commented 6 years ago

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!

jlkalberer commented 6 years ago

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).

jinyangqiao commented 6 years ago

OK,I see. I will try other methods first. Thanks very much!

759325100 commented 5 years ago

please,the problem is resolve?

jlkalberer commented 5 years ago

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.

jlkalberer commented 5 years ago

Actually, I made some changes in February that should have fixed things. You'll need to check and let me know though.

759325100 commented 5 years ago

Ok, I will test and inform you of the results as soon as possible.thanks.