When I use the Particle CLI tool to flash Tinker to an Electron, I see the following events raised (subscribed to via particle subscribe mine - this is all done on a personal Particle account, no Product anything involved):
spark/flash/status: started
spark/flash/status: success
spark/device/app-hash
I think the crux of all of this is alluded to in the doc for flashing, where it says "As updates are being delivered via the cloud to your device, you may see some events published by the cloud to help you monitor the update."
Is there a way that I can use the pre-compiled binary flash API and also receive the "success" and "failure" events for each flash?
Hmm, the responses I am describing are in the event stream (subscribed to via particle subscribe mine in another terminal via Particle CLI). What does your HTTP request look like? I am not familiar with the pf oled command you are using.
Got it. OK, I think that is similar to what I am seeing, and maybe this points me at the answer: what is the difference between what the Particle CLI tool is doing with that command, and my PUT request to the flash device with pre-built binary API.
Like i said, when you use a REST API endpoint, you will be returned with a response and the response will be a one time reply. In this case it will be as you saw: spark/flash/status: started
If you want to look at the events that are published which contains more information about the flashing status, you will need to subscribe to your event stream.
Sorry I am not being clear. I understand that that the events I am looking for are in the event stream, and not responses to the REST API. What I am trying to say, is that when I call the REST API, and monitor the event stream, the event stream is not giving me the spark/flash/status: success event. Because the only difference between what I am doing and what you are showing appears to be your use of the Particle CLI tool and my use of my own client library to do the REST API call, I assume the behavior I am observing is related to how I am calling the REST API.
I was able to reproduce the issue I am having with only the Particle CLI tool. I think this is the same procedure as @kennethlimcp posted above, except instead of a spark/flash/status: success message I receive a spark/status: offline message, followed immediately by my firmware starting up and doing its initial sync with our cloud:
The firmware is running in semi-automatic mode with the system thread enabled. Is there something we might be doing in the firmware that is interfering with this event being raised? I note that sometimes I do see the spark/flash/status: success message when running the flash with the Particle CLI tool, but the majority the cases appear like this.
I have noticed that having SYSTEM_THREAD(ENABLED) sometimes “messes” with OTA updates under some obscure circumstances.
After an apparent reset the device “restarts” but still running the old firmware but when you wait a second or two another proper reset will happen finishing off the update.
This also trips the sucess/fail check by the cloud.
If I want to be in the save I put my device into Safe Mode first before starting the OTA update.