Skip to content

Modify esp32 socket.write to reflect socket core module api #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion adafruit_esp32spi/adafruit_esp32spi_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ def connect(self, address, conntype=None):
raise RuntimeError("Failed to connect to host", host)
self._buffer = b''

def write(self, data): # pylint: disable=no-self-use
def send(self, data): # pylint: disable=no-self-use
"""Send some data to the socket"""
_the_interface.socket_write(self._socknum, data)
gc.collect()

def write(self, data):
"""Sends data to the socket."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a note this is deprecated, and will be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted!

self.send(data)

def readline(self):
"""Attempt to return as many bytes as we can up to but not including '\r\n'"""
#print("Socket readline")
Expand Down
6 changes: 3 additions & 3 deletions adafruit_esp32spi/adafruit_esp32spi_wsgiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ def finish_response(self, result):
for header in self._response_headers:
response += "{0}: {1}\r\n".format(*header)
response += "\r\n"
self._client_sock.write(response.encode("utf-8"))
self._client_sock.send(response.encode("utf-8"))
for data in result:
if isinstance(data, bytes):
self._client_sock.write(data)
self._client_sock.send(data)
else:
self._client_sock.write(data.encode("utf-8"))
self._client_sock.send(data.encode("utf-8"))
gc.collect()
finally:
print("closing")
Expand Down