Wait for AT response

That’s basically a state machine; with the semaphore encoding just 3 states - red, yellow, and green.

It would probably be better to use more meaningful state names; eg IMEI Requested, IMEI Not Available, IMEI Available.