24.05.2024, 08:45
Disable SMS script and 3g/4g connection then run this script once and post what you get in Logs. Don't forget to change apn variable value.
Code:
apn = 'PUT_YOUR_APN_HERE'
dial = '*99***1#'
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: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
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
sendlog('AT+CGDCONT=1,"IP","' .. apn .. '"') -- set apn
sendlog('ATD' .. dial) -- connect
res = table.concat(buf)
log(res)