Skip to content

New function get_remote_data() to expose NINA getRemoteData() #161

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
Mar 24, 2022
Merged
Changes from all 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
13 changes: 12 additions & 1 deletion adafruit_esp32spi/adafruit_esp32spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import struct
import time
from micropython import const
from digitalio import Direction
from adafruit_bus_device.spi_device import SPIDevice
from digitalio import Direction

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI.git"
Expand Down Expand Up @@ -70,6 +70,7 @@
_START_SCAN_NETWORKS = const(0x36)
_GET_FW_VERSION_CMD = const(0x37)
_SEND_UDP_DATA_CMD = const(0x39)
_GET_REMOTE_DATA_CMD = const(0x3A)
_GET_TIME = const(0x3B)
_GET_IDX_BSSID_CMD = const(0x3C)
_GET_IDX_CHAN_CMD = const(0x3D)
Expand Down Expand Up @@ -127,6 +128,8 @@
ADC_ATTEN_DB_6 = const(2)
ADC_ATTEN_DB_11 = const(3)

# pylint: disable=too-many-lines


class ESP_SPIcontrol: # pylint: disable=too-many-public-methods, too-many-instance-attributes
"""A class that will talk to an ESP32 module programmed with special firmware
Expand Down Expand Up @@ -847,6 +850,14 @@ def server_state(self, socket_num):
resp = self._send_command_get_response(_GET_STATE_TCP_CMD, self._socknum_ll)
return resp[0][0]

def get_remote_data(self, socket_num):
"""Get the IP address and port of the remote host"""
self._socknum_ll[0][0] = socket_num
resp = self._send_command_get_response(
_GET_REMOTE_DATA_CMD, self._socknum_ll, reply_params=2
)
return {"ip_addr": resp[0], "port": struct.unpack("<H", resp[1])[0]}

def set_esp_debug(self, enabled):
"""Enable/disable debug mode on the ESP32. Debug messages will be
written to the ESP32's UART."""
Expand Down