Networking Libraries
Functions for implementing networking
pico_btstack
Integration/wrapper libraries for BTstack the documentation for which is here. More...
Functions
-
const hal_flash_bank_t * pico_flash_bank_instance (void)
-
Return the singleton BTstack HAL flash instance, used for non-volatile storage.
-
const btstack_run_loop_t * btstack_run_loop_async_context_get_instance (async_context_t *context)
-
Initialize and eturn the singleton BTstack run loop instance that integrates with the async_context API.
Detailed Description
Integration/wrapper libraries for BTstack the documentation for which is here.
The pico_btstack_ble library
adds the support needed for Bluetooth Low Energy (BLE). The pico_btstack_classic library
adds the support needed for Bluetooth Classic. You can link to either library individually, or to both libraries thus enabling dual-mode support provided by BTstack.
To use BTstack you need to provide a btstack_config.h
file in your source tree and add its location to your include path. The BTstack configuration macros ENABLE_CLASSIC
and ENABLE_BLE
are defined for you when you link the pico_btstack_classic
and pico_btstack_ble
libraries respectively, so you should not define them yourself.
For more details, see How to configure BTstack and the relevant pico-examples.
The follow ibraries provided for you to link.
pico_btstack_ble -
Adds Bluetooth Low Energy (LE) support.pico_btstack_classic -
Adds Bluetooth Classic support.pico_btstack_sbc_encoder -
Adds Bluetooth Sub Band Coding (SBC) encoder support.pico_btstack_sbc_decoder -
Adds Bluetooth Sub Band Coding (SBC) decoder support.pico_btstack_bnep_lwip -
Adds Bluetooth Network Encapsulation Protocol (BNEP) support using LwIP.pico_btstack_bnep_lwip_sys_freertos -
Adds Bluetooth Network Encapsulation Protocol (BNEP) support using LwIP with FreeRTOS for NO_SYS=0.
Note |
The CMake function pico_btstack_make_gatt_header can be used to run the BTstack compile_gatt tool to make a GATT header file from a BTstack GATT file. |
See alsopico_btstack_cyw43 in pico_cyw43_driver, which adds the cyw43 driver support needed for BTstack including BTstack run loop support.
Function Documentation
◆ btstack_run_loop_async_context_get_instance()
const btstack_run_loop_t * btstack_run_loop_async_context_get_instance | ( | async_context_t * | context | ) |
Initialize and eturn the singleton BTstack run loop instance that integrates with the async_context API.
Parameters
context | the async_context instance that provides the abstraction for handling asynchronous work. |
Returns
the BTstack run loop instance
pico_lwip
Integration/wrapper libraries for lwIP the documentation for which is here. More...
Modules
-
lwIP compiler adapters. This is not included by default in
pico_lwip in
case you wish to implement your own. -
Glue library for integration lwIP in
NO_SYS=0
mode with the SDK. Simpleinit
anddeinit
are all that is required to hook up lwIP (with full blocking API support) via an async_context instance. -
Glue library for integration lwIP in
NO_SYS=1
mode with the SDK. Simpleinit
anddeinit
are all that is required to hook up lwIP via an async_context instance.
Detailed Description
Integration/wrapper libraries for lwIP the documentation for which is here.
The main pico_lwip library
itself aggregates the lwIP RAW API: pico_lwip_core,
pico_lwip_core4,
pico_lwip_core6,
pico_lwip_api,
pico_lwip_netif,
pico_lwip_sixlowpan and
pico_lwip_ppp.
If you wish to run in NO_SYS=1 mode, then you can link pico_lwip along
with pico_lwip_nosys.
If you wish to run in NO_SYS=0 mode, then you can link pico_lwip with
(for instance) pico_lwip_freertos, and also link in pico_lwip_api for the additional blocking/thread-safe APIs.
Additionally you must link in pico_lwip_arch unless you provide your own compiler bindings for lwIP.
Additional individual pieces of lwIP functionality are available à la cart, by linking any of the libraries below.
The following libraries are provided that contain exactly the equivalent lwIP functionality groups:
pico_lwip_core -
pico_lwip_core4 -
pico_lwip_core6 -
pico_lwip_netif -
pico_lwip_sixlowpan -
pico_lwip_ppp -
pico_lwip_api -
The following libraries are provided that contain exactly the equivalent lwIP application support:
pico_lwip_snmp -
pico_lwip_http -
pico_lwip_makefsdata -
pico_lwip_iperf -
pico_lwip_smtp -
pico_lwip_sntp -
pico_lwip_mdns -
pico_lwip_netbios -
pico_lwip_tftp -
pico_lwip_mbedtls -
pico_lwip_mqtt -
pico_lwip_arch
lwIP compiler adapters. This is not included by default in pico_lwip in
case you wish to implement your own.
lwIP compiler adapters. This is not included by default in pico_lwip in
case you wish to implement your own.
pico_lwip_freertos
Glue library for integration lwIP in NO_SYS=0
mode with the SDK. Simple init
and deinit
are all that is required to hook up lwIP (with full blocking API support) via an async_context instance.
More...
Functions
-
bool lwip_freertos_init (async_context_t *context)
-
Initializes lwIP (NO_SYS=0 mode) support support for FreeRTOS using the provided async_context.
-
void lwip_freertos_deinit (async_context_t *context)
-
De-initialize lwIP (NO_SYS=0 mode) support for FreeRTOS.
Detailed Description
Glue library for integration lwIP in NO_SYS=0
mode with the SDK. Simple init
and deinit
are all that is required to hook up lwIP (with full blocking API support) via an async_context instance.
Function Documentation
◆ lwip_freertos_deinit()
void lwip_freertos_deinit | ( | async_context_t * | context | ) |
De-initialize lwIP (NO_SYS=0 mode) support for FreeRTOS.
Note that since lwIP may only be initialized once, and doesn't itself provide a shutdown mechanism, lwIP itself may still consume resources.
It is however safe to call lwip_freertos_init again later.
Parameters
context | the async_context the lwip_freertos support was added to via lwip_freertos_init |
◆ lwip_freertos_init()
bool lwip_freertos_init | ( | async_context_t * | context | ) |
Initializes lwIP (NO_SYS=0 mode) support support for FreeRTOS using the provided async_context.
If the initialization succeeds, lwip_freertos_deinit() can be called to shutdown lwIP support
Parameters
context | the async_context instance that provides the abstraction for handling asynchronous work. Note in general this would be an async_context_freertos instance, though it doesn't have to be. |
Returns
true if the initialization succeeded
pico_lwip_nosys
Glue library for integration lwIP in NO_SYS=1
mode with the SDK. Simple init
and deinit
are all that is required to hook up lwIP via an async_context instance.
More...
Functions
-
bool lwip_nosys_init (async_context_t *context)
-
Initializes lwIP (NO_SYS=1 mode) support support using the provided async_context.
-
void lwip_nosys_deinit (async_context_t *context)
-
De-initialize lwIP (NO_SYS=1 mode) support.
Detailed Description
Glue library for integration lwIP in NO_SYS=1
mode with the SDK. Simple init
and deinit
are all that is required to hook up lwIP via an async_context instance.
Function Documentation
◆ lwip_nosys_deinit()
void lwip_nosys_deinit | ( | async_context_t * | context | ) |
De-initialize lwIP (NO_SYS=1 mode) support.
Note that since lwIP may only be initialized once, and doesn't itself provide a shutdown mechanism, lwIP itself may still consume resources
It is however safe to call lwip_nosys_init again later.
Parameters
context | the async_context the lwip_nosys support was added to via lwip_nosys_init |
◆ lwip_nosys_init()
bool lwip_nosys_init | ( | async_context_t * | context | ) |
Initializes lwIP (NO_SYS=1 mode) support support using the provided async_context.
If the initialization succeeds, lwip_nosys_deinit() can be called to shutdown lwIP support
Parameters
context | the async_context instance that provides the abstraction for handling asynchronous work. |
Returns
true if the initialization succeeded
pico_cyw43_driver
Functions
-
const hci_transport_t * hci_transport_cyw43_instance (void)
-
Get the Bluetooth HCI transport instance for cyw43.
-
bool cyw43_driver_init (async_context_t *context)
-
Initializes the lower level cyw43_driver and integrates it with the provided async_context.
-
void cyw43_driver_deinit (async_context_t *context)
-
De-initialize the lowever level cyw43_driver and unhooks it from the async_context.
Detailed Description
A wrapper around the lower level cyw43_driver, that integrates it with pico_async_context for handling background work.
Function Documentation
◆ cyw43_driver_deinit()
void cyw43_driver_deinit | ( | async_context_t * | context | ) |
De-initialize the lowever level cyw43_driver and unhooks it from the async_context.
Parameters
context | the async_context the cyw43_driver support was added to via cyw43_driver_init |
◆ cyw43_driver_init()
bool cyw43_driver_init | ( | async_context_t * | context | ) |
Initializes the lower level cyw43_driver and integrates it with the provided async_context.
If the initialization succeeds, lwip_nosys_deinit() can be called to shutdown lwIP support
Parameters
context | the async_context instance that provides the abstraction for handling asynchronous work. |
Returns
true if the initialization succeeded
Pico_bstack_cyw43
Low-level Bluetooth HCI support.
Low-level Bluetooth HCI support.
This library provides utility functions to initialise and de-initialise BTstack for CYW43,
pico_cyw43_arch
Macros
-
#define cyw43_arch_lwip_check() cyw43_thread_lock_check()
-
Checks the caller has any locks required for calling into lwIP.
Functions
-
int cyw43_arch_init (void)
-
Initialize the CYW43 architecture.
-
int cyw43_arch_init_with_country (uint32_t country)
-
Initialize the CYW43 architecture for use in a specific country.
-
void cyw43_arch_deinit (void)
-
De-initialize the CYW43 architecture.
-
async_context_t * cyw43_arch_async_context (void)
-
Return the current async_context currently in use by the cyw43_arch code.
-
void cyw43_arch_set_async_context (async_context_t *context)
-
Set the async_context to be used by the cyw43_arch_init.
-
async_context_t * cyw43_arch_init_default_async_context (void)
-
Initialize the default async_context for the current cyw43_arch type.
-
void cyw43_arch_poll (void)
-
Perform any processing required by the
cyw43_driver
or the TCP/IP stack. -
void cyw43_arch_wait_for_work_until (absolute_time_t until)
-
Sleep until there is cyw43_driver work to be done.
-
uint32_t cyw43_arch_get_country_code (void)
-
Return the country code used to initialize cyw43_arch.
-
void cyw43_arch_enable_sta_mode (void)
-
Enables Wi-Fi STA (Station) mode.
-
void cyw43_arch_enable_ap_mode (const char *ssid, const char *password, uint32_t auth)
-
Enables Wi-Fi AP (Access point) mode.
-
int cyw43_arch_wifi_connect_blocking (const char *ssid, const char *pw, uint32_t auth)
-
Attempt to connect to a wireless access point, blocking until the network is joined or a failure is detected.
-
int cyw43_arch_wifi_connect_bssid_blocking (const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth)
-
Attempt to connect to a wireless access point specified by SSID and BSSID, blocking until the network is joined or a failure is detected.
-
int cyw43_arch_wifi_connect_timeout_ms (const char *ssid, const char *pw, uint32_t auth, uint32_t timeout)
-
Attempt to connect to a wireless access point, blocking until the network is joined, a failure is detected or a timeout occurs.
-
int cyw43_arch_wifi_connect_bssid_timeout_ms (const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth, uint32_t timeout)
-
Attempt to connect to a wireless access point specified by SSID and BSSID, blocking until the network is joined, a failure is detected or a timeout occurs.
-
int cyw43_arch_wifi_connect_async (const char *ssid, const char *pw, uint32_t auth)
-
Start attempting to connect to a wireless access point.
-
int cyw43_arch_wifi_connect_bssid_async (const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth)
-
Start attempting to connect to a wireless access point specified by SSID and BSSID.
-
void cyw43_arch_gpio_put (uint wl_gpio, bool value)
-
Set a GPIO pin on the wireless chip to a given value.
-
bool cyw43_arch_gpio_get (uint wl_gpio)
-
Read the value of a GPIO pin on the wireless chip.
-
static void cyw43_arch_lwip_begin (void)
-
Acquire any locks required to call into lwIP.
-
static void cyw43_arch_lwip_end (void)
-
Release any locks required for calling into lwIP.
-
static int cyw43_arch_lwip_protect (int(*func)(void *param), void *param)
-
sad Release any locks required for calling into lwIP
Detailed Description
Architecture for integrating the CYW43 driver (for the wireless on Pico W) and lwIP (for TCP/IP stack) into the SDK. It is also necessary for accessing the on-board LED on Pico W
Both the low level cyw43_driver
and the lwIP stack require periodic servicing, and have limitations on whether they can be called from multiple cores/threads.
pico_cyw43_arch
attempts to abstract these complications into several behavioral groups:
'poll' - This not multi-core/IRQ safe, and requires the user to call cyw43_arch_poll periodically from their main loop
'thread_safe_background' - This is multi-core/thread/task safe, and maintenance of the driver and TCP/IP stack is handled automatically in the background
'freertos' - This is multi-core/thread/task safe, and uses a separate FreeRTOS task to handle lwIP and and driver work.
As of right now, lwIP is the only supported TCP/IP stack, however the use of pico_cyw43_arch
is intended to be independent of the particular TCP/IP stack used (and possibly Bluetooth stack used) in the future. For this reason, the integration of lwIP is handled in the base (pico_cyw43_arch
) library based on the #define CYW43_LWIP used by the cyw43_driver
.
Note |
As of version 1.5.0 of the Raspberry Pi Pico SDK, the The connection management APIs at least may be moved to a more generic library in a future release. The locking methods are now backed by their pico_async_context equivalents, and those methods may be used interchangeably (see cyw43_arch_lwip_begin, cyw43_arch_lwip_end and cyw43_arch_lwip_check for more details).
For examples of creating of your own async_context and addition of |
Whilst you can use the pico_cyw43_arch
library directly and specify CYW43_LWIP (and other defines) yourself, several other libraries are made available to the build which aggregate the defines and other dependencies for you:
-
pico_cyw43_arch_lwip_poll - For using the RAW lwIP API (in
NO_SYS=1
mode) without any background processing or multi-core/thread safety.The user must call pico_cyw43_poll periodically from their main loop.
This wrapper library:
Sets
CYW43_LWIP=1
to enable lwIP support inpico_cyw43_arch
andcyw43_driver
.Sets
PICO_CYW43_ARCH_POLL=1
to select the polling behavior.Adds the
pico_lwip
as a dependency to pull in lwIP.
-
pico_cyw43_arch_lwip_threadsafe_background - For using the RAW lwIP API (in
NO_SYS=1
mode) with multi-core/thread safety, and automatic servicing of thecyw43_driver
and lwIP in background.Calls into the
cyw43_driver
high level API (cyw43.h) may be made from either core or from lwIP callbacks, however calls into lwIP (which is not thread-safe) other than those made from lwIP callbacks, must be bracketed with cyw43_arch_lwip_begin and cyw43_arch_lwip_end. It is fine to bracket calls made from within lwIP callbacks too; you just don't have to.NotelwIP callbacks happen in a (low priority) IRQ context (similar to an alarm callback), so care should be taken when interacting with other code. This wrapper library:
Sets
CYW43_LWIP=1
to enable lwIP support inpico_cyw43_arch
andcyw43_driver
Sets
PICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1
to select the thread-safe/non-polling behavior.Adds the pico_lwip as a dependency to pull in lwIP.
This library can also be used under the RP2040 port of FreeRTOS with lwIP in
NO_SYS=1
mode (allowing you to callcyw43_driver
APIs from any task, and to call lwIP from lwIP callbacks, or from any task if you bracket the calls with cyw43_arch_lwip_begin and cyw43_arch_lwip_end. Again, you should be careful about what you do in lwIP callbacks, as you cannot call most FreeRTOS APIs from within an IRQ context. Unless you have good reason, you should probably use the full FreeRTOS integration (withNO_SYS=0
) provided bypico_cyw43_arch_lwip_sys_freertos
. -
pico_cyw43_arch_lwip_sys_freertos - For using the full lwIP API including blocking sockets in OS (
NO_SYS=0
) mode, along with with multi-core/task/thread safety, and automatic servicing of thecyw43_driver
and the lwIP stack.This wrapper library:
Sets
CYW43_LWIP=1
to enable lwIP support inpico_cyw43_arch
andcyw43_driver
.Sets
PICO_CYW43_ARCH_FREERTOS=1
to select the NO_SYS=0 lwip/FreeRTOS integrationSets
LWIP_PROVIDE_ERRNO=1
to provide error numbers needed for compilation without an OSAdds the
pico_lwip
as a dependency to pull in lwIP.Adds the lwIP/FreeRTOS code from lwip-contrib (in the contrib directory of lwIP)
Calls into the
cyw43_driver
high level API (cyw43.h) may be made from any task or from lwIP callbacks, but not from IRQs. Calls into the lwIP RAW API (which is not thread safe) must be bracketed with cyw43_arch_lwip_begin and cyw43_arch_lwip_end. It is fine to bracket calls made from within lwIP callbacks too; you just don't have to.Notethis wrapper library requires you to link FreeRTOS functionality with your application yourself. -
pico_cyw43_arch_none - If you do not need the TCP/IP stack but wish to use the on-board LED.
This wrapper library:
Sets
CYW43_LWIP=0
to disable lwIP support inpico_cyw43_arch
andcyw43_driver
Macro Definition Documentation
◆ cyw43_arch_lwip_check
void cyw43_arch_lwip_check | ( | void | ) | cyw43_thread_lock_check() |
Checks the caller has any locks required for calling into lwIP.
The lwIP API is not thread safe. You should surround calls into the lwIP API with calls to cyw43_arch_lwip_begin and this method. Note these calls are not necessary (but harmless) when you are calling back into the lwIP API from an lwIP callback.
This method will assert in debug mode, if the above conditions are not met (i.e. it is not safe to call into the lwIP API)
Note |
as of SDK release 1.5.0, this is now equivalent to calling async_context_lock_check on the async_context associated with cyw43_arch and lwIP. |
See alsocyw43_arch_lwip_begin cyw43_arch_lwip_protect async_context_lock_check cyw43_arch_async_context
Function Documentation
◆ cyw43_arch_async_context()
async_context_t * cyw43_arch_async_context | ( | void | ) |
Return the current async_context currently in use by the cyw43_arch code.
Returns
the async_context.
◆ cyw43_arch_deinit()
void cyw43_arch_deinit | ( | void | ) |
De-initialize the CYW43 architecture.
This method de-initializes the cyw43_driver
code and de-initializes the lwIP stack (if it was enabled at build time). Note this method should always be called from the same core (or RTOS task, depending on the environment) as cyw43_arch_init.
Additionally if the cyw43_arch is using its own async_context instance, then that instance is de-initialized.
◆ cyw43_arch_enable_ap_mode()
void cyw43_arch_enable_ap_mode | ( | const char * | ssid, |
const char * | password, | ||
uint32_t | auth | ||
) |
Enables Wi-Fi AP (Access point) mode.
This enables the Wi-Fi in Access Point mode such that connections can be made to the device by other Wi-Fi clients
Parameters
ssid | the name for the access point |
password | the password to use or NULL for no password. |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
◆ cyw43_arch_enable_sta_mode()
void cyw43_arch_enable_sta_mode | ( | void | ) |
Enables Wi-Fi STA (Station) mode.
This enables the Wi-Fi in \emStation mode such that connections can be made to other Wi-Fi Access Points
◆ cyw43_arch_get_country_code()
uint32_t cyw43_arch_get_country_code | ( | void | ) |
Return the country code used to initialize cyw43_arch.
Returns
the country code (see CYW43_COUNTRY_)
◆ cyw43_arch_gpio_get()
bool cyw43_arch_gpio_get | ( | uint | wl_gpio | ) |
Read the value of a GPIO pin on the wireless chip.
Note |
this method does not check for errors setting the GPIO. You can use the lower level cyw43_gpio_get instead if you wish to check for errors. |
Parameters
wl_gpio | the GPIO number on the wireless chip |
Returns
true if the GPIO is high, false otherwise
◆ cyw43_arch_gpio_put()
void cyw43_arch_gpio_put | ( | uint | wl_gpio, |
bool | value | ||
) |
Set a GPIO pin on the wireless chip to a given value.
Note |
this method does not check for errors setting the GPIO. You can use the lower level cyw43_gpio_set instead if you wish to check for errors. |
Parameters
wl_gpio | the GPIO number on the wireless chip |
value | true to set the GPIO, false to clear it. |
◆ cyw43_arch_init()
int cyw43_arch_init | ( | void | ) |
Initialize the CYW43 architecture.
This method initializes the cyw43_driver
code and initializes the lwIP stack (if it was enabled at build time). This method must be called prior to using any other pico_cyw43_arch
, cyw43_driver
or lwIP functions.
Note |
this method initializes wireless with a country code of PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE which defaults to CYW43_COUNTRY_WORLDWIDE . Worldwide settings may not give the best performance; consider setting PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE to a different value or calling cyw43_arch_init_with_country
|
By default this method initializes the cyw43_arch code's own async_context by calling cyw43_arch_init_default_async_context, however the user can specify use of their own async_context by calling cyw43_arch_set_async_context() before calling this method
Returns
0 if the initialization is successful, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_init_default_async_context()
async_context_t * cyw43_arch_init_default_async_context | ( | void | ) |
Initialize the default async_context for the current cyw43_arch type.
This method initializes and returns a pointer to the static async_context associated with cyw43_arch. This method is called by cyw43_arch_init automatically if a different async_context has not been set by cyw43_arch_set_async_context
Returns
the context or NULL if initialization failed.
◆ cyw43_arch_init_with_country()
int cyw43_arch_init_with_country | ( | uint32_t | country | ) |
Initialize the CYW43 architecture for use in a specific country.
This method initializes the cyw43_driver
code and initializes the lwIP stack (if it was enabled at build time). This method must be called prior to using any other pico_cyw43_arch
, cyw43_driver
or lwIP functions.
By default this method initializes the cyw43_arch code's own async_context by calling cyw43_arch_init_default_async_context, however the user can specify use of their own async_context by calling cyw43_arch_set_async_context() before calling this method
Parameters
country | the country code to use (see CYW43_COUNTRY_) |
Returns
0 if the initialization is successful, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_lwip_begin()
|
inlinestatic |
Acquire any locks required to call into lwIP.
The lwIP API is not thread safe. You should surround calls into the lwIP API with calls to this method and cyw43_arch_lwip_end. Note these calls are not necessary (but harmless) when you are calling back into the lwIP API from an lwIP callback. If you are using single-core polling only (pico_cyw43_arch_poll) then these calls are no-ops anyway it is good practice to call them anyway where they are necessary.
Note |
as of SDK release 1.5.0, this is now equivalent to calling pico_async_context_acquire_lock_blocking on the async_context associated with cyw43_arch and lwIP. |
See alsocyw43_arch_lwip_end cyw43_arch_lwip_protect async_context_acquire_lock_blocking cyw43_arch_async_context
◆ cyw43_arch_lwip_end()
|
inlinestatic |
Release any locks required for calling into lwIP.
The lwIP API is not thread safe. You should surround calls into the lwIP API with calls to cyw43_arch_lwip_begin and this method. Note these calls are not necessary (but harmless) when you are calling back into the lwIP API from an lwIP callback. If you are using single-core polling only (pico_cyw43_arch_poll) then these calls are no-ops anyway it is good practice to call them anyway where they are necessary.
Note |
as of SDK release 1.5.0, this is now equivalent to calling async_context_release_lock on the async_context associated with cyw43_arch and lwIP. |
See alsocyw43_arch_lwip_begin cyw43_arch_lwip_protect async_context_release_lock cyw43_arch_async_context
◆ cyw43_arch_lwip_protect()
|
inlinestatic |
sad Release any locks required for calling into lwIP
The lwIP API is not thread safe. You can use this method to wrap a function with any locking required to call into the lwIP API. If you are using single-core polling only (pico_cyw43_arch_poll) then there are no locks to required, but it is still good practice to use this function.
Parameters
func | the function ta call with any required locks held |
param | parameter to pass to func |
Returns
the return value from func
◆ cyw43_arch_poll()
void cyw43_arch_poll | ( | void | ) |
Perform any processing required by the cyw43_driver
or the TCP/IP stack.
This method must be called periodically from the main loop when using a polling style pico_cyw43_arch
(e.g. pico_cyw43_arch_lwip_poll
). It may be called in other styles, but it is unnecessary to do so.
◆ cyw43_arch_set_async_context()
void cyw43_arch_set_async_context | ( | async_context_t * | context | ) |
Set the async_context to be used by the cyw43_arch_init.
Note |
This method must be called before calling cyw43_arch_init or cyw43_arch_init_with_country if you wish to use a custom async_context instance. |
Parameters
context | the async_context to be used |
◆ cyw43_arch_wait_for_work_until()
void cyw43_arch_wait_for_work_until | ( | absolute_time_t | until | ) |
Sleep until there is cyw43_driver work to be done.
This method may be called by code that is waiting for an event to come from the cyw43_driver, and has no work to do, but would like to sleep without blocking any background work associated with the cyw43_driver.
Parameters
until | the time to wait until if there is no work to do. |
◆ cyw43_arch_wifi_connect_async()
int cyw43_arch_wifi_connect_async | ( | const char * | ssid, |
const char * | pw, | ||
uint32_t | auth | ||
) |
Start attempting to connect to a wireless access point.
This method tells the CYW43 driver to start connecting to an access point. You should subsequently check the status by calling cyw43_wifi_link_status.
Parameters
ssid | the network name to connect to |
pw | the network password or NULL if there is no password required |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
Returns
0 if the scan was started successfully, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_wifi_connect_blocking()
int cyw43_arch_wifi_connect_blocking | ( | const char * | ssid, |
const char * | pw, | ||
uint32_t | auth | ||
) |
Attempt to connect to a wireless access point, blocking until the network is joined or a failure is detected.
Parameters
ssid | the network name to connect to |
pw | the network password or NULL if there is no password required |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
Returns
0 if the initialization is successful, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_wifi_connect_bssid_async()
int cyw43_arch_wifi_connect_bssid_async | ( | const char * | ssid, |
const uint8_t * | bssid, | ||
const char * | pw, | ||
uint32_t | auth | ||
) |
Start attempting to connect to a wireless access point specified by SSID and BSSID.
This method tells the CYW43 driver to start connecting to an access point. You should subsequently check the status by calling cyw43_wifi_link_status.
Parameters
ssid | the network name to connect to |
bssid | the network BSSID to connect to or NULL if ignored |
password | the network password or NULL if there is no password required |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
Returns
0 if the scan was started successfully, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_wifi_connect_bssid_blocking()
int cyw43_arch_wifi_connect_bssid_blocking | ( | const char * | ssid, |
const uint8_t * | bssid, | ||
const char * | pw, | ||
uint32_t | auth | ||
) |
Attempt to connect to a wireless access point specified by SSID and BSSID, blocking until the network is joined or a failure is detected.
Parameters
ssid | the network name to connect to |
bssid | the network BSSID to connect to or NULL if ignored |
password | the network password or NULL if there is no password required |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
Returns
0 if the initialization is successful, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_wifi_connect_bssid_timeout_ms()
int cyw43_arch_wifi_connect_bssid_timeout_ms | ( | const char * | ssid, |
const uint8_t * | bssid, | ||
const char * | pw, | ||
uint32_t | auth, | ||
uint32_t | timeout | ||
) |
Attempt to connect to a wireless access point specified by SSID and BSSID, blocking until the network is joined, a failure is detected or a timeout occurs.
Parameters
ssid | the network name to connect to |
bssid | the network BSSID to connect to or NULL if ignored |
password | the network password or NULL if there is no password required |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
Returns
0 if the initialization is successful, an error code otherwise
See alsopico_error_codes
◆ cyw43_arch_wifi_connect_timeout_ms()
int cyw43_arch_wifi_connect_timeout_ms | ( | const char * | ssid, |
const char * | pw, | ||
uint32_t | auth, | ||
uint32_t | timeout | ||
) |
Attempt to connect to a wireless access point, blocking until the network is joined, a failure is detected or a timeout occurs.
Parameters
ssid | the network name to connect to |
pw | the network password or NULL if there is no password required |
auth | the authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_) |
Returns
0 if the initialization is successful, an error code otherwise
See alsopico_error_codes
cyw43_driver
Driver used for Pico W wireless. More...
Files
-
file cyw43.h
-
CYW43 driver interface.
-
file cyw43_country.h
-
CYW43 country codes.
Data Structures
-
struct _cyw43_t
Macros
-
#define CYW43_DEFAULT_PM cyw43_pm_value(CYW43_PM2_POWERSAVE_MODE, 200, 1, 1, 10)
-
Default power management mode.
-
#define CYW43_AGGRESSIVE_PM cyw43_pm_value(CYW43_PM2_POWERSAVE_MODE, 2000, 1, 1, 10)
-
Aggressive power management mode for optimial power usage at the cost of performance.
-
#define CYW43_PERFORMANCE_PM cyw43_pm_value(CYW43_PM2_POWERSAVE_MODE, 20, 1, 1, 1)
-
Performance power management mode where more power is used to increase performance.
-
#define CYW43_COUNTRY(A, B, REV) ((unsigned char)(A) | ((unsigned char)(B) << 8) | ((REV) << 16))
-
create a country code from the two character country and revision number
Typedefs
-
typedef struct _cyw43_t cyw43_t
Functions
-
void cyw43_init (cyw43_t *self)
-
Initialize the driver.
-
void cyw43_deinit (cyw43_t *self)
-
Shut the driver down.
-
int cyw43_ioctl (cyw43_t *self, uint32_t cmd, size_t len, uint8_t *buf, uint32_t iface)
-
Send an ioctl command to cyw43.
-
int cyw43_send_ethernet (cyw43_t *self, int itf, size_t len, const void *buf, bool is_pbuf)
-
Send a raw ethernet packet.
-
int cyw43_wifi_pm (cyw43_t *self, uint32_t pm)
-
Set the wifi power management mode.
-
int cyw43_wifi_get_pm (cyw43_t *self, uint32_t *pm)
-
Get the wifi power management mode.
-
int cyw43_wifi_link_status (cyw43_t *self, int itf)
-
Get the wifi link status.
-
void cyw43_wifi_set_up (cyw43_t *self, int itf, bool up, uint32_t country)
-
Set up and initialise wifi.
-
int cyw43_wifi_get_mac (cyw43_t *self, int itf, uint8_t mac[6])
-
Get the mac address of the device.
-
int cyw43_wifi_update_multicast_filter (cyw43_t *self, uint8_t *addr, bool add)
-
Add/remove multicast group address.
-
int cyw43_wifi_scan (cyw43_t *self, cyw43_wifi_scan_options_t *opts, void *env, int(*result_cb)(void *, const cyw43_ev_scan_result_t *))
-
Perform a wifi scan for wifi networks.
-
static bool cyw43_wifi_scan_active (cyw43_t *self)
-
Determine if a wifi scan is in progress.
-
int cyw43_wifi_join (cyw43_t *self, size_t ssid_len, const uint8_t *ssid, size_t key_len, const uint8_t *key, uint32_t auth_type, const uint8_t *bssid, uint32_t channel)
-
Connect or join a wifi network.
-
int cyw43_wifi_leave (cyw43_t *self, int itf)
-
Dissassociate from a wifi network.
-
int cyw43_wifi_get_rssi (cyw43_t *self, int32_t *rssi)
-
Get the signal strength (RSSI) of the wifi network.
-
int cyw43_wifi_get_bssid (cyw43_t *self, uint8_t bssid[6])
-
Get the BSSID of the connected wifi network.
-
static void cyw43_wifi_ap_get_ssid (cyw43_t *self, size_t *len, const uint8_t **buf)
-
Get the ssid for the access point.
-
static uint32_t cyw43_wifi_ap_get_auth (cyw43_t *self)
-
Get the security authorisation used in AP mode.
-
static void cyw43_wifi_ap_set_channel (cyw43_t *self, uint32_t channel)
-
Set the the channel for the access point.
-
static void cyw43_wifi_ap_set_ssid (cyw43_t *self, size_t len, const uint8_t *buf)
-
Set the ssid for the access point.
-
static void cyw43_wifi_ap_set_password (cyw43_t *self, size_t len, const uint8_t *buf)
-
Set the password for the wifi access point.
-
static void cyw43_wifi_ap_set_auth (cyw43_t *self, uint32_t auth)
-
Set the security authorisation used in AP mode.
-
void cyw43_wifi_ap_get_max_stas (cyw43_t *self, int *max_stas)
-
Get the maximum number of devices (STAs) that can be associated with the wifi access point.
-
void cyw43_wifi_ap_get_stas (cyw43_t *self, int *num_stas, uint8_t *macs)
-
Get the number of devices (STAs) associated with the wifi access point.
-
static bool cyw43_is_initialized (cyw43_t *self)
-
Determines if the cyw43 driver been initialised.
-
void cyw43_cb_tcpip_init (cyw43_t *self, int itf)
-
Initialise the IP stack.
-
void cyw43_cb_tcpip_deinit (cyw43_t *self, int itf)
-
Deinitialise the IP stack.
-
void cyw43_cb_tcpip_set_link_up (cyw43_t *self, int itf)
-
Notify the IP stack that the link is up.
-
void cyw43_cb_tcpip_set_link_down (cyw43_t *self, int itf)
-
Notify the IP stack that the link is down.
-
int cyw43_tcpip_link_status (cyw43_t *self, int itf)
-
Get the link status.
-
static uint32_t cyw43_pm_value (uint8_t pm_mode, uint16_t pm2_sleep_ret_ms, uint8_t li_beacon_period, uint8_t li_dtim_period, uint8_t li_assoc)
-
Return a power management value to pass to cyw43_wifi_pm.
Variables
-
cyw43_t cyw43_state
Link status
See alsostatus_name() to get a user readable name of the status for debug cyw43_wifi_link_status() to get the wifi status cyw43_tcpip_link_status() to get the overall link status
-
link is down
-
Connected to wifi.
-
Connected to wifi, but no IP address.
-
Connect to wifi with an IP address.
-
Connection failed.
-
No matching SSID found (could be out of range, or down)
-
#define CYW43_LINK_BADAUTH (-3)
Country codes
-
#define CYW43_COUNTRY_WORLDWIDE CYW43_COUNTRY('X', 'X', 0)
-
#define CYW43_COUNTRY_AUSTRALIA CYW43_COUNTRY('A', 'U', 0)
-
#define CYW43_COUNTRY_AUSTRIA CYW43_COUNTRY('A', 'T', 0)
-
#define CYW43_COUNTRY_BELGIUM CYW43_COUNTRY('B', 'E', 0)
-
#define CYW43_COUNTRY_BRAZIL CYW43_COUNTRY('B', 'R', 0)
-
#define CYW43_COUNTRY_CANADA CYW43_COUNTRY('C', 'A', 0)
-
#define CYW43_COUNTRY_CHILE CYW43_COUNTRY('C', 'L', 0)
-
#define CYW43_COUNTRY_CHINA CYW43_COUNTRY('C', 'N', 0)
-
#define CYW43_COUNTRY_COLOMBIA CYW43_COUNTRY('C', 'O', 0)
-
#define CYW43_COUNTRY_CZECH_REPUBLIC CYW43_COUNTRY('C', 'Z', 0)
-
#define CYW43_COUNTRY_DENMARK CYW43_COUNTRY('D', 'K', 0)
-
#define CYW43_COUNTRY_ESTONIA CYW43_COUNTRY('E', 'E', 0)
-
#define CYW43_COUNTRY_FINLAND CYW43_COUNTRY('F', 'I', 0)
-
#define CYW43_COUNTRY_FRANCE CYW43_COUNTRY('F', 'R', 0)
-
#define CYW43_COUNTRY_GERMANY CYW43_COUNTRY('D', 'E', 0)
-
#define CYW43_COUNTRY_GREECE CYW43_COUNTRY('G', 'R', 0)
-
#define CYW43_COUNTRY_HONG_KONG CYW43_COUNTRY('H', 'K', 0)
-
#define CYW43_COUNTRY_HUNGARY CYW43_COUNTRY('H', 'U', 0)
-
#define CYW43_COUNTRY_ICELAND CYW43_COUNTRY('I', 'S', 0)
-
#define CYW43_COUNTRY_INDIA CYW43_COUNTRY('I', 'N', 0)
-
#define CYW43_COUNTRY_ISRAEL CYW43_COUNTRY('I', 'L', 0)
-
#define CYW43_COUNTRY_ITALY CYW43_COUNTRY('I', 'T', 0)
-
#define CYW43_COUNTRY_JAPAN CYW43_COUNTRY('J', 'P', 0)
-
#define CYW43_COUNTRY_KENYA CYW43_COUNTRY('K', 'E', 0)
-
#define CYW43_COUNTRY_LATVIA CYW43_COUNTRY('L', 'V', 0)
-
#define CYW43_COUNTRY_LIECHTENSTEIN CYW43_COUNTRY('L', 'I', 0)
-
#define CYW43_COUNTRY_LITHUANIA CYW43_COUNTRY('L', 'T', 0)
-
#define CYW43_COUNTRY_LUXEMBOURG CYW43_COUNTRY('L', 'U', 0)
-
#define CYW43_COUNTRY_MALAYSIA CYW43_COUNTRY('M', 'Y', 0)
-
#define CYW43_COUNTRY_MALTA CYW43_COUNTRY('M', 'T', 0)
-
#define CYW43_COUNTRY_MEXICO CYW43_COUNTRY('M', 'X', 0)
-
#define CYW43_COUNTRY_NETHERLANDS CYW43_COUNTRY('N', 'L', 0)
-
#define CYW43_COUNTRY_NEW_ZEALAND CYW43_COUNTRY('N', 'Z', 0)
-
#define CYW43_COUNTRY_NIGERIA CYW43_COUNTRY('N', 'G', 0)
-
#define CYW43_COUNTRY_NORWAY CYW43_COUNTRY('N', 'O', 0)
-
#define CYW43_COUNTRY_PERU CYW43_COUNTRY('P', 'E', 0)
-
#define CYW43_COUNTRY_PHILIPPINES CYW43_COUNTRY('P', 'H', 0)
-
#define CYW43_COUNTRY_POLAND CYW43_COUNTRY('P', 'L', 0)
-
#define CYW43_COUNTRY_PORTUGAL CYW43_COUNTRY('P', 'T', 0)
-
#define CYW43_COUNTRY_SINGAPORE CYW43_COUNTRY('S', 'G', 0)
-
#define CYW43_COUNTRY_SLOVAKIA CYW43_COUNTRY('S', 'K', 0)
-
#define CYW43_COUNTRY_SLOVENIA CYW43_COUNTRY('S', 'I', 0)
-
#define CYW43_COUNTRY_SOUTH_AFRICA CYW43_COUNTRY('Z', 'A', 0)
-
#define CYW43_COUNTRY_SOUTH_KOREA CYW43_COUNTRY('K', 'R', 0)
-
#define CYW43_COUNTRY_SPAIN CYW43_COUNTRY('E', 'S', 0)
-
#define CYW43_COUNTRY_SWEDEN CYW43_COUNTRY('S', 'E', 0)
-
#define CYW43_COUNTRY_SWITZERLAND CYW43_COUNTRY('C', 'H', 0)
-
#define CYW43_COUNTRY_TAIWAN CYW43_COUNTRY('T', 'W', 0)
-
#define CYW43_COUNTRY_THAILAND CYW43_COUNTRY('T', 'H', 0)
-
#define CYW43_COUNTRY_TURKEY CYW43_COUNTRY('T', 'R', 0)
-
#define CYW43_COUNTRY_UK CYW43_COUNTRY('G', 'B', 0)
-
#define CYW43_COUNTRY_USA CYW43_COUNTRY('U', 'S', 0)
Function Documentation
◆ cyw43_cb_tcpip_deinit()
void cyw43_cb_tcpip_deinit | ( | cyw43_t * | self, |
int | itf | ||
) |
Deinitialise the IP stack.
This method must be provided by the network stack interface It is called to close the IP stack and free resources.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface used, either CYW43_ITF_STA or CYW43_ITF_AP |
◆ cyw43_cb_tcpip_init()
void cyw43_cb_tcpip_init | ( | cyw43_t * | self, |
int | itf | ||
) |
Initialise the IP stack.
This method must be provided by the network stack interface It is called to initialise the IP stack.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface used, either CYW43_ITF_STA or CYW43_ITF_AP |
◆ cyw43_cb_tcpip_set_link_down()
void cyw43_cb_tcpip_set_link_down | ( | cyw43_t * | self, |
int | itf | ||
) |
Notify the IP stack that the link is down.
This method must be provided by the network stack interface It is called to notify the IP stack that the link is down.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface used, either CYW43_ITF_STA or CYW43_ITF_AP |
◆ cyw43_cb_tcpip_set_link_up()
void cyw43_cb_tcpip_set_link_up | ( | cyw43_t * | self, |
int | itf | ||
) |
Notify the IP stack that the link is up.
This method must be provided by the network stack interface It is called to notify the IP stack that the link is up. This can, for example be used to request an IP address via DHCP.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface used, either CYW43_ITF_STA or CYW43_ITF_AP |
◆ cyw43_deinit()
void cyw43_deinit | ( | cyw43_t * | self | ) |
Shut the driver down.
This method will close the network interfaces, and free up resources
Parameters
self | the driver state object. This should always be &cyw43_state |
◆ cyw43_init()
void cyw43_init | ( | cyw43_t * | self | ) |
Initialize the driver.
This method must be called before using the driver
Parameters
self | the driver state object. This should always be &cyw43_state |
◆ cyw43_ioctl()
int cyw43_ioctl | ( | cyw43_t * | self, |
uint32_t | cmd, | ||
size_t | len, | ||
uint8_t * | buf, | ||
uint32_t | iface | ||
) |
Send an ioctl command to cyw43.
This method sends a command to cyw43.
Parameters
self | the driver state object. This should always be &cyw43_state |
cmd | the command to send |
len | the amount of data to send with the commannd |
buf | a buffer containing the data to send |
iface | the interface to use, either CYW43_ITF_STA or CYW43_ITF_AP |
Returns
0 on success
◆ cyw43_is_initialized()
|
inlinestatic |
Determines if the cyw43 driver been initialised.
Returns true if the cyw43 driver has been initialised with a call to cyw43_init
Parameters
self | the driver state object. This should always be &cyw43_state |
Returns
True if the cyw43 driver has been initialised
◆ cyw43_pm_value()
|
inlinestatic |
Return a power management value to pass to cyw43_wifi_pm.
Generate the power management (PM) value to pass to cyw43_wifi_pm
pm_mode | Meaning |
---|---|
CYW43_NO_POWERSAVE_MODE | No power saving |
CYW43_PM1_POWERSAVE_MODE | Aggressive power saving which reduces wifi throughput |
CYW43_PM2_POWERSAVE_MODE | Power saving with High throughput (preferred). Saves power when there is no wifi activity for some time. |
See alsoCYW43_DEFAULT_PM CYW43_AGGRESSIVE_PM CYW43_PERFORMANCE_PM
Parameters
pm_mode | Power management mode |
pm2_sleep_ret_ms | The maximum time to wait before going back to sleep for CYW43_PM2_POWERSAVE_MODE mode. Value measured in milliseconds and must be between 10 and 2000ms and divisible by 10 |
li_beacon_period | Wake period is measured in beacon periods |
li_dtim_period | Wake interval measured in DTIMs. If this is set to 0, the wake interval is measured in beacon periods |
li_assoc | Wake interval sent to the access point |
◆ cyw43_send_ethernet()
int cyw43_send_ethernet | ( | cyw43_t * | self, |
int | itf, | ||
size_t | len, | ||
const void * | buf, | ||
bool | is_pbuf | ||
) |
Send a raw ethernet packet.
This method sends a raw ethernet packet.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | interface to use, either CYW43_ITF_STA or CYW43_ITF_AP |
len | the amount of data to send |
buf | the data to send |
is_pbuf | true if buf points to an lwip struct pbuf |
Returns
0 on success
◆ cyw43_tcpip_link_status()
int cyw43_tcpip_link_status | ( | cyw43_t * | self, |
int | itf | ||
) |
Get the link status.
Returns the status of the link which is a superset of the wifi link status returned by cyw43_wifi_link_status
Note |
If the link status is negative it indicates an error |
link status | Meaning |
---|---|
CYW43_LINK_DOWN | Wifi down |
CYW43_LINK_JOIN | Connected to wifi |
CYW43_LINK_NOIP | Connected to wifi, but no IP address |
CYW43_LINK_UP | Connect to wifi with an IP address |
CYW43_LINK_FAIL | Connection failed |
CYW43_LINK_NONET | No matching SSID found (could be out of range, or down) |
CYW43_LINK_BADAUTH | Authenticatation failure |
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface for which to return the link status, should be CYW43_ITF_STA or CYW43_ITF_AP |
Returns
A value representing the link status
◆ cyw43_wifi_ap_get_auth()
|
inlinestatic |
Get the security authorisation used in AP mode.
For access point (AP) mode, this method can be used to get the security authorisation mode.
Parameters
self | the driver state object. This should always be &cyw43_state |
Returns
the current security authorisation mode for the access point
◆ cyw43_wifi_ap_get_max_stas()
void cyw43_wifi_ap_get_max_stas | ( | cyw43_t * | self, |
int * | max_stas | ||
) |
Get the maximum number of devices (STAs) that can be associated with the wifi access point.
For access point (AP) mode, this method can be used to get the maximum number of devices that can be connected to the wifi access point.
Parameters
self | the driver state object. This should always be &cyw43_state |
max_stas | Returns the maximum number of devices (STAs) that can be connected to the access point |
◆ cyw43_wifi_ap_get_ssid()
|
inlinestatic |
Get the ssid for the access point.
For access point (AP) mode, this method can be used to get the SSID name of the wifi access point.
Parameters
self | the driver state object. This should always be &cyw43_state |
len | Returns the length of the AP SSID name |
buf | Returns a pointer to an internal buffer containing the AP SSID name |
◆ cyw43_wifi_ap_get_stas()
void cyw43_wifi_ap_get_stas | ( | cyw43_t * | self, |
int * | num_stas, | ||
uint8_t * | macs | ||
) |
Get the number of devices (STAs) associated with the wifi access point.
For access point (AP) mode, this method can be used to get the number of devices and mac addresses of devices connected to the wifi access point.
Parameters
self | the driver state object. This should always be &cyw43_state |
num_stas | Returns the number of devices (STA) connected to the access point |
macs | Returns the mac addresses of devies (STA) connected to the access point. The supplied buffer should have enough room for 6 bytes per mac address. Call cyw43_wifi_ap_get_max_stas to determine how many mac addresses can be returned. |
◆ cyw43_wifi_ap_set_auth()
|
inlinestatic |
Set the security authorisation used in AP mode.
For access point (AP) mode, this method can be used to set how access to the access point is authorised.
Auth mode | Meaning |
---|---|
CYW43_AUTH_OPEN | Use an open access point with no authorisation required |
CYW43_AUTH_WPA_TKIP_PSK | Use WPA authorisation |
CYW43_AUTH_WPA2_AES_PSK | Use WPA2 (preferred) |
CYW43_AUTH_WPA2_MIXED_PSK | Use WPA2/WPA mixed (currently treated the same as CYW43_AUTH_WPA2_AES_PSK) |
Parameters
self | the driver state object. This should always be &cyw43_state |
auth | Auth mode for the access point |
◆ cyw43_wifi_ap_set_channel()
|
inlinestatic |
Set the the channel for the access point.
For access point (AP) mode, this method can be used to set the channel used for the wifi access point.
Parameters
self | the driver state object. This should always be &cyw43_state |
channel | Wifi channel to use for the wifi access point |
◆ cyw43_wifi_ap_set_password()
|
inlinestatic |
Set the password for the wifi access point.
For access point (AP) mode, this method can be used to set the password for the wifi access point.
Parameters
self | the driver state object. This should always be &cyw43_state |
len | The length of the AP password |
buf | A buffer containing the AP password |
◆ cyw43_wifi_ap_set_ssid()
|
inlinestatic |
Set the ssid for the access point.
For access point (AP) mode, this method can be used to set the SSID name of the wifi access point.
Parameters
self | the driver state object. This should always be &cyw43_state |
len | The length of the AP SSID name |
buf | A buffer containing the AP SSID name |
◆ cyw43_wifi_get_bssid()
int cyw43_wifi_get_bssid | ( | cyw43_t * | self, |
uint8_t | bssid[6] | ||
) |
Get the BSSID of the connected wifi network.
Parameters
self | the driver state object. This should always be &cyw43_state |
bssid | a buffer to receive the BSSID |
Returns
0 on success
◆ cyw43_wifi_get_mac()
int cyw43_wifi_get_mac | ( | cyw43_t * | self, |
int | itf, | ||
uint8_t | mac[6] | ||
) |
Get the mac address of the device.
This method returns the mac address of the interface.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface to use, either CYW43_ITF_STA or CYW43_ITF_AP |
mac | a buffer to receive the mac address |
Returns
0 on success
◆ cyw43_wifi_get_pm()
int cyw43_wifi_get_pm | ( | cyw43_t * | self, |
uint32_t * | pm | ||
) |
Get the wifi power management mode.
This method gets the power management mode used by cyw43. The value is expressed as an unsigned integer 0x00adbrrm where, m = pm_mode Power management mode rr = pm2_sleep_ret (in units of 10ms) b = li_beacon_period d = li_dtim_period a = li_assoc
See alsocyw43_pm_value for an explanation of these values This should be called after cyw43_wifi_set_up
Parameters
pm | Power management value |
Returns
0 on success
◆ cyw43_wifi_get_rssi()
int cyw43_wifi_get_rssi | ( | cyw43_t * | self, |
int32_t * | rssi | ||
) |
Get the signal strength (RSSI) of the wifi network.
For STA (client) mode, returns the signal strength or RSSI of the wifi network. An RSSI value of zero is returned if you call this function before a network is connected.
Parameters
self | the driver state object. This should always be &cyw43_state |
rssi | a pointer to which the returned RSSI value is stored. |
Returns
0 on success
◆ cyw43_wifi_join()
int cyw43_wifi_join | ( | cyw43_t * | self, |
size_t | ssid_len, | ||
const uint8_t * | ssid, | ||
size_t | key_len, | ||
const uint8_t * | key, | ||
uint32_t | auth_type, | ||
const uint8_t * | bssid, | ||
uint32_t | channel | ||
) |
Connect or join a wifi network.
Connect to a wifi network in STA (client) mode After success is returned, periodically call cyw43_wifi_link_status or cyw43_tcpip_link_status, to query the status of the link. It can take a many seconds to connect to fully join a network.
Note |
Call cyw43_wifi_leave to dissassociate from a wifi network. |
Parameters
self | the driver state object. This should always be &cyw43_state |
ssid_len | the length of the wifi network name |
ssid | A buffer containing the wifi network name |
key_len | The length of the wifi password |
key | A buffer containing the wifi password |
auth_type | Auth type, |
See alsoCYW43_AUTH_
Parameters
bssid | the mac address of the access point to connect to. This can be NULL. |
channel | Used to set the band of the connection. This is only used if bssid is non NULL. |
Returns
0 on success
◆ cyw43_wifi_leave()
int cyw43_wifi_leave | ( | cyw43_t * | self, |
int | itf | ||
) |
Dissassociate from a wifi network.
This method dissassociates from a wifi network.
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | The interface to disconnect, either CYW43_ITF_STA or CYW43_ITF_AP |
Returns
0 on success
◆ cyw43_wifi_link_status()
int cyw43_wifi_link_status | ( | cyw43_t * | self, |
int | itf | ||
) |
Get the wifi link status.
Returns the status of the wifi link.
link status | Meaning |
---|---|
CYW43_LINK_DOWN | Wifi down |
CYW43_LINK_JOIN | Connected to wifi |
CYW43_LINK_FAIL | Connection failed |
CYW43_LINK_NONET | No matching SSID found (could be out of range, or down) |
CYW43_LINK_BADAUTH | Authenticatation failure |
Note |
If the link status is negative it indicates an error The wifi link status for the interface CYW43_ITF_AP is always CYW43_LINK_DOWN |
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface to use, should be CYW43_ITF_STA or CYW43_ITF_AP |
Returns
A integer value representing the link status
◆ cyw43_wifi_pm()
int cyw43_wifi_pm | ( | cyw43_t * | self, |
uint32_t | pm | ||
) |
Set the wifi power management mode.
This method sets the power management mode used by cyw43. This should be called after cyw43_wifi_set_up
See alsocyw43_pm_value CYW43_DEFAULT_PM CYW43_AGGRESSIVE_PM CYW43_PERFORMANCE_PM
Parameters
self | the driver state object. This should always be &cyw43_state |
pm | Power management value |
Returns
0 on success
◆ cyw43_wifi_scan()
int cyw43_wifi_scan | ( | cyw43_t * | self, |
cyw43_wifi_scan_options_t * | opts, | ||
void * | env, | ||
int(*)(void *, const cyw43_ev_scan_result_t *) | result_cb | ||
) |
Perform a wifi scan for wifi networks.
Start a scan for wifi networks. Results are returned via the callback.
Note |
The scan is complete when cyw43_wifi_scan_active return false |
Parameters
self | the driver state object. This should always be &cyw43_state |
opts | An instance of cyw43_wifi_scan_options_t. Values in here are currently ignored. |
env | Pointer passed back in the callback |
result_cb | Callback for wifi scan results, see cyw43_ev_scan_result_t |
Returns
0 on success
◆ cyw43_wifi_scan_active()
|
inlinestatic |
Determine if a wifi scan is in progress.
This method tells you if the scan is still in progress
Parameters
self | the driver state object. This should always be &cyw43_state |
Returns
true if a wifi scan is in progress
◆ cyw43_wifi_set_up()
void cyw43_wifi_set_up | ( | cyw43_t * | self, |
int | itf, | ||
bool | up, | ||
uint32_t | country | ||
) |
Set up and initialise wifi.
This method turns on wifi and sets the country for regulation purposes. The power management mode is initialised to CYW43_DEFAULT_PM For CYW43_ITF_AP, the access point is enabled. For CYW43_ITF_STA, the TCP/IP stack is reinitialised
Parameters
self | the driver state object. This should always be &cyw43_state |
itf | the interface to use either CYW43_ITF_STA or CYW43_ITF_AP |
up | true to enable the link. Set to false to disable AP mode. Setting the up parameter to false for CYW43_ITF_STA is ignored. |
country | the country code, see CYW43_COUNTRY_ |
◆ cyw43_wifi_update_multicast_filter()
int cyw43_wifi_update_multicast_filter | ( | cyw43_t * | self, |
uint8_t * | addr, | ||
bool | add | ||
) |
Add/remove multicast group address.
This method adds/removes an address from the multicast filter, allowing frames sent to this group to be received
Parameters
self | the driver state object. This should always be &cyw43_state |
addr | a buffer containing a group mac address |
add | true to add the address, false to remove it |
Returns
0 on success
cyw43_ll
Low Level CYW43 driver interface. More...
Files
-
file cyw43_ll.h
-
Low Level CYW43 driver interface.
Data Structures
-
struct _cyw43_ev_scan_result_t
-
Structure to return wifi scan results. More...
-
struct _cyw43_async_event_t
-
struct _cyw43_wifi_scan_options_t
-
wifi scan options passed to cyw43_wifi_scan More...
-
struct _cyw43_ll_t
Macros
-
#define CYW43_SUP_KEYXCHANGE_WAIT_M1 CYW43_SUP_AUTHENTICATED
-
#define CYW43_SUP_KEYXCHANGE_WAIT_M3 CYW43_SUP_LAST_BASIC_STATE
-
#define CYW43_NO_POWERSAVE_MODE (0)
-
Power save mode paramter passed to cyw43_ll_wifi_pm.
-
Powersave mode on specified interface without regard for throughput reduction.
-
Powersave mode on specified interface with High throughput.
-
#define CYW43_CHANNEL_NONE (0xffffffff)
-
To indicate no specific channel when calling cyw43_ll_wifi_join with bssid specified.
Typedefs
-
typedef struct _cyw43_async_event_t cyw43_async_event_t
-
typedef struct _cyw43_ll_t cyw43_ll_t
Functions
-
void cyw43_ll_init (cyw43_ll_t *self, void *cb_data)
-
void cyw43_ll_deinit (cyw43_ll_t *self)
-
int cyw43_ll_bus_init (cyw43_ll_t *self, const uint8_t *mac)
-
void cyw43_ll_bus_sleep (cyw43_ll_t *self, bool can_sleep)
-
void cyw43_ll_process_packets (cyw43_ll_t *self)
-
int cyw43_ll_ioctl (cyw43_ll_t *self, uint32_t cmd, size_t len, uint8_t *buf, uint32_t iface)
-
int cyw43_ll_send_ethernet (cyw43_ll_t *self, int itf, size_t len, const void *buf, bool is_pbuf)
-
int cyw43_ll_wifi_on (cyw43_ll_t *self, uint32_t country)
-
int cyw43_ll_wifi_pm (cyw43_ll_t *self, uint32_t pm, uint32_t pm_sleep_ret, uint32_t li_bcn, uint32_t li_dtim, uint32_t li_assoc)
-
int cyw43_ll_wifi_get_pm (cyw43_ll_t *self, uint32_t *pm, uint32_t *pm_sleep_ret, uint32_t *li_bcn, uint32_t *li_dtim, uint32_t *li_assoc)
-
int cyw43_ll_wifi_scan (cyw43_ll_t *self, cyw43_wifi_scan_options_t *opts)
-
int cyw43_ll_wifi_join (cyw43_ll_t *self, size_t ssid_len, const uint8_t *ssid, size_t key_len, const uint8_t *key, uint32_t auth_type, const uint8_t *bssid, uint32_t channel)
-
void cyw43_ll_wifi_set_wpa_auth (cyw43_ll_t *self)
-
void cyw43_ll_wifi_rejoin (cyw43_ll_t *self)
-
int cyw43_ll_wifi_get_bssid (cyw43_ll_t *self_in, uint8_t *bssid)
-
int cyw43_ll_wifi_ap_init (cyw43_ll_t *self, size_t ssid_len, const uint8_t *ssid, uint32_t auth, size_t key_len, const uint8_t *key, uint32_t channel)
-
int cyw43_ll_wifi_ap_set_up (cyw43_ll_t *self, bool up)
-
int cyw43_ll_wifi_ap_get_stas (cyw43_ll_t *self, int *num_stas, uint8_t *macs)
-
int cyw43_ll_wifi_get_mac (cyw43_ll_t *self_in, uint8_t *addr)
-
int cyw43_ll_wifi_update_multicast_filter (cyw43_ll_t *self_in, uint8_t *addr, bool add)
-
bool cyw43_ll_has_work (cyw43_ll_t *self)
-
bool cyw43_ll_bt_has_work (cyw43_ll_t *self)
-
void cyw43_cb_process_async_event (void *cb_data, const cyw43_async_event_t *ev)
-
void cyw43_cb_process_ethernet (void *cb_data, int itf, size_t len, const uint8_t *buf)
-
void cyw43_ll_write_backplane_reg (cyw43_ll_t *self_in, uint32_t addr, uint32_t val)
-
uint32_t cyw43_ll_read_backplane_reg (cyw43_ll_t *self_in, uint32_t addr)
-
int cyw43_ll_write_backplane_mem (cyw43_ll_t *self_in, uint32_t addr, uint32_t len, const uint8_t *buf)
-
int cyw43_ll_read_backplane_mem (cyw43_ll_t *self_in, uint32_t addr, uint32_t len, uint8_t *buf)
-
enum { CYW43_ITF_STA , CYW43_ITF_AP }
-
Network interface types . More...
-
typedef struct _cyw43_ev_scan_result_t cyw43_ev_scan_result_t
-
Structure to return wifi scan results.
-
typedef struct _cyw43_wifi_scan_options_t cyw43_wifi_scan_options_t
-
wifi scan options passed to cyw43_wifi_scan
Authorization types
Used when setting up an access point, or connecting to an access point
-
No authorisation required (open)
-
WPA authorisation.
-
WPA2 authorisation (preferred)
-
#define CYW43_AUTH_WPA2_MIXED_PSK (0x00400006)
Macro Definition Documentation
◆ CYW43_AUTH_WPA2_MIXED_PSK
#define CYW43_AUTH_WPA2_MIXED_PSK (0x00400006) |
WPA2/WPA mixed authorisation