Hi,
I've used adafruit_requests.mpy from adafruit-circuitpython-bundle-7.x-mpy-20211013.zip with adafruit-circuitpython-unexpectedmaker_tinys2-en_GB-20211014-2d2d9b4.uf2 and your example code from https://learn.adafruit.com/adafruit-met ... ernet-test
As you'll see from the log below, it connects to my WiFi, gets and IP, is able to ping Google, but then fails when trying the basic HTTP get of http://wifitest.adafruit.com/testwifi/index.html, which should return "This is a test of Adafruit WiFi! If you can read this, its working :)"
Connecting to NETGEAR_11N
Connected to NETGEAR_11N!
My IP address is 10.0.0.146
Ping google.com: 9.999996 ms
Fetching text from http://wifitest.adafruit.com/testwifi/index.html
Traceback (most recent call last):
File "code.py", line 41, in <module>
File "adafruit_requests.py", line 615, in get
File "adafruit_requests.py", line 556, in request
File "adafruit_requests.py", line 428, in _get_socket
TypeError: extra positional arguments given
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
Any ideas, please?
Internet library issues? CircuitPython 7.n
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Internet library issues? CircuitPython 7.n
It looks like this part of the error is going to be the crux of it.
Can you post your code so I can determine which line is the culprit and we can figure it out form there. Please paste you code using CODE brackets.
I know you are using a tinyS2 image that is from within a day of our library image. It is possible that the tinyS2 image requries an earlier adafruit_requests library for compatibilty. That or the code you are running is actually passing too many arguments.TypeError: extra positional arguments given
Can you post your code so I can determine which line is the culprit and we can figure it out form there. Please paste you code using CODE brackets.
- MARKSE
- Posts: 21
- Joined: Mon Apr 24, 2017 4:09 am
Re: Internet library issues? CircuitPython 7.n
The code now a mashup of the neopixel example from Unexpected maker and the Adafruit Wifi example.
Code: Select all
import time, gc, os
import neopixel
import board, digitalio
import tinys2
import ipaddress
import wifi
import socketpool
import ssl
import adafruit_requests
# URLs to fetch from
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
JSON_QUOTES_URL = "https://www.adafruit.com/api/quotes.php"
JSON_STARS_URL = "https://api.github.com/repos/adafruit/circuitpython"
# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
print("ESP32-S2 WebClient Test")
print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])
print("Available WiFi networks:")
for network in wifi.radio.start_scanning_networks():
print("\t%s\t\tRSSI: %d\tChannel: %d" % (str(network.ssid, "utf-8"),
network.rssi, network.channel))
wifi.radio.stop_scanning_networks()
print("Connecting to %s"%secrets["ssid"])
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("Connected to %s!"%secrets["ssid"])
print("My IP address is", wifi.radio.ipv4_address)
# Create a NeoPixel instance
# Brightness of 0.3 is ample for the 1515 sized LED
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3, auto_write=True, pixel_order=neopixel.RGB)
# Show available memory
print("Memory Info - gc.mem_free()")
print("---------------------------")
print("{} Bytes\n".format(gc.mem_free()))
flash = os.statvfs('/')
flash_size = flash[0] * flash[2]
flash_free = flash[0] * flash[3]
# Show flash size
print("Flash - os.statvfs('/')")
print("---------------------------")
print("Size: {} Bytes\nFree: {} Bytes\n".format(flash_size, flash_free))
print("Pixel Time!\n")
# Create a colour wheel index int
color_index = 0
# Turn on the power to the NeoPixel
tinys2.set_pixel_power(True)
while True:
# Rainbow colours on the NeoPixel
for x in range(300):
# Get the R,G,B values of the next colour
r,g,b = tinys2.rgb_color_wheel( color_index )
# Set the colour on the NeoPixel
pixel[0] = ( r, g, b, 0.5)
# Increase the wheel index
color_index += 1
# Sleep for 15ms so the colour cycle isn't too fast
time.sleep(0.01)
ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000))
attempts = 3 # Number of attempts to retry each request
failure_count = 0
response = None
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
print("Fetching text from URL %s" % TEXT_URL)
while not response:
try:
response = requests.get(TEXT_URL)
failure_count = 0
except AssertionError as error:
print("Request failed, retrying...\n", error)
failure_count += 1
if failure_count >= attempts:
raise AssertionError(
"Failed to resolve hostname, \
please check your router's DNS configuration."
) from error
continue
print("-" * 40)
print("Text Response: ", response.text)
print("-" * 40)
response.close()
response = None
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Internet library issues? CircuitPython 7.n
It looks like the code.py you have submitted here and the one that you provided an error message for are not a match as line 41 is a commented out line above the NeoPixel settings.
Do you have a new error message that matches the current code?
Code: Select all
# Brightness of 0.3 is ample for the 1515 sized LED
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.3, auto_write=True, pixel_order=neopixel.RGB)
Please be positive and constructive with your questions and comments.