Wykres commitów

31 Commity (master)

Autor SHA1 Wiadomość Data
iabdalkader 7753045a8f extmod: Add interface and security constants at WLAN class level.
Other constants such as `machine.Pin.OUT` are defined on the class that
uses them, rather than at the module level.  This commit makes that the
case for WLAN network interfaces, adding IF_xxx and SEC_xxx constants.

The SEC_xxx constants are named as such to match the `security` keyword
that they are used with.  And the IF_xxx constants have IF as a prefix so
they are grouped together as names.

This scheme of putting constants on the class means that only the available
features (eg security configurations) are made available as constants.  It
also means that different network interfaces (eg WLAN vs LAN) can keep
their own specific constants within their class, such as PHY_xxx for LAN.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-28 12:52:28 +11:00
iabdalkader c231c89651 extmod/network_ninaw10: Fix error messages.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-14 18:26:41 +01:00
iabdalkader 2b6f81f2b9 extmod/network_ninaw10: Set the proper security mode if none provided.
If no security mode is provided, use WPA for station and WEP for AP.  Note
only WEP is supported in AP mode.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-14 17:40:25 +11:00
iabdalkader 8b4a21cd64 extmod/network_ninaw10: Activate the NIC on demand.
Activate the NIC on calls to connect() or config() if it's not already
active. This change makes the NINA NIC more in line with CYW43 and other
NICs, which allow configuring the NIC before or after it is activated.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-14 17:40:18 +11:00
Angus Gratton decf8e6a8b all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-07 14:20:42 +11:00
iabdalkader 0960d64d3b extmod/network_ninaw10: Switch to using soft-timer for polling.
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>
2023-12-06 17:32:21 +11:00
iabdalkader 2fda94c286 extmod/network_ninaw10: Fix select flags handling in socket poll.
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>
2023-10-27 15:49:17 +11:00
iabdalkader 7bbf7910fe extmod/network_ninaw10: Raise an error if nina_ioctl fails.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-20 12:18:00 +11:00
iabdalkader b4a0390cbe extmod/network_ninaw10: Add missing raw socket type to socket().
This regression was introduced by 3d46fe67bf.
2023-04-05 09:46:46 +10:00
iabdalkader 3d46fe67bf extmod/network_ninaw10: Check socket types when creating new sockets.
The NINA socket types have the same values as modnetwork, but that may
change in the future.  So check the socket types passed to socket() and
convert them (if needed) to their respective Nina socket types.

Also remove the unnecessary socket type check code from bind(), as pointed
out by @robert-hh.
2023-04-04 15:23:39 +10:00
Jim Mussared 5f8f32f917 extmod/modnetwork: Use a type protocol to implement NIC functions.
This was previously implemented by adding additional members to the
mp_obj_type_t defined for each NIC, which is difficult to do cleanly with
the new object type slots mechanism. The way this works is also not
supported on GCC 8.x and below.

Instead replace it with the type protocol, which is a much simpler way of
achieving the same thing.

This affects the WizNet (in non-LWIP mode) and Nina NIC drivers.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-15 17:40:06 +11:00
iabdalkader b9c1e4c205 drivers/ninaw10: Connect to WiFi asynchronously.
Before this patch, WiFi connection was blocking, and could raise exceptions
if the connection failed for any reason (including timeouts).  This doesn't
match the behavior of other WiFi modules, which connect asynchronously, and
requires handling of exceptions on connect.  This change makes `connect()`
work asynchronously by scheduling code to poll connection status, and
handle reconnects (if needed), and return immediately without blocking.
2022-11-16 09:46:43 +11:00
Jim Mussared 94beeabd2e py/obj: Convert make_new into a mp_obj_type_t slot.
Instead of being an explicit field, it's now a slot like all the other
methods.

This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:15 +10:00
Jim Mussared e8355eb163 py/obj: Add "full" and "empty" non-variable-length mp_obj_type_t.
This will always have the maximum/minimum size of a mp_obj_type_t
representation and can be used as a member in other structs.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:04 +10:00
Jim Mussared 662b9761b3 all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 19:06:01 +10:00
Jim Mussared a053827084 extmod/network_ninaw10: Move ninaw10 root pointer registrations here.
Originally in drivers/ninaw10/nina_wifi_bsp.c but that isn't a QSTR source.

Also remove outdated commment about root pointers in mpconfigport.h.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-07-21 16:21:50 +10:00
iabdalkader efa73ca833 extmod/network_ninaw10: Rename WLAN connect argument from essid to ssid.
Addresses issue #8083.
2022-06-17 21:43:44 +10:00
iabdalkader 0bdfceacbe extmod/network_ninaw10: Add support for socket events callback. 2022-05-26 11:15:07 +10:00
iabdalkader be83bdf9ec drivers/ninaw10: Update driver to support firmware 1.5.0.
* Firmware 1.5.0 introduces a new BSD-like sockets ABI,
which improves the integration with MicroPython.
2022-05-25 16:05:50 +02:00
iabdalkader 465b74e78d drivers/ninaw10: Add NIC-level ioctl function.
This commit adds support in the driver for irregular commands.  It
currently supports setting GPIO pin mode, and GPIO pin read/write value.
2022-02-18 14:35:26 +11:00
iabdalkader 1aac151d68 drivers/ninaw10: Return standard error numbers. 2022-01-21 13:35:05 +11:00
iabdalkader e401ff8935 drivers/ninaw10: Fix timeout handling to match modusocket. 2022-01-21 13:31:41 +11:00
iabdalkader 9a61bc3aa7 extmod/network_ninaw10: Implement MP_STREAM_POLL in ioctl.
There is currently no function to query if the socket is writable.
2022-01-21 13:30:48 +11:00
iabdalkader f2ccf87e0b extmod/network_ninaw10: Use socket timeout preset in modusocket. 2022-01-12 14:37:40 +11:00
iabdalkader 5a86031223 extmod/network_ninaw10: Make recv/recvfrom interchangeable. 2022-01-06 14:36:57 +11:00
iabdalkader 73a6b53dbe extmod/network_ninaw10: Return -1 on timeout from recv/send. 2022-01-06 14:36:55 +11:00
iabdalkader 544c232eb7 extmod/network_ninaw10: Make NIC state persistent. 2022-01-06 14:36:51 +11:00
iabdalkader 0f25e0387c extmod/network_ninaw10: Disable active connections before connecting. 2022-01-06 14:36:44 +11:00
iabdalkader 1b7eee24eb extmod/network_ninaw10: Fix config of AP mode.
* Fix missing call to connect to configure module in AP mode.
* Use enum for config/connect args indices.
2021-12-14 15:14:58 +11:00
iabdalkader f7a0c98e00 extmod/network_ninaw10: Fix scan list order to match other NICs. 2021-11-19 15:41:26 +11:00
iabdalkader 43079aaf86 drivers/ninaw10: Add ublox Nina-W10 WiFi/BT module driver.
- Add WiFi/BT drivers for ublox Nina-W10 (esp32 based) module.
- Add ublox Nina-W10 Python module in extmod.
2021-11-13 23:01:03 +11:00