summaryrefslogtreecommitdiff
path: root/extmod
AgeCommit message (Collapse)Author
2019-10-11extmod/modbluetooth: Use us instead of ms for advertising interval.Jim Mussared
This is to more accurately match the BLE spec, where intervals are configured in units of channel hop time (625us). When it was specified in ms, not all "valid" intervals were able to be specified. Now that we're also allowing configuration of scan interval, this commit updates advertising to match.
2019-10-11extmod/modbluetooth: Allow config of scan interval/window.Jim Mussared
This adds two additional optional kwargs to `gap_scan()`: - `interval_us`: How long between scans. - `window_us`: How long to scan for during a scan. The default with NimBLE is a 11.25ms window with a 1.28s interval. Changing these parameters is important for detecting low-frequency advertisements (e.g. beacons). Note: these params are in microseconds, not milliseconds in order to allow the 625us granularity offered by the spec.
2019-10-08stm32: Extract port-specific Nimble implementation.Jim Mussared
On other ports (e.g. ESP32) they provide a complete Nimble implementation (i.e. we don't need to use the code in extmod/nimble). This change extracts out the bits that we don't need to use in other ports: - malloc/free/realloc for Nimble memory. - pendsv poll handler - depowering the cywbt Also cleans up the root pointer management.
2019-10-01extmod/modbluetooth: Allow MP_BLUETOOTH_MAX_ATTR_SIZE in board config.Andrew Leech
2019-10-01extmod/modbluetooth_nimble: Use random addr if public isn't available.Andrew Leech
2019-10-01extmod/modbluetooth_nimble: Implement modbluetooth API with Nimble.Jim Mussared
2019-10-01extmod/modbluetooth: Add low-level Python BLE API.Jim Mussared
2019-10-01extmod/nimble: Add nimble bindings.Damien George
2019-09-23extmod/vfs_posix: Include stdio.h for declaration of function 'rename'.Bob Fanger
2019-09-02py/modstruct: Fix struct.pack_into with unaligned offset of native type.Damien George
Following the same fix for unpack.
2019-09-02py/modstruct: Fix struct.unpack with unaligned offset of native type.Tom McDermott
With this patch alignment is done relative to the start of the buffer that is being unpacked, not the raw pointer value, as per CPython. Fixes issue #3314.
2019-08-22extmod/crypto-algorithms: Add source to header and populate copyright.Damien George
As per the README.md of the upstream source at https://github.com/B-Con/crypto-algorithms, this source code was released into the public domain, so make that explicit in the copyright line in the header.
2019-08-22extmod/modujson: Support passing bytes/bytearray to json.loads.Damien George
CPython allows this, and it can be useful to reduce the number of memory allocations. Fixes issue #5031.
2019-08-20extmod: Give vars/funcs unique names so STATIC can be set to nothing.Damien George
Fixes issue #5018.
2019-08-20extmod/moducryptolib: Use "static" not "STATIC" for inline functions.Damien George
2019-08-19extmod/modure: Make regex dump-code debugging feature optional.Damien George
Enabled via MICROPY_PY_URE_DEBUG, disabled by default (but enabled on unix coverage build). This is a rarely used feature that costs a lot of code (500-800 bytes flash). Debugging of regular expressions can be done offline with other tools.
2019-08-06extmod/modlwip: Implement raw sockets for lwIP.Damien George
Configurable via MICROPY_PY_LWIP_SOCK_RAW.
2019-07-03extmod/modlwip: Use mp_sched_schedule to schedule socket callbacks.Damien George
The helper function exec_user_callback executes within the context of an lwIP C callback, and the user (Python) callback to be scheduled may want to perform further TCP/IP actions, so the latter should be scheduled to run outside the lwIP context (otherwise it's effectively a "hard IRQ" and such callbacks have lots of restrictions).
2019-07-03extmod/modlwip: For TCP send keep trying tcp_write if it returns ERR_MEMDamien George
If tcp_write returns ERR_MEM then it's not a fatal error but instead means the caller should retry the write later on (and this is what lwIP's netconn API does). This fixes problems where a TCP send would raise OSError(ENOMEM) in situations where the TCP/IP stack is under heavy load. See eg issues #1897 and #1971.
2019-07-03extmod/modwebrepl: Add config option to put filebuf[512] on stack/bss.Damien George
Since the esp8266 has a small stack this buffer is kept in the BSS.
2019-07-03extmod/modwebrepl: Make prompt/ver static arrays const to not use RAM.Damien George
The esp8266 lwip_open library is compiled with -mforce-l32 so these arrays do not need to be in RAM.
2019-07-03extmod/moduwebsocket: Make close_resp static array const to not use RAM.Damien George
The esp8266 lwip_open library is compiled with -mforce-l32 so this array does not need to be in RAM.
2019-07-01esp8266: Provide custom machine_time_pulse_us that feeds soft WDT.Damien George
So that the timeout for machine.time_pulse_us() can be large. Fixes issue #2775.
2019-07-01extmod/uos_dupterm: Add mp_uos_dupterm_poll to poll all dupterms.Damien George
2019-06-05extmod/extmod.mk: Include mdns app source in lwIP build.Damien George
2019-06-05extmod/modussl_mbedtls: Allow to build with object representation D.Damien George
2019-06-05extmod/extmod.mk: Integrate mbedTLS so it is built from source.Damien George
Setting MICROPY_PY_USSL and MICROPY_SSL_MBEDTLS at the Makefile-level will now build mbedTLS from source and include it in the build, with the ussl module using this TLS library. Extra settings like MBEDTLS_CONFIG_FILE may need to be provided by a given port. If a port wants to use its own mbedTLS library then it should not set MICROPY_SSL_MBEDTLS at the Makefile-level but rather set it at the C level, and provide the library as part of the build in its own way (see eg esp32 port).
2019-06-05extmod: Factor out makefile rules from py.mk to new extmod.mk file.Damien George
To logically separate extmod related rules out, and prevent py.mk from growing too large.
2019-06-03extmod: Add network-level class binding to cyw43 driver.Damien George
2019-05-29extmod/modlwip: Register TCP close-timeout callback before closing PCB.Damien George
In d5f0c87bb985ae344014dc2041fbaad5c522f638 this call to tcp_poll() was added to put a timeout on closing TCP sockets. But after calling tcp_close() the PCB may be freed and therefore invalid, so tcp_poll() can not be used at that point. As a fix this commit calls tcp_poll() before closing the TCP PCB. If the PCB is subsequently closed and freed by tcp_close() or tcp_abort() then the PCB will not be on any active list and the callback will not be executed, which is the desired behaviour (the _lwip_tcp_close_poll() callback only needs to be called if the PCB remains active for longer than the timeout).
2019-05-29extmod/modlwip: Free any incoming bufs/connections before closing PCB.Damien George
Commit 2848a613ac61fce209962354c2698ee587a2c26a introduced a bug where lwip_socket_free_incoming() accessed pcb.tcp->state after the PCB was closed. The state may have changed due to that close call, or the PCB may be freed and therefore invalid. This commit fixes that by calling lwip_socket_free_incoming() before the PCB is closed.
2019-05-20extmod/machine_i2c: Add i2c.writevto() that can write a vector of bufs.Damien George
For example: i2c.writevto(addr, (buf1, buf2)). This allows to efficiently (wrt memory) write data composed of separate buffers, such as a command followed by a large amount of data.
2019-05-20extmod/machine_i2c: Remove need for temporary memory in writemem() call.Damien George
2019-05-20extmod/machine_i2c: Change C-level API to allow split I2C transactions.Damien George
API is: int transfer( mp_obj_base_t *obj, uint16_t addr, size_t n, mp_machine_i2c_buf_t *bufs, unsigned int flags )
2019-05-17various: Add and update my copyright line based on git history.Paul Sokolovsky
For modules I initially created or made substantial contributions to.
2019-05-14extmod/modujson: Handle parsing of floats with + in the exponent.Damien George
Fixes issue #4780.
2019-05-06extmod/moducryptolib: Add AES-CTR support for axTLS builds.Yonatan Goldschmidt
2019-05-06extmod/moducryptolib: Add AES-CTR support.Yonatan Goldschmidt
Selectable at compile time via MICROPY_PY_UCRYPTOLIB_CTR. Disabled by default.
2019-04-30extmod/modussl_axtls: Add non-blocking mode support.Paul Sokolovsky
It consists of: 1. "do_handhake" param (default True) to wrap_socket(). If it's False, handshake won't be performed by wrap_socket(), as it would be done in blocking way normally. Instead, SSL socket can be set to non-blocking mode, and handshake would be performed before the first read/write request (by just returning EAGAIN to these requests, while instead reading/writing/ processing handshake over the connection). Unfortunately, axTLS doesn't really support non-blocking handshake correctly. So, while framework for this is implemented on MicroPython's module side, in case of axTLS, it won't work reliably. 2. Implementation of .setblocking() method. It must be called on SSL socket for blocking vs non-blocking operation to be handled correctly (for example, it's not enough to wrap non-blocking socket with wrap_socket() call - resulting SSL socket won't be itself non-blocking). Note that .setblocking() propagates call to the underlying socket object, as expected.
2019-04-30extmod/modussl_mbedtls: Support non-blocking handshake.Paul Sokolovsky
For this, add wrap_socket(do_handshake=False) param. CPython doesn't have such a param at a module's global function, and at SSLContext.wrap_socket() it has do_handshake_on_connect param, but that uselessly long. Beyond that, make write() handle not just MBEDTLS_ERR_SSL_WANT_WRITE, but also MBEDTLS_ERR_SSL_WANT_READ, as during handshake, write call may be actually preempted by need to read next handshake message from peer. Likewise, for read(). And even after the initial negotiation, situations like that may happen e.g. with renegotiation. Both MBEDTLS_ERR_SSL_WANT_READ and MBEDTLS_ERR_SSL_WANT_WRITE are however mapped to the same None return code. The idea is that if the same read()/write() method is called repeatedly, the progress will be made step by step anyway. The caveat is if user wants to add the underlying socket to uselect.poll(). To be reliable, in this case, the socket should be polled for both POLL_IN and POLL_OUT, as we don't know the actual expected direction. But that's actually problematic. Consider for example that write() ends with MBEDTLS_ERR_SSL_WANT_READ, but gets converted to None. We put the underlying socket on pull using POLL_IN|POLL_OUT but that probably returns immediately with POLL_OUT, as underlyings socket is writable. We call the same ussl write() again, which again results in MBEDTLS_ERR_SSL_WANT_READ, etc. We thus go into busy-loop. So, the handling in this patch is temporary and needs fixing. But exact way to fix it is not clear. One way is to provide explicit function for handshake (CPython has do_handshake()), and let *that* return distinct codes like WANT_READ/WANT_WRITE. But as mentioned above, past the initial handshake, such situation may happen again with at least renegotiation. So apparently, the only robust solution is to return "out of bound" special sentinels like WANT_READ/WANT_WRITE from read()/write() directly. CPython throws exceptions for these, but those are expensive to adopt that way for efficiency-conscious implementation like MicroPython.
2019-04-26extmod/machine_signal: Fix fault when no args are passed to Signal().Damien George
2019-04-16extmod/modurandom: Add init method to seed the Yasmarang generator.Léa Saviot
In CPython the random module is seeded differently on each import, and so this new macro option MICROPY_PY_URANDOM_SEED_INIT_FUNC allows to implement such a behaviour.
2019-04-11extmod/modlwip: Abort TCP conns that didn't close cleanly in a while.Damien George
2019-04-03extmod/modlwip: Use correct listening socket object in accept callback.Damien George
Since commit da938a83b587c7387b8849f795f3497735d14267 the tcp_arg() that is set for the new connection is the new connection itself, and the parent listening socket is found in the pcb->connected entry.
2019-04-01extmod/modlwip: Free any stored incoming bufs/connections on TCP error.Damien George
2019-04-01extmod/modlwip: Protect socket.accept with lwIP concurrency lock.Damien George
This is needed now that the accept queue can have pending connections removed asynchronously.
2019-04-01extmod/modlwip: Handle case of accept callback called with null PCB.Damien George
2019-04-01extmod/modlwip: Handle case of connection closing while on accept queue.Damien George
In such a case the connection is aborted by lwIP and so must be removed from the pending accept queue.
2019-04-01stm32: Make default USB_VCP stream go through uos.dupterm for main REPL.Andrew Leech
Use uos.dupterm for REPL configuration of the main USB_VCP(0) stream on dupterm slot 1, if USB is enabled. This means dupterm can also be used to disable the boot REPL port if desired, via uos.dupterm(None, 1). For efficiency this adds a simple hook to the global uos.dupterm code to work with streams that are known to be native streams.
2019-03-26extmod/vfs_fat: Fallback to FAT32 if standard FAT16/SFD format fails.Andrew Leech
This allows formatting SD cards, larger flash etc which do not support the default FAT16/SFD format mode.