Every time I want to reflash my photon it starts blinking purple but then takes about a minute to respond, sometimes just going back to its previous routine. It usually took about 5-10 seconds. Same wifi and everything else.
im using:
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);
could that be a problem?
there is a small part of my code that takes about 20 seconds running “blindly” (using delays and such), each second im executing:
Particle.process();
since I was told to run it as often as possible.
Impossible to say without seeing your code. You’re using SYSTEM_MODE(MANIAL) and you say you have a long running process in your loop. We would need to see your code to tell you what’s going on.
the code being run is this.
sorry for the bad indentation:
for(int i=0;i<multiples;i++){ //20 times
if (publishnow==0){i=multiples;} .
long timer1=millis();
int flagflow = 0;
pulses=0;
do{
if(interruptflag==1){timer1=millis()+TiempoLectura;}
if(digitalRead(flowpin) == LOW){
if(flagflow == 0)
{
pulses++; //count +1 every FALLING
flagflow=1;
Serial.print((int)pulses); Serial.print(" ");
}
}
else if(digitalRead(flowpin) == HIGH) {flagflow=0;}
}
while (millis() - timer1 < 1000 ); //do it for 1000ms
if(WiFi.ready()){ //this is kind of irrelevant
if(Particle.connected){
Particle.process();
}
}
Serial.print(flow); Serial.println(" ");
the rest is code that runs very quickly
the terminal window shows the prints and it never gets updated while the 20 repetitions happen, only afterwards. My question is, when is the code updated? shouldnt the photon interrupt whatever it is doing and update the code immediately?
One minute seems like not much but it gets boring after a while.
Not when running SYSTEM_THREAD(ENABLED).
The downloading of the application binary will be done in parallel. Only once the entire module is downloaded the actual flashing can kick in and that's when your running application will be stopped.
And as @mjones already mentioned you may also see a device OS update happening which will take considerably longer as it needs to update multiple modules with a reset/reconnect cycle for each.
You should put the Particle.process() into that do ... while() loop.