Skip to content

Commit ab36ca2

Browse files
author
brentru
committed
rewrite hostname parsing
1 parent d0a129a commit ab36ca2

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

adafruit_fona/adafruit_fona.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -506,23 +506,28 @@ def get_host_by_name(self, hostname):
506506
:param str hostname: Destination server.
507507
508508
"""
509-
self._read_line()
510509
if self._debug:
511510
print("*** get_host_by_name: ", hostname)
512511
if isinstance(hostname, str):
513512
hostname = bytes(hostname, "utf-8")
514513

515-
self._uart.write(b'AT+CDNSGIP="' + hostname + b'"\r\n')
516-
514+
self._read_line()
515+
self._uart.reset_input_buffer()
517516

518-
if not self._expect_reply(REPLY_OK):
519-
print("retin")
517+
if self._debug:
518+
print("\t---> AT+CDNSGIP=", hostname)
519+
520+
if not self._send_check_reply(b'AT+CDNSGIP="' + hostname + b'"\r\n', reply=REPLY_OK):
520521
return False
521-
# eat the blank line
522-
self._read_line()
523-
# parse the 3rd line
524-
self._read_line()
525522

523+
# self._uart.write(b'AT+CDNSGIP="' + hostname + b'"\r\n')
524+
# if not self._expect_reply(REPLY_OK):
525+
# return False
526+
527+
# parse the second response
528+
self._read_line()
529+
if self._debug:
530+
print("\t<--- ", self._buf)
526531
self._parse_reply(b"+CDNSGIP:", idx=2)
527532
return self._buf
528533

examples/fona_simpletest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# Initialize FONA module (this may take a few seconds)
2828
fona = FONA(uart, rst)
2929

30-
print("Adafruit FONA WebClient Test")
31-
3230
# Enable GPS
3331
fona.gps = True
3432

0 commit comments

Comments
 (0)