I'm wanting to loop on the CREG/CEREG phase to detect when the module connects but I'm not sure how I would incorporate that into the promise chain - or whether to use a promise chain. My first thought is a finite state machine, but how would I have the callback call the state machine? My initial solution is to have an interval timer call the state machine that issues the command and the callback sets a flag then tells the code to clock the machine .
Basically, issue CREG?/CEREG? at a regular interval until the module reports online or we try too many times and error out. The reason being the connect phase is power hungry and is variable so detecting it early is an advantage. The current 30 seconds seems to be either too long or not quite long enough.
© Espruino, powered by microcosm.
Report a problem