|
29 | 29 | import struct
|
30 | 30 | import time
|
31 | 31 | from micropython import const
|
32 |
| -from digitalio import Direction |
33 | 32 | from adafruit_bus_device.spi_device import SPIDevice
|
| 33 | +from digitalio import Direction |
34 | 34 |
|
35 | 35 | __version__ = "0.0.0-auto.0"
|
36 | 36 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI.git"
|
|
70 | 70 | _START_SCAN_NETWORKS = const(0x36)
|
71 | 71 | _GET_FW_VERSION_CMD = const(0x37)
|
72 | 72 | _SEND_UDP_DATA_CMD = const(0x39)
|
| 73 | +_GET_REMOTE_DATA_CMD = const(0x3A) |
73 | 74 | _GET_TIME = const(0x3B)
|
74 | 75 | _GET_IDX_BSSID_CMD = const(0x3C)
|
75 | 76 | _GET_IDX_CHAN_CMD = const(0x3D)
|
|
127 | 128 | ADC_ATTEN_DB_6 = const(2)
|
128 | 129 | ADC_ATTEN_DB_11 = const(3)
|
129 | 130 |
|
| 131 | +# pylint: disable=too-many-lines |
| 132 | + |
130 | 133 |
|
131 | 134 | class ESP_SPIcontrol: # pylint: disable=too-many-public-methods, too-many-instance-attributes
|
132 | 135 | """A class that will talk to an ESP32 module programmed with special firmware
|
@@ -847,6 +850,14 @@ def server_state(self, socket_num):
|
847 | 850 | resp = self._send_command_get_response(_GET_STATE_TCP_CMD, self._socknum_ll)
|
848 | 851 | return resp[0][0]
|
849 | 852 |
|
| 853 | + def get_remote_data(self, socket_num): |
| 854 | + """Get the IP address and port of the remote host""" |
| 855 | + self._socknum_ll[0][0] = socket_num |
| 856 | + resp = self._send_command_get_response( |
| 857 | + _GET_REMOTE_DATA_CMD, self._socknum_ll, reply_params=2 |
| 858 | + ) |
| 859 | + return {"ip_addr": resp[0], "port": struct.unpack("<H", resp[1])[0]} |
| 860 | + |
850 | 861 | def set_esp_debug(self, enabled):
|
851 | 862 | """Enable/disable debug mode on the ESP32. Debug messages will be
|
852 | 863 | written to the ESP32's UART."""
|
|
0 commit comments