Currently, the spark-protocol doesn't support OTA disable/enable functions on the device. When the OTA updates are disabled via calling System.disableUpdates(), the cloud tries to push OTA update, but fails and drops the connection to the device. The cloud doesn't recognize that the updates are disabled, dropping connections and trying OTA again - happening in a loop until the updates are enabled on the device again via System.enableUpdates().
We would like to disable updates for a couple of minutes after the startup of a device when there is a higher risk that the user will power-off the device again (tinkering with it). While the Photon should theoretically handle this, we've seen several cases (on a 700 devices fleet) when this exact thing resulted in the Photon getting stuck in OTA update - needed a manual flashing of the firmware over USB.
This is output from the cloud when trying to OTA to a device with disabled updates:
{"name":"Device.js","hostname":"DXXXX","pid":2137,"level":30,"deviceID":"3b002f000147393038000000","msg":"flash device started! - sending api event","time":"2021-04-30T08:26:10.917Z","v":0} {"name":"Flasher.js","hostname":"DXXXX","pid":2137,"level":30,"cache_key":"_6543","deviceID":"3b002f000147393038000000","msg":"fast ota enabled! ","time":"2021-04-30T08:26:10.917Z","v":0} {"name":"Device.js","hostname":"DXXXX","pid":2137,"level":30,"cache_key":"_6543","deviceID":"3b002f000147393038000000","duration":5.652,"disconnectCounter":1,"msg":"Device disconnected","time":"2021-04-30T08:26:16.437Z","v":0} {"name":"DeviceServer.js","hostname":"DXXXX","pid":2137,"level":40,"connectionKey":"_6543","deviceID":"3b002f000147393038000000","ownerID":null,"msg":"Session ended for Device","time":"2021-04-30T08:26:16.438Z","v":0} {"name":"Device.js","hostname":"DXXXX","pid":2137,"level":30,"deviceID":"3b002f000147393038000000","msg":"Releasing flash ownership","time":"2021-04-30T08:26:16.438Z","v":0} {"name":"Device.js","hostname":"DXXXX","pid":2137,"level":50,"deviceID":"3b002f000147393038000000","msg":"Flash device failed! - sending api event","time":"2021-04-30T08:26:16.439Z","v":0} {"name":"DeviceServer.js","hostname":"DXXXX","pid":2137,"level":50,"deviceID":"3b002f000147393038000000","err":{"message":"Cannot read property 'message' of undefined","name":"TypeError","stack":"TypeError: Cannot read property 'message' of undefined\n at Device._callee9$ (/usr/local/bin/spark-server/node_modules/spark-protocol/dist/clients/Device.js:1017:66)\n at tryCatch (/usr/local/bin/s park-server/node_modules/regenerator-runtime/runtime.js:62:40)\n at Generator.invoke [as _invoke] (/usr/local/bin/spark-server/node_modules/regenerator-runtime/runtime.js:296:22)\n at Generator.prototype.(anonymous function) [as throw] (/usr/local/bin/spark-server/node_modules/regenerator-runtime/runtime.js:114:21)\n at step (/usr/local/bin/spark-server/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)\n at /usr/local/bin/spark-server/node_modules/babel-runtime/helpers/asyncToGenerator.js:30:13\n at process._tickCallback (internal/process/next_tick.js:68:7)"},"msg":"Connection Error","time":"2021-04-30T08:26:16.439Z","v":0}