forked from espressif/esp-protocols
Compare commits
120 Commits
eppp-v0.0.
...
test_clang
Author | SHA1 | Date | |
---|---|---|---|
ec6fe22688 | |||
84fd3261c3 | |||
6deb731bda | |||
58efb58f5c | |||
5d69d3f0ac | |||
39d59032a2 | |||
e3418b5527 | |||
21d1540b76 | |||
186e258798 | |||
139166c2c5 | |||
7437d31368 | |||
d20255a40c | |||
6af6ca52a2 | |||
042533af90 | |||
732b1d5084 | |||
9e13870ad4 | |||
3f12ef6eea | |||
f1bc070b86 | |||
28c0e0b77b | |||
24ce86756d | |||
39dfe268a3 | |||
d96f45a1f9 | |||
90fdcfc340 | |||
7829e8f976 | |||
ce27c13352 | |||
eab58de630 | |||
fcb60806a9 | |||
22914d4b7b | |||
150a3ec06a | |||
c12616c91d | |||
f05c765e8b | |||
ed021a90d4 | |||
6393fcd79a | |||
c9439bd3d5 | |||
2c4c88b4fb | |||
d45c5cef9a | |||
afd98bb9c5 | |||
8f19c60c19 | |||
281e933808 | |||
f4bdf0ab6c | |||
e25b2a1d9d | |||
608b835680 | |||
93256d159b | |||
3a48c06e96 | |||
e011188377 | |||
1fb1ea9300 | |||
16be2f963b | |||
d786f0db88 | |||
f6f6ded001 | |||
eb84eed8d3 | |||
5df46437f2 | |||
bd6b66d9d1 | |||
d0c17ef0d5 | |||
06d013b20b | |||
f032a9f023 | |||
d16387859f | |||
6c82ce2915 | |||
d2b7c55b89 | |||
fd168d86fc | |||
d4c6d5ed5d | |||
c728eae5ea | |||
bd6e120509 | |||
13793a8236 | |||
0140455ff7 | |||
c4d9cc6beb | |||
887dbcd73b | |||
b3ba71ff4d | |||
fbdb2483f5 | |||
af330b6396 | |||
0b94d9ec47 | |||
f26f2f88c2 | |||
08d06a4b7d | |||
cb682a793e | |||
d053d671f4 | |||
16b79d170b | |||
dfb0035858 | |||
1750a3fda9 | |||
2a3db45ef1 | |||
fcc61e0929 | |||
4bdd90cc88 | |||
14763888ed | |||
a5954dda17 | |||
8bd4712677 | |||
a65d81c954 | |||
2585565483 | |||
b9c675b0b1 | |||
d4e693e392 | |||
963b32e7b4 | |||
cffe26818b | |||
08a62ccc85 | |||
56fe53279e | |||
5baaf54291 | |||
38de23fb1c | |||
84390eb4d4 | |||
4e844936b7 | |||
21c84bfa8d | |||
438449f58f | |||
a23a0027fa | |||
3f74b4e8c0 | |||
46a6244c37 | |||
7be16bcc88 | |||
1fb02a9a60 | |||
b5be844c92 | |||
5b467cbf5c | |||
f8a776d8a5 | |||
a82c7922aa | |||
d31ad025c8 | |||
4977f96a61 | |||
dcdf31187a | |||
b6bbe47cae | |||
302b46f8e2 | |||
45b1597ac3 | |||
a06de6431b | |||
3b80181d30 | |||
edc3c2dee0 | |||
943b683d38 | |||
d0ace0d1c9 | |||
9c54b72e1f | |||
16174470ee | |||
27adbfeb3b |
16
.github/workflows/asio__build-target-test.yml
vendored
16
.github/workflows/asio__build-target-test.yml
vendored
@ -13,16 +13,16 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32", "esp32s2"]
|
||||
example: ["asio_chat", "async_request", "socks4", "ssl_client_server", "tcp_echo_server", "udp_echo_server"]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
env:
|
||||
TEST_DIR: components/asio/examples
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
@ -43,7 +43,7 @@ jobs:
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
esptool.py --chip ${{ matrix.idf_target }} merge_bin --fill-flash-size 4MB -o flash_image.bin @flash_args
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: examples_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.example }}
|
||||
path: |
|
||||
@ -64,7 +64,7 @@ jobs:
|
||||
name: Target tests
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32"]
|
||||
example: ["asio_chat", "tcp_echo_server", "udp_echo_server", "ssl_client_server"]
|
||||
needs: build_asio
|
||||
@ -76,8 +76,8 @@ jobs:
|
||||
steps:
|
||||
- name: Clear repository
|
||||
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: examples_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.example }}
|
||||
path: ${{ env.TEST_DIR }}/${{ matrix.example }}/build
|
||||
@ -93,7 +93,7 @@ jobs:
|
||||
working-directory: ${{ env.TEST_DIR }}/${{ matrix.example }}
|
||||
run: |
|
||||
python -m pytest --log-cli-level DEBUG --junit-xml=./examples_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.config }}.xml --target=${{ matrix.idf_target }}
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: examples_results_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.example }}
|
||||
|
55
.github/workflows/clang-tidy.yml
vendored
Normal file
55
.github/workflows/clang-tidy.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
name: Run clang-tidy
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- test_clang_tidy
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Run clang-tidy
|
||||
runs-on: ubuntu-20.04
|
||||
container: espressif/idf:latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'true'
|
||||
- name: Install esp-clang
|
||||
run: |
|
||||
${IDF_PATH}/tools/idf_tools.py --non-interactive install esp-clang
|
||||
- name: Install clang-tidy-sarif
|
||||
run: |
|
||||
curl -sSL https://github.com/psastras/sarif-rs/releases/download/clang-tidy-sarif-v0.3.3/clang-tidy-sarif-x86_64-unknown-linux-gnu -o clang-tidy-sarif
|
||||
chmod +x clang-tidy-sarif
|
||||
curl -sSL https://raw.githubusercontent.com/espressif/idf-extra-components/master/.github/filter_sarif.py -o filter_sarif.py
|
||||
- name: Install pyclang
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install pyclang~=0.2.0
|
||||
- name: Run code analysis
|
||||
shell: bash
|
||||
env:
|
||||
IDF_TOOLCHAIN: clang
|
||||
IDF_TARGET: esp32
|
||||
working-directory: test_app
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
idf.py clang-check --include-paths $GITHUB_WORKSPACE --exclude-paths $PWD --run-clang-tidy-py run-clang-tidy
|
||||
cp warnings.txt ../
|
||||
- name: Convert clang-tidy results into SARIF output
|
||||
run: |
|
||||
export PATH=$PWD:$PATH
|
||||
./clang-tidy-sarif -o results.sarif.raw warnings.txt
|
||||
python3 filter_sarif.py -o results.sarif --include-prefix ${GITHUB_WORKSPACE}/ results.sarif.raw
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
path: |
|
||||
warnings.txt
|
||||
results.sarif
|
||||
results.sarif.raw
|
||||
- name: Upload SARIF file
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
category: clang-tidy
|
@ -13,20 +13,26 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32"]
|
||||
test: [ { app: ifconfig-basic, path: "components/console_cmd_ifconfig/examples"}]
|
||||
runs-on: ubuntu-20.04
|
||||
include:
|
||||
- idf_ver: "latest"
|
||||
warning: "the choice symbol ETHERNET_PHY_LAN867X\nis deprecated: Please use smi_gpio instead"
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
env:
|
||||
EXPECTED_WARNING: ${{ matrix.warning }}
|
||||
shell: bash
|
||||
working-directory: ${{matrix.test.path}}
|
||||
run: |
|
||||
${IDF_PATH}/install.sh --enable-pytest
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ../../../ci/build_apps.py ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app
|
||||
|
@ -13,20 +13,20 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32"]
|
||||
test: [ { app: ping-basic, path: "components/console_cmd_ping/examples" }]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
shell: bash
|
||||
working-directory: ${{matrix.test.path}}
|
||||
run: |
|
||||
${IDF_PATH}/install.sh --enable-pytest
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ../../../ci/build_apps.py ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app
|
||||
|
@ -13,20 +13,20 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32"]
|
||||
test: [ { app: wifi-basic, path: "components/console_cmd_wifi/examples" }]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
shell: bash
|
||||
working-directory: ${{matrix.test.path}}
|
||||
run: |
|
||||
${IDF_PATH}/install.sh --enable-pytest
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ../../../ci/build_apps.py ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app
|
||||
|
@ -13,20 +13,20 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32"]
|
||||
test: [ { app: console_basic, path: "components/console_simple_init/examples" }]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
shell: bash
|
||||
working-directory: ${{matrix.test.path}}
|
||||
run: |
|
||||
${IDF_PATH}/install.sh --enable-pytest
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ../../../ci/build_apps.py ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app
|
||||
|
4
.github/workflows/eppp__build.yml
vendored
4
.github/workflows/eppp__build.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest"]
|
||||
idf_ver: ["latest", "release-v5.3"]
|
||||
test: [ { app: host, path: "examples/host" }, { app: slave, path: "examples/slave" }, { app: test_app, path: "test/test_app" }]
|
||||
runs-on: ubuntu-20.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
@ -23,6 +23,6 @@ jobs:
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
|
||||
shell: bash
|
||||
run: |
|
||||
${IDF_PATH}/install.sh --enable-pytest
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ./ci/build_apps.py ./components/eppp_link/${{matrix.test.path}} -vv --preserve-all
|
||||
|
10
.github/workflows/examples_build-host-test.yml
vendored
10
.github/workflows/examples_build-host-test.yml
vendored
@ -13,12 +13,12 @@ jobs:
|
||||
name: Build examples
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.1"]
|
||||
runs-on: ubuntu-20.04
|
||||
idf_ver: ["latest", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Build with IDF-${{ matrix.idf_ver }}
|
||||
shell: bash
|
||||
run: |
|
||||
@ -33,11 +33,11 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest"]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Build with IDF-${{ matrix.idf_ver }}
|
||||
shell: bash
|
||||
run: |
|
||||
|
16
.github/workflows/mdns__build-target-test.yml
vendored
16
.github/workflows/mdns__build-target-test.yml
vendored
@ -13,20 +13,20 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.2", "release-v5.3"]
|
||||
test: [ { app: example, path: "examples/query_advertise" }, { app: unit_test, path: "tests/unit_test" }, { app: test_app, path: "tests/test_apps" } ]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
python -m pip install idf-build-apps
|
||||
# Build default configs for all targets
|
||||
python ./ci/build_apps.py components/mdns/${{ matrix.test.path }} -r default -m components/mdns/.build-test-rules.yml -d
|
||||
python ./ci/build_apps.py components/mdns/${{ matrix.test.path }} -r default -d
|
||||
# Build specific configs for test targets
|
||||
python ./ci/build_apps.py components/mdns/${{ matrix.test.path }}
|
||||
cd components/mdns/${{ matrix.test.path }}
|
||||
@ -34,7 +34,7 @@ jobs:
|
||||
$GITHUB_WORKSPACE/ci/clean_build_artifacts.sh `pwd`/$dir
|
||||
zip -qur artifacts.zip $dir
|
||||
done
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mdns_bin_esp32_${{ matrix.idf_ver }}_${{ matrix.test.app }}
|
||||
path: components/mdns/${{ matrix.test.path }}/artifacts.zip
|
||||
@ -58,8 +58,8 @@ jobs:
|
||||
steps:
|
||||
- name: Clear repository
|
||||
run: sudo rm -fr $GITHUB_WORKSPACE && mkdir $GITHUB_WORKSPACE
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: mdns_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${{ matrix.test.app }}
|
||||
path: components/mdns/${{ matrix.test.path }}/ci/
|
||||
@ -77,7 +77,7 @@ jobs:
|
||||
mv $dir build
|
||||
python -m pytest --log-cli-level DEBUG --junit-xml=./results_${{ matrix.test.app }}_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${dir#"ci/build_"}.xml --target=${{ matrix.idf_target }}
|
||||
done
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: results_${{ matrix.test.app }}_${{ matrix.idf_target }}_${{ matrix.idf_ver }}.xml
|
||||
|
8
.github/workflows/mdns__host-tests.yml
vendored
8
.github/workflows/mdns__host-tests.yml
vendored
@ -11,12 +11,12 @@ jobs:
|
||||
host_test_mdns:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'mdns') || github.event_name == 'push'
|
||||
name: Host test
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:release-v5.1
|
||||
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@master
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: esp-protocols
|
||||
|
||||
@ -40,11 +40,11 @@ jobs:
|
||||
idf_ver: ["latest"]
|
||||
idf_target: ["esp32"]
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@master
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: esp-protocols
|
||||
- name: Install Necessary Libs
|
||||
|
39
.github/workflows/modem__build-host-tests.yml
vendored
39
.github/workflows/modem__build-host-tests.yml
vendored
@ -13,27 +13,29 @@ jobs:
|
||||
name: Build examples
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v4.3", "release-v4.4", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v4.4", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
example: ["pppos_client", "modem_console", "modem_tcp_client", "ap_to_pppos", "simple_cmux_client"]
|
||||
exclude:
|
||||
- idf_ver: "release-v4.3"
|
||||
example: modem_tcp_client
|
||||
- idf_ver: "release-v4.4"
|
||||
example: modem_tcp_client
|
||||
include:
|
||||
- idf_ver: "release-v4.3"
|
||||
skip_config: usb
|
||||
- idf_ver: "release-v5.0"
|
||||
example: "simple_cmux_client"
|
||||
warning: "Warning: The smallest app partition is nearly full"
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
- name: Check out code (v3) # @v4 failed due to Node 20's requirement, incompatible with older IDF versions
|
||||
if: matrix.idf_ver != 'latest' && matrix.idf_ver < 'release-v5.0'
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: protocols
|
||||
- name: Check out code (v4)
|
||||
if: matrix.idf_ver == 'latest' || matrix.idf_ver >= 'release-v5.0'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: protocols
|
||||
- if: ${{ matrix.skip_config }}
|
||||
run: rm -f $GITHUB_WORKSPACE/protocols/components/esp_modem/examples/${{ matrix.example }}/sdkconfig.ci.${{ matrix.skip_config }}*
|
||||
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }}
|
||||
@ -51,14 +53,14 @@ jobs:
|
||||
name: Build tests
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["release-v5.0", "release-v5.1", "latest"]
|
||||
idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "latest"]
|
||||
test: ["target", "target_ota", "target_iperf"]
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: protocols
|
||||
- name: Build ${{ matrix.test }} with IDF-${{ matrix.idf_ver }}
|
||||
@ -76,10 +78,25 @@ jobs:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
||||
uses: "./.github/workflows/run-host-tests.yml"
|
||||
with:
|
||||
idf_version: "release-v4.3"
|
||||
idf_version: "latest"
|
||||
app_name: "host_modem_test"
|
||||
app_path: "esp-protocols/components/esp_modem/test/host_test"
|
||||
component_path: "esp-protocols/components/esp_modem"
|
||||
upload_artifacts: true
|
||||
run_executable: true
|
||||
run_coverage: true
|
||||
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
|
||||
publish_unit_test_result: true
|
||||
|
||||
build_linux_example:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
||||
uses: "./.github/workflows/run-host-tests.yml"
|
||||
with:
|
||||
idf_version: "latest"
|
||||
app_name: "linux_modem"
|
||||
app_path: "esp-protocols/components/esp_modem/examples/linux_modem"
|
||||
component_path: "esp-protocols/components/esp_modem"
|
||||
upload_artifacts: true
|
||||
run_executable: false
|
||||
run_coverage: false
|
||||
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
|
||||
|
5
.github/workflows/modem__target-test.yml
vendored
5
.github/workflows/modem__target-test.yml
vendored
@ -20,13 +20,13 @@ jobs:
|
||||
- idf_ver: "latest"
|
||||
idf_target: "esp32s2"
|
||||
test: { app: usb_a7670_s2, path: examples/pppos_client }
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
env:
|
||||
TEST_DIR: components/esp_modem/${{ matrix.test.path }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build esp-modem target tests with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
@ -80,4 +80,5 @@ jobs:
|
||||
- name: Run Example Test on target
|
||||
working-directory: ${{ env.TEST_DIR }}
|
||||
run: |
|
||||
python -m pip install -r $GITHUB_WORKSPACE/ci/requirements.txt
|
||||
python -m pytest --log-cli-level DEBUG --target=${{ matrix.idf_target }}
|
||||
|
8
.github/workflows/mqtt_cxx__build.yml
vendored
8
.github/workflows/mqtt_cxx__build.yml
vendored
@ -13,20 +13,20 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.0"]
|
||||
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
|
||||
idf_target: ["esp32"]
|
||||
test: [ { app: mqtt-basic, path: "components/esp_mqtt_cxx/examples" }]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
shell: bash
|
||||
working-directory: ${{matrix.test.path}}
|
||||
run: |
|
||||
${IDF_PATH}/install.sh --enable-pytest
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ../../../ci/build_apps.py ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app
|
||||
|
2
.github/workflows/pre_commit_check.yml
vendored
2
.github/workflows/pre_commit_check.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.base_ref }}
|
||||
fetch-depth: 20
|
||||
|
4
.github/workflows/publish-docs-component.yml
vendored
4
.github/workflows/publish-docs-component.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
if: github.repository == 'espressif/esp-protocols'
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
@ -98,5 +98,7 @@ jobs:
|
||||
components/console_cmd_ping;
|
||||
components/console_cmd_ifconfig;
|
||||
components/console_cmd_wifi;
|
||||
components/esp_wifi_remote;
|
||||
components/mbedtls_cxx;
|
||||
namespace: "espressif"
|
||||
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
|
||||
|
30
.github/workflows/run-host-tests.yml
vendored
30
.github/workflows/run-host-tests.yml
vendored
@ -18,6 +18,12 @@ on:
|
||||
upload_artifacts:
|
||||
type: boolean
|
||||
required: true
|
||||
run_executable:
|
||||
type: boolean
|
||||
required: true
|
||||
run_coverage:
|
||||
type: boolean
|
||||
required: true
|
||||
pre_run_script:
|
||||
type: string
|
||||
required: false
|
||||
@ -28,14 +34,14 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
name: Build App
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
checks: write
|
||||
contents: write
|
||||
container: espressif/idf:${{inputs.idf_version}}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: esp-protocols
|
||||
- name: Build ${{ inputs.app_name }} with IDF-${{ inputs.idf_version }}
|
||||
@ -51,7 +57,11 @@ jobs:
|
||||
# The sdkconfig.ci.linux specifies Linux as the build target with apropriate settings.
|
||||
cp sdkconfig.ci.linux sdkconfig.defaults
|
||||
idf.py build
|
||||
./build/${{inputs.app_name}}.elf -r junit -o junit.xml
|
||||
if [ "${{ inputs.run_executable}}" == "false" ]; then
|
||||
echo "Executeable wasn't run"
|
||||
exit 0
|
||||
fi
|
||||
./build/${{inputs.app_name}}.elf
|
||||
- name: Publish Unit Test Result
|
||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||
if: ${{ inputs.publish_unit_test_result }}
|
||||
@ -59,6 +69,7 @@ jobs:
|
||||
files: ${{inputs.component_path}}/**/*junit.xml
|
||||
- name: Build with Coverage Enabled
|
||||
shell: bash
|
||||
if: ${{ inputs.run_coverage }}
|
||||
run: |
|
||||
component=$(basename ${{ inputs.component_path }})
|
||||
if [ -f "${{ inputs.pre_run_script }}" ]; then
|
||||
@ -74,9 +85,12 @@ jobs:
|
||||
./build/${{inputs.app_name}}.elf
|
||||
- name: Run Coverage
|
||||
shell: bash
|
||||
if: ${{ inputs.run_coverage }}
|
||||
run: |
|
||||
apt-get update && apt-get install -y python3-pip rsync
|
||||
python -m pip install gcovr
|
||||
apt-get update && apt-get install -y rsync
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
python3 -m pip install gcovr
|
||||
cd $GITHUB_WORKSPACE/${{inputs.component_path}}
|
||||
component=$(basename ${{ inputs.component_path }})
|
||||
gcov `find . -name "$component*gcda"`
|
||||
@ -86,6 +100,7 @@ jobs:
|
||||
cp index.html ${{inputs.app_name}}_coverage_report
|
||||
cp -rf ${{inputs.app_name}}_coverage_report ${{inputs.app_name}}_coverage.xml $GITHUB_WORKSPACE
|
||||
- name: Code Coverage Summary Report
|
||||
if: ${{ inputs.run_coverage }}
|
||||
uses: irongut/CodeCoverageSummary@v1.3.0
|
||||
with:
|
||||
filename: esp-protocols/**/${{inputs.app_name}}_coverage.xml
|
||||
@ -99,9 +114,10 @@ jobs:
|
||||
thresholds: '60 80'
|
||||
- name: Write to Job Summary
|
||||
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
|
||||
if: ${{ inputs.run_coverage }}
|
||||
- name: Upload files to artifacts for run-target job
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{inputs.upload_artifacts}}
|
||||
uses: actions/upload-artifact@v4
|
||||
if: ${{ inputs.run_coverage }}
|
||||
with:
|
||||
name: ${{inputs.app_name}}_coverage_report
|
||||
path: |
|
||||
|
30
.github/workflows/tls_cxx__build.yml
vendored
Normal file
30
.github/workflows/tls_cxx__build.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: "mbedtls-cxx: build-tests"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
|
||||
jobs:
|
||||
build_tls_cxx:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'tls_cxx') || github.event_name == 'push'
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest", "release-v5.3", "release-v5.2", "release-v5.1"]
|
||||
test: [ { app: client, path: "examples/tls_client" }, { app: udp, path: "examples/udp_mutual_auth" }, { app: test, path: "tests/uart_mutual_auth" } ]
|
||||
runs-on: ubuntu-20.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ./ci/build_apps.py ./components/mbedtls_cxx/${{ matrix.test.path }} -vv --preserve-all
|
@ -17,4 +17,6 @@ jobs:
|
||||
app_name: "websocket"
|
||||
app_path: "esp-protocols/components/esp_websocket_client/examples/linux"
|
||||
component_path: "esp-protocols/components/esp_websocket_client"
|
||||
run_executable: true
|
||||
upload_artifacts: true
|
||||
run_coverage: true
|
||||
|
@ -13,15 +13,15 @@ jobs:
|
||||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["release-v5.0", "release-v5.1", "latest"]
|
||||
idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "latest"]
|
||||
test: [ { app: example, path: "examples/target" }, { app: unit_test, path: "test" } ]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
env:
|
||||
TEST_DIR: components/esp_websocket_client/${{ matrix.test.path }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build ${{ matrix.example }} with IDF-${{ matrix.idf_ver }} for ${{ matrix.idf_target }}
|
||||
@ -35,7 +35,7 @@ jobs:
|
||||
$GITHUB_WORKSPACE/ci/clean_build_artifacts.sh `pwd`/$dir
|
||||
zip -qur artifacts.zip $dir
|
||||
done
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: websocket_bin_esp32_${{ matrix.idf_ver }}_${{ matrix.test.app }}
|
||||
path: ${{ env.TEST_DIR }}/artifacts.zip
|
||||
@ -51,7 +51,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
idf_ver: ["release-v5.0", "release-v5.1", "latest"]
|
||||
idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "latest"]
|
||||
idf_target: ["esp32"]
|
||||
test: [ { app: example, path: "examples/target" }, { app: unit_test, path: "test" } ]
|
||||
runs-on:
|
||||
@ -60,8 +60,8 @@ jobs:
|
||||
env:
|
||||
TEST_DIR: components/esp_websocket_client/${{ matrix.test.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: websocket_bin_esp32_${{ matrix.idf_ver }}_${{ matrix.test.app }}
|
||||
path: ${{ env.TEST_DIR }}/ci/
|
||||
@ -79,7 +79,7 @@ jobs:
|
||||
mv $dir build
|
||||
python -m pytest --log-cli-level DEBUG --junit-xml=./results_${{ matrix.test.app }}_${{ matrix.idf_target }}_${{ matrix.idf_ver }}_${dir#"ci/build_"}.xml --target=${{ matrix.idf_target }}
|
||||
done
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: results_${{ matrix.test.app }}_${{ matrix.idf_target }}_${{ matrix.idf_ver }}.xml
|
||||
|
77
.github/workflows/wifi_remote__build.yml
vendored
Normal file
77
.github/workflows/wifi_remote__build.yml
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
name: "esp_wifi_remote: build-tests"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
|
||||
jobs:
|
||||
wifi_remote_api_compat:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push'
|
||||
name: Check API compatibility of WiFi Remote
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest"]
|
||||
runs-on: ubuntu-20.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
- name: Check that headers are the same as generated
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
cd ./components/esp_wifi_remote/scripts
|
||||
python generate_and_check.py
|
||||
|
||||
build_wifi_remote:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push'
|
||||
name: Build WiFi Remote Test
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest"]
|
||||
test: [ { app: smoke_test, path: "test/smoke_test" }]
|
||||
runs-on: ubuntu-20.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.idf_ver }}
|
||||
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ./ci/build_apps.py ./components/esp_wifi_remote/${{matrix.test.path}} -vv --preserve-all
|
||||
|
||||
build_wifi_remote_example:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'wifi_remote') || github.event_name == 'push'
|
||||
name: Build WiFi Remote Example
|
||||
strategy:
|
||||
matrix:
|
||||
idf_ver: ["latest"]
|
||||
example: [ { app: host, path: "examples/mqtt" }, { app: slave, path: "examples/server" }]
|
||||
include:
|
||||
- idf_ver: "latest"
|
||||
example: { app: slave, path: "examples/server" }
|
||||
warning: "Warning: The smallest app partition is nearly full"
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
container: espressif/idf:${{ matrix.idf_ver }}
|
||||
steps:
|
||||
- name: Checkout esp-protocols
|
||||
uses: actions/checkout@v3
|
||||
- name: Build ${{ matrix.example.app }} with IDF-${{ matrix.idf_ver }}
|
||||
env:
|
||||
EXPECTED_WARNING: ${{ matrix.warning }}
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
pip install idf-component-manager idf-build-apps --upgrade
|
||||
python ./ci/build_apps.py ./components/esp_wifi_remote/${{matrix.example.path}} -vv --preserve-all
|
@ -51,7 +51,7 @@ repos:
|
||||
rev: c0013808882a15a0c0c2c1a9b5c903866c53a653
|
||||
hooks:
|
||||
- id: astyle_py
|
||||
args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper']
|
||||
args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper', '--exclude-list=ci/ignore_astyle.txt']
|
||||
- repo: https://github.com/commitizen-tools/commitizen
|
||||
rev: v2.42.1
|
||||
hooks:
|
||||
@ -61,8 +61,8 @@ repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: commit message scopes
|
||||
name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common, eppp"
|
||||
entry: '\A(?!(feat|fix|ci|bump|test|docs)\((mdns|modem|common|console|websocket|asio|mqtt_cxx|examples|eppp)\)\:)'
|
||||
name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common, eppp, wifi_remote, tls_cxx"
|
||||
entry: '\A(?!(feat|fix|ci|bump|test|docs)\((mdns|modem|common|console|websocket|asio|mqtt_cxx|examples|eppp|wifi_remote|tls_cxx)\)\:)'
|
||||
language: pygrep
|
||||
args: [--multiline]
|
||||
stages: [commit-msg]
|
||||
|
@ -53,3 +53,11 @@ Please refer to instructions in [ESP-IDF](https://github.com/espressif/esp-idf)
|
||||
### ESP PPP Link (eppp)
|
||||
|
||||
* Brief introduction [README](components/eppp_link/README.md)
|
||||
|
||||
### esp_wifi_remote
|
||||
|
||||
* Brief introduction [README](components/esp_wifi_remote/README.md)
|
||||
|
||||
### mbedtls_cxx
|
||||
|
||||
* Brief introduction [README](components/mbedtls_cxx/README.md)
|
||||
|
@ -83,13 +83,14 @@ def main():
|
||||
changelog += '\n### {}\n\n'.format(sections[section])
|
||||
for it in item:
|
||||
changelog += '- {}\n'.format(it)
|
||||
changelog += '\n'
|
||||
filename = os.path.join(root_path, 'components', component, 'CHANGELOG.md')
|
||||
# Check if the changelog file exists.
|
||||
if not os.path.exists(filename):
|
||||
# File does not exist, create it
|
||||
with open(filename, 'w') as file:
|
||||
file.write('# Changelog\n\n')
|
||||
else:
|
||||
changelog += '\n'
|
||||
# insert the actual changelog to the beginning of the file, just after the title (2nd line)
|
||||
with open(filename, 'r') as orig_changelog:
|
||||
changelog_title = orig_changelog.readline(
|
||||
|
2
ci/ignore_astyle.txt
Normal file
2
ci/ignore_astyle.txt
Normal file
@ -0,0 +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
|
@ -3,6 +3,6 @@ commitizen:
|
||||
bump_message: 'bump(eppp): $current_version -> $new_version'
|
||||
pre_bump_hooks: python ../../ci/changelog.py eppp_link
|
||||
tag_format: eppp-v$version
|
||||
version: 0.0.1
|
||||
version: 0.1.1
|
||||
version_files:
|
||||
- idf_component.yml
|
||||
|
@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## [0.1.1](https://github.com/espressif/esp-protocols/commits/eppp-v0.1.1)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Make some common netif options configurable ([7829e8f](https://github.com/espressif/esp-protocols/commit/7829e8f))
|
||||
|
||||
## [0.1.0](https://github.com/espressif/esp-protocols/commits/eppp-v0.1.0)
|
||||
|
||||
### Features
|
||||
|
||||
- Added CI job to build examples and tests ([7eefcf0](https://github.com/espressif/esp-protocols/commit/7eefcf0))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fixed to select PPP LWIP opts which are OFF by default ([16be2f9](https://github.com/espressif/esp-protocols/commit/16be2f9))
|
||||
- Example to use iperf component from the registry ([bd6b66d](https://github.com/espressif/esp-protocols/commit/bd6b66d))
|
||||
- Fixed defalt config designated init issue in C++ ([8bd4712](https://github.com/espressif/esp-protocols/commit/8bd4712))
|
||||
|
||||
## [0.0.1](https://github.com/espressif/esp-protocols/commits/eppp-v0.0.1)
|
||||
|
||||
### Features
|
||||
|
@ -1,5 +1,11 @@
|
||||
menu "eppp_link"
|
||||
|
||||
config EPPP_LINK_USES_LWIP
|
||||
bool
|
||||
default "y"
|
||||
select LWIP_PPP_SUPPORT
|
||||
select LWIP_PPP_SERVER_SUPPORT
|
||||
|
||||
choice EPPP_LINK_DEVICE
|
||||
prompt "Choose PPP device"
|
||||
default EPPP_LINK_DEVICE_UART
|
||||
|
@ -157,7 +157,7 @@ static void netif_deinit(esp_netif_t *netif)
|
||||
}
|
||||
}
|
||||
|
||||
static esp_netif_t *netif_init(eppp_type_t role)
|
||||
static esp_netif_t *netif_init(eppp_type_t role, eppp_config_t *eppp_config)
|
||||
{
|
||||
if (s_eppp_netif_count > 9) { // Limit to max 10 netifs, since we use "EPPPx" as the unique key (where x is 0-9)
|
||||
ESP_LOGE(TAG, "Cannot create more than 10 instances");
|
||||
@ -217,10 +217,13 @@ static esp_netif_t *netif_init(eppp_type_t role)
|
||||
char if_key[] = "EPPP0"; // netif key needs to be unique
|
||||
if_key[sizeof(if_key) - 2 /* 2 = two chars before the terminator */ ] += s_eppp_netif_count++;
|
||||
base_netif_cfg.if_key = if_key;
|
||||
if (role == EPPP_CLIENT) {
|
||||
base_netif_cfg.if_desc = "pppos_client";
|
||||
if (eppp_config->ppp.netif_description) {
|
||||
base_netif_cfg.if_desc = eppp_config->ppp.netif_description;
|
||||
} else {
|
||||
base_netif_cfg.if_desc = "pppos_server";
|
||||
base_netif_cfg.if_desc = role == EPPP_CLIENT ? "pppos_client" : "pppos_server";
|
||||
}
|
||||
if (eppp_config->ppp.netif_prio) {
|
||||
base_netif_cfg.route_prio = eppp_config->ppp.netif_prio;
|
||||
}
|
||||
esp_netif_config_t netif_ppp_config = { .base = &base_netif_cfg,
|
||||
.driver = ppp_driver_cfg,
|
||||
@ -703,7 +706,12 @@ void eppp_deinit(esp_netif_t *netif)
|
||||
|
||||
esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
|
||||
{
|
||||
esp_netif_t *netif = netif_init(role);
|
||||
if (config == NULL || (role != EPPP_SERVER && role != EPPP_CLIENT)) {
|
||||
ESP_LOGE(TAG, "Invalid configuration or role");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
esp_netif_t *netif = netif_init(role, config);
|
||||
if (!netif) {
|
||||
ESP_LOGE(TAG, "Failed to initialize PPP netif");
|
||||
remove_handlers();
|
||||
@ -730,6 +738,10 @@ esp_netif_t *eppp_init(eppp_type_t role, eppp_config_t *config)
|
||||
|
||||
esp_netif_t *eppp_open(eppp_type_t role, eppp_config_t *config, int connect_timeout_ms)
|
||||
{
|
||||
if (config == NULL || (role != EPPP_SERVER && role != EPPP_CLIENT)) {
|
||||
ESP_LOGE(TAG, "Invalid configuration or role");
|
||||
return NULL;
|
||||
}
|
||||
#if CONFIG_EPPP_LINK_DEVICE_UART
|
||||
if (config->transport != EPPP_TRANSPORT_UART) {
|
||||
ESP_LOGE(TAG, "Invalid transport: UART device must be enabled in Kconfig");
|
||||
|
@ -1,7 +1,6 @@
|
||||
# The following four lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/iperf)
|
||||
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
@ -1,4 +1,5 @@
|
||||
dependencies:
|
||||
espressif/iperf-cmd: "^0.1.1"
|
||||
espressif/eppp_link:
|
||||
version: "*"
|
||||
override_path: "../../.."
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 0.0.1
|
||||
version: 0.1.1
|
||||
url: https://github.com/espressif/esp-protocols/tree/master/components/eppp_link
|
||||
description: The component provides a general purpose PPP connectivity, typically used as WiFi-PPP router
|
||||
dependencies:
|
||||
|
@ -35,8 +35,10 @@
|
||||
.priority = 8, \
|
||||
}, \
|
||||
. ppp = { \
|
||||
.our_ip4_addr.addr = our_ip, \
|
||||
.their_ip4_addr.addr = their_ip, \
|
||||
.our_ip4_addr = { .addr = our_ip }, \
|
||||
.their_ip4_addr = { .addr = their_ip }, \
|
||||
.netif_prio = 0, \
|
||||
.netif_description = NULL, \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -88,6 +90,8 @@ typedef struct eppp_config_t {
|
||||
struct eppp_config_pppos_s {
|
||||
esp_ip4_addr_t our_ip4_addr;
|
||||
esp_ip4_addr_t their_ip4_addr;
|
||||
int netif_prio;
|
||||
const char *netif_description;
|
||||
} ppp;
|
||||
|
||||
} eppp_config_t;
|
||||
|
@ -1,6 +1,6 @@
|
||||
components/esp_modem/examples/ap_to_pppos:
|
||||
disable:
|
||||
- if: IDF_TARGET in ["esp32h2"]
|
||||
- if: IDF_TARGET in ["esp32h2", "esp32p4"]
|
||||
|
||||
components/esp_modem/examples/modem_console:
|
||||
disable:
|
||||
|
@ -45,8 +45,3 @@ set_target_properties(${COMPONENT_LIB} PROPERTIES
|
||||
if(CONFIG_ESP_MODEM_ADD_CUSTOM_MODULE)
|
||||
idf_component_optional_requires(PUBLIC main)
|
||||
endif()
|
||||
|
||||
if(${target} STREQUAL "linux")
|
||||
# This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64
|
||||
set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format)
|
||||
endif()
|
||||
|
@ -22,8 +22,7 @@ using namespace esp_modem;
|
||||
|
||||
[[maybe_unused]] constexpr auto TAG = "linux_modem_main";
|
||||
|
||||
|
||||
int main()
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
// init the DTE
|
||||
esp_modem_dte_config_t dte_config = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRCS mbedtls_wrap.cpp
|
||||
tls_transport.cpp
|
||||
idf_component_register(SRCS tls_transport.cpp
|
||||
INCLUDE_DIRS include
|
||||
REQUIRES tcp_transport)
|
||||
REQUIRES tcp_transport
|
||||
PRIV_REQUIRES mbedtls_cxx)
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
static const char *TAG = "tls_transport";
|
||||
|
||||
using namespace idf::mbedtls_cxx;
|
||||
|
||||
class TlsTransport: public Tls {
|
||||
public:
|
||||
explicit TlsTransport(esp_transport_handle_t parent) : Tls(), transport_(parent) {}
|
||||
|
@ -2,3 +2,6 @@ dependencies:
|
||||
espressif/esp_modem:
|
||||
version: "^1.0.1"
|
||||
override_path: "../../../"
|
||||
espressif/mbedtls_cxx:
|
||||
version: "*"
|
||||
override_path: "../../../../mbedtls_cxx"
|
||||
|
@ -63,26 +63,6 @@ menu "Example Configuration"
|
||||
help
|
||||
Set APN (Access Point Name), a logical name to choose data network
|
||||
|
||||
config EXAMPLE_MODEM_PPP_AUTH_USERNAME
|
||||
string "Set username for authentication"
|
||||
default "espressif"
|
||||
depends on !EXAMPLE_MODEM_PPP_AUTH_NONE
|
||||
help
|
||||
Set username for PPP Authentication.
|
||||
|
||||
config EXAMPLE_MODEM_PPP_AUTH_PASSWORD
|
||||
string "Set password for authentication"
|
||||
default "esp32"
|
||||
depends on !EXAMPLE_MODEM_PPP_AUTH_NONE
|
||||
help
|
||||
Set password for PPP Authentication.
|
||||
|
||||
config EXAMPLE_MODEM_PPP_AUTH_NONE
|
||||
bool "Skip PPP authentication"
|
||||
default n
|
||||
help
|
||||
Set to true for the PPP client to skip authentication
|
||||
|
||||
config EXAMPLE_SEND_MSG
|
||||
bool "Short message (SMS)"
|
||||
default n
|
||||
|
@ -49,7 +49,7 @@ std::unique_ptr<DCE_gnss> create_SIM7070_GNSS_dce(const esp_modem::dce_config *c
|
||||
return gnss_factory::LocalFactory::create(config, std::move(dte), netif);
|
||||
}
|
||||
|
||||
esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::CommandableIf *t, esp_modem_gps_t &gps)
|
||||
esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::CommandableIf *t, sim70xx_gps_t &gps)
|
||||
{
|
||||
|
||||
ESP_LOGV(TAG, "%s", __func__ );
|
||||
@ -67,24 +67,26 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl
|
||||
}
|
||||
/**
|
||||
* Parsing +CGNSINF:
|
||||
* <GNSS run status>,
|
||||
* <Fix status>,
|
||||
* <UTC date & Time>,
|
||||
* <Latitude>,
|
||||
* <Longitude>,
|
||||
* <MSL Altitude>,
|
||||
* <Speed Over Ground>,
|
||||
* <Course Over Ground>,
|
||||
* <Fix Mode>,
|
||||
* <Reserved1>,
|
||||
* <HDOP>,
|
||||
* <PDOP>,
|
||||
* <VDOP>,
|
||||
* <Reserved2>,
|
||||
* <GNSS Satellites in View>,
|
||||
* <Reserved3>,
|
||||
* <HPA>,
|
||||
* <VPA>
|
||||
| **Index** | **Parameter** | **Unit** | **Range** | **Length** |
|
||||
|-----------|------------------------|--------------------|--------------------------------------------------------------------------------------|------------|
|
||||
| 1 | GNSS run status | -- | 0-1 | 1 |
|
||||
| 2 | Fix status | -- | 0-1 | 1 |
|
||||
| 3 | UTC date & Time | yyyyMMddhhmmss.sss | yyyy: [1980,2039] MM : [1,12] dd: [1,31] hh: [0,23] mm: [0,59] ss.sss:[0.000,60.999] | 18 |
|
||||
| 4 | Latitude | ±dd.dddddd | [-90.000000,90.000000] | 10 |
|
||||
| 5 | Longitude | ±dd.dddddd | -180.000000,180.000000] | 11 |
|
||||
| 6 | MSL Altitude | meters | [0,999.99] | 8 |
|
||||
| 7 | Speed Over Ground | Km/hour | [0,360.00] | 6 |
|
||||
| 8 | Course Over Ground | degrees | 0,1,2[1] | 6 |
|
||||
| 9 | Fix Mode | -- | | 1 |
|
||||
| 10 | Reserved1 | | | 0 |
|
||||
| 11 | HDOP | -- | [0,99.9] | 4 |
|
||||
| 12 | PDOP | -- | [0,99.9] | 4 |
|
||||
| 13 | VDOP | -- | [0,99.9] | 4 |
|
||||
| 14 | Reserved2 | | | 0 |
|
||||
| 15 | GPS Satellites in View | -- | -- [0,99] | 2 |
|
||||
| 16 | Reserved3 | | | 0 |
|
||||
| 17 | HPA[2] | meters | [0,9999.9] | 6 |
|
||||
| 18 | VPA[2] | meters | [0,9999.9] | 6 |
|
||||
*/
|
||||
out = out.substr(pattern.size());
|
||||
int pos = 0;
|
||||
@ -291,11 +293,11 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl
|
||||
{
|
||||
std::string_view sats_in_view = out.substr(0, pos);
|
||||
if (sats_in_view.length() > 1) {
|
||||
if (std::from_chars(out.data(), out.data() + pos, gps.sats_in_view).ec == std::errc::invalid_argument) {
|
||||
if (std::from_chars(out.data(), out.data() + pos, gps.sat.num).ec == std::errc::invalid_argument) {
|
||||
return esp_modem::command_result::FAIL;
|
||||
}
|
||||
} else {
|
||||
gps.sats_in_view = 0;
|
||||
gps.sat.num = 0;
|
||||
}
|
||||
} //clean up sats_in_view
|
||||
|
||||
@ -330,12 +332,12 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl
|
||||
return esp_modem::command_result::OK;
|
||||
}
|
||||
|
||||
esp_modem::command_result SIM7070_gnss::get_gnss_information_sim70xx(esp_modem_gps_t &gps)
|
||||
esp_modem::command_result SIM7070_gnss::get_gnss_information_sim70xx(sim70xx_gps_t &gps)
|
||||
{
|
||||
return get_gnss_information_sim70xx_lib(dte.get(), gps);
|
||||
}
|
||||
|
||||
esp_modem::command_result DCE_gnss::get_gnss_information_sim70xx(esp_modem_gps_t &gps)
|
||||
esp_modem::command_result DCE_gnss::get_gnss_information_sim70xx(sim70xx_gps_t &gps)
|
||||
{
|
||||
return device->get_gnss_information_sim70xx(gps);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "cxx_include/esp_modem_dce_factory.hpp"
|
||||
#include "cxx_include/esp_modem_dce_module.hpp"
|
||||
#include "nmea_parser.h"
|
||||
#include "sim70xx_gps.h"
|
||||
|
||||
/**
|
||||
* @brief Definition of a custom SIM7070 class with GNSS capabilities.
|
||||
@ -23,7 +23,7 @@
|
||||
class SIM7070_gnss: public esp_modem::SIM7070 {
|
||||
using SIM7070::SIM7070;
|
||||
public:
|
||||
esp_modem::command_result get_gnss_information_sim70xx(esp_modem_gps_t &gps);
|
||||
esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -47,7 +47,7 @@ public:
|
||||
|
||||
#undef ESP_MODEM_DECLARE_DCE_COMMAND
|
||||
|
||||
esp_modem::command_result get_gnss_information_sim70xx(esp_modem_gps_t &gps);
|
||||
esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps);
|
||||
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,6 @@ extern "C" {
|
||||
#define GPS_MAX_SATELLITES_IN_VIEW (16)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief GPS fix type
|
||||
*
|
||||
@ -53,9 +52,6 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t num; /*!< Satellite number */
|
||||
uint8_t elevation; /*!< Satellite elevation */
|
||||
uint16_t azimuth; /*!< Satellite azimuth */
|
||||
uint8_t snr; /*!< Satellite signal noise ratio */
|
||||
} gps_satellite_t;
|
||||
|
||||
/**
|
||||
@ -79,54 +75,31 @@ typedef struct {
|
||||
uint16_t year; /*!< Year (start from 2000) */
|
||||
} gps_date_t;
|
||||
|
||||
/**
|
||||
* @brief NMEA Statement
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
STATEMENT_UNKNOWN = 0, /*!< Unknown statement */
|
||||
STATEMENT_GGA, /*!< GGA */
|
||||
STATEMENT_GSA, /*!< GSA */
|
||||
STATEMENT_RMC, /*!< RMC */
|
||||
STATEMENT_GSV, /*!< GSV */
|
||||
STATEMENT_GLL, /*!< GLL */
|
||||
STATEMENT_VTG /*!< VTG */
|
||||
} nmea_statement_t;
|
||||
|
||||
/**
|
||||
* @brief GPS object
|
||||
*
|
||||
*/
|
||||
struct esp_modem_gps {
|
||||
struct sim70xx_gps {
|
||||
gps_run_t run; /*!< run status */
|
||||
gps_fix_t fix; /*!< Fix status */
|
||||
gps_date_t date; /*!< Fix date */
|
||||
gps_time_t tim; /*!< time in UTC */
|
||||
float latitude; /*!< Latitude (degrees) */
|
||||
float longitude; /*!< Longitude (degrees) */
|
||||
float altitude; /*!< Altitude (meters) */
|
||||
gps_run_t run; /*!< run status */
|
||||
gps_fix_t fix; /*!< Fix status */
|
||||
uint8_t sats_in_use; /*!< Number of satellites in use */
|
||||
gps_time_t tim; /*!< time in UTC */
|
||||
float speed; /*!< Ground speed, unit: m/s */
|
||||
float cog; /*!< Course over ground */
|
||||
gps_fix_mode_t fix_mode; /*!< Fix mode */
|
||||
float dop_h; /*!< Horizontal dilution of precision */
|
||||
float dop_p; /*!< Position dilution of precision */
|
||||
float dop_v; /*!< Vertical dilution of precision */
|
||||
uint8_t sats_in_view; /*!< Number of satellites in view */
|
||||
gps_date_t date; /*!< Fix date */
|
||||
float speed; /*!< Ground speed, unit: m/s */
|
||||
float cog; /*!< Course over ground */
|
||||
gps_satellite_t sat; /*!< Number of satellites in view */
|
||||
float hpa; /*!< Horizontal Position Accuracy */
|
||||
float vpa; /*!< Vertical Position Accuracy */
|
||||
};
|
||||
|
||||
typedef struct esp_modem_gps esp_modem_gps_t;
|
||||
typedef struct sim70xx_gps sim70xx_gps_t;
|
||||
|
||||
/**
|
||||
* @brief NMEA Parser Event ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
GPS_UPDATE, /*!< GPS information has been updated */
|
||||
GPS_UNKNOWN /*!< Unknown statements detected */
|
||||
} nmea_event_id_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -142,7 +142,6 @@ private:
|
||||
size_t frame_header_offset;
|
||||
uint8_t *payload_start;
|
||||
size_t total_payload_size;
|
||||
int instance;
|
||||
int sabm_ack;
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,6 @@ private:
|
||||
static void on_ppp_changed(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
|
||||
|
||||
std::shared_ptr<DTE> ppp_dte;
|
||||
esp_netif_t *netif;
|
||||
struct ppp_netif_driver driver {};
|
||||
SignalGroup signal;
|
||||
static const size_t PPP_STARTED = SignalGroup::bit0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -13,6 +13,12 @@
|
||||
|
||||
using namespace esp_modem;
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_LINUX
|
||||
#define PRIsize_t "lu"
|
||||
#else
|
||||
#define PRIsize_t "u"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MODEM_CMUX_DEFRAGMENT_PAYLOAD
|
||||
/**
|
||||
* @brief Define this to defragment partially received data of CMUX payload
|
||||
@ -144,7 +150,7 @@ bool CMux::data_available(uint8_t *data, size_t len)
|
||||
return false;
|
||||
}
|
||||
} else if ((type & FT_UIH) == FT_UIH && dlci == 0) { // notify the internal DISC command
|
||||
if ((len > 0 && (data[0] & 0xE1) == 0xE1) || (data == nullptr)) {
|
||||
if ((data == nullptr) || (len > 0 && (data[0] & 0xE1) == 0xE1)) {
|
||||
// Not a DISC, ignore (MSC frame)
|
||||
return true;
|
||||
}
|
||||
@ -245,7 +251,7 @@ bool CMux::on_header(CMuxFrame &frame)
|
||||
|
||||
bool CMux::on_payload(CMuxFrame &frame)
|
||||
{
|
||||
ESP_LOGD("CMUX", "Payload frame: dlci:%02x type:%02x payload:%d available:%d", dlci, type, payload_len, frame.len);
|
||||
ESP_LOGD("CMUX", "Payload frame: dlci:%02x type:%02x payload:%" PRIsize_t " available:%" PRIsize_t, dlci, type, payload_len, frame.len);
|
||||
if (frame.len < payload_len) { // payload
|
||||
state = cmux_state::PAYLOAD;
|
||||
if (!data_available(frame.ptr, frame.len)) { // partial read
|
||||
@ -312,7 +318,7 @@ bool CMux::on_cmux_data(uint8_t *data, size_t actual_len)
|
||||
auto data_end = buffer.get() + buffer.size;
|
||||
data_to_read = payload_len + 2; // 2 -- CMUX protocol footer
|
||||
if (data + data_to_read >= data_end) {
|
||||
ESP_LOGW("CUMX", "Failed to defragment longer payload (payload=%d)", payload_len);
|
||||
ESP_LOGW("CUMX", "Failed to defragment longer payload (payload=%" PRIsize_t ")", payload_len);
|
||||
// If you experience this error, your device uses longer payloads while
|
||||
// the configured buffer is too small to defragment the payload properly.
|
||||
// To resolve this issue you can:
|
||||
@ -340,6 +346,9 @@ bool CMux::on_cmux_data(uint8_t *data, size_t actual_len)
|
||||
actual_len = term->read(data, buffer.size);
|
||||
#endif
|
||||
}
|
||||
if (data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
ESP_LOG_BUFFER_HEXDUMP("CMUX Received", data, actual_len, ESP_LOG_VERBOSE);
|
||||
CMuxFrame frame = { .ptr = data, .len = actual_len };
|
||||
while (frame.len > 0) {
|
||||
|
@ -69,7 +69,7 @@ void Netif::receive(uint8_t *data, size_t len)
|
||||
}
|
||||
|
||||
Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
|
||||
ppp_dte(std::move(e)), netif(ppp_netif)
|
||||
ppp_dte(std::move(e))
|
||||
{
|
||||
driver.base.netif = ppp_netif;
|
||||
driver.ppp = this;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -29,11 +29,15 @@ esp_err_t Netif::esp_modem_post_attach(esp_netif_t *esp_netif, void *args)
|
||||
|
||||
void Netif::receive(uint8_t *data, size_t len)
|
||||
{
|
||||
esp_netif_receive(netif, data, len);
|
||||
esp_netif_receive(driver.base.netif, data, len);
|
||||
}
|
||||
|
||||
Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
|
||||
ppp_dte(std::move(e)), netif(ppp_netif) {}
|
||||
ppp_dte(std::move(e))
|
||||
{
|
||||
driver.base.netif = ppp_netif;
|
||||
driver.ppp = this;
|
||||
}
|
||||
|
||||
void Netif::start()
|
||||
{
|
||||
@ -41,8 +45,8 @@ void Netif::start()
|
||||
receive(data, len);
|
||||
return true;
|
||||
});
|
||||
netif->transmit = esp_modem_dte_transmit;
|
||||
netif->ctx = (void *)this;
|
||||
driver.base.netif->transmit = esp_modem_dte_transmit;
|
||||
driver.base.netif->ctx = (void *)this;
|
||||
signal.set(PPP_STARTED);
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ int FdTerminal::write(uint8_t *data, size_t len)
|
||||
|
||||
FdTerminal::~FdTerminal()
|
||||
{
|
||||
stop();
|
||||
FdTerminal::stop();
|
||||
}
|
||||
|
||||
} // namespace esp_modem
|
||||
|
@ -160,6 +160,11 @@ void UartTerminal::task()
|
||||
ESP_LOGW(TAG, "unknown uart event type: %d", event.type);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
uart_get_buffered_data_len(uart.port, &len);
|
||||
if (len && on_read) {
|
||||
on_read(nullptr, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "uart_resource.hpp"
|
||||
#include "vfs_resource/vfs_create.hpp"
|
||||
|
||||
constexpr const char *TAG = "vfs_uart_creator";
|
||||
[[maybe_unused]] constexpr const char *TAG = "vfs_uart_creator";
|
||||
|
||||
|
||||
struct esp_modem_vfs_resource {
|
||||
|
@ -3,19 +3,14 @@
|
||||
idf_version=$1
|
||||
component=$2
|
||||
|
||||
if [[ "$idf_version" == "release-v4.3" ]] && [[ "$component" == "esp_modem" ]]; then
|
||||
lwip=lwip-2.1.2
|
||||
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
||||
lwip_contrib=contrib-2.1.0
|
||||
lwip=lwip-2.1.2
|
||||
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
||||
lwip_contrib=contrib-2.1.0
|
||||
|
||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||
unzip -oq ${lwip}.zip
|
||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||
unzip -oq ${lwip_contrib}.zip
|
||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||
unzip -oq ${lwip}.zip
|
||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||
unzip -oq ${lwip_contrib}.zip
|
||||
|
||||
apt-get update && apt-get install -y gcc-8 g++-8
|
||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
||||
rm /usr/bin/gcov && ln -s /usr/bin/gcov-8 /usr/bin/gcov
|
||||
export LWIP_PATH=`pwd`/$lwip
|
||||
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
|
||||
fi
|
||||
export LWIP_PATH=`pwd`/$lwip
|
||||
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
|
||||
|
@ -1,11 +1,12 @@
|
||||
idf_component_register(SRCS "test_modem.cpp" "LoopbackTerm.cpp"
|
||||
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
||||
REQUIRES esp_modem)
|
||||
REQUIRES esp_modem WHOLE_ARCHIVE)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE Threads::Threads)
|
||||
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain)
|
||||
|
||||
set_target_properties(${COMPONENT_LIB} PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
|
@ -0,0 +1,5 @@
|
||||
dependencies:
|
||||
espressif/catch2:
|
||||
version: '*'
|
||||
idf:
|
||||
version: ">=5.0"
|
@ -1,14 +1,16 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#define CATCH_CONFIG_MAIN // This tells the catch header to generate a main
|
||||
#include <memory>
|
||||
#include <future>
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/catch_session.hpp>
|
||||
#include "cxx_include/esp_modem_api.hpp"
|
||||
#include "LoopbackTerm.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace esp_modem;
|
||||
|
||||
@ -346,3 +348,25 @@ TEST_CASE("CMUX manual mode transitions", "[esp_modem][transitions]")
|
||||
CHECK(dce->set_mode(esp_modem::modem_mode::UNDEF) == true); // Succeeds from any state
|
||||
|
||||
}
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
extern "C" int app_main(void)
|
||||
{
|
||||
// Define the argument count and arguments for Catch2, including JUnit reporting
|
||||
int argc = 5;
|
||||
const char *argv[] = {"esp_modem", "-r", "junit", "-o", "junit.xml", nullptr};
|
||||
|
||||
// Run the Catch2 session and store the result
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
|
||||
// Use more descriptive error handling
|
||||
if (result != 0) {
|
||||
printf("Test failed with result %d.\n", result);
|
||||
} else {
|
||||
printf("All tests passed successfully.\n");
|
||||
}
|
||||
|
||||
// Check for the junit.xml file in the current working directory
|
||||
// Exit the application with the test result as the status code
|
||||
std::exit(result);
|
||||
}
|
||||
|
@ -2,9 +2,5 @@
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/system/console/advanced/components
|
||||
$ENV{IDF_PATH}/examples/common_components/iperf
|
||||
"../..")
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(pppd_test)
|
||||
|
@ -0,0 +1,6 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp_modem:
|
||||
version: "^1.1.0"
|
||||
override_path: "../../.."
|
||||
espressif/iperf-cmd: "^0.1.1"
|
@ -8,7 +8,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_console.h"
|
||||
#include "cmd_system.h"
|
||||
|
||||
void register_pppd(void);
|
||||
|
||||
@ -22,7 +21,6 @@ void app_main(void)
|
||||
ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl));
|
||||
|
||||
/* Register commands */
|
||||
register_system_common();
|
||||
register_pppd();
|
||||
|
||||
printf("\n =======================================================\n");
|
||||
|
@ -2,7 +2,7 @@
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS "../.." "../../examples/modem_tcp_client/components")
|
||||
set(EXTRA_COMPONENT_DIRS "../.." "../../../mbedtls_cxx")
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(ota_test)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS manual_ota.cpp transport_batch_tls.cpp
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES extra_tcp_transports esp_http_client app_update)
|
||||
PRIV_REQUIRES mbedtls_cxx esp_http_client app_update)
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#define TAG "batch-tls"
|
||||
|
||||
using namespace idf::mbedtls_cxx;
|
||||
|
||||
class TlsTransport: public Tls {
|
||||
public:
|
||||
explicit TlsTransport(esp_transport_handle_t parent):
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -7,12 +7,12 @@
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <variant>
|
||||
|
||||
#include "mqtt_client.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "esp_mqtt.hpp"
|
||||
#include "esp_mqtt_client_config.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -133,6 +133,22 @@ esp_mqtt_client_config_t make_config(BrokerConfiguration const &broker, ClientCr
|
||||
esp_mqtt_client_config_t mqtt_client_cfg{};
|
||||
config_broker(mqtt_client_cfg, broker);
|
||||
config_client_credentials(mqtt_client_cfg, credentials);
|
||||
mqtt_client_cfg.session.keepalive = config.session.keepalive;
|
||||
mqtt_client_cfg.session.last_will.msg = config.session.last_will.lwt_msg;
|
||||
mqtt_client_cfg.session.last_will.topic = config.session.last_will.lwt_topic;
|
||||
mqtt_client_cfg.session.last_will.msg_len = config.session.last_will.lwt_msg_len;
|
||||
mqtt_client_cfg.session.last_will.qos = config.session.last_will.lwt_qos;
|
||||
mqtt_client_cfg.session.last_will.retain = config.session.last_will.lwt_retain;
|
||||
mqtt_client_cfg.session.protocol_ver = config.session.protocol_ver;
|
||||
mqtt_client_cfg.session.disable_keepalive = config.session.disable_keepalive;
|
||||
mqtt_client_cfg.network.reconnect_timeout_ms = config.connection.reconnect_timeout_ms;
|
||||
mqtt_client_cfg.network.timeout_ms = config.connection.network_timeout_ms;
|
||||
mqtt_client_cfg.network.disable_auto_reconnect = config.connection.disable_auto_reconnect;
|
||||
mqtt_client_cfg.network.refresh_connection_after_ms = config.connection.refresh_connection_after_ms;
|
||||
mqtt_client_cfg.task.priority = config.task.task_prio;
|
||||
mqtt_client_cfg.task.stack_size = config.task.task_stack;
|
||||
mqtt_client_cfg.buffer.size = config.buffer_size;
|
||||
mqtt_client_cfg.buffer.out_size = config.out_buffer_size;
|
||||
return mqtt_client_cfg;
|
||||
}
|
||||
}
|
||||
@ -150,7 +166,6 @@ Client::Client(esp_mqtt_client_config_t const &config) : handler(esp_mqtt_clien
|
||||
CHECK_THROW_SPECIFIC(esp_mqtt_client_start(handler.get()), mqtt::MQTTException);
|
||||
}
|
||||
|
||||
|
||||
void Client::mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) noexcept
|
||||
{
|
||||
ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIu32, base, event_id);
|
||||
|
@ -3,6 +3,6 @@ commitizen:
|
||||
bump_message: 'bump(websocket): $current_version -> $new_version'
|
||||
pre_bump_hooks: python ../../ci/changelog.py esp_websocket_client
|
||||
tag_format: websocket-v$version
|
||||
version: 1.2.2
|
||||
version: 1.2.3
|
||||
version_files:
|
||||
- idf_component.yml
|
||||
|
@ -1,5 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
## [1.2.3](https://github.com/espressif/esp-protocols/commits/websocket-v1.2.3)
|
||||
|
||||
### Features
|
||||
|
||||
- Expanded example to demonstrate the transfer over TLS ([0d0630ed76](https://github.com/espressif/esp-protocols/commit/0d0630ed76))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- fix esp_event dependency management ([1fb02a9a60](https://github.com/espressif/esp-protocols/commit/1fb02a9a60))
|
||||
- Skip warn on zero timeout and auto reconnect is disabled ([5b467cbf5c](https://github.com/espressif/esp-protocols/commit/5b467cbf5c))
|
||||
- Fixed to use int return value in Tx functions ([9c54b72e1f](https://github.com/espressif/esp-protocols/commit/9c54b72e1f))
|
||||
- Fixed Tx functions with DYNAMIC_BUFFER ([16174470ee](https://github.com/espressif/esp-protocols/commit/16174470ee))
|
||||
- added dependency checks, sdkconfig.defaults and refined README.md ([312982e4aa](https://github.com/espressif/esp-protocols/commit/312982e4aa))
|
||||
- Close websocket and dispatch event if server does not close within a reasonable amount of time. ([d85311880d](https://github.com/espressif/esp-protocols/commit/d85311880d))
|
||||
- Continue waiting for TCP connection to be closed ([2b092e0db4](https://github.com/espressif/esp-protocols/commit/2b092e0db4))
|
||||
|
||||
### Updated
|
||||
|
||||
- docs(websocket): Added README for websocket host example ([2f7c58259d](https://github.com/espressif/esp-protocols/commit/2f7c58259d))
|
||||
|
||||
## [1.2.2](https://github.com/espressif/esp-protocols/commits/websocket-v1.2.2)
|
||||
|
||||
### Bug Fixes
|
||||
|
@ -16,6 +16,6 @@ if(${IDF_TARGET} STREQUAL "linux")
|
||||
else()
|
||||
idf_component_register(SRCS "esp_websocket_client.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES lwip esp-tls tcp_transport http_parser
|
||||
PRIV_REQUIRES esp_timer esp_event)
|
||||
REQUIRES lwip esp-tls tcp_transport http_parser esp_event
|
||||
PRIV_REQUIRES esp_timer)
|
||||
endif()
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -497,6 +497,9 @@ static esp_err_t esp_websocket_client_create_transport(esp_websocket_client_hand
|
||||
|
||||
esp_transport_set_default_port(ssl, WEBSOCKET_SSL_DEFAULT_PORT);
|
||||
esp_transport_list_add(client->transport_list, ssl, "_ssl"); // need to save to transport list, for cleanup
|
||||
if (client->keep_alive_cfg.keep_alive_enable) {
|
||||
esp_transport_ssl_set_keep_alive(ssl, &client->keep_alive_cfg);
|
||||
}
|
||||
if (client->config->use_global_ca_store == true) {
|
||||
esp_transport_ssl_enable_global_ca_store(ssl);
|
||||
} else if (client->config->cert) {
|
||||
@ -550,9 +553,33 @@ static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_hand
|
||||
int ret = -1;
|
||||
int need_write = len;
|
||||
int wlen = 0, widx = 0;
|
||||
|
||||
bool contained_fin = opcode & WS_TRANSPORT_OPCODES_FIN;
|
||||
|
||||
if (client == NULL || len < 0 || (data == NULL && len > 0)) {
|
||||
ESP_LOGE(TAG, "Invalid arguments");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!esp_websocket_client_is_connected(client)) {
|
||||
ESP_LOGE(TAG, "Websocket client is not connected");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (client->transport == NULL) {
|
||||
ESP_LOGE(TAG, "Invalid transport");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xSemaphoreTakeRecursive(client->lock, timeout) != pdPASS) {
|
||||
ESP_LOGE(TAG, "Could not lock ws-client within %" PRIu32 " timeout", timeout);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (esp_websocket_new_buf(client, true) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to setup tx buffer");
|
||||
goto unlock_and_return;
|
||||
}
|
||||
|
||||
while (widx < len || opcode) { // allow for sending "current_opcode" only message with len==0
|
||||
if (need_write > client->buffer_size) {
|
||||
need_write = client->buffer_size;
|
||||
@ -576,14 +603,18 @@ static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_hand
|
||||
esp_websocket_client_error(client, "esp_transport_write() returned %d, errno=%d", ret, errno);
|
||||
}
|
||||
esp_websocket_client_abort_connection(client, WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT);
|
||||
return ret;
|
||||
goto unlock_and_return;
|
||||
}
|
||||
opcode = 0;
|
||||
widx += wlen;
|
||||
need_write = len - widx;
|
||||
}
|
||||
esp_websocket_free_buf(client, true);
|
||||
return widx;
|
||||
ret = widx;
|
||||
|
||||
unlock_and_return:
|
||||
xSemaphoreGiveRecursive(client->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_client_config_t *config)
|
||||
@ -629,7 +660,7 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie
|
||||
ESP_WS_CLIENT_MEM_CHECK(TAG, client->config->scheme, goto _websocket_init_fail);
|
||||
}
|
||||
|
||||
if (config->reconnect_timeout_ms <= 0) {
|
||||
if (!config->disable_auto_reconnect && config->reconnect_timeout_ms <= 0) {
|
||||
client->wait_timeout_ms = WEBSOCKET_RECONNECT_TIMEOUT_MS;
|
||||
ESP_LOGW(TAG, "`reconnect_timeout_ms` is not set, or it is less than or equal to zero, using default time out %d (milliseconds)", WEBSOCKET_RECONNECT_TIMEOUT_MS);
|
||||
} else {
|
||||
@ -1204,41 +1235,7 @@ int esp_websocket_client_send_fin(esp_websocket_client_handle_t client, TickType
|
||||
|
||||
int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client, ws_transport_opcodes_t opcode, const uint8_t *data, int len, TickType_t timeout)
|
||||
{
|
||||
int ret = ESP_OK;
|
||||
if (client == NULL || len < 0 || (data == NULL && len > 0)) {
|
||||
ESP_LOGE(TAG, "Invalid arguments");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (xSemaphoreTakeRecursive(client->lock, timeout) != pdPASS) {
|
||||
ESP_LOGE(TAG, "Could not lock ws-client within %" PRIu32 " timeout", timeout);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (!esp_websocket_client_is_connected(client)) {
|
||||
ESP_LOGE(TAG, "Websocket client is not connected");
|
||||
ret = ESP_FAIL;
|
||||
goto unlock_and_return;
|
||||
}
|
||||
|
||||
if (client->transport == NULL) {
|
||||
ESP_LOGE(TAG, "Invalid transport");
|
||||
ret = ESP_FAIL;
|
||||
goto unlock_and_return;
|
||||
}
|
||||
if (esp_websocket_new_buf(client, true) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to setup tx buffer");
|
||||
ret = ESP_FAIL;
|
||||
goto unlock_and_return;
|
||||
}
|
||||
ret = esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout);
|
||||
if (ret < 0) {
|
||||
ESP_LOGE(TAG, "Failed to send the buffer");
|
||||
goto unlock_and_return;
|
||||
}
|
||||
unlock_and_return:
|
||||
xSemaphoreGiveRecursive(client->lock);
|
||||
return ret;
|
||||
return esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout);
|
||||
}
|
||||
|
||||
bool esp_websocket_client_is_connected(esp_websocket_client_handle_t client)
|
||||
|
@ -1,14 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(COMPONENTS esp_websocket_client main)
|
||||
set(common_component_dir ../../../../common_components)
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
../../..
|
||||
"${common_component_dir}/linux_compat/esp_timer"
|
||||
"${common_component_dir}/linux_compat"
|
||||
"${common_component_dir}/linux_compat/freertos")
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(common_component_dir ../../../../common_components)
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
../..
|
||||
"${common_component_dir}/linux_compat/esp_timer"
|
||||
"${common_component_dir}/linux_compat"
|
||||
"${common_component_dir}/linux_compat/freertos"
|
||||
$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs
|
||||
$ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
|
||||
|
||||
set(COMPONENTS main)
|
||||
project(websocket)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -96,14 +96,24 @@ static void websocket_app_start(void)
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Sending fragmented message");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
// Sending text data
|
||||
ESP_LOGI(TAG, "Sending fragmented text message");
|
||||
memset(data, 'a', sizeof(data));
|
||||
esp_websocket_client_send_text_partial(client, data, sizeof(data), portMAX_DELAY);
|
||||
memset(data, 'b', sizeof(data));
|
||||
esp_websocket_client_send_cont_msg(client, data, sizeof(data), portMAX_DELAY);
|
||||
esp_websocket_client_send_fin(client, portMAX_DELAY);
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
// Sending binary data
|
||||
ESP_LOGI(TAG, "Sending fragmented binary message");
|
||||
char binary_data[128];
|
||||
memset(binary_data, 0, sizeof(binary_data));
|
||||
esp_websocket_client_send_bin_partial(client, binary_data, sizeof(binary_data), portMAX_DELAY);
|
||||
memset(binary_data, 1, sizeof(binary_data));
|
||||
esp_websocket_client_send_cont_msg(client, binary_data, sizeof(binary_data), portMAX_DELAY);
|
||||
esp_websocket_client_send_fin(client, portMAX_DELAY);
|
||||
|
||||
esp_websocket_client_destroy(client);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,9 @@ static void websocket_event_handler(void *handler_args, esp_event_base_t base, i
|
||||
case WEBSOCKET_EVENT_DATA:
|
||||
ESP_LOGI(TAG, "WEBSOCKET_EVENT_DATA");
|
||||
ESP_LOGI(TAG, "Received opcode=%d", data->op_code);
|
||||
if (data->op_code == 0x08 && data->data_len == 2) {
|
||||
if (data->op_code == 0x2) { // Opcode 0x2 indicates binary data
|
||||
ESP_LOG_BUFFER_HEX("Received binary data", data->data_ptr, data->data_len);
|
||||
} else if (data->op_code == 0x08 && data->data_len == 2) {
|
||||
ESP_LOGW(TAG, "Received closed message with code=%d", 256 * data->data_ptr[0] + data->data_ptr[1]);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Received=%.*s\n\n", data->data_len, (char *)data->data_ptr);
|
||||
@ -183,13 +185,32 @@ static void websocket_app_start(void)
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Sending fragmented message");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
// Sending text data
|
||||
ESP_LOGI(TAG, "Sending fragmented text message");
|
||||
memset(data, 'a', sizeof(data));
|
||||
esp_websocket_client_send_text_partial(client, data, sizeof(data), portMAX_DELAY);
|
||||
memset(data, 'b', sizeof(data));
|
||||
esp_websocket_client_send_cont_msg(client, data, sizeof(data), portMAX_DELAY);
|
||||
esp_websocket_client_send_fin(client, portMAX_DELAY);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
|
||||
// Sending binary data
|
||||
ESP_LOGI(TAG, "Sending fragmented binary message");
|
||||
char binary_data[5];
|
||||
memset(binary_data, 0, sizeof(binary_data));
|
||||
esp_websocket_client_send_bin_partial(client, binary_data, sizeof(binary_data), portMAX_DELAY);
|
||||
memset(binary_data, 1, sizeof(binary_data));
|
||||
esp_websocket_client_send_cont_msg(client, binary_data, sizeof(binary_data), portMAX_DELAY);
|
||||
esp_websocket_client_send_fin(client, portMAX_DELAY);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
|
||||
// Sending text data longer than ws buffer (default 1024)
|
||||
ESP_LOGI(TAG, "Sending text longer than ws buffer (default 1024)");
|
||||
const int size = 2000;
|
||||
char *long_data = malloc(size);
|
||||
memset(long_data, 'a', size);
|
||||
esp_websocket_client_send_text(client, long_data, size, portMAX_DELAY);
|
||||
|
||||
xSemaphoreTake(shutdown_sema, portMAX_DELAY);
|
||||
esp_websocket_client_close(client, portMAX_DELAY);
|
||||
|
@ -27,10 +27,13 @@ def get_my_ip():
|
||||
|
||||
|
||||
class WebsocketTestEcho(WebSocket):
|
||||
|
||||
def handleMessage(self):
|
||||
self.sendMessage(self.data)
|
||||
print('\n Server sent: {}\n'.format(self.data))
|
||||
if isinstance(self.data, bytes):
|
||||
print(f'\n Server received binary data: {self.data.hex()}\n')
|
||||
self.sendMessage(self.data, binary=True)
|
||||
else:
|
||||
print(f'\n Server received: {self.data}\n')
|
||||
self.sendMessage(self.data)
|
||||
|
||||
def handleConnected(self):
|
||||
print('Connection from: {}'.format(self.address))
|
||||
@ -86,6 +89,9 @@ def test_examples_protocol_websocket(dut):
|
||||
3. send and receive data
|
||||
"""
|
||||
|
||||
# Test for echo functionality:
|
||||
# Sends a series of simple "hello" messages to the WebSocket server and verifies that each one is echoed back correctly.
|
||||
# This tests the basic responsiveness and correctness of the WebSocket connection.
|
||||
def test_echo(dut):
|
||||
dut.expect('WEBSOCKET_EVENT_CONNECTED')
|
||||
for i in range(0, 5):
|
||||
@ -93,12 +99,16 @@ def test_examples_protocol_websocket(dut):
|
||||
print('All echos received')
|
||||
sys.stdout.flush()
|
||||
|
||||
# Test for clean closure of the WebSocket connection:
|
||||
# Ensures that the WebSocket can correctly receive a close frame and terminate the connection without issues.
|
||||
def test_close(dut):
|
||||
code = dut.expect(
|
||||
re.compile(
|
||||
b'websocket: Received closed message with code=(\\d*)'))[0]
|
||||
print('Received close frame with code {}'.format(code))
|
||||
|
||||
# Test for JSON message handling:
|
||||
# Sends a JSON formatted string and verifies that the received message matches the expected JSON structure.
|
||||
def test_json(dut, websocket):
|
||||
json_string = """
|
||||
[
|
||||
@ -118,7 +128,7 @@ def test_examples_protocol_websocket(dut):
|
||||
match = dut.expect(
|
||||
re.compile(b'Json=({[a-zA-Z0-9]*).*}')).group(0).decode()[5:]
|
||||
if match == str(data[0]):
|
||||
print('Sent message and received message are equal \n')
|
||||
print('\n Sent message and received message are equal \n')
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
raise ValueError(
|
||||
@ -126,6 +136,8 @@ def test_examples_protocol_websocket(dut):
|
||||
\nreceived: {}\nwith length {}'.format(
|
||||
data[0], len(data[0]), match, len(match)))
|
||||
|
||||
# Test for receiving long messages:
|
||||
# This sends a message with a specified length (2000 characters) to ensure the WebSocket can handle large data payloads. Repeated 3 times for reliability.
|
||||
def test_recv_long_msg(dut, websocket, msg_len, repeats):
|
||||
|
||||
send_msg = ''.join(
|
||||
@ -142,7 +154,7 @@ def test_examples_protocol_websocket(dut):
|
||||
recv_msg += match
|
||||
|
||||
if recv_msg == send_msg:
|
||||
print('Sent message and received message are equal \n')
|
||||
print('\n Sent message and received message are equal \n')
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
raise ValueError(
|
||||
@ -150,9 +162,50 @@ def test_examples_protocol_websocket(dut):
|
||||
\nreceived: {}\nwith length {}'.format(
|
||||
send_msg, len(send_msg), recv_msg, len(recv_msg)))
|
||||
|
||||
def test_fragmented_msg(dut):
|
||||
# Test for receiving the first fragment of a large message:
|
||||
# Verifies the WebSocket's ability to correctly process the initial segment of a fragmented message.
|
||||
def test_recv_fragmented_msg1(dut):
|
||||
dut.expect('websocket: Total payload length=2000, data_len=1024, current payload offset=0')
|
||||
|
||||
# Test for receiving the second fragment of a large message:
|
||||
# Confirms that the WebSocket can correctly handle and process the subsequent segment of a fragmented message.
|
||||
def test_recv_fragmented_msg2(dut):
|
||||
dut.expect('websocket: Total payload length=2000, data_len=976, current payload offset=1024')
|
||||
|
||||
# Test for receiving fragmented text messages:
|
||||
# Checks if the WebSocket can accurately reconstruct a message sent in several smaller parts.
|
||||
def test_fragmented_txt_msg(dut):
|
||||
dut.expect('Received=' + 32 * 'a' + 32 * 'b')
|
||||
print('Fragmented data received')
|
||||
print('\nFragmented data received\n')
|
||||
|
||||
# Extract the hexdump portion of the log line
|
||||
def parse_hexdump(line):
|
||||
match = re.search(r'\(.*\) Received binary data: ([0-9A-Fa-f ]+)', line)
|
||||
if match:
|
||||
hexdump = match.group(1).strip().replace(' ', '')
|
||||
# Convert the hexdump string to a bytearray
|
||||
return bytearray.fromhex(hexdump)
|
||||
return bytearray()
|
||||
|
||||
# Capture the binary log output from the DUT
|
||||
def test_fragmented_binary_msg(dut):
|
||||
match = dut.expect(r'\(.*\) Received binary data: .*')
|
||||
if match:
|
||||
line = match.group(0).strip()
|
||||
if isinstance(line, bytes):
|
||||
line = line.decode('utf-8')
|
||||
|
||||
# Parse the hexdump from the log line
|
||||
received_data = parse_hexdump(line)
|
||||
|
||||
# Create the expected bytearray with the specified pattern
|
||||
expected_data = bytearray([0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
|
||||
|
||||
# Validate the received data
|
||||
assert received_data == expected_data, f'Received data does not match expected data. Received: {received_data}, Expected: {expected_data}'
|
||||
print('\nFragmented data received\n')
|
||||
else:
|
||||
assert False, 'Log line with binary data not found'
|
||||
|
||||
# Starting of the test
|
||||
try:
|
||||
@ -184,10 +237,12 @@ def test_examples_protocol_websocket(dut):
|
||||
dut.expect('Please enter uri of websocket endpoint', timeout=30)
|
||||
dut.write(uri)
|
||||
test_echo(dut)
|
||||
# Message length should exceed DUT's buffer size to test fragmentation, default is 1024 byte
|
||||
test_recv_long_msg(dut, ws, 2000, 3)
|
||||
test_json(dut, ws)
|
||||
test_fragmented_msg(dut)
|
||||
test_fragmented_txt_msg(dut)
|
||||
test_fragmented_binary_msg(dut)
|
||||
test_recv_fragmented_msg1(dut)
|
||||
test_recv_fragmented_msg2(dut)
|
||||
test_close(dut)
|
||||
else:
|
||||
print('DUT connecting to {}'.format(uri))
|
||||
|
@ -0,0 +1,14 @@
|
||||
CONFIG_IDF_TARGET="esp32"
|
||||
CONFIG_IDF_TARGET_LINUX=n
|
||||
CONFIG_WEBSOCKET_URI_FROM_STDIN=n
|
||||
CONFIG_WEBSOCKET_URI_FROM_STRING=y
|
||||
CONFIG_EXAMPLE_CONNECT_ETHERNET=y
|
||||
CONFIG_EXAMPLE_CONNECT_WIFI=n
|
||||
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
|
||||
CONFIG_EXAMPLE_ETH_PHY_IP101=y
|
||||
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
|
||||
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
|
||||
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
|
||||
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
|
||||
CONFIG_EXAMPLE_CONNECT_IPV6=y
|
||||
CONFIG_ESP_WS_CLIENT_ENABLE_DYNAMIC_BUFFER=y
|
@ -1,4 +1,4 @@
|
||||
version: "1.2.2"
|
||||
version: "1.2.3"
|
||||
description: WebSocket protocol client for ESP-IDF
|
||||
url: https://github.com/espressif/esp-protocols/tree/master/components/esp_websocket_client
|
||||
dependencies:
|
||||
|
8
components/esp_wifi_remote/.cz.yaml
Normal file
8
components/esp_wifi_remote/.cz.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
commitizen:
|
||||
bump_message: 'bump(wifi_remote): $current_version -> $new_version'
|
||||
pre_bump_hooks: python ../../ci/changelog.py esp_wifi_remote
|
||||
tag_format: wifi_remote-v$version
|
||||
version: 0.2.3
|
||||
version_files:
|
||||
- idf_component.yml
|
40
components/esp_wifi_remote/CHANGELOG.md
Normal file
40
components/esp_wifi_remote/CHANGELOG.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Changelog
|
||||
|
||||
## [0.2.3](https://github.com/espressif/esp-protocols/commits/wifi_remote-v0.2.3)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix server event/command race condtion using eventfd ([732b1d5](https://github.com/espressif/esp-protocols/commit/732b1d5))
|
||||
- Lock server before marshalling events ([9e13870](https://github.com/espressif/esp-protocols/commit/9e13870))
|
||||
|
||||
## [0.2.2](https://github.com/espressif/esp-protocols/commits/wifi_remote-v0.2.2)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Added more netif options for eppp connection ([24ce867](https://github.com/espressif/esp-protocols/commit/24ce867))
|
||||
- Do not restrict EPPP config to RSA keys only ([f05c765](https://github.com/espressif/esp-protocols/commit/f05c765), [#570](https://github.com/espressif/esp-protocols/issues/570))
|
||||
|
||||
## [0.2.1](https://github.com/espressif/esp-protocols/commits/wifi_remote-v0.2.1)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Added misc wifi API in eppp impl ([93256d1](https://github.com/espressif/esp-protocols/commit/93256d1))
|
||||
- Updated eppp dependency not to use fixed version ([3a48c06](https://github.com/espressif/esp-protocols/commit/3a48c06))
|
||||
|
||||
## [0.2.0](https://github.com/espressif/esp-protocols/commits/wifi_remote-v0.2.0)
|
||||
|
||||
### Features
|
||||
|
||||
- Add support for simple eppp based RPC ([fd168d8](https://github.com/espressif/esp-protocols/commit/fd168d8))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Make services restartable, code cleanup ([6c82ce2](https://github.com/espressif/esp-protocols/commit/6c82ce2))
|
||||
- Add examples to CI ([d2b7c55](https://github.com/espressif/esp-protocols/commit/d2b7c55))
|
||||
|
||||
## [0.1.12](https://github.com/espressif/esp-protocols/commits/wifi_remote-v0.1.12)
|
||||
|
||||
### Features
|
||||
|
||||
- Added generation step for wifi_remote based on IDF ([dfb00358](https://github.com/espressif/esp-protocols/commit/dfb00358))
|
||||
- Move to esp-protocols ([edc3c2d](https://github.com/espressif/esp-protocols/commit/edc3c2d))
|
20
components/esp_wifi_remote/CMakeLists.txt
Normal file
20
components/esp_wifi_remote/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
if(NOT CONFIG_ESP_WIFI_ENABLED)
|
||||
set(src_wifi_is_remote esp_wifi_remote.c esp_wifi_with_remote.c esp_wifi_remote_net.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESP_WIFI_REMOTE_LIBRARY_EPPP)
|
||||
set(src_wifi_remote_eppp eppp/wifi_remote_rpc_client.cpp eppp/wifi_remote_rpc_server.cpp eppp/eppp_init.c)
|
||||
else()
|
||||
set(src_wifi_remote_weak esp_wifi_remote_weak.c)
|
||||
endif()
|
||||
|
||||
idf_component_register(INCLUDE_DIRS include
|
||||
SRCS ${src_wifi_remote_weak}
|
||||
${src_wifi_remote_eppp}
|
||||
${src_wifi_is_remote}
|
||||
PRIV_INCLUDE_DIRS eppp
|
||||
REQUIRES esp_event esp_netif
|
||||
PRIV_REQUIRES esp_wifi esp-tls vfs)
|
||||
|
||||
idf_component_get_property(wifi esp_wifi COMPONENT_LIB)
|
||||
target_link_libraries(${wifi} PUBLIC ${COMPONENT_LIB})
|
678
components/esp_wifi_remote/Kconfig
Normal file
678
components/esp_wifi_remote/Kconfig
Normal file
@ -0,0 +1,678 @@
|
||||
# This file is auto-generated
|
||||
menu "Wi-Fi Remote"
|
||||
config ESP_WIFI_REMOTE_ENABLED
|
||||
bool
|
||||
default y
|
||||
|
||||
orsource "./Kconfig.soc_wifi_caps.in"
|
||||
orsource "./Kconfig.rpc.in"
|
||||
|
||||
config ESP_WIFI_STATIC_RX_BUFFER_NUM
|
||||
int "Max number of WiFi static RX buffers"
|
||||
range 2 25 if !SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
range 2 128 if SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
help
|
||||
Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM.
|
||||
The static rx buffers are allocated when esp_wifi_init is called, they are not freed
|
||||
until esp_wifi_deinit is called.
|
||||
|
||||
WiFi hardware use these buffers to receive all 802.11 frames.
|
||||
A higher number may allow higher throughput but increases memory use. If ESP_WIFI_AMPDU_RX_ENABLED
|
||||
is enabled, this value is recommended to set equal or bigger than ESP_WIFI_RX_BA_WIN in order to
|
||||
achieve better throughput and compatibility with both stations and APs.
|
||||
|
||||
config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM
|
||||
int "Max number of WiFi dynamic RX buffers"
|
||||
range 0 128 if !LWIP_WND_SCALE
|
||||
range 0 1024 if LWIP_WND_SCALE
|
||||
default 32
|
||||
help
|
||||
Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated
|
||||
(provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of
|
||||
the received data frame.
|
||||
|
||||
For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers
|
||||
it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has
|
||||
successfully received the data frame.
|
||||
|
||||
For some applications, WiFi data frames may be received faster than the application can
|
||||
process them. In these cases we may run out of memory if RX buffer number is unlimited (0).
|
||||
|
||||
If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers.
|
||||
|
||||
choice ESP_WIFI_TX_BUFFER
|
||||
prompt "Type of WiFi TX buffers"
|
||||
default ESP_WIFI_DYNAMIC_TX_BUFFER
|
||||
help
|
||||
Select type of WiFi TX buffers:
|
||||
|
||||
If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released
|
||||
when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB.
|
||||
|
||||
If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is
|
||||
delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame
|
||||
has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length
|
||||
of each data frame sent by the TCP/IP layer.
|
||||
|
||||
If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers.
|
||||
If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM.
|
||||
|
||||
config ESP_WIFI_STATIC_TX_BUFFER
|
||||
bool "Static"
|
||||
config ESP_WIFI_DYNAMIC_TX_BUFFER
|
||||
bool "Dynamic"
|
||||
depends on !SPIRAM_USE_MALLOC
|
||||
endchoice
|
||||
|
||||
config ESP_WIFI_TX_BUFFER_TYPE
|
||||
int
|
||||
default 0 if ESP_WIFI_STATIC_TX_BUFFER
|
||||
default 1 if ESP_WIFI_DYNAMIC_TX_BUFFER
|
||||
|
||||
config ESP_WIFI_STATIC_TX_BUFFER_NUM
|
||||
int "Max number of WiFi static TX buffers"
|
||||
depends on ESP_WIFI_STATIC_TX_BUFFER
|
||||
range 1 64
|
||||
default 16
|
||||
help
|
||||
Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM.
|
||||
The static RX buffers are allocated when esp_wifi_init() is called, they are not released
|
||||
until esp_wifi_deinit() is called.
|
||||
|
||||
For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a
|
||||
copy of it in a TX buffer. For some applications especially UDP applications, the upper
|
||||
layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out
|
||||
of TX buffers.
|
||||
|
||||
config ESP_WIFI_CACHE_TX_BUFFER_NUM
|
||||
int "Max number of WiFi cache TX buffers"
|
||||
depends on SPIRAM
|
||||
range 16 128
|
||||
default 32
|
||||
help
|
||||
Set the number of WiFi cache TX buffer number.
|
||||
|
||||
For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to allocate a static TX
|
||||
buffer and makes a copy of uplayer packet. If WiFi driver fails to allocate the static TX buffer,
|
||||
it caches the uplayer packets to a dedicated buffer queue, this option is used to configure the
|
||||
size of the cached TX queue.
|
||||
|
||||
config ESP_WIFI_DYNAMIC_TX_BUFFER_NUM
|
||||
int "Max number of WiFi dynamic TX buffers"
|
||||
depends on ESP_WIFI_DYNAMIC_TX_BUFFER
|
||||
range 1 128
|
||||
default 32
|
||||
help
|
||||
Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed,
|
||||
it depends on the size of each transmitted data frame.
|
||||
|
||||
For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy
|
||||
of it in a TX buffer. For some applications, especially UDP applications, the upper layer
|
||||
can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX
|
||||
buffers.
|
||||
|
||||
choice ESP_WIFI_MGMT_RX_BUFFER
|
||||
prompt "Type of WiFi RX MGMT buffers"
|
||||
default ESP_WIFI_STATIC_RX_MGMT_BUFFER
|
||||
help
|
||||
Select type of WiFi RX MGMT buffers:
|
||||
|
||||
If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released
|
||||
when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes.
|
||||
|
||||
If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is
|
||||
received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver.
|
||||
|
||||
|
||||
config ESP_WIFI_STATIC_RX_MGMT_BUFFER
|
||||
bool "Static"
|
||||
config ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER
|
||||
bool "Dynamic"
|
||||
endchoice
|
||||
|
||||
config ESP_WIFI_DYNAMIC_RX_MGMT_BUF
|
||||
int
|
||||
default 0 if ESP_WIFI_STATIC_RX_MGMT_BUFFER
|
||||
default 1 if ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER
|
||||
|
||||
config ESP_WIFI_RX_MGMT_BUF_NUM_DEF
|
||||
int "Max number of WiFi RX MGMT buffers"
|
||||
range 1 10
|
||||
default 5
|
||||
help
|
||||
Set the number of WiFi RX_MGMT buffers.
|
||||
|
||||
For Management buffers, the number of dynamic and static management buffers is the same.
|
||||
In order to prevent memory fragmentation, the management buffer type should be set to static first.
|
||||
|
||||
config ESP_WIFI_CSI_ENABLED
|
||||
bool "WiFi CSI(Channel State Information)"
|
||||
depends on SLAVE_SOC_WIFI_CSI_SUPPORT
|
||||
default n
|
||||
help
|
||||
Select this option to enable CSI(Channel State Information) feature. CSI takes about
|
||||
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM KB of RAM. If CSI is not used, it is better to disable
|
||||
this feature in order to save memory.
|
||||
|
||||
config ESP_WIFI_AMPDU_TX_ENABLED
|
||||
bool "WiFi AMPDU TX"
|
||||
default y
|
||||
help
|
||||
Select this option to enable AMPDU TX feature
|
||||
|
||||
|
||||
config ESP_WIFI_TX_BA_WIN
|
||||
int "WiFi AMPDU TX BA window size"
|
||||
depends on ESP_WIFI_AMPDU_TX_ENABLED
|
||||
range 2 32 if !SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
range 2 64 if SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
default 6
|
||||
help
|
||||
Set the size of WiFi Block Ack TX window. Generally a bigger value means higher throughput but
|
||||
more memory. Most of time we should NOT change the default value unless special reason, e.g.
|
||||
test the maximum UDP TX throughput with iperf etc. For iperf test in shieldbox, the recommended
|
||||
value is 9~12.
|
||||
|
||||
config ESP_WIFI_AMPDU_RX_ENABLED
|
||||
bool "WiFi AMPDU RX"
|
||||
default y
|
||||
help
|
||||
Select this option to enable AMPDU RX feature
|
||||
|
||||
config ESP_WIFI_RX_BA_WIN
|
||||
int "WiFi AMPDU RX BA window size"
|
||||
depends on ESP_WIFI_AMPDU_RX_ENABLED
|
||||
range 2 32 if !SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
range 2 64 if SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
help
|
||||
Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better
|
||||
compatibility but more memory. Most of time we should NOT change the default value unless special
|
||||
reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the
|
||||
recommended value is 9~12. If PSRAM is used and WiFi memory is preferred to allocate in PSRAM first,
|
||||
the default and minimum value should be 16 to achieve better throughput and compatibility with both
|
||||
stations and APs.
|
||||
|
||||
config ESP_WIFI_AMSDU_TX_ENABLED
|
||||
bool "WiFi AMSDU TX"
|
||||
depends on SPIRAM
|
||||
default n
|
||||
help
|
||||
Select this option to enable AMSDU TX feature
|
||||
|
||||
config ESP_WIFI_NVS_ENABLED
|
||||
bool "WiFi NVS flash"
|
||||
default y
|
||||
help
|
||||
Select this option to enable WiFi NVS flash
|
||||
|
||||
choice ESP_WIFI_TASK_CORE_ID
|
||||
depends on !FREERTOS_UNICORE
|
||||
prompt "WiFi Task Core ID"
|
||||
default ESP_WIFI_TASK_PINNED_TO_CORE_0
|
||||
help
|
||||
Pinned WiFi task to core 0 or core 1.
|
||||
|
||||
config ESP_WIFI_TASK_PINNED_TO_CORE_0
|
||||
bool "Core 0"
|
||||
config ESP_WIFI_TASK_PINNED_TO_CORE_1
|
||||
bool "Core 1"
|
||||
endchoice
|
||||
|
||||
config ESP_WIFI_SOFTAP_BEACON_MAX_LEN
|
||||
int "Max length of WiFi SoftAP Beacon"
|
||||
range 752 1256
|
||||
default 752
|
||||
help
|
||||
ESP-MESH utilizes beacon frames to detect and resolve root node conflicts (see documentation). However
|
||||
the default length of a beacon frame can simultaneously hold only five root node identifier structures,
|
||||
meaning that a root node conflict of up to five nodes can be detected at one time. In the occurrence of
|
||||
more root nodes conflict involving more than five root nodes, the conflict resolution process will
|
||||
detect five of the root nodes, resolve the conflict, and re-detect more root nodes. This process will
|
||||
repeat until all root node conflicts are resolved. However this process can generally take a very long
|
||||
time.
|
||||
|
||||
To counter this situation, the beacon frame length can be increased such that more root nodes can be
|
||||
detected simultaneously. Each additional root node will require 36 bytes and should be added on top of
|
||||
the default beacon frame length of
|
||||
752 bytes. For example, if you want to detect 10 root nodes simultaneously, you need to set the beacon
|
||||
frame length as
|
||||
932 (752+36*5).
|
||||
|
||||
Setting a longer beacon length also assists with debugging as the conflicting root nodes can be
|
||||
identified more quickly.
|
||||
|
||||
config ESP_WIFI_MGMT_SBUF_NUM
|
||||
int "WiFi mgmt short buffer number"
|
||||
range 6 32
|
||||
default 32
|
||||
help
|
||||
Set the number of WiFi management short buffer.
|
||||
|
||||
config ESP_WIFI_IRAM_OPT
|
||||
bool "WiFi IRAM speed optimization"
|
||||
default n if (BT_ENABLED && SPIRAM && SLAVE_IDF_TARGET_ESP32)
|
||||
default y
|
||||
help
|
||||
Select this option to place frequently called Wi-Fi library functions in IRAM.
|
||||
When this option is disabled, more than 10Kbytes of IRAM memory will be saved
|
||||
but Wi-Fi throughput will be reduced.
|
||||
|
||||
config ESP_WIFI_EXTRA_IRAM_OPT
|
||||
bool "WiFi EXTRA IRAM speed optimization"
|
||||
default y if SLAVE_IDF_TARGET_ESP32C6
|
||||
default n
|
||||
help
|
||||
Select this option to place additional frequently called Wi-Fi library functions
|
||||
in IRAM. When this option is disabled, more than 5Kbytes of IRAM memory will be saved
|
||||
but Wi-Fi throughput will be reduced.
|
||||
|
||||
config ESP_WIFI_RX_IRAM_OPT
|
||||
bool "WiFi RX IRAM speed optimization"
|
||||
default n if (BT_ENABLED && SPIRAM && SLAVE_IDF_TARGET_ESP32)
|
||||
default y
|
||||
help
|
||||
Select this option to place frequently called Wi-Fi library RX functions in IRAM.
|
||||
When this option is disabled, more than 17Kbytes of IRAM memory will be saved
|
||||
but Wi-Fi performance will be reduced.
|
||||
|
||||
config ESP_WIFI_ENABLE_WPA3_SAE
|
||||
bool "Enable WPA3-Personal"
|
||||
default y
|
||||
select ESP_WIFI_MBEDTLS_CRYPTO
|
||||
help
|
||||
Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's.
|
||||
PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
|
||||
explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide
|
||||
for details.
|
||||
|
||||
config ESP_WIFI_ENABLE_SAE_PK
|
||||
bool "Enable SAE-PK"
|
||||
default y
|
||||
depends on ESP_WIFI_ENABLE_WPA3_SAE
|
||||
help
|
||||
Select this option to enable SAE-PK
|
||||
|
||||
config ESP_WIFI_SOFTAP_SAE_SUPPORT
|
||||
bool "Enable WPA3 Personal(SAE) SoftAP"
|
||||
default y
|
||||
depends on ESP_WIFI_ENABLE_WPA3_SAE
|
||||
depends on ESP_WIFI_SOFTAP_SUPPORT
|
||||
help
|
||||
Select this option to enable SAE support in softAP mode.
|
||||
|
||||
config ESP_WIFI_ENABLE_WPA3_OWE_STA
|
||||
bool "Enable OWE STA"
|
||||
default y
|
||||
select ESP_WIFI_MBEDTLS_CRYPTO
|
||||
help
|
||||
Select this option to allow the device to establish OWE connection with eligible AP's.
|
||||
PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
|
||||
explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide
|
||||
for details.
|
||||
|
||||
config ESP_WIFI_SLP_IRAM_OPT
|
||||
bool "WiFi SLP IRAM speed optimization"
|
||||
select PM_SLP_DEFAULT_PARAMS_OPT
|
||||
select PERIPH_CTRL_FUNC_IN_IRAM
|
||||
help
|
||||
Select this option to place called Wi-Fi library TBTT process and receive beacon functions in IRAM.
|
||||
Some functions can be put in IRAM either by ESP_WIFI_IRAM_OPT and ESP_WIFI_RX_IRAM_OPT, or this one.
|
||||
If already enabled ESP_WIFI_IRAM_OPT, the other 7.3KB IRAM memory would be taken by this option.
|
||||
If already enabled ESP_WIFI_RX_IRAM_OPT, the other 1.3KB IRAM memory would be taken by this option.
|
||||
If neither of them are enabled, the other 7.4KB IRAM memory would be taken by this option.
|
||||
Wi-Fi power-save mode average current would be reduced if this option is enabled.
|
||||
|
||||
config ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME
|
||||
int "Minimum active time"
|
||||
range 8 60
|
||||
default 50
|
||||
depends on ESP_WIFI_SLP_IRAM_OPT
|
||||
help
|
||||
The minimum timeout for waiting to receive data, unit: milliseconds.
|
||||
|
||||
config ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME
|
||||
int "Maximum keep alive time"
|
||||
range 10 60
|
||||
default 10
|
||||
depends on ESP_WIFI_SLP_IRAM_OPT
|
||||
help
|
||||
The maximum time that wifi keep alive, unit: seconds.
|
||||
|
||||
config ESP_WIFI_FTM_ENABLE
|
||||
bool "WiFi FTM"
|
||||
default n
|
||||
depends on SLAVE_SOC_WIFI_FTM_SUPPORT
|
||||
help
|
||||
Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT).
|
||||
|
||||
config ESP_WIFI_FTM_INITIATOR_SUPPORT
|
||||
bool "FTM Initiator support"
|
||||
default y
|
||||
depends on ESP_WIFI_FTM_ENABLE
|
||||
|
||||
config ESP_WIFI_FTM_RESPONDER_SUPPORT
|
||||
bool "FTM Responder support"
|
||||
default y
|
||||
depends on ESP_WIFI_FTM_ENABLE
|
||||
|
||||
config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE
|
||||
bool "Power Management for station at disconnected"
|
||||
default y
|
||||
help
|
||||
Select this option to enable power_management for station when disconnected.
|
||||
Chip will do modem-sleep when rf module is not in use any more.
|
||||
|
||||
config ESP_WIFI_GCMP_SUPPORT
|
||||
bool "WiFi GCMP Support(GCMP128 and GCMP256)"
|
||||
default n
|
||||
depends on SLAVE_SOC_WIFI_GCMP_SUPPORT
|
||||
help
|
||||
Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support.
|
||||
|
||||
config ESP_WIFI_GMAC_SUPPORT
|
||||
bool "WiFi GMAC Support(GMAC128 and GMAC256)"
|
||||
default n
|
||||
help
|
||||
Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192 bit certification.
|
||||
|
||||
config ESP_WIFI_SOFTAP_SUPPORT
|
||||
bool "WiFi SoftAP Support"
|
||||
default y
|
||||
help
|
||||
WiFi module can be compiled without SoftAP to save code size.
|
||||
|
||||
config ESP_WIFI_ENHANCED_LIGHT_SLEEP
|
||||
bool "WiFi modem automatically receives the beacon"
|
||||
default n
|
||||
depends on ESP_PHY_MAC_BB_PD && SOC_PM_SUPPORT_BEACON_WAKEUP
|
||||
help
|
||||
The wifi modem automatically receives the beacon frame during light sleep.
|
||||
|
||||
config ESP_WIFI_SLP_BEACON_LOST_OPT
|
||||
bool "Wifi sleep optimize when beacon lost"
|
||||
help
|
||||
Enable wifi sleep optimization when beacon loss occurs and immediately enter
|
||||
sleep mode when the WiFi module detects beacon loss.
|
||||
|
||||
config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT
|
||||
int "Beacon loss timeout"
|
||||
range 5 100
|
||||
default 10
|
||||
depends on ESP_WIFI_SLP_BEACON_LOST_OPT
|
||||
help
|
||||
Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond.
|
||||
|
||||
config ESP_WIFI_SLP_BEACON_LOST_THRESHOLD
|
||||
int "Maximum number of consecutive lost beacons allowed"
|
||||
range 0 8
|
||||
default 3
|
||||
depends on ESP_WIFI_SLP_BEACON_LOST_OPT
|
||||
help
|
||||
Maximum number of consecutive lost beacons allowed, WiFi keeps Rx state when
|
||||
the number of consecutive beacons lost is greater than the given threshold.
|
||||
|
||||
config ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME
|
||||
int "Delta early time for RF PHY on"
|
||||
range 0 100
|
||||
default 2
|
||||
depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
help
|
||||
Delta early time for rf phy on, When the beacon is lost, the next rf phy on will
|
||||
be earlier the time specified by the configuration item, Unit: 32 microsecond.
|
||||
|
||||
config ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME
|
||||
int "Delta timeout time for RF PHY off"
|
||||
range 0 8
|
||||
default 2
|
||||
depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
help
|
||||
Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will
|
||||
be delayed for the time specified by the configuration item. Unit: 1024 microsecond.
|
||||
|
||||
config ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM
|
||||
int "Maximum espnow encrypt peers number"
|
||||
range 0 4 if SLAVE_IDF_TARGET_ESP32C2
|
||||
range 0 17 if (!SLAVE_IDF_TARGET_ESP32C2)
|
||||
default 2 if SLAVE_IDF_TARGET_ESP32C2
|
||||
default 7 if (!SLAVE_IDF_TARGET_ESP32C2)
|
||||
help
|
||||
Maximum number of encrypted peers supported by espnow.
|
||||
The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same
|
||||
hardware keys. So this configuration will affect the maximum connection number of SoftAP.
|
||||
Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware
|
||||
keys number. When using ESP mesh, this value should be set to a maximum of 6.
|
||||
|
||||
config ESP_WIFI_NAN_ENABLE
|
||||
bool "WiFi Aware"
|
||||
default n
|
||||
depends on SLAVE_SOC_WIFI_NAN_SUPPORT
|
||||
help
|
||||
Enable WiFi Aware (NAN) feature.
|
||||
|
||||
config ESP_WIFI_ENABLE_WIFI_TX_STATS
|
||||
bool "Enable Wi-Fi transmission statistics"
|
||||
depends on SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
default "y"
|
||||
help
|
||||
Enable Wi-Fi transmission statistics. Total support 4 access category. Each access category
|
||||
will use 346 bytes memory.
|
||||
|
||||
config ESP_WIFI_MBEDTLS_CRYPTO
|
||||
bool "Use MbedTLS crypto APIs"
|
||||
default y
|
||||
select MBEDTLS_AES_C
|
||||
select MBEDTLS_ECP_C
|
||||
select MBEDTLS_ECDH_C
|
||||
select MBEDTLS_ECDSA_C
|
||||
select MBEDTLS_CMAC_C
|
||||
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
help
|
||||
Select this option to enable the use of MbedTLS crypto APIs.
|
||||
The internal crypto support within the supplicant is limited
|
||||
and may not suffice for all new security features, including WPA3.
|
||||
|
||||
It is recommended to always keep this option enabled. Additionally,
|
||||
note that MbedTLS can leverage hardware acceleration if available,
|
||||
resulting in significantly faster cryptographic operations.
|
||||
|
||||
if ESP_WIFI_MBEDTLS_CRYPTO
|
||||
config ESP_WIFI_MBEDTLS_TLS_CLIENT
|
||||
bool "Use MbedTLS TLS client for WiFi Enterprise connection"
|
||||
depends on ESP_WIFI_ENTERPRISE_SUPPORT
|
||||
default y
|
||||
select MBEDTLS_TLS_ENABLED
|
||||
help
|
||||
Select this option to use MbedTLS TLS client for WPA2 enterprise connection.
|
||||
Please note that from MbedTLS-3.0 onwards, MbedTLS does not support SSL-3.0
|
||||
TLS-v1.0, TLS-v1.1 versions. In case your server is using one of these version,
|
||||
it is advisable to update your server.
|
||||
Please disable this option for compatibility with older TLS versions.
|
||||
|
||||
config ESP_WIFI_EAP_TLS1_3
|
||||
bool "Enable EAP-TLS v1.3 Support for WiFi Enterprise connection"
|
||||
default n
|
||||
select MBEDTLS_SSL_PROTO_TLS1_3
|
||||
depends on ESP_WIFI_MBEDTLS_TLS_CLIENT && IDF_EXPERIMENTAL_FEATURES
|
||||
help
|
||||
Select this option to support EAP with TLS v1.3.
|
||||
This configuration still supports compatibility with EAP-TLS v1.2.
|
||||
Please note that enabling this configuration will cause every application which
|
||||
uses TLS go for TLS1.3 if server supports that. TLS1.3 is still in development in mbedtls
|
||||
and there may be interoperability issues with this. Please modify your application to set
|
||||
max version as TLS1.2 if you want to enable TLS1.3 only for WiFi connection.
|
||||
|
||||
endif
|
||||
|
||||
config ESP_WIFI_WAPI_PSK
|
||||
bool "Enable WAPI PSK support"
|
||||
depends on SLAVE_SOC_WIFI_WAPI_SUPPORT
|
||||
default n
|
||||
help
|
||||
Select this option to enable WAPI-PSK
|
||||
which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003).
|
||||
|
||||
config ESP_WIFI_SUITE_B_192
|
||||
bool "Enable NSA suite B support with 192 bit key"
|
||||
default n
|
||||
depends on SLAVE_SOC_WIFI_GCMP_SUPPORT
|
||||
select ESP_WIFI_GCMP_SUPPORT
|
||||
select ESP_WIFI_GMAC_SUPPORT
|
||||
help
|
||||
Select this option to enable 192 bit NSA suite-B.
|
||||
This is necessary to support WPA3 192 bit security.
|
||||
|
||||
config ESP_WIFI_11KV_SUPPORT
|
||||
bool "Enable 802.11k, 802.11v APIs Support"
|
||||
default n
|
||||
help
|
||||
Select this option to enable 802.11k 802.11v APIs(RRM and BTM support).
|
||||
Only APIs which are helpful for network assisted roaming
|
||||
are supported for now.
|
||||
Enable this option with BTM and RRM enabled in sta config
|
||||
to make device ready for network assisted roaming.
|
||||
BTM: BSS transition management enables an AP to request a station to transition
|
||||
to a specific AP, or to indicate to a station a set of preferred APs.
|
||||
RRM: Radio measurements enable STAs to understand the radio environment,
|
||||
it enables STAs to observe and gather data on radio link performance
|
||||
and on the radio environment. Current implementation adds beacon report,
|
||||
link measurement, neighbor report.
|
||||
|
||||
config ESP_WIFI_SCAN_CACHE
|
||||
bool "Keep scan results in cache"
|
||||
depends on ESP_WIFI_11KV_SUPPORT
|
||||
default n
|
||||
help
|
||||
Keep scan results in cache, if not enabled, those
|
||||
will be flushed immediately.
|
||||
|
||||
config ESP_WIFI_MBO_SUPPORT
|
||||
bool "Enable Multi Band Operation Certification Support"
|
||||
default n
|
||||
select ESP_WIFI_11KV_SUPPORT
|
||||
select ESP_WIFI_SCAN_CACHE
|
||||
help
|
||||
Select this option to enable WiFi Multiband operation certification support.
|
||||
|
||||
config ESP_WIFI_ENABLE_ROAMING_APP
|
||||
bool "Advanced support for Wi-Fi Roaming (Experimental)"
|
||||
depends on IDF_EXPERIMENTAL_FEATURES
|
||||
default n
|
||||
select ESP_WIFI_SCAN_CACHE
|
||||
help
|
||||
Enable Espressif's roaming app to allow for efficient Wi-Fi roaming.
|
||||
This includes configurable periodic environment scans, maintaining a cache of the
|
||||
best APs, handling low rssi events etc.
|
||||
|
||||
Risk Warning
|
||||
Please note that this feature is still experimental and enabling this potentially can
|
||||
lead to unpredictable scanning, connection and roaming attempts.
|
||||
We are still working on tuning and optimising this feature to ensure reliable and stable use.
|
||||
|
||||
menu "Configure roaming App"
|
||||
depends on ESP_WIFI_ENABLE_ROAMING_APP
|
||||
rsource "wifi_apps/roaming_app/src/Kconfig.roaming"
|
||||
endmenu
|
||||
|
||||
config ESP_WIFI_DPP_SUPPORT
|
||||
bool "Enable DPP support"
|
||||
default n
|
||||
select ESP_WIFI_MBEDTLS_CRYPTO
|
||||
help
|
||||
Select this option to enable WiFi Easy Connect Support.
|
||||
|
||||
config ESP_WIFI_11R_SUPPORT
|
||||
bool "Enable 802.11R (Fast Transition) Support"
|
||||
default n
|
||||
help
|
||||
Select this option to enable WiFi Fast Transition Support.
|
||||
|
||||
config ESP_WIFI_WPS_SOFTAP_REGISTRAR
|
||||
bool "Add WPS Registrar support in SoftAP mode"
|
||||
depends on ESP_WIFI_SOFTAP_SUPPORT
|
||||
default n
|
||||
help
|
||||
Select this option to enable WPS registrar support in softAP mode.
|
||||
|
||||
config ESP_WIFI_ENABLE_WIFI_RX_STATS
|
||||
bool "Enable Wi-Fi reception statistics"
|
||||
depends on SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
default "y"
|
||||
help
|
||||
Enable Wi-Fi reception statistics. Total support 2 access category. Each access category
|
||||
will use 190 bytes memory.
|
||||
|
||||
config ESP_WIFI_ENABLE_WIFI_RX_MU_STATS
|
||||
bool "Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics"
|
||||
depends on ESP_WIFI_ENABLE_WIFI_RX_STATS
|
||||
default "y"
|
||||
help
|
||||
Enable Wi-Fi DL MU-MIMO and DL OFDMA reception statistics. Will use 10932 bytes memory.
|
||||
|
||||
menu "WPS Configuration Options"
|
||||
config ESP_WIFI_WPS_STRICT
|
||||
bool "Strictly validate all WPS attributes"
|
||||
default n
|
||||
help
|
||||
Select this option to enable validate each WPS attribute
|
||||
rigorously. Disabling this add the workarounds with various APs.
|
||||
Enabling this may cause inter operability issues with some APs.
|
||||
|
||||
config ESP_WIFI_WPS_PASSPHRASE
|
||||
bool "Get WPA2 passphrase in WPS config"
|
||||
default n
|
||||
help
|
||||
Select this option to get passphrase during WPS configuration.
|
||||
This option fakes the virtual display capabilities to get the
|
||||
configuration in passphrase mode.
|
||||
Not recommended to be used since WPS credentials should not
|
||||
be shared to other devices, making it in readable format increases
|
||||
that risk, also passphrase requires pbkdf2 to convert in psk.
|
||||
|
||||
endmenu # "WPS Configuration Options"
|
||||
|
||||
|
||||
config ESP_WIFI_DEBUG_PRINT
|
||||
bool "Print debug messages from WPA Supplicant"
|
||||
default n
|
||||
help
|
||||
Select this option to print logging information from WPA supplicant,
|
||||
this includes handshake information and key hex dumps depending
|
||||
on the project logging level.
|
||||
|
||||
Enabling this could increase the build size ~60kb
|
||||
depending on the project logging level.
|
||||
|
||||
config ESP_WIFI_TESTING_OPTIONS
|
||||
bool "Add DPP testing code"
|
||||
default n
|
||||
help
|
||||
Select this to enable unity test for DPP.
|
||||
|
||||
config ESP_WIFI_ENTERPRISE_SUPPORT
|
||||
bool "Enable enterprise option"
|
||||
default y
|
||||
help
|
||||
Select this to enable/disable enterprise connection support.
|
||||
|
||||
disabling this will reduce binary size.
|
||||
disabling this will disable the use of any esp_wifi_sta_wpa2_ent_* (as APIs will be meaningless)
|
||||
|
||||
Note that when using bigger certificates on low-power chips without crypto
|
||||
hardware acceleration, it is recommended to adjust the task watchdog timer (TWDT)
|
||||
if it is enabled. For precise information on timing requirements, you can check
|
||||
performance numbers at https://github.com/espressif/mbedtls/wiki/Performance-Numbers.
|
||||
|
||||
config ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER
|
||||
bool "Free dynamic buffers during WiFi enterprise connection"
|
||||
depends on ESP_WIFI_ENTERPRISE_SUPPORT
|
||||
default y if SLAVE_IDF_TARGET_ESP32C2
|
||||
default n if !SLAVE_IDF_TARGET_ESP32C2
|
||||
help
|
||||
Select this configuration to free dynamic buffers during WiFi enterprise connection.
|
||||
This will enable chip to reduce heap consumption during WiFi enterprise connection.
|
||||
|
||||
endmenu # Wi-Fi Remote
|
74
components/esp_wifi_remote/Kconfig.rpc.in
Normal file
74
components/esp_wifi_remote/Kconfig.rpc.in
Normal file
@ -0,0 +1,74 @@
|
||||
choice ESP_WIFI_REMOTE_LIBRARY
|
||||
prompt "Choose WiFi-remote implementation"
|
||||
default ESP_WIFI_REMOTE_LIBRARY_EPPP
|
||||
help
|
||||
Select type of WiFi Remote implementation
|
||||
|
||||
ESP-HOSTED is the default and most versatile option.
|
||||
It's also possible to use EPPP, which uses PPPoS link between micros and NAPT, so it's slower
|
||||
and less universal.
|
||||
|
||||
config ESP_WIFI_REMOTE_LIBRARY_HOSTED
|
||||
bool "ESP-HOSTED"
|
||||
config ESP_WIFI_REMOTE_LIBRARY_EPPP
|
||||
bool "EPPP"
|
||||
endchoice
|
||||
|
||||
if ESP_WIFI_REMOTE_LIBRARY_EPPP
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_UART_TX_PIN
|
||||
int "TXD Pin Number"
|
||||
default 10
|
||||
range 0 31
|
||||
help
|
||||
Pin number of UART TX.
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_UART_RX_PIN
|
||||
int "RXD Pin Number"
|
||||
default 11
|
||||
range 0 31
|
||||
help
|
||||
Pin number of UART RX.
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_NETIF_PRIORITY
|
||||
int "Routing priority of eppp netif"
|
||||
default 100
|
||||
range 0 256
|
||||
help
|
||||
Set the priority of the wifi-remote netif.
|
||||
The bigger the number the higher the priority.
|
||||
The interface which is up and with the highest priority will act as a default GW.
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_NETIF_DESCRIPTION
|
||||
string "eppp network interface description"
|
||||
default "example_netif_sta"
|
||||
help
|
||||
Textual description of the wifi remote network interface.
|
||||
By default it is set to "example_netif_sta" to be used in IDF protocol example
|
||||
as default wifi station substitution.
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_SERVER_CA
|
||||
string "Servers CA certificate"
|
||||
default "--- Please copy content of the CA certificate ---"
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_CLIENT_CRT
|
||||
string "Client certificate"
|
||||
default "--- Please copy content of the Client certificate ---"
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_CLIENT_KEY
|
||||
string "Client key"
|
||||
default "--- Please copy content of the Client key ---"
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_CLIENT_CA
|
||||
string "Clients CA certificate"
|
||||
default "--- Please copy content of the CA certificate ---"
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_SERVER_CRT
|
||||
string "Server certificate"
|
||||
default "--- Please copy content of the Client certificate ---"
|
||||
|
||||
config ESP_WIFI_REMOTE_EPPP_SERVER_KEY
|
||||
string "Server key"
|
||||
default "--- Please copy content of the Client key ---"
|
||||
|
||||
endif
|
237
components/esp_wifi_remote/Kconfig.soc_wifi_caps.in
Normal file
237
components/esp_wifi_remote/Kconfig.soc_wifi_caps.in
Normal file
@ -0,0 +1,237 @@
|
||||
# This file is auto-generated
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_WAPI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_CSI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_MESH_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_NAN_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
endif # ESP32
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32S2
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
|
||||
int
|
||||
default 12
|
||||
|
||||
config SLAVE_SOC_WIFI_HW_TSF
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_FTM_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_WAPI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_CSI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_MESH_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_NAN_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
endif # ESP32S2
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32C3
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
|
||||
int
|
||||
default 12
|
||||
|
||||
config SLAVE_SOC_WIFI_HW_TSF
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_FTM_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_GCMP_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_WAPI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_CSI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_MESH_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND
|
||||
bool
|
||||
default y
|
||||
|
||||
endif # ESP32C3
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32S3
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
|
||||
int
|
||||
default 12
|
||||
|
||||
config SLAVE_SOC_WIFI_HW_TSF
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_FTM_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_GCMP_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_WAPI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_CSI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_MESH_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND
|
||||
bool
|
||||
default y
|
||||
|
||||
endif # ESP32S3
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32C2
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
|
||||
int
|
||||
default 12
|
||||
|
||||
config SLAVE_SOC_WIFI_HW_TSF
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_FTM_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND
|
||||
bool
|
||||
default y
|
||||
|
||||
endif # ESP32C2
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32C6
|
||||
|
||||
config SLAVE_SOC_WIFI_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
|
||||
int
|
||||
default 12
|
||||
|
||||
config SLAVE_SOC_WIFI_HW_TSF
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_FTM_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_GCMP_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_WAPI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_CSI_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_MESH_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SLAVE_SOC_WIFI_HE_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
endif # ESP32C6
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32H2
|
||||
|
||||
endif # ESP32H2
|
||||
|
||||
if SLAVE_IDF_TARGET_ESP32P4
|
||||
|
||||
config SLAVE_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH
|
||||
int
|
||||
default 12
|
||||
|
||||
endif # ESP32P4
|
202
components/esp_wifi_remote/LICENSE
Normal file
202
components/esp_wifi_remote/LICENSE
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
26
components/esp_wifi_remote/README.md
Normal file
26
components/esp_wifi_remote/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
# esp_wifi_remote
|
||||
|
||||
[](https://components.espressif.com/components/espressif/esp_wifi_remote)
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
* 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.
|
22
components/esp_wifi_remote/eppp/eppp_init.c
Normal file
22
components/esp_wifi_remote/eppp/eppp_init.c
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "eppp_link.h"
|
||||
|
||||
__attribute__((weak)) esp_netif_t *wifi_remote_eppp_init(eppp_type_t role)
|
||||
{
|
||||
uint32_t our_ip = role == EPPP_SERVER ? EPPP_DEFAULT_SERVER_IP() : EPPP_DEFAULT_CLIENT_IP();
|
||||
uint32_t their_ip = role == EPPP_SERVER ? EPPP_DEFAULT_CLIENT_IP() : EPPP_DEFAULT_SERVER_IP();
|
||||
eppp_config_t config = EPPP_DEFAULT_CONFIG(our_ip, their_ip);
|
||||
// We currently support only UART transport
|
||||
config.transport = EPPP_TRANSPORT_UART;
|
||||
config.uart.tx_io = CONFIG_ESP_WIFI_REMOTE_EPPP_UART_TX_PIN;
|
||||
config.uart.rx_io = CONFIG_ESP_WIFI_REMOTE_EPPP_UART_RX_PIN;
|
||||
config.ppp.netif_description = CONFIG_ESP_WIFI_REMOTE_EPPP_NETIF_DESCRIPTION;
|
||||
config.ppp.netif_prio = CONFIG_ESP_WIFI_REMOTE_EPPP_NETIF_PRIORITY;
|
||||
return eppp_open(role, &config, portMAX_DELAY);
|
||||
}
|
318
components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp
Normal file
318
components/esp_wifi_remote/eppp/wifi_remote_rpc_client.cpp
Normal file
@ -0,0 +1,318 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <netdb.h>
|
||||
#include <memory>
|
||||
#include <cinttypes>
|
||||
#include "esp_log.h"
|
||||
#include "esp_tls.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_check.h"
|
||||
#include "wifi_remote_rpc_impl.hpp"
|
||||
#include "eppp_link.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "wifi_remote_rpc_params.h"
|
||||
|
||||
extern "C" esp_netif_t *wifi_remote_eppp_init(eppp_type_t role);
|
||||
|
||||
namespace eppp_rpc {
|
||||
|
||||
namespace client {
|
||||
const char *TAG = "rpc_client";
|
||||
|
||||
const unsigned char ca_crt[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CA "\n-----END CERTIFICATE-----";
|
||||
const unsigned char crt[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CRT "\n-----END CERTIFICATE-----";
|
||||
const unsigned char key[] = "-----BEGIN PRIVATE KEY-----\n" CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_KEY "\n-----END PRIVATE KEY-----";
|
||||
// TODO: Add option to supply keys and certs via a global symbol (file)
|
||||
|
||||
}
|
||||
|
||||
using namespace client;
|
||||
|
||||
class Sync {
|
||||
friend class RpcInstance;
|
||||
public:
|
||||
void lock()
|
||||
{
|
||||
xSemaphoreTake(mutex, portMAX_DELAY);
|
||||
}
|
||||
void unlock()
|
||||
{
|
||||
xSemaphoreGive(mutex);
|
||||
}
|
||||
esp_err_t init()
|
||||
{
|
||||
mutex = xSemaphoreCreateMutex();
|
||||
events = xEventGroupCreate();
|
||||
return mutex == nullptr || events == nullptr ? ESP_ERR_NO_MEM : ESP_OK;
|
||||
}
|
||||
esp_err_t wait_for(EventBits_t bits, uint32_t timeout = portMAX_DELAY)
|
||||
{
|
||||
return (xEventGroupWaitBits(events, bits, pdTRUE, pdTRUE, timeout) & bits) == bits ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
esp_err_t notify(EventBits_t bits)
|
||||
{
|
||||
xEventGroupSetBits(events, bits);
|
||||
return ESP_OK;
|
||||
}
|
||||
~Sync()
|
||||
{
|
||||
if (mutex) {
|
||||
vSemaphoreDelete(mutex);
|
||||
}
|
||||
if (events) {
|
||||
vEventGroupDelete(events);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
SemaphoreHandle_t mutex{nullptr};
|
||||
EventGroupHandle_t events{nullptr};
|
||||
|
||||
const int request = 1;
|
||||
const int resp_header = 2;
|
||||
const int resp_payload = 4;
|
||||
const int restart = 8;
|
||||
};
|
||||
|
||||
class RpcInstance {
|
||||
friend class Sync;
|
||||
public:
|
||||
|
||||
template<typename T>
|
||||
esp_err_t send(api_id id, T *t)
|
||||
{
|
||||
pending_resp = id;
|
||||
ESP_RETURN_ON_ERROR(sync.notify(sync.request), TAG, "failed to notify req");
|
||||
ESP_RETURN_ON_ERROR(rpc.send<T>(id, t), TAG, "Failed to send request");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// overload of the templated method (used for functions with no arguments)
|
||||
esp_err_t send(api_id id)
|
||||
{
|
||||
pending_resp = id;
|
||||
ESP_RETURN_ON_ERROR(sync.notify(sync.request), TAG, "failed to notify req");
|
||||
ESP_RETURN_ON_ERROR(rpc.send(id), TAG, "Failed to send request");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T get_resp(api_id id)
|
||||
{
|
||||
sync.wait_for(sync.resp_header);
|
||||
auto ret = rpc.template get_payload<T>(id, pending_header);
|
||||
sync.notify(sync.resp_payload);
|
||||
return ret;
|
||||
}
|
||||
esp_err_t init()
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(netif = wifi_remote_eppp_init(EPPP_CLIENT), ESP_FAIL, TAG, "Failed to connect to EPPP server");
|
||||
ESP_RETURN_ON_ERROR(esp_event_handler_register(IP_EVENT, IP_EVENT_PPP_GOT_IP, got_ip, this), TAG, "Failed to register event");
|
||||
ESP_RETURN_ON_ERROR(sync.init(), TAG, "Failed to init sync primitives");
|
||||
ESP_RETURN_ON_ERROR(rpc.init(), TAG, "Failed to init RPC engine");
|
||||
return xTaskCreate(task, "client", 8192, this, 5, nullptr) == pdTRUE ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
RpcEngine rpc{eppp_rpc::role::CLIENT};
|
||||
Sync sync;
|
||||
private:
|
||||
api_id pending_resp{api_id::UNDEF};
|
||||
RpcHeader pending_header{};
|
||||
esp_err_t process_ip_event(RpcHeader &header)
|
||||
{
|
||||
auto event = rpc.get_payload<esp_wifi_remote_eppp_ip_event>(api_id::IP_EVENT, header);
|
||||
// Now bypass network layers with EPPP interface
|
||||
ESP_RETURN_ON_ERROR(esp_netif_set_dns_info(netif, ESP_NETIF_DNS_MAIN, &event.dns), TAG, "Failed to set DNS info");
|
||||
ESP_RETURN_ON_ERROR(esp_netif_set_default_netif(netif), TAG, "Failed to set default netif to EPPP");
|
||||
ip_event_got_ip_t evt = {
|
||||
.esp_netif = netif,
|
||||
.ip_info = {},
|
||||
.ip_changed = true,
|
||||
};
|
||||
esp_netif_get_ip_info(netif, &evt.ip_info);
|
||||
ESP_RETURN_ON_ERROR(esp_event_post(IP_EVENT, IP_EVENT_STA_GOT_IP, &evt, sizeof(evt), 0), TAG, "Failed to post IP event");
|
||||
ESP_LOGI(TAG, "Main DNS:" IPSTR, IP2STR(&event.dns.ip.u_addr.ip4));
|
||||
ESP_LOGI(TAG, "EPPP IP:" IPSTR, IP2STR(&event.ppp_ip.ip));
|
||||
ESP_LOGI(TAG, "WIFI IP:" IPSTR, IP2STR(&event.wifi_ip.ip));
|
||||
ESP_LOGI(TAG, "WIFI GW:" IPSTR, IP2STR(&event.wifi_ip.gw));
|
||||
ESP_LOGI(TAG, "WIFI mask:" IPSTR, IP2STR(&event.wifi_ip.netmask));
|
||||
return ESP_OK;
|
||||
}
|
||||
esp_err_t process_wifi_event(RpcHeader &header)
|
||||
{
|
||||
auto event_id = rpc.get_payload<int32_t>(api_id::WIFI_EVENT, header);
|
||||
ESP_RETURN_ON_ERROR(esp_event_post(WIFI_EVENT, event_id, nullptr, 0, 0), TAG, "Failed to post WiFi event");
|
||||
return ESP_OK;
|
||||
}
|
||||
esp_err_t perform()
|
||||
{
|
||||
auto header = rpc.get_header();
|
||||
if (api_id(header.id) == api_id::ERROR) { // network error
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (api_id(header.id) == api_id::UNDEF) { // network timeout
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if (api_id(header.id) == api_id::IP_EVENT) {
|
||||
return process_ip_event(header);
|
||||
}
|
||||
if (api_id(header.id) == api_id::WIFI_EVENT) {
|
||||
return process_wifi_event(header);
|
||||
}
|
||||
if (sync.wait_for(sync.request, 0) == ESP_OK && api_id(header.id) == pending_resp) {
|
||||
pending_header = header;
|
||||
pending_resp = api_id::UNDEF;
|
||||
sync.notify(sync.resp_header);
|
||||
sync.wait_for(sync.resp_payload);
|
||||
return ESP_OK;
|
||||
}
|
||||
ESP_LOGE(TAG, "Unexpected header %" PRIi32, static_cast<uint32_t>(header.id));
|
||||
return ESP_FAIL;
|
||||
|
||||
}
|
||||
static void task(void *ctx)
|
||||
{
|
||||
auto instance = static_cast<RpcInstance *>(ctx);
|
||||
do {
|
||||
while (instance->perform() == ESP_OK) {}
|
||||
} while (instance->restart() == ESP_OK);
|
||||
vTaskDelete(nullptr);
|
||||
}
|
||||
esp_err_t restart()
|
||||
{
|
||||
rpc.deinit();
|
||||
ESP_RETURN_ON_ERROR(sync.wait_for(sync.restart, pdMS_TO_TICKS(10000)), TAG, "Didn't receive EPPP address in time");
|
||||
return rpc.init();
|
||||
}
|
||||
static void got_ip(void *ctx, esp_event_base_t base, int32_t id, void *data)
|
||||
{
|
||||
auto instance = static_cast<RpcInstance *>(ctx);
|
||||
instance->sync.notify(instance->sync.restart);
|
||||
}
|
||||
esp_netif_t *netif{nullptr};
|
||||
};
|
||||
|
||||
|
||||
namespace client {
|
||||
constinit RpcInstance instance;
|
||||
} // namespace client
|
||||
|
||||
RpcInstance *RpcEngine::init_client()
|
||||
{
|
||||
char host[4 * 4 + 1] = {}; // IPv4: 4 x (3 numbers + '.') + \0
|
||||
esp_ip4_addr_t ip = { .addr = EPPP_DEFAULT_SERVER_IP() };
|
||||
if (esp_ip4addr_ntoa(&ip, host, sizeof(host)) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
esp_tls_cfg_t cfg = {};
|
||||
cfg.cacert_buf = client::ca_crt;
|
||||
cfg.cacert_bytes = sizeof(client::ca_crt);
|
||||
cfg.clientcert_buf = client::crt;
|
||||
cfg.clientcert_bytes = sizeof(client::crt);
|
||||
cfg.clientkey_buf = client::key;
|
||||
cfg.clientkey_bytes = sizeof(client::key);
|
||||
cfg.common_name = "espressif.local";
|
||||
|
||||
ESP_RETURN_ON_FALSE(tls_ = esp_tls_init(), nullptr, TAG, "Failed to create ESP-TLS instance");
|
||||
int retries = 0;
|
||||
while (esp_tls_conn_new_sync(host, strlen(host), rpc_port, &cfg, tls_) <= 0) {
|
||||
esp_tls_conn_destroy(tls_);
|
||||
tls_ = nullptr;
|
||||
ESP_RETURN_ON_FALSE(retries++ < 3, nullptr, TAG, "Failed to open connection to %s", host);
|
||||
ESP_LOGW(TAG, "Connection to RPC server failed! Will retry in %d second(s)", retries);
|
||||
vTaskDelay(pdMS_TO_TICKS(1000 * retries));
|
||||
ESP_RETURN_ON_FALSE(tls_ = esp_tls_init(), nullptr, TAG, "Failed to create ESP-TLS instance");
|
||||
}
|
||||
return &client::instance;
|
||||
}
|
||||
} // namespace eppp_rpc
|
||||
|
||||
//
|
||||
// esp_wifi_remote API implementation
|
||||
//
|
||||
using namespace eppp_rpc;
|
||||
using namespace client;
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config)
|
||||
{
|
||||
// Here we initialize this client's RPC
|
||||
ESP_RETURN_ON_ERROR(instance.init(), TAG, "Failed to initialize eppp-rpc");
|
||||
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::INIT, config), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::INIT);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf)
|
||||
{
|
||||
esp_wifi_remote_config params = { .interface = interface, .conf = {} };
|
||||
memcpy(¶ms.conf, conf, sizeof(wifi_config_t));
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::SET_CONFIG, ¶ms), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::SET_CONFIG);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_start(void)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::START), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::START);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_stop(void)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::STOP), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::STOP);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_connect(void)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::CONNECT), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::CONNECT);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6])
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::GET_MAC, &ifx), TAG, "Failed to send request");
|
||||
auto ret = instance.get_resp<esp_wifi_remote_mac_t>(api_id::GET_MAC);
|
||||
ESP_LOG_BUFFER_HEXDUMP("MAC", ret.mac, 6, ESP_LOG_DEBUG);
|
||||
memcpy(mac, ret.mac, 6);
|
||||
return ret.err;
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::SET_MODE, &mode), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::SET_MODE);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_deinit(void)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::DEINIT), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::DEINIT);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_disconnect(void)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::DISCONNECT), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::DISCONNECT);
|
||||
}
|
||||
|
||||
extern "C" esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage)
|
||||
{
|
||||
std::lock_guard<Sync> lock(instance.sync);
|
||||
ESP_RETURN_ON_ERROR(instance.send(api_id::SET_STORAGE, &storage), TAG, "Failed to send request");
|
||||
return instance.get_resp<esp_err_t>(api_id::SET_STORAGE);
|
||||
}
|
179
components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp
Normal file
179
components/esp_wifi_remote/eppp/wifi_remote_rpc_impl.hpp
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
|
||||
namespace eppp_rpc {
|
||||
|
||||
static constexpr int rpc_port = 3333;
|
||||
|
||||
/**
|
||||
* @brief Currently supported RPC commands/events
|
||||
*/
|
||||
enum class api_id : uint32_t {
|
||||
ERROR,
|
||||
UNDEF,
|
||||
INIT,
|
||||
DEINIT,
|
||||
SET_MODE,
|
||||
SET_CONFIG,
|
||||
START,
|
||||
STOP,
|
||||
CONNECT,
|
||||
DISCONNECT,
|
||||
GET_MAC,
|
||||
SET_STORAGE,
|
||||
WIFI_EVENT,
|
||||
IP_EVENT,
|
||||
};
|
||||
|
||||
enum class role {
|
||||
SERVER,
|
||||
CLIENT,
|
||||
};
|
||||
|
||||
struct RpcHeader {
|
||||
api_id id;
|
||||
uint32_t size;
|
||||
} __attribute((__packed__));
|
||||
|
||||
/**
|
||||
* @brief Structure holding the outgoing or incoming parameter
|
||||
*/
|
||||
template<typename T>
|
||||
struct RpcData {
|
||||
RpcHeader head;
|
||||
T value_{};
|
||||
explicit RpcData(api_id id) : head{id, sizeof(T)} {}
|
||||
|
||||
uint8_t *value()
|
||||
{
|
||||
return (uint8_t *) &value_;
|
||||
}
|
||||
|
||||
uint8_t *marshall(T *t, size_t &size)
|
||||
{
|
||||
size = head.size + sizeof(RpcHeader);
|
||||
memcpy(value(), t, sizeof(T));
|
||||
return (uint8_t *) this;
|
||||
}
|
||||
} __attribute((__packed__));
|
||||
|
||||
/**
|
||||
* @brief Singleton holding the static data for either the client or server side
|
||||
*/
|
||||
class RpcInstance;
|
||||
|
||||
/**
|
||||
* @brief Engine that implements a simple RPC mechanism
|
||||
*/
|
||||
class RpcEngine {
|
||||
public:
|
||||
constexpr explicit RpcEngine(role r) : tls_(nullptr), role_(r) {}
|
||||
|
||||
esp_err_t init()
|
||||
{
|
||||
if (tls_ != nullptr) {
|
||||
return ESP_OK;
|
||||
}
|
||||
if (role_ == role::CLIENT) {
|
||||
instance = init_client();
|
||||
}
|
||||
if (role_ == role::SERVER) {
|
||||
instance = init_server();
|
||||
}
|
||||
return instance == nullptr ? ESP_FAIL : ESP_OK;
|
||||
}
|
||||
|
||||
void deinit()
|
||||
{
|
||||
if (tls_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (role_ == role::CLIENT) {
|
||||
esp_tls_conn_destroy(tls_);
|
||||
} else if (role_ == role::SERVER) {
|
||||
esp_tls_server_session_delete(tls_);
|
||||
}
|
||||
tls_ = nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
esp_err_t send(api_id id, T *t)
|
||||
{
|
||||
RpcData<T> req(id);
|
||||
size_t size;
|
||||
auto buf = req.marshall(t, size);
|
||||
ESP_LOGD("rpc", "Sending API id:%d", (int) id);
|
||||
ESP_LOG_BUFFER_HEXDUMP("rpc", buf, size, ESP_LOG_VERBOSE);
|
||||
int len = esp_tls_conn_write(tls_, buf, size);
|
||||
if (len <= 0) {
|
||||
ESP_LOGE("rpc", "Failed to write data to the connection");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t send(api_id id) // overload for (void)
|
||||
{
|
||||
RpcHeader head = {.id = id, .size = 0};
|
||||
int len = esp_tls_conn_write(tls_, &head, sizeof(head));
|
||||
if (len <= 0) {
|
||||
ESP_LOGE("rpc", "Failed to write data to the connection");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int get_socket_fd()
|
||||
{
|
||||
int sock;
|
||||
if (esp_tls_get_conn_sockfd(tls_, &sock) != ESP_OK) {
|
||||
return -1;
|
||||
}
|
||||
return sock;
|
||||
}
|
||||
|
||||
RpcHeader get_header()
|
||||
{
|
||||
RpcHeader header{};
|
||||
int len = esp_tls_conn_read(tls_, (char *) &header, sizeof(header));
|
||||
if (len <= 0) {
|
||||
if (len < 0 && errno != EAGAIN) {
|
||||
ESP_LOGE("rpc", "Failed to read header data from the connection %d %s", errno, strerror(errno));
|
||||
return {.id = api_id::ERROR, .size = 0};
|
||||
}
|
||||
return {.id = api_id::UNDEF, .size = 0};
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T get_payload(api_id id, RpcHeader &head)
|
||||
{
|
||||
RpcData<T> resp(id);
|
||||
if (head.id != id || head.size != resp.head.size) {
|
||||
ESP_LOGE("rpc", "unexpected header %d %d or sizes %" PRIu32 " %" PRIu32, (int)head.id, (int)id, head.size, resp.head.size);
|
||||
return {};
|
||||
}
|
||||
int len = esp_tls_conn_read(tls_, (char *) resp.value(), resp.head.size);
|
||||
if (len <= 0) {
|
||||
ESP_LOGE("rpc", "Failed to read data from the connection");
|
||||
return {};
|
||||
}
|
||||
return resp.value_;
|
||||
}
|
||||
|
||||
private:
|
||||
RpcInstance *init_server();
|
||||
RpcInstance *init_client();
|
||||
esp_tls_t *tls_;
|
||||
role role_;
|
||||
RpcInstance *instance{nullptr};
|
||||
};
|
||||
|
||||
};
|
23
components/esp_wifi_remote/eppp/wifi_remote_rpc_params.h
Normal file
23
components/esp_wifi_remote/eppp/wifi_remote_rpc_params.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
struct esp_wifi_remote_config {
|
||||
wifi_interface_t interface;
|
||||
wifi_config_t conf;
|
||||
};
|
||||
|
||||
struct esp_wifi_remote_mac_t {
|
||||
esp_err_t err;
|
||||
uint8_t mac[6];
|
||||
};
|
||||
|
||||
struct esp_wifi_remote_eppp_ip_event {
|
||||
int32_t id;
|
||||
esp_netif_ip_info_t wifi_ip;
|
||||
esp_netif_ip_info_t ppp_ip;
|
||||
esp_netif_dns_info_t dns;
|
||||
};
|
383
components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp
Normal file
383
components/esp_wifi_remote/eppp/wifi_remote_rpc_server.cpp
Normal file
@ -0,0 +1,383 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <netdb.h>
|
||||
#include <memory>
|
||||
#include <cerrno>
|
||||
#include <sys/socket.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_tls.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "wifi_remote_rpc_impl.hpp"
|
||||
#include "eppp_link.h"
|
||||
#include "wifi_remote_rpc_params.h"
|
||||
#include "lwip/apps/snmp.h"
|
||||
#include "esp_vfs.h"
|
||||
#include "esp_vfs_eventfd.h"
|
||||
|
||||
extern "C" esp_netif_t *wifi_remote_eppp_init(eppp_type_t role);
|
||||
|
||||
namespace eppp_rpc {
|
||||
|
||||
namespace server {
|
||||
const char *TAG = "rpc_server";
|
||||
|
||||
const unsigned char ca_crt[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CA "\n-----END CERTIFICATE-----";
|
||||
const unsigned char crt[] = "-----BEGIN CERTIFICATE-----\n" CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CRT "\n-----END CERTIFICATE-----";
|
||||
const unsigned char key[] = "-----BEGIN PRIVATE KEY-----\n" CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_KEY "\n-----END PRIVATE KEY-----";
|
||||
// TODO: Add option to supply keys and certs via a global symbol (file)
|
||||
|
||||
}
|
||||
|
||||
using namespace server;
|
||||
|
||||
struct Events {
|
||||
api_id type;
|
||||
int32_t id;
|
||||
esp_wifi_remote_eppp_ip_event *ip_data{nullptr};
|
||||
bool clean_ip_data{true};
|
||||
esp_err_t create_ip_data()
|
||||
{
|
||||
ip_data = new (std::nothrow) esp_wifi_remote_eppp_ip_event;
|
||||
return ip_data ? ESP_OK : ESP_ERR_NO_MEM;
|
||||
}
|
||||
~Events()
|
||||
{
|
||||
if (clean_ip_data) {
|
||||
delete ip_data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Sync {
|
||||
friend class RpcInstance;
|
||||
public:
|
||||
esp_err_t put(Events &ev)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(xQueueSend(queue, &ev, pdMS_TO_TICKS(queue_timeout)), ESP_FAIL, TAG, "Failed to queue event %" PRIi32, ev.id);
|
||||
ev.clean_ip_data = false; // IP data were successfully sent to the queue, will free manually after receiving from it
|
||||
uint64_t event_queued = 1;
|
||||
write(fd, &event_queued, sizeof(event_queued)); // trigger the wait loop that
|
||||
return ESP_OK;
|
||||
}
|
||||
Events get()
|
||||
{
|
||||
Events ev{};
|
||||
if (!xQueueReceive(queue, &ev, 0)) {
|
||||
ev.type = api_id::ERROR;
|
||||
}
|
||||
return ev;
|
||||
}
|
||||
esp_err_t init()
|
||||
{
|
||||
queue = xQueueCreate(max_items, sizeof(Events));
|
||||
esp_vfs_eventfd_config_t config = ESP_VFS_EVENTD_CONFIG_DEFAULT();
|
||||
esp_vfs_eventfd_register(&config);
|
||||
fd = eventfd(0, EFD_SUPPORT_ISR);
|
||||
return queue == nullptr || fd < 0 ? ESP_ERR_NO_MEM : ESP_OK;
|
||||
}
|
||||
~Sync()
|
||||
{
|
||||
if (queue) {
|
||||
vQueueDelete(queue);
|
||||
}
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
int fd{-1};
|
||||
// Used to trigger task by either an internal event or rpc command
|
||||
static const int NONE = 0;
|
||||
static const int ERROR = 1;
|
||||
static const int EVENT = 2;
|
||||
static const int RPC = 4;
|
||||
private:
|
||||
QueueHandle_t queue{nullptr};
|
||||
const int max_items = 15;
|
||||
const int queue_timeout = 200;
|
||||
};
|
||||
|
||||
class RpcInstance {
|
||||
friend class Sync;
|
||||
public:
|
||||
RpcEngine rpc{role::SERVER};
|
||||
int sock{-1};
|
||||
|
||||
esp_err_t init()
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(netif = wifi_remote_eppp_init(EPPP_SERVER), ESP_FAIL, TAG, "Failed to init EPPP connection");
|
||||
ESP_RETURN_ON_ERROR(start_server(), TAG, "Failed to start RPC server");
|
||||
ESP_RETURN_ON_ERROR(rpc.init(), TAG, "Failed to init RPC engine");
|
||||
ESP_RETURN_ON_ERROR(esp_netif_napt_enable(netif), TAG, "Failed to enable NAPT");
|
||||
ESP_RETURN_ON_ERROR(sync.init(), TAG, "Failed to init event queue");
|
||||
ESP_RETURN_ON_ERROR(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, handler, this), TAG, "Failed to register event");
|
||||
ESP_RETURN_ON_ERROR(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, handler, this), TAG, "Failed to register event");
|
||||
return xTaskCreate(task, "server", 8192, this, 5, nullptr) == pdTRUE ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
Sync sync;
|
||||
private:
|
||||
esp_netif_t *netif{nullptr};
|
||||
static void task(void *ctx)
|
||||
{
|
||||
auto instance = static_cast<RpcInstance *>(ctx);
|
||||
while (instance->perform() == ESP_OK) {}
|
||||
esp_restart();
|
||||
}
|
||||
esp_err_t start_server()
|
||||
{
|
||||
struct sockaddr_in dest_addr = {};
|
||||
int ret;
|
||||
int opt = 1;
|
||||
dest_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
dest_addr.sin_family = AF_INET;
|
||||
dest_addr.sin_port = htons(rpc_port);
|
||||
int listen_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||
ESP_RETURN_ON_FALSE(listen_sock >= 0, ESP_FAIL, TAG, "Failed to create listening socket");
|
||||
setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
|
||||
ret = bind(listen_sock, (struct sockaddr *) &dest_addr, sizeof(dest_addr));
|
||||
ESP_RETURN_ON_FALSE(ret == 0, ESP_FAIL, TAG, "Failed to bind the listening socket");
|
||||
ret = listen(listen_sock, 1);
|
||||
ESP_RETURN_ON_FALSE(ret == 0, ESP_FAIL, TAG, "Failed to start listening");
|
||||
struct sockaddr_storage source_addr {};
|
||||
socklen_t addr_len = sizeof(source_addr);
|
||||
sock = accept(listen_sock, (struct sockaddr *) &source_addr, &addr_len);
|
||||
ESP_RETURN_ON_FALSE(sock >= 0, ESP_FAIL, TAG, "Failed to accept connections: errno %d", errno);
|
||||
ESP_LOGI(TAG, "Socket accepted on: %s", inet_ntoa(((struct sockaddr_in *) &source_addr)->sin_addr));
|
||||
return ESP_OK;
|
||||
}
|
||||
esp_err_t wifi_event(int32_t id)
|
||||
{
|
||||
ESP_LOGI(TAG, "Received WIFI event %" PRIi32, id);
|
||||
Events ev{api_id::WIFI_EVENT, id, nullptr};
|
||||
ESP_RETURN_ON_ERROR(sync.put(ev), TAG, "Failed to queue WiFi event");
|
||||
return ESP_OK;
|
||||
}
|
||||
esp_err_t ip_event(int32_t id, ip_event_got_ip_t *ip_data)
|
||||
{
|
||||
ESP_LOGI(TAG, "Received IP event %" PRIi32, id);
|
||||
Events ev{api_id::IP_EVENT, id, nullptr};
|
||||
if (ip_data->esp_netif) {
|
||||
ESP_RETURN_ON_ERROR(ev.create_ip_data(), TAG, "Failed to allocate event data");
|
||||
ev.ip_data->id = id;
|
||||
ESP_RETURN_ON_ERROR(esp_netif_get_dns_info(ip_data->esp_netif, ESP_NETIF_DNS_MAIN, &ev.ip_data->dns), TAG, "Failed to get DNS info");
|
||||
ESP_LOGI(TAG, "Main DNS:" IPSTR, IP2STR(&ev.ip_data->dns.ip.u_addr.ip4));
|
||||
memcpy(&ev.ip_data->wifi_ip, &ip_data->ip_info, sizeof(ev.ip_data->wifi_ip));
|
||||
ESP_RETURN_ON_ERROR(esp_netif_get_ip_info(netif, &ev.ip_data->ppp_ip), TAG, "Failed to get IP info");
|
||||
ESP_LOGI(TAG, "IP address:" IPSTR, IP2STR(&ip_data->ip_info.ip));
|
||||
}
|
||||
ESP_RETURN_ON_ERROR(sync.put(ev), TAG, "Failed to queue IP event");
|
||||
return ESP_OK;
|
||||
}
|
||||
static void handler(void *ctx, esp_event_base_t base, int32_t id, void *data)
|
||||
{
|
||||
auto instance = static_cast<RpcInstance *>(ctx);
|
||||
if (base == WIFI_EVENT) {
|
||||
instance->wifi_event(id);
|
||||
} else if (base == IP_EVENT) {
|
||||
auto *ip_data = (ip_event_got_ip_t *)data;
|
||||
instance->ip_event(id, ip_data);
|
||||
}
|
||||
}
|
||||
int select()
|
||||
{
|
||||
struct timeval timeout = { .tv_sec = 1, .tv_usec = 0};
|
||||
int rpc_sock = rpc.get_socket_fd();
|
||||
|
||||
ESP_RETURN_ON_FALSE(rpc_sock != -1, Sync::ERROR, TAG, "failed ot get rpc socket");
|
||||
fd_set readset;
|
||||
fd_set errset;
|
||||
FD_ZERO(&readset);
|
||||
FD_ZERO(&errset);
|
||||
FD_SET(rpc_sock, &readset);
|
||||
FD_SET(sync.fd, &readset);
|
||||
FD_SET(rpc_sock, &errset);
|
||||
int ret = ::select(std::max(rpc_sock, 5) + 1, &readset, nullptr, &errset, &timeout);
|
||||
if (ret == 0) {
|
||||
ESP_LOGV(TAG, "poll_read: select - Timeout before any socket was ready!");
|
||||
return Sync::NONE;
|
||||
}
|
||||
if (ret < 0) {
|
||||
ESP_LOGE(TAG, "select error: %d", errno);
|
||||
return Sync::ERROR;
|
||||
}
|
||||
if (FD_ISSET(rpc_sock, &errset)) {
|
||||
int sock_errno = 0;
|
||||
uint32_t optlen = sizeof(sock_errno);
|
||||
getsockopt(rpc_sock, SOL_SOCKET, SO_ERROR, &sock_errno, &optlen);
|
||||
ESP_LOGE(TAG, "select failed, socket errno = %d", sock_errno);
|
||||
return Sync::ERROR;
|
||||
}
|
||||
int result = Sync::NONE;
|
||||
if (FD_ISSET(rpc_sock, &readset)) {
|
||||
result |= Sync::RPC;
|
||||
}
|
||||
if (FD_ISSET(sync.fd, &readset)) {
|
||||
result |= Sync::EVENT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
esp_err_t marshall_events()
|
||||
{
|
||||
api_id type;
|
||||
do {
|
||||
Events ev = sync.get();
|
||||
type = ev.type;
|
||||
if (ev.type == api_id::WIFI_EVENT) {
|
||||
ESP_RETURN_ON_ERROR(rpc.send(api_id::WIFI_EVENT, &ev.id), TAG, "Failed to marshall WiFi event");
|
||||
} else if (ev.type == api_id::IP_EVENT && ev.ip_data) {
|
||||
ESP_RETURN_ON_ERROR(rpc.send(api_id::IP_EVENT, ev.ip_data), TAG, "Failed to marshal IP event");
|
||||
}
|
||||
} while (type != api_id::ERROR);
|
||||
return ESP_OK;
|
||||
}
|
||||
esp_err_t perform()
|
||||
{
|
||||
auto res = select();
|
||||
if (res == Sync::ERROR) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (res & Sync::EVENT) {
|
||||
uint64_t data;
|
||||
read(sync.fd, &data, sizeof(data));
|
||||
if (marshall_events() != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
if (res & Sync::RPC) {
|
||||
if (handle_commands() != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t handle_commands()
|
||||
{
|
||||
auto header = rpc.get_header();
|
||||
ESP_LOGI(TAG, "Received header id %d", (int) header.id);
|
||||
switch (header.id) {
|
||||
case api_id::SET_MODE: {
|
||||
auto req = rpc.get_payload<wifi_mode_t>(api_id::SET_MODE, header);
|
||||
auto ret = esp_wifi_set_mode(req);
|
||||
if (rpc.send(api_id::SET_MODE, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::INIT: {
|
||||
auto req = rpc.get_payload<wifi_init_config_t>(api_id::INIT, header);
|
||||
req.osi_funcs = &g_wifi_osi_funcs;
|
||||
req.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs;
|
||||
auto ret = esp_wifi_init(&req);
|
||||
if (rpc.send(api_id::INIT, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::SET_CONFIG: {
|
||||
auto req = rpc.get_payload<esp_wifi_remote_config>(api_id::SET_CONFIG, header);
|
||||
auto ret = esp_wifi_set_config(req.interface, &req.conf);
|
||||
if (rpc.send(api_id::SET_CONFIG, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::START: {
|
||||
if (header.size != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
auto ret = esp_wifi_start();
|
||||
if (rpc.send(api_id::START, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::CONNECT: {
|
||||
if (header.size != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
auto ret = esp_wifi_connect();
|
||||
if (rpc.send(api_id::CONNECT, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::DISCONNECT: {
|
||||
if (header.size != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
auto ret = esp_wifi_disconnect();
|
||||
if (rpc.send(api_id::DISCONNECT, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::DEINIT: {
|
||||
if (header.size != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
auto ret = esp_wifi_deinit();
|
||||
if (rpc.send(api_id::DEINIT, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::SET_STORAGE: {
|
||||
auto req = rpc.get_payload<wifi_storage_t>(api_id::SET_STORAGE, header);
|
||||
auto ret = esp_wifi_set_storage(req);
|
||||
if (rpc.send(api_id::SET_STORAGE, &ret) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case api_id::GET_MAC: {
|
||||
auto req = rpc.get_payload<wifi_interface_t>(api_id::GET_MAC, header);
|
||||
esp_wifi_remote_mac_t resp = {};
|
||||
resp.err = esp_wifi_get_mac(req, resp.mac);
|
||||
if (rpc.send(api_id::GET_MAC, &resp) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace server {
|
||||
constinit RpcInstance instance;
|
||||
}
|
||||
|
||||
RpcInstance *RpcEngine::init_server()
|
||||
{
|
||||
esp_tls_cfg_server_t cfg = {};
|
||||
cfg.cacert_buf = server::ca_crt;
|
||||
cfg.cacert_bytes = sizeof(server::ca_crt);
|
||||
cfg.servercert_buf = server::crt;
|
||||
cfg.servercert_bytes = sizeof(server::crt);
|
||||
cfg.serverkey_buf = server::key;
|
||||
cfg.serverkey_bytes = sizeof(server::key);
|
||||
|
||||
ESP_RETURN_ON_FALSE(tls_ = esp_tls_init(), nullptr, TAG, "Failed to create ESP-TLS instance");
|
||||
ESP_RETURN_ON_FALSE(esp_tls_server_session_create(&cfg, server::instance.sock, tls_) == ESP_OK, nullptr, TAG, "Failed to create TLS session");
|
||||
return &server::instance;
|
||||
}
|
||||
|
||||
} // namespace eppp_rpc
|
||||
|
||||
using namespace eppp_rpc;
|
||||
|
||||
extern "C" esp_err_t server_init(void)
|
||||
{
|
||||
return server::instance.init();
|
||||
}
|
34
components/esp_wifi_remote/esp_wifi_remote.c
Normal file
34
components/esp_wifi_remote/esp_wifi_remote.c
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi_remote.h"
|
||||
|
||||
#define WEAK __attribute__((weak))
|
||||
|
||||
WEAK ESP_EVENT_DEFINE_BASE(WIFI_EVENT);
|
||||
|
||||
#if !CONFIG_SOC_WIFI_SUPPORTED
|
||||
struct wifi_osi_funcs_t { };
|
||||
#endif
|
||||
|
||||
WEAK wifi_osi_funcs_t g_wifi_osi_funcs;
|
||||
WEAK const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
|
||||
WEAK uint64_t g_wifi_feature_caps =
|
||||
#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE
|
||||
CONFIG_FEATURE_WPA3_SAE_BIT |
|
||||
#endif
|
||||
#if CONFIG_SPIRAM
|
||||
CONFIG_FEATURE_CACHE_TX_BUF_BIT |
|
||||
#endif
|
||||
#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT
|
||||
CONFIG_FEATURE_FTM_INITIATOR_BIT |
|
||||
#endif
|
||||
#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT
|
||||
CONFIG_FEATURE_FTM_RESPONDER_BIT |
|
||||
#endif
|
||||
0;
|
89
components/esp_wifi_remote/esp_wifi_remote_net.c
Normal file
89
components/esp_wifi_remote/esp_wifi_remote_net.c
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <esp_private/wifi.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_remote.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#define CHANNELS 2
|
||||
#define WEAK __attribute__((weak))
|
||||
|
||||
static esp_remote_channel_tx_fn_t s_tx_cb[CHANNELS];
|
||||
static esp_remote_channel_t s_channel[CHANNELS];
|
||||
static wifi_rxcb_t s_rx_fn[CHANNELS];
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_channel_rx(void *h, void *buffer, void *buff_to_free, size_t len)
|
||||
{
|
||||
assert(h);
|
||||
if (h == s_channel[0] && s_rx_fn[0]) {
|
||||
return s_rx_fn[0](buffer, len, buff_to_free);
|
||||
}
|
||||
if (h == s_channel[1] && s_rx_fn[1]) {
|
||||
return s_rx_fn[1](buffer, len, buff_to_free);
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_channel_set(wifi_interface_t ifx, void *h, esp_remote_channel_tx_fn_t tx_cb)
|
||||
{
|
||||
if (ifx == WIFI_IF_STA) {
|
||||
s_channel[0] = h;
|
||||
s_tx_cb[0] = tx_cb;
|
||||
return ESP_OK;
|
||||
}
|
||||
if (ifx == WIFI_IF_AP) {
|
||||
s_channel[1] = h;
|
||||
s_tx_cb[1] = tx_cb;
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_internal_set_sta_ip(void)
|
||||
{
|
||||
// TODO: Pass this information to the slave target
|
||||
// Note that this function is called from the default event loop, so we shouldn't block here
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_internal_reg_netstack_buf_cb(wifi_netstack_buf_ref_cb_t ref, wifi_netstack_buf_free_cb_t free)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
WEAK void esp_wifi_internal_free_rx_buffer(void *buffer)
|
||||
{
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
WEAK int esp_wifi_internal_tx(wifi_interface_t ifx, void *buffer, uint16_t len)
|
||||
{
|
||||
if (ifx == WIFI_IF_STA && s_tx_cb[0]) {
|
||||
|
||||
/* TODO: If not needed, remove arg3 */
|
||||
return s_tx_cb[0](s_channel[0], buffer, len);
|
||||
}
|
||||
if (ifx == WIFI_IF_AP && s_tx_cb[1]) {
|
||||
return s_tx_cb[1](s_channel[1], buffer, len);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_internal_reg_rxcb(wifi_interface_t ifx, wifi_rxcb_t fn)
|
||||
{
|
||||
if (ifx == WIFI_IF_STA) {
|
||||
ESP_LOGI("esp_wifi_remote", "%s: sta: %p", __func__, fn);
|
||||
s_rx_fn[0] = fn;
|
||||
return ESP_OK;
|
||||
}
|
||||
if (ifx == WIFI_IF_AP) {
|
||||
s_rx_fn[1] = fn;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
return ESP_FAIL;
|
||||
}
|
377
components/esp_wifi_remote/esp_wifi_remote_weak.c
Normal file
377
components/esp_wifi_remote/esp_wifi_remote_weak.c
Normal file
@ -0,0 +1,377 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
// This file is auto-generated
|
||||
#include "esp_wifi_remote.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#define WEAK __attribute__((weak))
|
||||
#define LOG_UNSUPPORTED_AND_RETURN(ret) ESP_LOGW("esp_wifi_remote_weak", "%s unsupported", __func__); \
|
||||
return ret;
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_init(const wifi_init_config_t *config)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_deinit(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_mode(wifi_mode_t mode)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_mode(wifi_mode_t *mode)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_start(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_stop(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_restore(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_connect(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_disconnect(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_clear_fast_connect(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_deauth_sta(uint16_t aid)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_scan_start(const wifi_scan_config_t *config, _Bool block)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_scan_stop(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_scan_get_ap_num(uint16_t *number)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_scan_get_ap_record(wifi_ap_record_t *ap_record)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_clear_ap_list(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_sta_get_ap_info(wifi_ap_record_t *ap_info)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_ps(wifi_ps_type_t type)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_ps(wifi_ps_type_t *type)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_channel(uint8_t primary, wifi_second_chan_t second)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_channel(uint8_t *primary, wifi_second_chan_t *second)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_country(const wifi_country_t *country)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_country(wifi_country_t *country)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_mac(wifi_interface_t ifx, const uint8_t mac[6])
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_mac(wifi_interface_t ifx, uint8_t mac[6])
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_promiscuous(_Bool en)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_promiscuous(_Bool *en)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_promiscuous_filter(wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_config(wifi_interface_t interface, wifi_config_t *conf)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_config(wifi_interface_t interface, wifi_config_t *conf)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_ap_get_sta_list(wifi_sta_list_t *sta)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_storage(wifi_storage_t storage)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_max_tx_power(int8_t power)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_max_tx_power(int8_t *power)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_event_mask(uint32_t mask)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_event_mask(uint32_t *mask)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_csi_config(const wifi_csi_config_t *config)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_csi(_Bool en)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK int64_t esp_wifi_remote_get_tsf_time(wifi_interface_t interface)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(-1);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_inactive_time(wifi_interface_t ifx, uint16_t sec)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_inactive_time(wifi_interface_t ifx, uint16_t *sec)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_statis_dump(uint32_t modules)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_rssi_threshold(int32_t rssi)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_ftm_end_session(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_ftm_resp_set_offset(int16_t offset_cm)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_config_11b_rate(wifi_interface_t ifx, _Bool disable)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_connectionless_module_set_wake_interval(uint16_t wake_interval)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_force_wakeup_acquire(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_force_wakeup_release(void)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_country_code(const char *country, _Bool ieee80211d_enabled)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_get_country_code(char *country)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_disable_pmf_config(wifi_interface_t ifx)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_sta_get_aid(uint16_t *aid)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_set_dynamic_cs(_Bool enabled)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
WEAK esp_err_t esp_wifi_remote_sta_get_rssi(int *rssi)
|
||||
{
|
||||
LOG_UNSUPPORTED_AND_RETURN(ESP_ERR_NOT_SUPPORTED);
|
||||
}
|
373
components/esp_wifi_remote/esp_wifi_with_remote.c
Normal file
373
components/esp_wifi_remote/esp_wifi_with_remote.c
Normal file
@ -0,0 +1,373 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
// This file is auto-generated
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_wifi_remote.h"
|
||||
|
||||
esp_err_t esp_wifi_init(const wifi_init_config_t *config)
|
||||
{
|
||||
return esp_wifi_remote_init(config);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_deinit(void)
|
||||
{
|
||||
return esp_wifi_remote_deinit();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_mode(wifi_mode_t mode)
|
||||
{
|
||||
return esp_wifi_remote_set_mode(mode);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode)
|
||||
{
|
||||
return esp_wifi_remote_get_mode(mode);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_start(void)
|
||||
{
|
||||
return esp_wifi_remote_start();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_stop(void)
|
||||
{
|
||||
return esp_wifi_remote_stop();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_restore(void)
|
||||
{
|
||||
return esp_wifi_remote_restore();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_connect(void)
|
||||
{
|
||||
return esp_wifi_remote_connect();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_disconnect(void)
|
||||
{
|
||||
return esp_wifi_remote_disconnect();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_clear_fast_connect(void)
|
||||
{
|
||||
return esp_wifi_remote_clear_fast_connect();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_deauth_sta(uint16_t aid)
|
||||
{
|
||||
return esp_wifi_remote_deauth_sta(aid);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, _Bool block)
|
||||
{
|
||||
return esp_wifi_remote_scan_start(config, block);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_scan_stop(void)
|
||||
{
|
||||
return esp_wifi_remote_scan_stop();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number)
|
||||
{
|
||||
return esp_wifi_remote_scan_get_ap_num(number);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records)
|
||||
{
|
||||
return esp_wifi_remote_scan_get_ap_records(number, ap_records);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_scan_get_ap_record(wifi_ap_record_t *ap_record)
|
||||
{
|
||||
return esp_wifi_remote_scan_get_ap_record(ap_record);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_clear_ap_list(void)
|
||||
{
|
||||
return esp_wifi_remote_clear_ap_list();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_sta_get_ap_info(wifi_ap_record_t *ap_info)
|
||||
{
|
||||
return esp_wifi_remote_sta_get_ap_info(ap_info);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_ps(wifi_ps_type_t type)
|
||||
{
|
||||
return esp_wifi_remote_set_ps(type);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type)
|
||||
{
|
||||
return esp_wifi_remote_get_ps(type);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_protocol(wifi_interface_t ifx, uint8_t protocol_bitmap)
|
||||
{
|
||||
return esp_wifi_remote_set_protocol(ifx, protocol_bitmap);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_protocol(wifi_interface_t ifx, uint8_t *protocol_bitmap)
|
||||
{
|
||||
return esp_wifi_remote_get_protocol(ifx, protocol_bitmap);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t bw)
|
||||
{
|
||||
return esp_wifi_remote_set_bandwidth(ifx, bw);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw)
|
||||
{
|
||||
return esp_wifi_remote_get_bandwidth(ifx, bw);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_channel(uint8_t primary, wifi_second_chan_t second)
|
||||
{
|
||||
return esp_wifi_remote_set_channel(primary, second);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second)
|
||||
{
|
||||
return esp_wifi_remote_get_channel(primary, second);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_country(const wifi_country_t *country)
|
||||
{
|
||||
return esp_wifi_remote_set_country(country);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_country(wifi_country_t *country)
|
||||
{
|
||||
return esp_wifi_remote_get_country(country);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_mac(wifi_interface_t ifx, const uint8_t mac[6])
|
||||
{
|
||||
return esp_wifi_remote_set_mac(ifx, mac);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_mac(wifi_interface_t ifx, uint8_t mac[6])
|
||||
{
|
||||
return esp_wifi_remote_get_mac(ifx, mac);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb)
|
||||
{
|
||||
return esp_wifi_remote_set_promiscuous_rx_cb(cb);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_promiscuous(_Bool en)
|
||||
{
|
||||
return esp_wifi_remote_set_promiscuous(en);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_promiscuous(_Bool *en)
|
||||
{
|
||||
return esp_wifi_remote_get_promiscuous(en);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_promiscuous_filter(const wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
return esp_wifi_remote_set_promiscuous_filter(filter);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_promiscuous_filter(wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
return esp_wifi_remote_get_promiscuous_filter(filter);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_promiscuous_ctrl_filter(const wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
return esp_wifi_remote_set_promiscuous_ctrl_filter(filter);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter)
|
||||
{
|
||||
return esp_wifi_remote_get_promiscuous_ctrl_filter(filter);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf)
|
||||
{
|
||||
return esp_wifi_remote_set_config(interface, conf);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_config(wifi_interface_t interface, wifi_config_t *conf)
|
||||
{
|
||||
return esp_wifi_remote_get_config(interface, conf);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta)
|
||||
{
|
||||
return esp_wifi_remote_ap_get_sta_list(sta);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_ap_get_sta_aid(const uint8_t mac[6], uint16_t *aid)
|
||||
{
|
||||
return esp_wifi_remote_ap_get_sta_aid(mac, aid);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_storage(wifi_storage_t storage)
|
||||
{
|
||||
return esp_wifi_remote_set_storage(storage);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_vendor_ie(_Bool enable, wifi_vendor_ie_type_t type, wifi_vendor_ie_id_t idx, const void *vnd_ie)
|
||||
{
|
||||
return esp_wifi_remote_set_vendor_ie(enable, type, idx, vnd_ie);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx)
|
||||
{
|
||||
return esp_wifi_remote_set_vendor_ie_cb(cb, ctx);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_max_tx_power(int8_t power)
|
||||
{
|
||||
return esp_wifi_remote_set_max_tx_power(power);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_max_tx_power(int8_t *power)
|
||||
{
|
||||
return esp_wifi_remote_get_max_tx_power(power);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_event_mask(uint32_t mask)
|
||||
{
|
||||
return esp_wifi_remote_set_event_mask(mask);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_event_mask(uint32_t *mask)
|
||||
{
|
||||
return esp_wifi_remote_get_event_mask(mask);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, _Bool en_sys_seq)
|
||||
{
|
||||
return esp_wifi_remote_80211_tx(ifx, buffer, len, en_sys_seq);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_csi_rx_cb(wifi_csi_cb_t cb, void *ctx)
|
||||
{
|
||||
return esp_wifi_remote_set_csi_rx_cb(cb, ctx);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_csi_config(const wifi_csi_config_t *config)
|
||||
{
|
||||
return esp_wifi_remote_set_csi_config(config);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_csi(_Bool en)
|
||||
{
|
||||
return esp_wifi_remote_set_csi(en);
|
||||
}
|
||||
|
||||
int64_t esp_wifi_get_tsf_time(wifi_interface_t interface)
|
||||
{
|
||||
return esp_wifi_remote_get_tsf_time(interface);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec)
|
||||
{
|
||||
return esp_wifi_remote_set_inactive_time(ifx, sec);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec)
|
||||
{
|
||||
return esp_wifi_remote_get_inactive_time(ifx, sec);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_statis_dump(uint32_t modules)
|
||||
{
|
||||
return esp_wifi_remote_statis_dump(modules);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi)
|
||||
{
|
||||
return esp_wifi_remote_set_rssi_threshold(rssi);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_ftm_initiate_session(wifi_ftm_initiator_cfg_t *cfg)
|
||||
{
|
||||
return esp_wifi_remote_ftm_initiate_session(cfg);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_ftm_end_session(void)
|
||||
{
|
||||
return esp_wifi_remote_ftm_end_session();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_ftm_resp_set_offset(int16_t offset_cm)
|
||||
{
|
||||
return esp_wifi_remote_ftm_resp_set_offset(offset_cm);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_ftm_get_report(wifi_ftm_report_entry_t *report, uint8_t num_entries)
|
||||
{
|
||||
return esp_wifi_remote_ftm_get_report(report, num_entries);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, _Bool disable)
|
||||
{
|
||||
return esp_wifi_remote_config_11b_rate(ifx, disable);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_connectionless_module_set_wake_interval(uint16_t wake_interval)
|
||||
{
|
||||
return esp_wifi_remote_connectionless_module_set_wake_interval(wake_interval);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_force_wakeup_acquire(void)
|
||||
{
|
||||
return esp_wifi_remote_force_wakeup_acquire();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_force_wakeup_release(void)
|
||||
{
|
||||
return esp_wifi_remote_force_wakeup_release();
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_country_code(const char *country, _Bool ieee80211d_enabled)
|
||||
{
|
||||
return esp_wifi_remote_set_country_code(country, ieee80211d_enabled);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_get_country_code(char *country)
|
||||
{
|
||||
return esp_wifi_remote_get_country_code(country);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate)
|
||||
{
|
||||
return esp_wifi_remote_config_80211_tx_rate(ifx, rate);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx)
|
||||
{
|
||||
return esp_wifi_remote_disable_pmf_config(ifx);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_sta_get_aid(uint16_t *aid)
|
||||
{
|
||||
return esp_wifi_remote_sta_get_aid(aid);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode)
|
||||
{
|
||||
return esp_wifi_remote_sta_get_negotiated_phymode(phymode);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_set_dynamic_cs(_Bool enabled)
|
||||
{
|
||||
return esp_wifi_remote_set_dynamic_cs(enabled);
|
||||
}
|
||||
|
||||
esp_err_t esp_wifi_sta_get_rssi(int *rssi)
|
||||
{
|
||||
return esp_wifi_remote_sta_get_rssi(rssi);
|
||||
}
|
5
components/esp_wifi_remote/examples/mqtt/CMakeLists.txt
Normal file
5
components/esp_wifi_remote/examples/mqtt/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# This project serves as a demo to enable using esp-mqtt on ESP platform targets as well as on linux
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(esp_mqtt_demo)
|
31
components/esp_wifi_remote/examples/mqtt/README.md
Normal file
31
components/esp_wifi_remote/examples/mqtt/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# MQTT application running on WiFi station
|
||||
|
||||
This is a simple mqtt demo, that connects to WiFi AP first. This application has a dependency to `esp_wifi_remote`, so that if it's build and executed on a chipset without WiFI capabilities it redirects all wifi calls the remote target.
|
||||
|
||||
## Overview
|
||||
|
||||
When running this example on a target that doesn't natively support WiFi, please make sure that the remote target (slave application) is connected to your chipset via the configured transport interface.
|
||||
|
||||
Connection to the slave device also depends on RPC library used. It is recommended to use [`esp_hosted`](https://github.com/espressif/esp-hosted). Alternatively you can use [`eppp_link`](https://components.espressif.com/components/espressif/eppp_link).
|
||||
|
||||
Please note, that `esp_hosted` as a component is currently WIP, so the `wifi_remote` defaults to `eppp`, for now.
|
||||
|
||||
## HW connection
|
||||
|
||||
We currently support only `UART` transport, so the connection is very simple. You only need to connect Rx, Tx and GND with the remote target.
|
||||
You need to configure these fields according to your connection:
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_UART_TX_PIN
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_UART_RX_PIN
|
||||
|
||||
## SW configuration
|
||||
|
||||
The RPC mechanism between the host and the slave micro uses TLS with mutual authentication, so you would have to configure certificates and keys for both parties. This application -- host target -- is considered RPC client, so it needs client's certificate and key, as well as the CA certificate to validate the server (slave application).
|
||||
If self-signed certificates are acceptable, you can use [generate_test_certs](../test_certs/generate_test_certs.sh) script to generate both the CA and the keys itself and convert them to the PEM format that's accepted by the EPPP RPC engine.
|
||||
You will have to configure these options:
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CA
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CRT
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_KEY
|
||||
|
||||
## Setting up slave device
|
||||
|
||||
You need to set up the connection and configuration in a similar way on the slave part (connection pins + certificates and keys). Please refer to the [slave_application](../server/README.md) README for more information.
|
@ -0,0 +1,4 @@
|
||||
idf_component_register(SRCS "app_main.c"
|
||||
INCLUDE_DIRS ".")
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
@ -0,0 +1,21 @@
|
||||
menu "Example Configuration"
|
||||
|
||||
config BROKER_URL
|
||||
string "Broker URL"
|
||||
default "mqtt://mqtt.eclipseprojects.io"
|
||||
help
|
||||
URL of the broker to connect to
|
||||
|
||||
config ESP_WIFI_SSID
|
||||
string "WiFi SSID"
|
||||
default "myssid"
|
||||
help
|
||||
SSID (network name) for the example to connect to.
|
||||
|
||||
config ESP_WIFI_PASSWORD
|
||||
string "WiFi Password"
|
||||
default "mypassword"
|
||||
help
|
||||
WiFi password (WPA or WPA2) for the example to use.
|
||||
|
||||
endmenu
|
204
components/esp_wifi_remote/examples/mqtt/main/app_main.c
Normal file
204
components/esp_wifi_remote/examples/mqtt/main/app_main.c
Normal file
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_system.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_client.h"
|
||||
|
||||
static const char *TAG = "esp_mqtt_demo";
|
||||
static EventGroupHandle_t s_wifi_event_group;
|
||||
static int s_retry_num = 0;
|
||||
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
|
||||
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
|
||||
#define EXAMPLE_ESP_MAXIMUM_RETRY 5
|
||||
|
||||
static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
|
||||
{
|
||||
ESP_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%d", base, event_id);
|
||||
esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data;
|
||||
esp_mqtt_client_handle_t client = event->client;
|
||||
int msg_id;
|
||||
switch ((esp_mqtt_event_id_t)event_id) {
|
||||
case MQTT_EVENT_CONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos1", "data_3", 0, 1, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos0", 0);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
|
||||
msg_id = esp_mqtt_client_subscribe(client, "/topic/qos1", 1);
|
||||
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
||||
|
||||
msg_id = esp_mqtt_client_unsubscribe(client, "/topic/qos1");
|
||||
ESP_LOGI(TAG, "sent unsubscribe successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
case MQTT_EVENT_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");
|
||||
break;
|
||||
|
||||
case MQTT_EVENT_SUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id);
|
||||
msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0);
|
||||
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
||||
break;
|
||||
case MQTT_EVENT_UNSUBSCRIBED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", event->msg_id);
|
||||
break;
|
||||
case MQTT_EVENT_PUBLISHED:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id);
|
||||
break;
|
||||
case MQTT_EVENT_DATA:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_DATA");
|
||||
printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);
|
||||
printf("DATA=%.*s\r\n", event->data_len, event->data);
|
||||
break;
|
||||
case MQTT_EVENT_ERROR:
|
||||
ESP_LOGI(TAG, "MQTT_EVENT_ERROR");
|
||||
break;
|
||||
default:
|
||||
ESP_LOGI(TAG, "Other event id:%d", event->event_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mqtt_app_start(void)
|
||||
{
|
||||
esp_mqtt_client_config_t mqtt_cfg = {};
|
||||
mqtt_cfg.broker.address.uri = CONFIG_BROKER_URL;
|
||||
mqtt_cfg.credentials.client_id = "idf_on_linux_client";
|
||||
|
||||
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
|
||||
/* The last argument may be used to pass data to the event handler, in this example mqtt_event_handler */
|
||||
esp_mqtt_client_register_event(client, (esp_mqtt_event_id_t)ESP_EVENT_ANY_ID, mqtt_event_handler, NULL);
|
||||
esp_mqtt_client_start(client);
|
||||
}
|
||||
|
||||
static void event_handler(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
ESP_LOGI(TAG, "EVENT type %s id %d", event_base, (int)event_id);
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||
esp_wifi_connect();
|
||||
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||
if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) {
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "retry to connect to the AP");
|
||||
} else {
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
ESP_LOGI(TAG, "connect to the AP fail");
|
||||
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
|
||||
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
s_retry_num = 0;
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
static void wifi_init_sta()
|
||||
{
|
||||
s_wifi_event_group = xEventGroupCreate();
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
esp_event_handler_instance_t instance_any_id;
|
||||
esp_event_handler_instance_t instance_got_ip;
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||
ESP_EVENT_ANY_ID,
|
||||
&event_handler,
|
||||
NULL,
|
||||
&instance_any_id));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||
IP_EVENT_STA_GOT_IP,
|
||||
&event_handler,
|
||||
NULL,
|
||||
&instance_got_ip));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = EXAMPLE_ESP_WIFI_SSID,
|
||||
.password = EXAMPLE_ESP_WIFI_PASS,
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
|
||||
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
|
||||
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||
* number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */
|
||||
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||
pdFALSE,
|
||||
pdFALSE,
|
||||
portMAX_DELAY);
|
||||
|
||||
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||
* happened. */
|
||||
if (bits & WIFI_CONNECTED_BIT) {
|
||||
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
|
||||
EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
|
||||
} else if (bits & WIFI_FAIL_BIT) {
|
||||
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||
EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "[APP] Startup..");
|
||||
ESP_LOGI(TAG, "[APP] Free memory: %d bytes", esp_get_free_heap_size());
|
||||
ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version());
|
||||
|
||||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
esp_log_level_set("mqtt_client", ESP_LOG_VERBOSE);
|
||||
esp_log_level_set("esp_mqtt_demo", ESP_LOG_VERBOSE);
|
||||
esp_log_level_set("transport_base", ESP_LOG_VERBOSE);
|
||||
esp_log_level_set("esp-tls", ESP_LOG_VERBOSE);
|
||||
esp_log_level_set("transport", ESP_LOG_VERBOSE);
|
||||
esp_log_level_set("outbox", ESP_LOG_VERBOSE);
|
||||
|
||||
//Initialize NVS
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
|
||||
wifi_init_sta();
|
||||
|
||||
mqtt_app_start();
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
dependencies:
|
||||
esp_wifi_remote:
|
||||
version: "*"
|
||||
override_path: ../../..
|
5
components/esp_wifi_remote/examples/mqtt/sdkconfig.ci.p4
Normal file
5
components/esp_wifi_remote/examples/mqtt/sdkconfig.ci.p4
Normal file
@ -0,0 +1,5 @@
|
||||
CONFIG_ESP_WIFI_REMOTE_EPPP_UART_TX_PIN=17
|
||||
CONFIG_ESP_WIFI_REMOTE_EPPP_UART_RX_PIN=16
|
||||
CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CA="MIIDIzCCAgugAwIBAgIULOncUeRLKxgrihIh1kHGGlPV7ecwDQYJKoZIhvcNAQELBQAwITELMAkGA1UEBhMCQ1oxEjAQBgNVBAMMCUVzcHJlc3NpZjAeFw0yNDA0MDMwOTE0MjNaFw0zNDA0MDEwOTE0MjNaMCExCzAJBgNVBAYTAkNaMRIwEAYDVQQDDAlFc3ByZXNzaWYwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbayaZAuzQWrwRj3oiFP9AZK0ECaDvVlJec4M6yokded1pqNY+bNmA7VsHSQkf3d1rO1G5GwEXoMPli15m7rJodq9iYp1J2LhLhpKDNapm19reyH9A4rAfjSyk/WyvT+3Y5sNHVFdE2t1EetOyzy90CfOHT9JfWG9PiV6b1W65CqgjJVCHMWioppVAGQCoN+mDBf1VhD4am6onei+ijHdALJDfp74mSIOJGulm/IR7504s+yy7068PQ05V/wHkmd9O1Iww5fnJdRh2KvTFZVOB5u9y54MTJb0sGZj+JfxIbcFiIWAykLFVWBk5PO6yj8fNMmk/Ogb2K4wo7AZnJ3qBAgMBAAGjUzBRMB0GA1UdDgQWBBT3j77hJHm/hI34fEn3tocHqB4INzAfBgNVHSMEGDAWgBT3j77hJHm/hI34fEn3tocHqB4INzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBstXfBIRvqZp4OBQ2kCJig/CErcfdB4qQOS2LzQmpIOUQ4d/zvZOQD2WIw/x2Rd1/hto/+f57pOZNHsi8vfX2Z7kPOlD9ZG1wTznl1v8wOMP01AFJuVtmJQV0C4lVupb2/Mmu42xqP9pr/uL5pJ2rFb8ujl2xakhSvYVdMONtZL0mh9+hdnUb7Fj7KI3qWxzc7+uXGjCzh6LkOmcMBOB6+0V6xW2NVpUUPtuXytK0t2oyWpDvwFIrl0J6qBNRlH1ON1iz33HOo73IjprMNx3hIo5y/N8+TTxY6KEegbP67hSnJJhQ7tezoOu4OE0xmJp0XmGPMNewYARqL2UvHnZyf"
|
||||
CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CRT="MIICwjCCAaoCFAWE4aJdYWbMJAaBTMxVpoXMrhzvMA0GCSqGSIb3DQEBCwUAMCExCzAJBgNVBAYTAkNaMRIwEAYDVQQDDAlFc3ByZXNzaWYwHhcNMjQwNDAzMDkxNjE4WhcNMzQwNDAxMDkxNjE4WjAaMRgwFgYDVQQDDA9lc3ByZXNzaWYubG9jYWwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDcjdBQ3sHbfuWRo2LlqZF37Dfuymz5/fq+szcOLUUWCccxku9qNNEdZAcZHMsINurezpHXa6ZNKGqmbmqZPVrEKzMUIolpnQmcerRt/yKqxCZ/kgsJE3IZyqi1T+xDwaBEhgdB6+wxyrL0/uBlLCbEdZAA7MPcauIKz8ykfIwo7Ht/vcHNxGaFFu+DcNoJI/Pw6hERlC9DHuUftK0/Lap1K2o+6kFQKqhVrvNQmaiqnz3Dr9psPO90AvbRqeODmfpi7rtU4MKOprQhUrMS9s9d5yVdJILp74pt6nzu3EnFiixRD5XD9PtK5NvP1sgDAgbWgTttwM9X7N6mzEe/gVUZAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAJVsbAamDRuZ1J2ogHLo/UmjmcmIATmqO7Ebaoid7+FYme/2NFzofOFtJNaCumdhwxSyf7ER6m2DUO6bDseblqNCTyRDNNXzTHEFQiYh2PThKSDdH0fbEf4IpcbOCnpSEpIg9C/ywEhq/wzYiOlxPhNWxBKHLhEkM7aWBerAhInCRRXymfus2HUf6aTWZ0wigMoUVKwOu16Zh04D2d6qb314cEMgKvANPiTTdgEae7Ot+rP1s2Zp75zUbWuz4uWd4wJDOHWR25mkD3ZELfbrpmEymbOTQ26zOpIUiPNfYZ1t9KwEjkKN+jBTXKu7QhB/u+g5yBHjRL++LEli4YGGGiA="
|
||||
CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_KEY="MIIEpQIBAAKCAQEA3I3QUN7B237lkaNi5amRd+w37sps+f36vrM3Di1FFgnHMZLvajTRHWQHGRzLCDbq3s6R12umTShqpm5qmT1axCszFCKJaZ0JnHq0bf8iqsQmf5ILCRNyGcqotU/sQ8GgRIYHQevsMcqy9P7gZSwmxHWQAOzD3GriCs/MpHyMKOx7f73BzcRmhRbvg3DaCSPz8OoREZQvQx7lH7StPy2qdStqPupBUCqoVa7zUJmoqp89w6/abDzvdAL20anjg5n6Yu67VODCjqa0IVKzEvbPXeclXSSC6e+Kbep87txJxYosUQ+Vw/T7SuTbz9bIAwIG1oE7bcDPV+zepsxHv4FVGQIDAQABAoIBAQDPzzc224yg+iHoZaArcOhFrGbPMiAYNLxrroTzcKglqbTr+txmn7lhDfy6Jq0O4l/O66fy59Vb4fcLNgJuvKanK2UHVbtPrc1+iQc0lS7e4866aKrJNG9P6emoXNPqy6fsqLRx4o88IxcXTIe2DDHC7lpu5KdvKa4uLblOSqPtcZTHXPD9olVe8ZYF5CttMUTc4SkF4HSkY2jb0j+6kASN4eQ2CqEt+IW4IxI5NiEzrlzZSOdyqIOeyGUZz+QcfILOProWZHYzH3jOHQe4PJSXO57f2dojY1GqRcjnr3guQMpw1s7wmDYO1QekiBYwRERNzjEY7VhgDq8T0rwJPHP5AoGBAPO13QpJVSj1NfQ/H0AgZlsJIIlIwIC2YwuwjA7b36A3JOFolkHjtq4eNntThNRQbTL9OficbxJSHXQcOsQeo7dvwEhJjuVwEajL4/6cjc9b4oyGJxLlTKTshUPmeKPfGWUjRZKGbVWbT3m4BXqGiv4laCZ0LDHiCt4DvEzQ1Bo3AoGBAOetBClbcbUJhxkAme5HHI9A5VcqyOi2CrRh+HjKd/2IJlDA+Vmbl2iEB+9cMRGRubazbrk1yAzgtW29GX8kngr8yxDtIM8M7lPR2NhXx7XbmCKwKosZ7l6hHNdnD12TFyLCjuuJlUA37sWXw8r33623mLFQlNVjnL0onUa1XSMvAoGACw47+cR73YDKMstOQp11pzmRxUiMmworEhOvNtlYmq8FuEgDUPfgiKOMOyn9w5fmbEK6h4GpND6PYX4KWG0/ZgnmwiC8H8Jmuq6NKDa35Ck57MAFM8E9Kdok7YCeBmkPgNwJwuzgNtr1zwK/FODXm1HdGKl6e8TSU2H9/8oVZR8CgYEAoHSWI0awNCCLLufZtMwPna/mpz58s6ARPel0u8QO4st/LgLZMBSxArQfAsqpOW/iXgVcNG5pRXIEdiK4G/TyeM2onup9BKoCDo+SThRNv0h9z9iPPpQRIf0YCp/YZojPR0XU0pERi86xUqzP8C1I//neiUA0NK6vCdutQiGuhgUCgYEAp89EFcM1WvtPRJE+md8N8BUef5MJ+JJ0nb+BW1kkLY50Q1MVmsVXdUowYupWLBgEfMn8fy8Q+xD9EeiISTF9MtT1X4iQSI/pzKW5LLd0OJYnqPMWzyggASzSNWdYBIGNkqsQGmGCtF9+i6V4acfTTbMD9LiB7u5/enQa8N0Qg+s="
|
@ -0,0 +1,3 @@
|
||||
CONFIG_LWIP_PPP_SUPPORT=y
|
||||
CONFIG_LWIP_PPP_SERVER_SUPPORT=y
|
||||
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n
|
@ -0,0 +1,6 @@
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(pppos_slave)
|
21
components/esp_wifi_remote/examples/server/README.md
Normal file
21
components/esp_wifi_remote/examples/server/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# WiFi remote EPPP RPC server
|
||||
|
||||
This is a standalone application serving as the slave device for `esp_wifi_remote` users (with `eppp` RPC).
|
||||
|
||||
## Overview
|
||||
|
||||
You need to configure and connect a slave device to the `esp_wifi_remote` host and run this application. Please fallow carefully these guidelines on HW connection and configuration of the slave device, based on the host device.
|
||||
|
||||
## HW connection
|
||||
|
||||
We currently support only `UART` transport you just need to connect Rx, Tx and GND and configure these fields accordingly:
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_UART_TX_PIN
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_UART_RX_PIN
|
||||
|
||||
## SW configuration
|
||||
|
||||
You will have to install server side certificates and keys, as well as the CA which should verify the client side.
|
||||
Please configure these options:
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_CLIENT_CA
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_CRT
|
||||
* CONFIG_ESP_WIFI_REMOTE_EPPP_SERVER_KEY
|
@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "station_example_main.c"
|
||||
INCLUDE_DIRS ".")
|
@ -0,0 +1,4 @@
|
||||
dependencies:
|
||||
esp_wifi_remote:
|
||||
version: "*"
|
||||
override_path: ../../..
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user