summaryrefslogtreecommitdiff
path: root/extmod
AgeCommit message (Collapse)Author
2022-07-20extmod/btstack: Fix descriptor discovery handle range and events.Damien George
This fixes two problems with the BTstack implementation of descriptor discovery: - The call to gatt_client_discover_characteristic_descriptors needs to have value_handle set to the starting handle (actually characteristic handle) to start the search from. - The BTstack event for a descriptor query result is GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT. With this change the test tests/multi_bluetooth/ble_subscribe.py now passes when BTstack is instance1 (for BTstack to pass as instance0 requires gatts_write to support sending an update on BTstack). Signed-off-by: Damien George <damien@micropython.org>
2022-07-20extmod/modussl_mbedtls: Implement cert_reqs and cadata arguments.Carlosgg
Add cert_reqs and cadata keyword-args to ssl.wrap_socket() and ssl.CERT_NONE, ssl.CERT_OPTIONAL, ssl.CERT_REQUIRED constants to allow certificate validation. CPython doesn't accept cadata in ssl.wrap_socket(), but it does in SSLContext.load_verify_locations(), so we use this name to at least match the same name in load_verify_locations(). Add docs for these new arguments, as well as docs for the existing server_hostname argument which is important for certificate validation. Tests are added as well. Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2022-07-18extmod: Always use custom mbedtls error message code.Damien George
All ports that use mbedtls use the custom error messages in mp_mbedtls_errors.c. This commit simplifies the build so that ports don't need to explicitly add this file, it's now used by default when mbedtls is enabled. Signed-off-by: Damien George <damien@micropython.org>
2022-07-18extmod/modbluetooth: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register `bluetooth` instead of using a conditional inside of mp_state_vm_t. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18extmod/vfs: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register vfs_cur and vfs_mount_table instead of using a conditional inside of mp_state_vm_t. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18extmod/modlwip: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register lwip_slip_stream instead of using a conditional inside of mp_state_vm_t. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18extmod/uos_dupterm: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register dupterm_objs instead of using a conditional inside of mp_state_vm_t. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18extmod/modnetwork: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register mod_network_nic_list and removes the same from all mpconfigport.h. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18extmod/nimble: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_nimble_memory and bluetooth_nimble_root_pointers and removes the same from all mpconfigport.h. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-18extmod/btstack: Use MP_REGISTER_ROOT_POINTER().David Lechner
This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_btstack_root_pointers and removes the same from all mpconfigport.h. Signed-off-by: David Lechner <david@pybricks.com>
2022-07-05extmod/network_cyw43: Add "security" config option to get/set auth mode.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30extmod/modnetwork: Include cyw43-driver header if it's enabled.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30extmod/network_cyw43: Support new cyw43-driver.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30extmod/vfs: Prevent uninitialized variable warning for path_out.Damien George
The warning can appear when building in Release mode on the rp2 port. Signed-off-by: Damien George <damien@micropython.org>
2022-06-24extmod/uasyncio: Implement stream read(-1) to read all data up to EOF.Damien George
Fixes issue #6355. Signed-off-by: Damien George <damien@micropython.org>
2022-06-24extmod/uasyncio: Attempt to write immediately in Stream.write method.Thorsten von Eicken
The main aim of this change is to reduce the number of heap allocations when writing data to a stream. This is done in two ways: 1. Eliminate appending of data when .write() is called multiple times before calling .drain(). With this commit, the data is written out immediately if the underlying stream is not blocked, so there is no accumulation of the data in a temporary buffer. 2. Eliminate copying of non-bytes objects passed to .write(). Prior to this commit, passing a bytearray or memoryview to .write() would always result in a copy of it being made and turned into a bytes object. That won't happen now if the underlying stream is not blocked. Also, this change makes .write () more closely implement the CPython documented semantics: "The method attempts to write the data to the underlying socket immediately. If that fails, the data is queued in an internal write buffer until it can be sent."
2022-06-23py/parsenum: Optimise when building with complex disabled.Damien George
To reduce code size when MICROPY_PY_BUILTINS_COMPLEX is disabled. Signed-off-by: Damien George <damien@micropython.org>
2022-06-21extmod/modbtree: Use buffer protocol for keys/values.David Lechner
This changes the btree implementation to use the buffer protocol for reading key/values in all methods. `str` and `bytes` objects are not the only bytes-like objects that could be used. Documentation and tests are also updated. Addresses issue #8748. Signed-off-by: David Lechner <david@pybricks.com>
2022-06-21extmod/extmod.mk: Separate out extmod file list from py.mk to extmod.mk.David Lechner
This separates extmod source files from `py.mk`. Previously, `py.mk` assumed that every consumer of the py/ directory also wanted to include extmod/. However, this is not the case. For example, building mpy-cross uses py/ but doesn't need extmod/. This commit moves all extmod-specific items from `py.mk` to `extmod.mk` and explicitly includes `extmod.mk` in ports that use it. Signed-off-by: David Lechner <david@pybricks.com>
2022-06-20extmod/extmod.cmake: Only include modbtree in build if it's enabled.Damien George
Following how it's done in extmod.mk. Signed-off-by: Damien George <damien@micropython.org>
2022-06-20extmod/modlwip: Clean up inclusion of modlwip in build process.Damien George
The following changes are made: - Guard entire file with MICROPY_PY_LWIP, so it can be included in the build while still being disabled (for consistency with other extmod modules). - Add modlwip.c to list of all extmod source in py/py.mk and extmod/extmod.cmake so all ports can easily use it. - Move generic modlwip GIT_SUBMODULES build configuration code from ports/rp2/CMakeLists.txt to extmod/extmod.cmake, so it can be reused by other ports. - Remove now unnecessary inclusion of modlwip.c in EXTMOD_SRC_C in esp8266 port, and in SRC_QSTR in mimxrt port. Signed-off-by: Damien George <damien@micropython.org>
2022-06-17extmod/network_ninaw10: Rename WLAN connect argument from essid to ssid.iabdalkader
Addresses issue #8083.
2022-06-17extmod/network_cyw43: Rename WLAN keyword args to ssid/security/key.iabdalkader
Rename WLAN keyword args to scan(), connect() and config() to be more consistent across ports and WLAN drivers. This change is backwards compatible and will support obsolete keyword args, except for positional "essid" which is now deprecated in favor of "ssid". The changed argument names are - "essid" changed to "ssid" - "auth" or "authmode" changed to "security" - "password" changed to "key" Addresses issue #8083.
2022-06-17extmod/machine_i2c: Only use WRITE1 option if transfer supports it.Damien George
When MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 is enabled the port's hardware I2C transfer functions should support the MP_MACHINE_I2C_FLAG_WRITE1 option, but software I2C will not. So add a flag to the I2C protocol struct so each individual protocol can indicate whether it supports this option or not. Fixes issue #8765. Signed-off-by: Damien George <damien@micropython.org>
2022-06-11extmod/extmod.cmake: Fix hard-coded mbedtls config file path.iabdalkader
* The mbedtls config file path is hard-coded to the config file in the stm32 port. Any port using this cmake fragment is not actually using its own config file.
2022-06-08extmod/modusocket: Fix polling of closed sockets.iabdalkader
Unbound sockets in NEW state should return HUP|WR when polled, and return NVAL when in CLOSED state.
2022-06-08extmod/modusocket: Add socket state to track new/listening/conn/closed.iabdalkader
2022-06-08extmod/extmod.cmake: Require components to be explicitly enabled.Damien George
Otherwise include directories are added unconditionally to the build variables if the component (submodule) is checked out. This can lead to, eg, the esp32 build using lib/lwip header files, instead of lwip header files from the IDF. Fixes issue #8727. Signed-off-by: Damien George <damien@micropython.org>
2022-06-07extmod/modurandom: Fix missing void in empty argument list.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2022-06-07all: Rename MICROPY_PY_WIZNET5K to MICROPY_PY_NETWORK_WIZNET5K.Damien George
To match MICROPY_PY_NETWORK_CYW43 and MICROPY_PY_NETWORK_NINAW10. Signed-off-by: Damien George <damien@micropython.org>
2022-06-03extmod/modussl_mbedtls: Poll EVENT_POLL_HOOK in ssl handshake loop.Andrew Leech
Otherwise this is essentially an infinite loop on ports that do not use interrupts to service network interfaces. Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03rp2: Integrate lwIP network stack.Andrew Leech
Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03extmod/network_wiznet5k: Add Wiznet Ethernet network interface.Andrew Leech
Originally based on both stm32/network_wiznet5k and stm32/modnwwiznet5k. If MICROPY_PY_LWIP is enabled it uses the lwIP TCP stack in MicroPython, communicating with the Wiznet controller in MACRAW mode. In this mode it supports using the INTN pin from Wiznet controller to receive data from an interrupt trigger. If lwIP is not enabled, it runs in modnetwork/socket mode providing an interface to the TCP stack running on the Wiznet controller chip. In this mode it includes some updates by @irinakim12 from #8021, most notably bringing in DHCP support. Supports defining hardware pins in board config or dynamically set at runtime. Sets a default MAC address in the random namespace from board unique-id. Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03extmod/nimble: Add support for reading whole HCI UART packets.Andrew Leech
This can improve efficiency for Bluetooth systems that already process whole packets at the lower layers.
2022-06-02extmod/uasyncio: Fix edge case for cancellation of wait_for.Damien George
This fixes the cases where the task being waited on finishes just before or just after the wait_for itself is cancelled. Fixes issue #8717. Signed-off-by: Damien George <damien@micropython.org>
2022-06-02all: Remove third argument to MP_REGISTER_MODULE.Damien George
It's no longer needed because this macro is now processed after preprocessing the source code via cpp (in the qstr extraction stage), which means unused MP_REGISTER_MODULE's are filtered out by the preprocessor. Signed-off-by: Damien George <damien@micropython.org>
2022-06-01extmod/machine_i2c: Add optional support for write-then-read transfers.Damien George
This option is useful for ports where it's more efficient to do a full I2C transfer in one go. Signed-off-by: Damien George <damien@micropython.org>
2022-05-26extmod/network_ninaw10: Add support for socket events callback.iabdalkader
2022-05-25drivers/ninaw10: Update driver to support firmware 1.5.0.iabdalkader
* Firmware 1.5.0 introduces a new BSD-like sockets ABI, which improves the integration with MicroPython.
2022-05-25py/builtin: Clean up and simplify import_stat and builtin_open config.Damien George
The following changes are made: - If MICROPY_VFS is enabled then mp_vfs_import_stat and mp_vfs_open are automatically used for mp_import_stat and mp_builtin_open respectively. - If MICROPY_PY_IO is enabled then "open" is automatically included in the set of builtins, and points to mp_builtin_open_obj. This helps to clean up and simplify the most common port configuration. Signed-off-by: Damien George <damien@micropython.org>
2022-05-25extmod/modusocket: Add sendall function.iabdalkader
2022-05-25extmod/modusocket: Add timeout and callback to socket object.iabdalkader
2022-05-25extmod/modusocket: Fix socket_make_new argument parsing.iabdalkader
2022-05-25extmod/modusocket: Add support for socket events callback.iabdalkader
Add support for the special sockopt 20.
2022-05-25extmod/modusocket: Add socket type print function.iabdalkader
2022-05-25extmod/modusocket: Fix errcode returned from socket read/write.iabdalkader
Drivers should ensure a positive errcode is returned from read/write.
2022-05-25extmod/modusocket: Bind unconnected socket to default NIC in setsockopt.iabdalkader
Bind socket to default NIC if setsockopt is called before the socket is bound, to allow setting SO_REUSEADDR before calling socket_bind(). Fixes issue #8653.
2022-05-25extmod/modusocket: Fix polling of a new socket.iabdalkader
New sockets should return HUP and WR when polled, following modlwip.
2022-05-24extmod/webrepl: Fix setting password in foreground mode and factor code.iabdalkader
The password was not being set when running in foreground mode. Duplicate code has been removed.
2022-05-24extmod: Revert accidental usocket->socket rename.Jim Mussared
The registration of the usocket module was accidentally changed to socket in moving to MP_REGISTER_MODULE in bb794f05b7fef75696118ea1eb03a769a9fac40d