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

Conversation

brentru
Copy link
Member

@brentru brentru commented Aug 29, 2019

Switching socket.write to socket.send to match the CircuitPython Socket API and the CPython Socket API.

Related library PRs:

Tested on: Adafruit CircuitPython 4.0.2 on 2019-06-27; Adafruit PyPortal with samd51j20

Tests ran:
esp32spi_simpletest.py - ESP + Requests

Code done running. Waiting for reload.
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
ESP32 SPI webclient test
ESP32 found and in idle mode
Firmware vers. bytearray(b'1.2.2\x00')
MAC addr: ['SNIP', '0x31', '0xe', '0x33', '0x4f', '0xc4']
SNIP
Connecting to AP...
Connected to SNIP   RSSI: -48
My IP address is SNIP
IP lookup adafruit.com: SNIP
Ping google.com: 10 ms
Fetching text from http://wifitest.adafruit.com/testwifi/index.html
----------------------------------------
This is a test of Adafruit WiFi!
If you can read this, its working :)

----------------------------------------

Fetching json from http://api.coindesk.com/v1/bpi/currentprice/USD.json
----------------------------------------
{'time': {'updated': 'Aug 29, 2019 16:28:00 UTC', 'updatedISO': '2019-08-29T16:28:00+00:00', 'updateduk': 'Aug 29, 2019 at 17:28 BST'}, 'disclaimer': 'This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org', 'bpi': {'USD': {'code': 'USD', 'description': 'United States Dollar', 'rate_float': 9504.23, 'rate': '9,504.2283'}}}
----------------------------------------
Done!

esp32spi_aio_post.py - WiFiManager + Requests

code.py output:
ESP32 SPI webclient test
Posting data...{'lat': None, 'feed_id': 997503, 'ele': None, 'expiration': '2019-10-28T16:29:22Z', 'id': '0E82Q1KT67MR5XGEDR29EW84KM', 'lon': None, 'value': '0', 'feed_key': 'test', 'location': None, 'created_at': '2019-08-29T16:29:22Z', 'created_epoch': 1567096162}
OK

esp32spi_wsgiserver.py - server + esp

ESP32 SPI simple web server test!
open this IP in your browser:  SNIP
closing
closing
closing
{'b': 240, 'g': 255, 'r': 133}
closing
{'b': 255, 'g': 250, 'r': 121}

@ladyada
Copy link
Member

ladyada commented Aug 29, 2019

to ease the transition please have a write = send function assignment so either works

@brentru
Copy link
Member Author

brentru commented Aug 29, 2019

@ladyada added and tested with the current (pre-PR'd) version of requests

"""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!

@brentru brentru merged commit e16dd06 into adafruit:master Aug 29, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 30, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 1.9.2 from 1.9.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#71 from brentru/switch-read
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#70 from brentru/sock-send
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#68 from mscosti/get_time_err_ap

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3DH to 5.0.1 from 5.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3DH#55 from jerryneedell/jerryn_adc
  > Merge pull request adafruit/Adafruit_CircuitPython_LIS3DH#53 from jerryneedell/jerryn_pygamer

Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 1.1.4 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#8 from brentru/switch-read
  > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#7 from brentru/sock-send

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.1.2 from v1.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#9 from brentru/switch-read
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#8 from brentru/sock-send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants