This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

reactor not get ip from GSM
#19
Connect script fails because of "NO CARRIER" message meaning that there's no mobile connection.

Run this updated script and post what you get in Logs:
Code:
io.writefile('/sys/class/gpio/export', 8)
io.writefile('/sys/class/gpio/export', 71)

io.writefile('/sys/class/gpio/gpio8/direction', 'high')
os.sleep(1)
io.writefile('/sys/class/gpio/gpio8/direction', 'low')

io.writefile('/sys/class/gpio/gpio71/direction', 'high')

tty1 = '/dev/ttyACM3'
tty2 = '/dev/ttyUSB2'

for i = 1, 20 do
  os.sleep(1)

  if io.exists(tty1) then
    tty = tty1
    break
  elseif io.exists(tty2) then
    tty = tty2
    break
  end
end

if not tty then
  log('init failed')
  return
end

buf = {}

function send(cmd, timeout)
  port:flush()
  port:write(cmd .. '\r\n')
  local res, err = port:read(1000, timeout or 1)
  return res, err
end

function sendlog(cmd, timeout)
  local res = send(cmd, timeout)

  if res then
    buf[ #buf + 1 ] = res
  end

  return res
end

port = require('serial').open(tty)
log('open port', tty)

for i = 1, 20 do
  res = send('AT')
  if res then
    break
  end
end

if not res then
  log('no response')
  return
end

sendlog('AT&F', 10) -- reset settings
sendlog('ATE1') -- echo enabled

function readstatus()
  local data, res, simok, network

  data = sendlog('AT+CSQ')

  if data then
    res = data:match('+CSQ: (%d+)')
    res = tonumber(res)

    if res then
      log('Signal: ' .. tostring(res))
    else
      log('Signal: no response')
    end
  else
    log('Signal: no data from port')
  end

  data = sendlog('AT+CPIN?') or ''

  if data:find('CME ERROR') then
    log('SIM: not found')
  elseif data:find('+CPIN: READY') then
    log('SIM: OK')
    simok = true
  else
    log('SIM: unknown')
  end

  data = sendlog('AT+COPS?')

  if data then
    res = data:match('+COPS: %d+,%d+,"(.*)",%d+')

    if res then
      log('Network: ' .. tostring(res))
      network = res
    else
      log('Network: no info')
    end
  else
    log('Network: no data from port')
  end

  return simok and network
end

for i = 1, 20 do
  if readstatus() then
    break
  end
end

res = table.concat(buf)
log(res)
Reply


Messages In This Thread
reactor not get ip from GSM - by Frank68 - 23.05.2024, 07:28
RE: reactor not get ip from GSM - by admin - 23.05.2024, 07:52
RE: reactor not get ip from GSM - by Frank68 - 23.05.2024, 07:56
RE: reactor not get ip from GSM - by admin - 23.05.2024, 07:58
RE: reactor not get ip from GSM - by Frank68 - 23.05.2024, 08:08
RE: reactor not get ip from GSM - by admin - 23.05.2024, 08:11
RE: reactor not get ip from GSM - by Frank68 - 23.05.2024, 08:17
RE: reactor not get ip from GSM - by admin - 23.05.2024, 08:31
RE: reactor not get ip from GSM - by Frank68 - 23.05.2024, 08:39
RE: reactor not get ip from GSM - by admin - 23.05.2024, 08:48
RE: reactor not get ip from GSM - by Frank68 - 23.05.2024, 08:51
RE: reactor not get ip from GSM - by Frank68 - 24.05.2024, 06:27
RE: reactor not get ip from GSM - by admin - 24.05.2024, 07:31
RE: reactor not get ip from GSM - by Frank68 - 24.05.2024, 07:44
RE: reactor not get ip from GSM - by admin - 24.05.2024, 08:45
RE: reactor not get ip from GSM - by Frank68 - 24.05.2024, 08:56
RE: reactor not get ip from GSM - by admin - 24.05.2024, 08:59
RE: reactor not get ip from GSM - by Frank68 - 24.05.2024, 09:04
RE: reactor not get ip from GSM - by admin - 24.05.2024, 09:27
RE: reactor not get ip from GSM - by Frank68 - 24.05.2024, 09:35
RE: reactor not get ip from GSM - by admin - 24.05.2024, 09:40

Forum Jump: