docs: def _modem_sm(self):
          """Handle modem response state machine."""
          import datetime
  
          read_timeout = READ_IDLE_TIMEOUT
          while self.ser:
              try:
                  resp = self.read(read_timeout)
              except (serial.SerialException, SystemExit, TypeError):
                  _LOGGER.debug('Unable to read from port %s', self.port)
                  break
  
              if self.state != self.STATE_IDLE and len(resp) == 0:
                  read_timeout = READ_IDLE_TIMEOUT
                  self.set_state(self.STATE_IDLE)
                  self.incomingcallnotificationfunc(self.state)
                  continue
  
              resp = resp.decode()
              resp = resp.strip('\r\n')
              if self.cmd_response == '':
                  self.cmd_responselines.append(resp)
              _LOGGER.debug('mdm: %s', resp)
  
              if resp in ['OK', 'ERROR']:
                  self.cmd_response = resp
                  continue
  
              if resp in ['RING']:
                  if self.state == self.STATE_IDLE:
                      self.cid_name = ''
                      self.cid_number = ''
                      self.cid_time = datetime.datetime.now()
  
                  self.set_state(self.STATE_RING)
                  self.incomingcallnotificationfunc(self.state)
                  read_timeout = READ_RING_TIMOUT
                  continue
  
              if len(resp) <= 4 or resp.find('=') == -1:
                  continue
  
              read_timeout = READ_RING_TIMOUT
              cid_field, cid_data = resp.split('=')
              cid_field = cid_field.strip()
              cid_data = cid_data.strip()
              if cid_field in ['DATE']:
                  self.cid_time = datetime.datetime.now()
                  continue
  
              if cid_field in ['NMBR']:
                  self.cid_number = cid_data
                  continue
  
              if cid_field in ['NAME']:
                  self.cid_name = cid_data
                  self.set_state(self.STATE_CALLERID)
                  self.incomingcallnotificationfunc(self.state)
                  _LOGGER.debug('CID: %s %s %s',
                                self.cid_time.strftime("%I:%M %p"),
                                self.cid_name,
                                self.cid_number)
                  try:
                      self.write(self.cmd_callerid)
                  except serial.SerialException:
                      _LOGGER.error('Unable to write to port %s', self.port)
                      break
  
              continue
  
          self.set_state(self.STATE_FAILED)
          _LOGGER.debug('Exiting modem state machine')
          return