Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network.config() #67

Merged
merged 18 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f7a44d7
ports/psoc6/modules/network: Fixed obj-ptr convert in scan function.
jaenrig-ifx Jul 11, 2023
c1af5cc
ports/psoc6/modules/network: WIP config and reworked reconnect.
jaenrig-ifx Jul 17, 2023
3f7251b
tests/psoc6/multi/network: WIP network config tests.
jaenrig-ifx Jul 17, 2023
4373fc2
ports/psoc6/modules/network: Refactoring config as per interface.
jaenrig-ifx Jul 17, 2023
7e2a523
ports/psoc6/network: Completed network config for STA and AP.
jaenrig-ifx Jul 19, 2023
5aa0535
tests/psoc6/multi/network: Moving config test to new file.
jaenrig-ifx Jul 19, 2023
297d058
ports/psoc6/modules/network: Refined network config function.
jaenrig-ifx Jul 19, 2023
9e1be9e
tests/psoc6/multi/network_config.py: Added network config multi test.
jaenrig-ifx Jul 19, 2023
e0015a2
ports/psoc6/modules/network: Reworked ifconfig function.
jaenrig-ifx Jul 20, 2023
ac2b014
tests/psoc6/multi/network_config: Added ifconfig tests.
jaenrig-ifx Jul 20, 2023
3f6badb
ports/psoc6/modules/network: Completed module print function.
jaenrig-ifx Jul 20, 2023
16cfeaa
tests/psoc6/multi/network_config: Addedd module print test.
jaenrig-ifx Jul 20, 2023
6c939ef
docs/psoc6/quickref.rst: Network module specialization docs.
jaenrig-ifx Jul 21, 2023
4af7dfe
docs/psoc6/quickref.rst: Network module specialization docs.
jaenrig-ifx Jul 21, 2023
30893f1
docs/psoc6/quickref.rst: Network module specialization docs.
jaenrig-ifx Jul 21, 2023
ca86dd6
docs/psoc6/quickref.rst: Network module specialization docs.
jaenrig-ifx Jul 21, 2023
ccdb6e8
docs/psoc6/quickref.rst: Network module specialization docs.
jaenrig-ifx Jul 21, 2023
f49c418
docs/psoc6/quickref.rst: Network module specialization docs.
jaenrig-ifx Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 51 additions & 30 deletions docs/psoc6/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,43 +244,64 @@ The :mod:`network` module

See :ref:`network.WLAN <network.WLAN>`

The network module is used to configure the WiFi connection.The WiFi interface for the station mode is only configured for
this port.Create WLAN interface object using ::
For some methods and constants, the PSoC6 network port implements certain specialization and slightly different behavior. This is explained in this section.

import network
wlan = network.WLAN(network.STA_IF) # create station interface
Methods
^^^^^^^

Scan for the available wireless networks using
.. method:: WLAN.scan(ssid=None, bssid=None)

::
The scan option accepts the following filters as keyword arguments, removing from scan results any network not matching these parameters values:

wlan.scan()

Scan function returns a list of tuple information about access points
(ssid, bssid, channel, RSSI, security, hidden) .There are 7 levels of security:

* ``0 - open``,
* ``1 - WEP``,
* ``2 - WPA``,
* ``3 - WPA2``,
* ``4 - WPA2_WPA``,
* ``5 - WPA3``,
* ``6 - WPS``,
* ``7 - Unknown security``.

These are the other functions available in the network module
* ``ssid``
* ``bssid``

.. method:: WLAN.status('param')

.. warning::
The function does not provide status of the connection. Use the ``active()`` for that purpose. Any errors or failure are communicated when using the corresponding enable/disable or connect/disconnect functions.

The following query parameters are allowed:
* ``rssi``. Only for STA.
* ``stations``. List of connected stations (only for AP).

.. method:: WLAN.config('param')
WLAN.config(param=value, ...)

::
Among the suggested parameters of the general network WLAN API, for this port, only these are available:

wlan.active(True) # activate the interface
wlan.scan() # scan for access points
wlan.isconnected() # check if the station is connected to an AP
wlan.connect('ssid', 'key') # connect to an AP
wlan.disconnect() # disconnect from the connected AP
wlan.status() # check the link status and returns 1 for linkup & 0 for linkdown
wlan.ifconfig() # get the interface's IP/netmask/gateway/DNS addresses
* AP & STA query parameters

- ``channel``
- ``ssid``
- ``security```
- ``key/password``. Only for default AP key.
- ``mac``
* AP set parameters

- ``channel``
- ``ssid``
- ``security```
- ``key/password``. Only for default AP key.

* STA has no configurable parameter.

Constants
^^^^^^^^^

Security modes constants:

.. data:: WLAN.OPEN
WLAN.WEP
WLAN.WPA
WLAN.WPA2
WLAN.WPA3
WLAN.WPA2_WPA_PSK
WLAN.SEC_UNKNOWN

.. note::
Power modes configuration not implemented.


Here is a function you can run (or put in your boot.py file) to automatically connect to your WiFi network:

::
Expand Down
Loading