Instead, configure the default once at compile-time. This means the GAP
name will no longer be set to default after re-initializing Bluetooth.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
The calculation of the lfs2 cache_size was incorrect, the maximum allowed
size is block_size.
The cache size must be: "a multiple of the read and program sizes, and a
factor of the block size".
Signed-off-by: Peter Züger <zueger.peter@icloud.com>
In case of multiple outputs, the minimum successful write length is
returned. In line with this, in case any output has a write error, zero is
returned.
In case of no outputs, -1 is returned.
The return value can be used to assess whether writes were attempted, and
if so, whether they succeeded.
Signed-off-by: Maarten van der Schrieck <maarten@thingsconnected.nl>
The poll_obj_t instances have their pollfd field point into this
allocation. So if re-allocating results in a move, we need to update the
existing poll_obj_t's.
Update the test to cover this case.
Fixes issue #12887.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
It looks like these never worked and there are no tests for this
functionality. Furthermore, CPython doesn't support this.
Fixes#12995.
Signed-off-by: Damien George <damien@micropython.org>
esp8266 doesn't need ets task because the notify is now scheduled (see
commits 7d57037906 and
c60caf1995 for relevant history).
Signed-off-by: Damien George <damien@micropython.org>
This adds asyncio ssl support with SSLContext and the corresponding
tests in `tests/net_inet` and `tests/multi_net`.
Note that not doing the handshake on connect will delegate the handshake to
the following `mbedtls_ssl_read/write` calls. However if the handshake
fails when a client certificate is required and not presented by the peer,
it needs to be notified of this handshake error (otherwise it will hang
until timeout if any). Finally at MicroPython side raise the proper
mbedtls error code and message.
Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
Fixes two issues:
- None should not be allowed in the list, otherwise the corresponding entry
in ciphersuites[i] will have an undefined value.
- The terminating 0 needs to be put in ciphersuites[len].
Signed-off-by: Damien George <damien@micropython.org>
And only enable this method when the relevant feature is available in
mbedtls. Otherwise, if mbedtls doesn't support getting the peer
certificate, this method always returns None and it's confusing why it does
that. It's better to remove the method altogether, so the error trying to
use it is more obvious.
Signed-off-by: Damien George <damien@micropython.org>
This commit adds:
1) Methods to SSLContext class that match CPython signature:
- `SSLContext.load_cert_chain(certfile, keyfile)`
- `SSLContext.load_verify_locations(cafile=, cadata=)`
- `SSLContext.get_ciphers()` --> ["CIPHERSUITE"]
- `SSLContext.set_ciphers(["CIPHERSUITE"])`
2) `sslsocket.cipher()` to get current ciphersuite and protocol
version.
3) `ssl.MBEDTLS_VERSION` string constant.
4) Certificate verification errors info instead of
`MBEDTLS_ERR_X509_CERT_VERIFY_FAILED`.
5) Tests in `net_inet` and `multi_net` to test these new methods.
`SSLContext.load_cert_chain` method allows loading key and cert from disk
passing a filepath in `certfile` or `keyfile` options.
`SSLContext.load_verify_locations`'s `cafile` option enables the same
functionality for ca files.
Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
So that ports don't need to specify each of these files, they can simply
refer to the appropriate make/cmake variable.
Signed-off-by: Damien George <damien@micropython.org>
See previous commit for details of these functions. As of this commit,
these still call the old hook macros on all ports.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This patch simplifies the connection and sockets polling code, by switching
to a soft-timer to schedule polling code, and by using one node for
scheduling. This also fixes any issues that could result from using a heap
allocated machine_timer, and includes better handling of the sockets poll
list.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This is usually called on soft-reboot, a NIC can implement this to do any
necessary cleaning up (such as invalidating root pointers).
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
All ports using this common configuration already enable time/date
validation, so this commit is a no-op change.
Signed-off-by: Damien George <damien@micropython.org>
The os.dupterm() function has changed on this port, it now matches the
semantics used by all other ports (except it's restricted to accept only
machine.UART objects).
Signed-off-by: Damien George <damien@micropython.org>
The ports esp32, mimxrt, rp2 and samd all shared exactly the same
implementation of machine.disable_irq() and machine.enable_irq(),
implemented in terms of MICROPY_{BEGIN,END}_ATOMIC_SECTION. This commit
factors these implementations into extmod/modmachine.c.
The cc3200, esp8266, nrf, renesas-ra and stm32 ports do not yet use this
common implementation.
Signed-off-by: Damien George <damien@micropython.org>
Minor changes for consistency are:
- nrf gains: unique_id(), freq() [they do nothing]
- samd: deepsleep() now resets after calling lightsleep()
- esp32: lightsleep()/deepsleep() no longer take kw arg "sleep", instead
it's positional to match others. also, passing 0 here will now do a 0ms
sleep instead of acting like nothing was passed.
reset_cause() no longer takes any args (before it would just ignore them)
- mimxrt: freq() with an argument and lightsleep() both raise
NotImplementedError
Signed-off-by: Damien George <damien@micropython.org>
And use it in all ports. The ports are unchanged, except esp8266 which now
just returns None from this function instead of the time elapsed (to match
other ports), and qemu-arm which gains this function.
Signed-off-by: Damien George <damien@micropython.org>
This is a code factoring to have the dict for the machine module in one
location, and all the ports use that same dict. The machine.soft_reset()
function implementation is also factored because it's the same for all
ports that did already implement it. Eventually more functions/bindings
can be factored.
All ports remain functionally the same, except:
- cc3200 port: gains soft_reset, mem8, mem16, mem32, Signal; loses POWER_ON
(which was a legacy constant, replaced long ago by PWRON_RESET)
- nrf port: gains Signal
- qemu-arm port: gains soft_reset
- unix port: gains soft_reset
- zephyr port: gains soft_reset, mem8, mem16, mem32
Signed-off-by: Damien George <damien@micropython.org>
Fixes undefined behavior when calling vfs_posix_file_ioctl with
MP_STREAM_CLOSE as request because that casts away the constness and
assigns -1 to the object's fd member.
Fixes issue #12670.
Signed-off-by: stijn <stijn@ignitron.net>
Similar to 3883f29485 where this change was
implemented for threads: when the Bluetooth IRQ handler is called the
thread state is not not zero-initialized and thus we need to manually set
this to NULL.
Fixes issue #12239.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings. At this stage only esp32 implements
this class, so the code for the bindings comes from that port.
The documentation is also updated to reflect the esp32's behaviour of
ADCBlock.connect().
Signed-off-by: Damien George <damien@micropython.org>
This fixes the case where e.g.
struct foo_t {
mp_obj_t x;
uint16_t y;
char buf[];
};
will have `sizeof(struct foo_t)==8`, but `offsetof(struct foo_t, buf)==6`.
When computing the size to allocate for `m_new_obj_var` we need to use
offsetof to avoid over-allocating. This is important especially when it
might cause it to spill over into another GC block.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The flags returned from `select()` were misinterpreted to mean an error had
occurred for the socket, when it's actually just an exceptional condition
for the socket, such as OOB data.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The contents of machine_mem.h, machine_i2c.h and machine_spi.h have been
moved into extmod/modmachine.h.
Signed-off-by: Damien George <damien@micropython.org>
The contents of machine_bitstream.h, machine_pinbase.h, machine_pulse.h and
machine_signal.h have been moved into extmod/modmachine.h.
Signed-off-by: Damien George <damien@micropython.org>
The machine_i2c_type, machine_spi_type and machine_timer_type symbols are
already declared in extmod/modmachine.h and should not be declared anywhere
else.
Also move declarations of machine_pin_type and machine_rtc_type to the
common header in extmod.
Signed-off-by: Damien George <damien@micropython.org>
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings. For all ports except the two listed
below there is no functional change.
The nrf port has UART.sendbreak() removed, but this method previously did
nothing.
The zephyr port has the following methods added:
- UART.init(): supports setting timeout and timeout_char.
- UART.deinit(): does nothing, just returns None.
- UART.flush(): raises OSError(EINVAL) because it's not implemented.
- UART.any() and UART.txdone(): raise NotImplementedError.
Signed-off-by: Damien George <damien@micropython.org>
No functional change, just code factoring to have the Python bindings in
one location, and all the ports use those same bindings.
Signed-off-by: Damien George <damien@micropython.org>
This factors the basic top-level I2S class code from the ports into
extmod/machine_i2s.c:
- I2S class definition and method table.
- The init and deinit method wrappers.
- The make_new code.
Further factoring will follow.
Signed-off-by: Damien George <damien@micropython.org>
With public declarations moved to extmod/modmachine.h. It's now mandatory
for a port to define MICROPY_PY_MACHINE_PWM_INCLUDEFILE if it enables
MICROPY_PY_MACHINE_PWM. This follows how extmod/machine_wdt.c works.
All ports have been updated to work with this modified scheme.
Signed-off-by: Damien George <damien@micropython.org>