Error "OSError: 118"
Posted: Thu Jul 04, 2019 2:38 pm
I need to run a URL and it is giving this error "Error" OSError: 118 " when I execute the command" s.connect (addr) "
Below my code:
import time
import sys
from machine import UART, Pin
import socket
startgprs = Pin (26, Pin.OUT)
ledpower = Pin (19, Pin.OUT)
ledgprs = Pin (23, Pin.OUT)
ledgps = Pin (18, Pin.OUT)
led = Pin (22, Pin.OUT)
phone = UART (1, baudrate = 9200, rx = 16, tx = 17, timeout = 10)
answer = ""
led (0)
ledgprs (0)
ledgps (0)
ledpower (1)
def executes (with):
res = (phone.read ())
phone.write (b '% s \ r'% (with))
time.sleep (0.5)
res = (phone.read ())
return res
def command (with):
res = (phone.read ())
phone.write (b '% s \ r'% (with))
return
def connectgprs ():
startgprs (1)
time.sleep (3)
startgprs (0)
def connect gps ():
time.sleep (3)
command ('AT + CGNSPWR = 1')
def http_get (host, path):
print (host)
print (path)
addr = socket.getaddrinfo (host, 80) [0] [- 1]
s = socket.socket ()
s.connect (addr)
s.send (bytes ('GET /% s HTTP / 1.0 \ r \ nHost:% \ path \ host \' utf8 '))
while True:
date = s.recv (100)
if data:
print (str (data, 'utf8'), end = '')
else:
break
http_get ('x.x.x.x', 'gps_recebedados.php')
I believe this error is because I can not get on the internet.
Because I'm using an ESP32 and an ev80 SIM808.
I can send SMS through this SIM808 module. But I was not sure if I still surf the internet with him.
In C ++ I can execute this URL.
How can I test this output for the internet.
I'm not going to use wifi in this project.
Thank you!
Below my code:
import time
import sys
from machine import UART, Pin
import socket
startgprs = Pin (26, Pin.OUT)
ledpower = Pin (19, Pin.OUT)
ledgprs = Pin (23, Pin.OUT)
ledgps = Pin (18, Pin.OUT)
led = Pin (22, Pin.OUT)
phone = UART (1, baudrate = 9200, rx = 16, tx = 17, timeout = 10)
answer = ""
led (0)
ledgprs (0)
ledgps (0)
ledpower (1)
def executes (with):
res = (phone.read ())
phone.write (b '% s \ r'% (with))
time.sleep (0.5)
res = (phone.read ())
return res
def command (with):
res = (phone.read ())
phone.write (b '% s \ r'% (with))
return
def connectgprs ():
startgprs (1)
time.sleep (3)
startgprs (0)
def connect gps ():
time.sleep (3)
command ('AT + CGNSPWR = 1')
def http_get (host, path):
print (host)
print (path)
addr = socket.getaddrinfo (host, 80) [0] [- 1]
s = socket.socket ()
s.connect (addr)
s.send (bytes ('GET /% s HTTP / 1.0 \ r \ nHost:% \ path \ host \' utf8 '))
while True:
date = s.recv (100)
if data:
print (str (data, 'utf8'), end = '')
else:
break
http_get ('x.x.x.x', 'gps_recebedados.php')
I believe this error is because I can not get on the internet.
Because I'm using an ESP32 and an ev80 SIM808.
I can send SMS through this SIM808 module. But I was not sure if I still surf the internet with him.
In C ++ I can execute this URL.
How can I test this output for the internet.
I'm not going to use wifi in this project.
Thank you!