TTGO-T-Call-V1-3-ESP32 - SIM800L - getaddrinfo DNS

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
fxmike08
Posts: 5
Joined: Wed Feb 05, 2020 1:01 pm

TTGO-T-Call-V1-3-ESP32 - SIM800L - getaddrinfo DNS

Post by fxmike08 » Sat Aug 29, 2020 12:49 pm

Hi everybody,

I'm trying to use micropython 1.12 with TTGO-T-Call-V1-3-ESP32. I managed to create a custom module based on https://raw.githubusercontent.com/lobor ... 2/modgsm.c with some modification.

Everything works fine except when trying to call:

Code: Select all

>>> socket.getaddrinfo('212.237.59.104', 80)
[(2, 1, 0, '212.237.59.104', ('212.237.59.104', 80))]
>>> socket.getaddrinfo('micropython.org', 80)
[]

It's always returning an empty list. I think is because I'm using "internet" from my gsm custom module. Somehow is unable to resolve that DNS address. If I try directly with the IP address is working.

My python code is: https://github.com/Xinyuan-LilyGO/LilyG ... Bo/main.py

Any idea?

Thanks.
Last edited by fxmike08 on Sat Aug 29, 2020 1:05 pm, edited 1 time in total.

User avatar
Roberthh
Posts: 3668
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: TTGO-T-Call-V1-3-ESP32 - SIM800L - getaddrinfo DNS

Post by Roberthh » Sat Aug 29, 2020 12:56 pm

What happens if you use the full url
Http://micopython.org

fxmike08
Posts: 5
Joined: Wed Feb 05, 2020 1:01 pm

Re: TTGO-T-Call-V1-3-ESP32 - SIM800L - getaddrinfo DNS

Post by fxmike08 » Sat Aug 29, 2020 1:04 pm

Still empty.

Code: Select all

>>> socket.getaddrinfo('http://micropython.org', 80)
[]
As I suspected if I connect to WLAN is working:
>> socket.getaddrinfo('micropython.org', 80)
[(2, 1, 0, 'micropython.org', ('176.58.119.26', 80))]

Code: Select all

>>> wlan.connect('SSID', '******') # connect to an AP
>>> I (319901) wifi: new:<2,0>, old:<1,0>, ap:<255,255>, sta:<2,0>, prof:1
I (320751) wifi: state: init -> auth (b0)
I (320751) wifi: state: auth -> assoc (0)
I (320761) wifi: new:<2,1>, old:<2,0>, ap:<255,255>, sta:<2,1>, prof:1
I (320761) wifi: state: assoc -> run (10)
I (320771) wifi: connected with SSID, channel 2, 40U, bssid = 14:22:33:e8:39:d8
I (320771) wifi: pm start, type: 1

I (320781) network: CONNECTED
I (320831) wifi: new:<2,0>, old:<2,1>, ap:<255,255>, sta:<2,0>, prof:1

>>>
>>>
>>> I (323261) event: sta ip: 192.168.89.5, mask: 255.255.255.0, gw: 192.168.89.1
I (323261) network: GOT_IP
>>> gsm.disconnect()
I (351441) [PPPOS CLIENT]: Disconnect requested.
W (351481) [PPPOS CLIENT]: status_cb: User interrupt (disconnected)
I (352581) [PPPOS CLIENT]: AT COMMAND: [AT..]
I (352601) [PPPOS CLIENT]: AT RESPONSE: [..OK..]
I (352601) [PPPOS CLIENT]: Disconnected.
True
>>>
>>>
>>> socket.getaddrinfo('micropython.org', 80)
[(2, 1, 0, 'micropython.org', ('176.58.119.26', 80))]

If I try to disconnect from WLAN and connect back to gsm:

Code: Select all


>>> wlan.disconnect()
>>> I (896081) wifi: STA_DISCONNECTED, reason:8

>>> gsm.connect()
I (912101) [PPPOS CLIENT]: Reconnect requested.
I (912101) [PPPOS CLIENT]: GSM initialization start
I (912701) [PPPOS CLIENT]: AT COMMAND: [AT..]
	...
I (915711) [PPPOS CLIENT]: GSM initialized.
I (916601) [PPPOS CLIENT]: status_cb: Connected
I (916601) [PPPOS CLIENT]:    ipaddr    = 10.4.93.171
I (916601) [PPPOS CLIENT]:    gateway   = 192.168.254.254
I (916611) [PPPOS CLIENT]:    netmask   = 255.255.255.255
I (916611) [PPPOS CLIENT]:    ip6addr   = ::
>>> socket.getaddrinfo('google.com', 80)
[]
>>> socket.getaddrinfo('micropython.org', 80)
[(2, 1, 0, 'micropython.org', ('176.58.119.26', 80))]
>>> socket.getaddrinfo('google.com', 80)
[]
>>> I (1016081) event: station ip lost
I (1016081) network: event 8

>>> addr = socket.getaddrinfo('172.217.16.110', 80)[0][-1]
>>> s = socket.socket()
>>> s.connect(addr)
>>> s.send(b'GET / HTTP/1.1\r\nHost: google.com\r\n\r\n')
36
>>> data = s.recv(1000)
>>> print(data)
b'HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.google.com/\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Sat, 29 Aug 2020 13:21:03 GMT\r\nExpires: Mon, 28 Sep 2020 13:21:03 GMT\r\nCache-Control: public, max-age=2592000\r\nServer: gws\r\nContent-Length: 219\r\nX-XSS-Protection: 0\r\nX-Frame-Options: SAMEORIGIN\r\n\r\n<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">\n<TITLE>301 Moved</TITLE></HEAD><BODY>\n<H1>301 Moved</H1>\nThe document has moved\n<A HREF="http://www.google.com/">here</A>.\r\n</BODY></HTML>\r\n'
>>> s.close()

If I connect to WIFI this is working...any idea how I could make this work by only using my "gsm" custom module. The module is an external C module...

Thanks.

fxmike08
Posts: 5
Joined: Wed Feb 05, 2020 1:01 pm

Re: TTGO-T-Call-V1-3-ESP32 - SIM800L - getaddrinfo DNS

Post by fxmike08 » Sat Aug 29, 2020 3:42 pm

Found a quick solution ... wlan.ifconfig(('0.0.0.0', '255.255.255.0', '0.0.0.0', '8.8.8.8'))
This will set the DNS... and then it will work ... I'm looking for a way to set the DNS directly from C code. Any idea ?

Post Reply