summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/circuitpy_defns.mk23
-rw-r--r--py/circuitpy_mpconfig.h41
-rw-r--r--py/circuitpy_mpconfig.mk18
-rw-r--r--py/modbuiltins.c3
-rw-r--r--py/obj.h2
-rw-r--r--py/objexcept.c10
-rw-r--r--py/runtime.c8
-rw-r--r--py/runtime.h2
8 files changed, 103 insertions, 4 deletions
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 36524b2fb..04e38d81e 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -168,6 +168,9 @@ endif
ifeq ($(CIRCUITPY_I2CPERIPHERAL),1)
SRC_PATTERNS += i2cperipheral/%
endif
+ifeq ($(CIRCUITPY_IPADDRESS),1)
+SRC_PATTERNS += ipaddress/%
+endif
ifeq ($(CIRCUITPY_MATH),1)
SRC_PATTERNS += math/%
endif
@@ -228,6 +231,12 @@ endif
ifeq ($(CIRCUITPY_SHARPDISPLAY),1)
SRC_PATTERNS += sharpdisplay/%
endif
+ifeq ($(CIRCUITPY_SOCKETPOOL),1)
+SRC_PATTERNS += socketpool/%
+endif
+ifeq ($(CIRCUITPY_SSL),1)
+SRC_PATTERNS += ssl/%
+endif
ifeq ($(CIRCUITPY_STAGE),1)
SRC_PATTERNS += _stage/%
endif
@@ -264,6 +273,9 @@ endif
ifeq ($(CIRCUITPY_WATCHDOG),1)
SRC_PATTERNS += watchdog/%
endif
+ifeq ($(CIRCUITPY_WIFI),1)
+SRC_PATTERNS += wifi/%
+endif
ifeq ($(CIRCUITPY_PEW),1)
SRC_PATTERNS += _pew/%
endif
@@ -332,11 +344,20 @@ SRC_COMMON_HAL_ALL = \
rtc/__init__.c \
sdioio/SDCard.c \
sdioio/__init__.c \
+ socketpool/__init__.c \
+ socketpool/SocketPool.c \
+ socketpool/Socket.c \
+ ssl/__init__.c \
+ ssl/SSLContext.c \
supervisor/Runtime.c \
supervisor/__init__.c \
watchdog/WatchDogMode.c \
watchdog/WatchDogTimer.c \
watchdog/__init__.c \
+ wifi/Network.c \
+ wifi/Radio.c \
+ wifi/ScannedNetworks.c \
+ wifi/__init__.c \
ifeq ($(CIRCUITPY_BLEIO_HCI),1)
# Helper code for _bleio HCI.
@@ -414,6 +435,8 @@ SRC_SHARED_MODULE_ALL = \
fontio/__init__.c \
framebufferio/FramebufferDisplay.c \
framebufferio/__init__.c \
+ ipaddress/IPv4Address.c \
+ ipaddress/__init__.c \
sdcardio/SDCard.c \
sdcardio/__init__.c \
gamepad/GamePad.c \
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index d144f0ba8..0fafbe876 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -364,6 +364,13 @@ extern const struct _mp_obj_module_t terminalio_module;
#define TERMINALIO_MODULE
#endif
+#if CIRCUITPY_ESPIDF
+extern const struct _mp_obj_module_t espidf_module;
+#define ESPIDF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_espidf),(mp_obj_t)&espidf_module },
+#else
+#define ESPIDF_MODULE
+#endif
+
#if CIRCUITPY_FRAMEBUFFERIO
extern const struct _mp_obj_module_t framebufferio_module;
#define FRAMEBUFFERIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_framebufferio), (mp_obj_t)&framebufferio_module },
@@ -421,6 +428,13 @@ extern const struct _mp_obj_module_t i2cperipheral_module;
#define I2CPERIPHERAL_MODULE
#endif
+#if CIRCUITPY_IPADDRESS
+extern const struct _mp_obj_module_t ipaddress_module;
+#define IPADDRESS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ipaddress), (mp_obj_t)&ipaddress_module },
+#else
+#define IPADDRESS_MODULE
+#endif
+
#if CIRCUITPY_MATH
extern const struct _mp_obj_module_t math_module;
#define MATH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module },
@@ -574,6 +588,7 @@ extern const struct _mp_obj_module_t sdioio_module;
#define SDIOIO_MODULE
#endif
+
#if CIRCUITPY_SHARPDISPLAY
extern const struct _mp_obj_module_t sharpdisplay_module;
#define SHARPDISPLAY_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sharpdisplay),(mp_obj_t)&sharpdisplay_module },
@@ -581,6 +596,20 @@ extern const struct _mp_obj_module_t sharpdisplay_module;
#define SHARPDISPLAY_MODULE
#endif
+#if CIRCUITPY_SOCKETPOOL
+extern const struct _mp_obj_module_t socketpool_module;
+#define SOCKETPOOL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_socketpool), (mp_obj_t)&socketpool_module },
+#else
+#define SOCKETPOOL_MODULE
+#endif
+
+#if CIRCUITPY_SSL
+extern const struct _mp_obj_module_t ssl_module;
+#define SSL_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ssl), (mp_obj_t)&ssl_module },
+#else
+#define SSL_MODULE
+#endif
+
#if CIRCUITPY_STAGE
extern const struct _mp_obj_module_t stage_module;
#define STAGE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__stage), (mp_obj_t)&stage_module },
@@ -691,6 +720,13 @@ extern const struct _mp_obj_module_t watchdog_module;
#define WATCHDOG_MODULE
#endif
+#if CIRCUITPY_WIFI
+extern const struct _mp_obj_module_t wifi_module;
+#define WIFI_MODULE { MP_ROM_QSTR(MP_QSTR_wifi), MP_ROM_PTR(&wifi_module) },
+#else
+#define WIFI_MODULE
+#endif
+
// Define certain native modules with weak links so they can be replaced with Python
// implementations. This list may grow over time.
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
@@ -729,12 +765,14 @@ extern const struct _mp_obj_module_t watchdog_module;
TERMINALIO_MODULE \
VECTORIO_MODULE \
ERRNO_MODULE \
+ ESPIDF_MODULE \
FRAMEBUFFERIO_MODULE \
FREQUENCYIO_MODULE \
GAMEPAD_MODULE \
GAMEPADSHIFT_MODULE \
GNSS_MODULE \
I2CPERIPHERAL_MODULE \
+ IPADDRESS_MODULE \
JSON_MODULE \
MATH_MODULE \
_EVE_MODULE \
@@ -758,6 +796,8 @@ extern const struct _mp_obj_module_t watchdog_module;
SDCARDIO_MODULE \
SDIOIO_MODULE \
SHARPDISPLAY_MODULE \
+ SOCKETPOOL_MODULE \
+ SSL_MODULE \
STAGE_MODULE \
STORAGE_MODULE \
STRUCT_MODULE \
@@ -768,6 +808,7 @@ extern const struct _mp_obj_module_t watchdog_module;
USB_MIDI_MODULE \
USTACK_MODULE \
WATCHDOG_MODULE \
+ WIFI_MODULE \
// If weak links are enabled, just include strong links in the main list of modules,
// and also include the underscore alternate names.
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index 90e8b5fde..a2da9c42f 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -99,6 +99,12 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO)
CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO)
+# CIRCUITPY_ESPIDF is handled in the esp32s2 tree.
+# Only for ESP32S chips.
+# Assume not a ESP build.
+CIRCUITPY_ESPIDF ?= 0
+CFLAGS += -DCIRCUITPY_ESPIDF=$(CIRCUITPY_ESPIDF)
+
ifeq ($(CIRCUITPY_DISPLAYIO),1)
CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD)
else
@@ -124,6 +130,9 @@ CFLAGS += -DCIRCUITPY_GNSS=$(CIRCUITPY_GNSS)
CIRCUITPY_I2CPERIPHERAL ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_I2CPERIPHERAL=$(CIRCUITPY_I2CPERIPHERAL)
+CIRCUITPY_IPADDRESS ?= $(CIRCUITPY_WIFI)
+CFLAGS += -DCIRCUITPY_IPADDRESS=$(CIRCUITPY_IPADDRESS)
+
CIRCUITPY_MATH ?= 1
CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH)
@@ -191,6 +200,12 @@ CFLAGS += -DCIRCUITPY_SDIOIO=$(CIRCUITPY_SDIOIO)
CIRCUITPY_SHARPDISPLAY ?= $(CIRCUITPY_FRAMEBUFFERIO)
CFLAGS += -DCIRCUITPY_SHARPDISPLAY=$(CIRCUITPY_SHARPDISPLAY)
+CIRCUITPY_SOCKETPOOL ?= $(CIRCUITPY_WIFI)
+CFLAGS += -DCIRCUITPY_SOCKETPOOL=$(CIRCUITPY_SOCKETPOOL)
+
+CIRCUITPY_SSL ?= $(CIRCUITPY_WIFI)
+CFLAGS += -DCIRCUITPY_SSL=$(CIRCUITPY_SSL)
+
# Currently always off.
CIRCUITPY_STAGE ?= 0
CFLAGS += -DCIRCUITPY_STAGE=$(CIRCUITPY_STAGE)
@@ -263,6 +278,9 @@ CFLAGS += -DCIRCUITPY_ULAB=$(CIRCUITPY_ULAB)
CIRCUITPY_WATCHDOG ?= 0
CFLAGS += -DCIRCUITPY_WATCHDOG=$(CIRCUITPY_WATCHDOG)
+CIRCUITPY_WIFI ?= 0
+CFLAGS += -DCIRCUITPY_WIFI=$(CIRCUITPY_WIFI)
+
# Enabled micropython.native decorator (experimental)
CIRCUITPY_ENABLE_MPY_NATIVE ?= 0
CFLAGS += -DCIRCUITPY_ENABLE_MPY_NATIVE=$(CIRCUITPY_ENABLE_MPY_NATIVE)
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 905c3471f..41e1d4e48 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -726,6 +726,9 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) },
{ MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) },
{ MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) },
+ { MP_ROM_QSTR(MP_QSTR_TimeoutError), MP_ROM_PTR(&mp_type_TimeoutError) },
+ { MP_ROM_QSTR(MP_QSTR_ConnectionError), MP_ROM_PTR(&mp_type_ConnectionError) },
+ { MP_ROM_QSTR(MP_QSTR_BrokenPipeError), MP_ROM_PTR(&mp_type_BrokenPipeError) },
{ MP_ROM_QSTR(MP_QSTR_OverflowError), MP_ROM_PTR(&mp_type_OverflowError) },
{ MP_ROM_QSTR(MP_QSTR_RuntimeError), MP_ROM_PTR(&mp_type_RuntimeError) },
#if MICROPY_PY_ASYNC_AWAIT
diff --git a/py/obj.h b/py/obj.h
index 943e1a389..805b26e48 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -627,6 +627,8 @@ extern const mp_obj_type_t mp_type_NameError;
extern const mp_obj_type_t mp_type_NotImplementedError;
extern const mp_obj_type_t mp_type_OSError;
extern const mp_obj_type_t mp_type_TimeoutError;
+extern const mp_obj_type_t mp_type_ConnectionError;
+extern const mp_obj_type_t mp_type_BrokenPipeError;
extern const mp_obj_type_t mp_type_OverflowError;
extern const mp_obj_type_t mp_type_RuntimeError;
extern const mp_obj_type_t mp_type_StopAsyncIteration;
diff --git a/py/objexcept.c b/py/objexcept.c
index e3b953543..01ba6da9c 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -282,15 +282,17 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
*/
MP_DEFINE_EXCEPTION(OSError, Exception)
- MP_DEFINE_EXCEPTION(TimeoutError, OSError)
- /*
- MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
- MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
+ MP_DEFINE_EXCEPTION(TimeoutError, OSError)
MP_DEFINE_EXCEPTION(ConnectionError, OSError)
MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
+ /*
MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError)
MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError)
MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError)
+ */
+ /*
+ MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
+ MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
MP_DEFINE_EXCEPTION(InterruptedError, OSError)
MP_DEFINE_EXCEPTION(IsADirectoryError, OSError)
MP_DEFINE_EXCEPTION(NotADirectoryError, OSError)
diff --git a/py/runtime.c b/py/runtime.c
index f9ef7819d..e63e2337d 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1602,6 +1602,14 @@ NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) {
va_end(argptr);
}
+NORETURN void mp_raise_ConnectionError(const compressed_string_t *msg) {
+ mp_raise_msg(&mp_type_ConnectionError, msg);
+}
+
+NORETURN void mp_raise_BrokenPipeError(void) {
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE)));
+}
+
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_NotImplementedError, msg);
}
diff --git a/py/runtime.h b/py/runtime.h
index dbc04b94e..ad7d0feab 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -166,6 +166,8 @@ NORETURN void mp_raise_OSError(int errno_);
NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str);
NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
+NORETURN void mp_raise_ConnectionError(const compressed_string_t *msg);
+NORETURN void mp_raise_BrokenPipeError(void);
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...);