Currently the invocation and behavior of System.connect() is controlled (partially) by the SYSTEM_MODE() macro.
However, there are cases where I’d like to, for example, use SEMI_AUTOMATIC mode, but still be able to have System.connect() return in a non-blocking fashion as it does in MANUAL mode.
I propose the following change:
current prototype: void System.connect(void);
Proposed: bool System.connect(int32_t timeout = 0);
If timeout < 0, run in non-blocking mode, start the connection in the background and return immediately. (as is default in MANUAL mode).
If timeout == 0, behave as is standard today, based on SYSTEM_MODE() setting.
If timeout > 0, start the connection process and then wait up to timeout milliseconds for System.connected() to be true. Return at the first of System.connected()==true (return true) or timeout exceeded (return false).
In all cases, the return value should be the same as System.connected(), true if connection is established at the time of return, false otherwise.
I believe this functionality would be very useful for a variety of battery and other low-power scenarios.