Where required code is stored

I have an RGB tail and am using this class …

// Device Code
#require “WS2812.class.nut:2.0.1”

Does this class get stored in the Imp memory, or does the imp have to get it from the agent each time it is powered up?

I’m wondering about running the RGB tail even if the imp gets too far away from WiFi, or loses WiFi. If agent is required, then can the class be put within the device code instead of using #require?

The #requires are pulled in at compilation time and the total code (requires and your code compiled to bytecode) are cached on the device so they can run regardless of whether there is a network connection.

You should look at the connection manager class - see https://electricimp.com/docs/libraries/utilities/connectionmanager/ - note you should instantiate this (or set the send timeout policy to be RETURN_ON_ERROR) if you want your code to not block on any failing network connects. You must do this before any of your code calls anything that might cause network activity (eg: server.log, agent.send, etc).

Thanks Hugo.