I’ve noticed that when changing the model running on an Imp the agent code doesn’t switch over to the new model’s agent code. The Imp device code gets loaded on the Imp and runs, but the agent code appears not to change. This leads to all sorts of problems if the models are quite different in terms of agent code.
In order to work around this problem, one must change a line in the agent code and save it, then cause the Imp and agent to start again.
Thanks PeterAP - The problem I encountered may be a corner case related to the Imp not waking from sleep…
If the Imp is not online when you change models, and you cause the Imp to come online by removing it from the socket and reinserting it, the Imp downloads the new code, but the agent doesn’t change and stays on the one from the previous model.
@TheBarrelShifter I have make a try just in IDE - switch between codes for not online imp. I have “mechanically” make a code changes for imps online, offline and reinserting imp and haven’t recognise any strange “working” or not “working”. Inserting download new code and Agent, I suppose, change too - everything is working as expected. But I havent take a look directly on Agent code - it’s changing or not.
I’ll try some variants a bit later - question is very important for me too.
I have tested 3 live Models containing different Device code and Agent code for 1 imp.
In all cases Model changing for Device follow by code change in Agent as well as in Device. Everything works as designed.
@TheBarrelShifter is it possible to download new code when imp is sleeping? I don’t know, need to check. As I understand - to get work with new code it’s necessary to download it. Do you see in IDE that code doesn’t change or imp is just working without changes?
I’m not saying that the code changes whilst the Imp is asleep. The Imp awakes from sleep and downloads new code at that point, however the agent code that is running doesn’t change. You end up with device code from the new model running on the Imp, but agent code from the old model running on the server.
I didn’t find it in the documentation either, I’m just saying what I see.
It seems logical, though, that if the Imp cannot obtain new code whilst it’s asleep (which it can’t as the wi-fi is off), then it obtains new code when it wakes up.
@TheBarrelShifter, I make some tests and cannot find that awake forces to download new code. I change model in IDE and imp still work with pervious model, awaking or continuous running. Only pressing “Run” make change.
Pushing “Run” will change the code straightaway if the imp is awake.
If the imp is asleep (or powered off), then what happens is, the first time it connects to the server after waking up again, it checks whether its code is now out-of-date (i.e. whether someone pushed “Run” while it was disconnected) and, if so, it downloads and runs the new code instead.
@DolfTraanberg, hmmm…red lines mess up “clear vision”. imp goes offline, then boot to online.
When red lines will disappear?
very necessary and good function, thanks!