gsmd. 1/ Need to make sure device is working. run muxer get a connection run CFUN? and CFUN=1 try COPS Check if Pin needed. Watch /var/run/gsm-state/pin to get number. If we cannot get anything useful, kill muxer power down, power up try again rate limit this severely. 2/ get suspend notification and request updates On every update and at least every 30 seconds, get signal strength Also check CFUN if 0, try COPS validate COPS every 5 minutes If COPS? is 0, get COPS=? every 10 minutes. or when Store state info in /var/run/gsm-state/ cell carrier strength activity newsms incoming signal_strength 3/ When a suspend is signalled disable notification of cellid and status - leave SMS allow suspend on wake, request updates ------------------------- When sending a command, need to "\r" to get attention If last reply was more than 5 seconds ago, send 'AT\r' every second until get a response, or reset. Wait for OK, then send command. Always expect async notifications and handle them directly. So: we need an 'init' string. ATV1;E0;+CMEE=2;+CRC=1; Then some settings that we can check and set. +CFUN? +CFUN: (\d+) 0 +CFUN=1 +COPS? +COPS: (.*) 0 +COPS +CMFG? +CMFG: \d 0 +CMGF=1 +CPIN? +CPIN: READY Some things we just periodically get +CSQ +CSQ: \d+,\d+ CLIP CNMI CSCB So each of these settings has: - string to send to check - string to send to set - regexp to see if check or not - last send time - last recv time - count of attempts to set - current setting - poll timeout - handler to call on change I need to know: - phone is on - provider - cell id - signal strength - call state - incoming caller number - incoming TXT message I need to adjust to requested state: - active - suspend - flight mode Someone else worries about whether to answer calls etc. Flight mode must survive power-cycle. So it doesn't live in /var/volatile. Probably /var/state or /var/lib/misc Others are in /var/run places. There is /var/run/suspend/whatever and /var/run/gsm/{provider,cell,signal,state,CNI,lasttxt So states are: flight suspend idle incoming on-call For each of these, there is a collection of setting that we want to impose and monitor