Skip to content

Commit a153696

Browse files
committed
Fixes adafruit#48
Adds airlift to example
1 parent eb116da commit a153696

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

adafruit_requests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,11 @@ def wrap_socket(self, socket, server_hostname=None):
652652
def set_socket(sock, iface=None):
653653
"""Legacy API for setting the socket and network interface. Use a `Session` instead."""
654654
global _default_session # pylint: disable=global-statement,invalid-name
655-
_default_session = Session(sock, _FakeSSLContext(iface))
656-
if iface:
657-
sock.set_interface(iface)
655+
if not iface:
656+
_default_session = Session(sock, _FakeSSLContext(sock._the_interface))
657+
else:
658+
_default_session = Session(sock, _FakeSSLContext(iface))
659+
sock.set_interface(iface)
658660

659661

660662
def request(method, url, data=None, json=None, headers=None, stream=False, timeout=1):

examples/requests_simpletest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
# esp32_ready = DigitalInOut(board.D10)
3030
# esp32_reset = DigitalInOut(board.D5)
3131

32+
# If you have an AirLift Featherwing or ItsyBitsy Airlift:
33+
# esp32_cs = DigitalInOut(board.D13)
34+
# esp32_ready = DigitalInOut(board.D11)
35+
# esp32_reset = DigitalInOut(board.D12)
36+
3237
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
3338
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
3439

@@ -46,8 +51,8 @@
4651
requests.set_socket(socket, esp)
4752

4853
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
49-
JSON_GET_URL = "http://httpbin.org/get"
50-
JSON_POST_URL = "http://httpbin.org/post"
54+
JSON_GET_URL = "https://httpbin.org/get"
55+
JSON_POST_URL = "https://httpbin.org/post"
5156

5257
print("Fetching text from %s" % TEXT_URL)
5358
response = requests.get(TEXT_URL)

0 commit comments

Comments
 (0)