TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
208 stars 96 forks source link

Hide wait process in setup #44

Closed dorianamouroux closed 8 years ago

dorianamouroux commented 8 years ago
  // Wait a maximum of 10s for Serial Monitor
  while (!debugSerial && millis() < 10000);

I think this line can be put in the ttn.init() function. If it create a problem, we can add a third parameter to init to disable the wait. We can also create a separate function in ttn to do so.

FokkeZB commented 8 years ago

We should do this in ttn.init() indeed and add an argument to override the time out, defaulting to 10000.

johanstokking commented 8 years ago

Still do it relative to the time when the method has been called, otherwise the time-out will depend on how long things took before calling init.

Also, this is only necessary if a) you're connecting a serial monitor and b) it's important that you wait with your application until your serial monitor is connected. This is fine for prototyping, but I think it's good to be able to set the library in debug mode. If debug mode is on, we wait like this on init(), and if not, we don't wait. Then still, if you have a serial monitor connected, you will see output, but you don't have that 10 seconds start delay.

FokkeZB commented 8 years ago

On second thought, I'm not sure if we should do this at all. It makes it feel like a feature of the lib, while it's just an Arduino debug best practice.

johanstokking commented 8 years ago

Exactly, so if the user wants to do it, he or she will do it in setup()