Instead of polling AT+CSQ? and later AT+CGATT? repeatedly, it might be nicer to issue AT+CEREG? during the startup. This will cause an Unsolicited Result Code (URC) to be sent:
+CEREG:0 when the radio is switched on.
+CEREG:2 when the cdp is set and the device starts to connect to the network.
+CEREG:1 (with additional data) once the device has successfully registered.
There are more responses indicating other interesting situations.
Instead of polling AT+CSQ? and later AT+CGATT? repeatedly, it might be nicer to issue AT+CEREG? during the startup. This will cause an Unsolicited Result Code (URC) to be sent:
+CEREG:0 when the radio is switched on. +CEREG:2 when the cdp is set and the device starts to connect to the network. +CEREG:1 (with additional data) once the device has successfully registered.
There are more responses indicating other interesting situations.
Source: SARA-N2 AT Commands Manual