Skip to content

Commit

Permalink
fix(wifi_remote): Per review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cermak committed Mar 22, 2024
1 parent 8896d10 commit 75e2a37
Show file tree
Hide file tree
Showing 29 changed files with 807 additions and 513 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/wifi_remote__build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
${IDF_PATH}/install.sh --enable-pytest
. ${IDF_PATH}/export.sh
cd ./components/esp_wifi_remote/scripts
python parse_header.py
./check_headers.sh
python generate_and_check.py
build_wifi_remote:
if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push'
Expand All @@ -40,6 +39,10 @@ jobs:
steps:
- name: Checkout esp-protocols
uses: actions/checkout@v3
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.idf_ver }}
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions ci/ignore_astyle.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# The below file is generated from esp_wifi_types_native.h in IDF, which doesn't follow atyle
components/esp_wifi_remote/include/esp_wifi_types_native.h
2 changes: 1 addition & 1 deletion components/esp_wifi_remote/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ if(NOT CONFIG_ESP_WIFI_ENABLED)
endif()

idf_component_register(INCLUDE_DIRS include
SRCS wifi_remote_rpc.c wifi_remote_net.c wifi_remote_init.c ${src_wifi_is_remote}
SRCS wifi_remote_rpc.c wifi_remote_net.c wifi_remote_init.c ${src_wifi_is_remote} esp_wifi_remote_weak.c
REQUIRES esp_event esp_netif
PRIV_REQUIRES esp_wifi esp_hosted)
1 change: 1 addition & 0 deletions components/esp_wifi_remote/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This file is auto-generated
menu "Wi-Fi Remote"
orsource "./Kconfig.soc_wifi_caps.in"

Expand Down
3 changes: 2 additions & 1 deletion components/esp_wifi_remote/Kconfig.soc_wifi_caps.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This file is auto-generated

if SLAVE_IDF_TARGET_ESP32

Expand Down Expand Up @@ -199,7 +200,7 @@ if SLAVE_IDF_TARGET_ESP32C6

config SLAVE_SOC_WIFI_FTM_SUPPORT
bool
default n
default y

config SLAVE_SOC_WIFI_GCMP_SUPPORT
bool
Expand Down
18 changes: 12 additions & 6 deletions components/esp_wifi_remote/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@

[![Component Registry](https://components.espressif.com/components/espressif/esp_wifi_remote/badge.svg)](https://components.espressif.com/components/espressif/esp_wifi_remote)

This component wraps the public API of `esp_wifi` and provides a set of the same function calls namespaces with `esp_wifi_remote` prefix that translate to RPC calls to another target device (called `slave` device) which executes the appropriate `esp_wifi` APIs.
The `esp_wifi_remote` component is designed to extend WiFi functionality to ESP chipsets that lack native WiFi support. By simply adding a dependency to this component from your project, you gain access to WiFi capabilities via the WiFi-remote menuconfig and standard `esp_wifi` interface.

This component is heavily dependent on a specific version of the `esp_wifi` component, as that's why most of its headers, sources and configuration files are pre-generated based on the actual version of `esp_wifi`.
Moreover, `esp_wifi_remote` can be utilized on ESP chipsets that do support native WiFi, providing an additional WiFi interface through the `esp_wifi_remote` API.

This component doesn't implement the RPC calls by itself, but uses their dependencies for the functionality. Currently, only `esp_hosted` is supported to provide the RPC functionality of `esp_wifi_remote`.
To employ this component, a slave device -- capable of WiFi connectivity -- must be connected to your target device in a specified manner, as defined by the transport layer of [`esp_hosted`](https://github.com/espressif/esp-hosted).

Functionally, `esp_wifi_remote` wraps the public API of `esp_wifi`, offering a set of function call namespaces prefixed with esp_wifi_remote. These calls are translated into Remote Procedure Calls (RPC) to another target device (referred to as the "slave" device), which then executes the appropriate `esp_wifi` APIs.

Notably, `esp_wifi_remote` heavily relies on a specific version of the `esp_wifi` component. Consequently, the majority of its headers, sources, and configuration files are pre-generated based on the actual version of `esp_wifi`.

It's important to highlight that `esp_wifi_remote` does not directly implement the RPC calls; rather, it relies on dependencies for this functionality. Presently, only esp_hosted is supported to provide the RPC functionality required by esp_wifi_remote.


## Dependencies on `esp_wifi`

Public API needs to correspond exactly to the `esp_wifi` API. Some of the internal types depend on the actual wifi target, as well as some default configuration values. Therefore it's easier to maintain consistency between this component and the exact version of `esp_wifi` automatically in CI:

We extract function prototypes from `esp_wifi.h` and use them to generate `esp_wifi_remote` function declarations (and forwarding the definitions to the underlying RPC component -- `esp_hosted`)
We process the local `esp_wifi_types_native.h` and replace `CONFIG_IDF_TARGET` to `CONFIG_SLAVE_IDF_TARGET` and `CONFIG_SOC_WIFI_...` to `CONFIG_SLAVE_...`.
Similarly we process `esp_wifi`'s Kconfig, so the dependencies are on the slave target and slave SOC capabilities.
* We extract function prototypes from `esp_wifi.h` and use them to generate `esp_wifi_remote` function declarations.
* We process the local `esp_wifi_types_native.h` and replace `CONFIG_IDF_TARGET` to `CONFIG_SLAVE_IDF_TARGET` and `CONFIG_SOC_WIFI_...` to `CONFIG_SLAVE_....`
* Similarly we process `esp_wifi`'s Kconfig, so the dependencies are on the slave target and slave SOC capabilities.

Please check the [README.md](./scripts/README.md) for more details on the generation step and testing consistency.
16 changes: 16 additions & 0 deletions components/esp_wifi_remote/esp_wifi_remote_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_wifi.h"
#include "esp_wifi_remote.h"

esp_err_t remote_esp_wifi_init_slave(void);

// handling channels
esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len);
esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb);
esp_err_t esp_wifi_remote_rpc_channel_rx(void *h, void *buffer, size_t len);
esp_err_t esp_wifi_remote_rpc_channel_set(void *h, esp_remote_channel_tx_fn_t tx_cb);
Loading

0 comments on commit 75e2a37

Please sign in to comment.