summaryrefslogtreecommitdiff
path: root/ports/esp32s2
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-08-11 14:50:37 -0700
committerScott Shawcroft <scott@tannewt.org>2020-08-19 14:22:13 -0700
commit7bdd243bf6f3cd84ddfd9cf6f35a2d6d8a6a415f (patch)
tree5f5e4b98d6ffa479ecd1f032da01cc999afe3732 /ports/esp32s2
parent3860991111511a9e4a60ea24f208b8de8f801ce7 (diff)
Ping works!
Diffstat (limited to 'ports/esp32s2')
-rw-r--r--ports/esp32s2/common-hal/wifi/Radio.c1
-rw-r--r--ports/esp32s2/common-hal/wifi/__init__.c14
-rw-r--r--ports/esp32s2/common-hal/wifi/__init__.h4
3 files changed, 19 insertions, 0 deletions
diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c
index 49ad0592e..d4f17f2bb 100644
--- a/ports/esp32s2/common-hal/wifi/Radio.c
+++ b/ports/esp32s2/common-hal/wifi/Radio.c
@@ -28,6 +28,7 @@
#include <string.h>
+#include "common-hal/wifi/__init__.h"
#include "lib/utils/interrupt_char.h"
#include "py/runtime.h"
#include "shared-bindings/ipaddress/IPv4Address.h"
diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c
index 1dc9ef9a8..eb033256d 100644
--- a/ports/esp32s2/common-hal/wifi/__init__.c
+++ b/ports/esp32s2/common-hal/wifi/__init__.c
@@ -24,6 +24,9 @@
* THE SOFTWARE.
*/
+#include "common-hal/wifi/__init__.h"
+
+#include "shared-bindings/ipaddress/IPv4Address.h"
#include "shared-bindings/wifi/Radio.h"
#include "py/runtime.h"
@@ -148,3 +151,14 @@ void wifi_reset(void) {
radio->netif = NULL;
ESP_ERROR_CHECK(esp_netif_deinit());
}
+
+void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t* esp_ip_address) {
+ if (!MP_OBJ_IS_TYPE(ip_address, &ipaddress_ipv4address_type)) {
+ mp_raise_ValueError(translate("Only IPv4 addresses supported"));
+ }
+ mp_obj_t packed = common_hal_ipaddress_ipv4address_get_packed(ip_address);
+ size_t len;
+ const char* bytes = mp_obj_str_get_data(packed, &len);
+
+ IP_ADDR4(esp_ip_address, bytes[0], bytes[1], bytes[2], bytes[3]);
+}
diff --git a/ports/esp32s2/common-hal/wifi/__init__.h b/ports/esp32s2/common-hal/wifi/__init__.h
index bb68bcfdf..d2bd06c57 100644
--- a/ports/esp32s2/common-hal/wifi/__init__.h
+++ b/ports/esp32s2/common-hal/wifi/__init__.h
@@ -29,6 +29,10 @@
#include "py/obj.h"
+#include "lwip/api.h"
+
void wifi_reset(void);
+void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t* esp_ip_address);
+
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_WIFI___INIT___H