Compare commits

..

39 Commits

Author SHA1 Message Date
1750a3fda9 Merge pull request #535 from gabsuren/websocket_update
bump(websocket): 1.2.2 -> 1.2.3
2024-03-27 17:35:52 +04:00
2a3db45ef1 Merge pull request #541 from gabsuren/websocket_host_example_4
fix(websocket): fix of websocket host build
2024-03-26 20:33:55 +04:00
fcc61e0929 fix(websocket): fix of websocket host build 2024-03-26 19:00:03 +04:00
14763888ed Merge pull request #534 from gabsuren/mdns_docs
fix(mdns): updated the document to clarify service advertisment prerequisite (IDFGH-6982)
2024-03-26 13:15:21 +04:00
a5954dda17 Merge pull request #533 from david-cermak/fix/mdns_process_tx_packets
fix(mdns): Schedule all queued Tx packets from timer task
2024-03-26 10:12:41 +01:00
a65d81c954 bump(websocket): 1.2.2 -> 1.2.3
1.2.3
Features
- Expanded example to demonstrate the transfer over TLS (0d0630ed76)
Bug Fixes
- fix esp_event dependency management (1fb02a9a60)
- Skip warn on zero timeout and auto reconnect is disabled (5b467cbf5c)
- Fixed to use int return value in Tx functions (9c54b72e1f)
- Fixed Tx functions with DYNAMIC_BUFFER (16174470ee)
- added dependency checks, sdkconfig.defaults and refined README.md (312982e4aa)
- Close websocket and dispatch event if server does not close within a reasonable amount of time. (d85311880d)
- Continue waiting for TCP connection to be closed (2b092e0db4)
Updated
- docs(websocket): Added README for websocket host example (2f7c58259d)
2024-03-22 14:37:13 +04:00
2585565483 fix(mdns): updated the document to clarify service advertisment prerequisite (IDFGH-6982) 2024-03-22 11:57:24 +04:00
b9c675b0b1 Merge pull request #523 from bryghtlabs-richard/master
fix(websocket): fix esp_event dependency management (IDFGH-12301) (IDFGH-12302)
2024-03-20 19:09:29 +01:00
d4e693e392 fix(mdns): Schedule all queued Tx packets from timer task
Co-Authored-By: not-my-real-name <none@interent.com>

Partially addresses: https://github.com/espressif/esp-idf/issues/13333
2024-03-20 11:47:29 +01:00
963b32e7b4 Merge pull request #497 from rretanubun/make-mdns-console-kcconfig
feat(mdns): Make including mdns_console KConfig (IDFGH-11988)
2024-03-20 09:39:34 +01:00
cffe26818b Merge pull request #531 from david-cermak/fix/modem_minor_prs
[esp_modem]: Accept some PRs
2024-03-18 16:34:21 +01:00
08a62ccc85 fix(modem): Cleanup unused configs from PPPoS example
Merges https://github.com/espressif/esp-protocols/pull/403
2024-03-18 14:10:46 +01:00
56fe53279e fix(modem): Update CMUX example with SIM7070_gnss cleaned-up
Merges https://github.com/espressif/esp-protocols/pull/246
2024-03-18 14:10:46 +01:00
5baaf54291 fix(modem): Update console example with SIM7070_gnss format comments
Merges https://github.com/espressif/esp-protocols/pull/245
2024-03-18 14:10:46 +01:00
38de23fb1c Merge pull request #532 from gabsuren/ci_fix_modem
fix(modem): install requirements.txt for modem target tests
2024-03-18 14:09:53 +01:00
84390eb4d4 fix(modem): install requirements.txt for modem target tests 2024-03-18 15:18:44 +04:00
4e844936b7 Merge pull request #529 from zwx1995esp/fix/add_lock_for_mdns_common_api
fix(mdns): add lock for some common apis (IDFGH-12338)
2024-03-15 11:14:16 +04:00
zwx
21c84bfa8d fix(mdns): add lock for some common apis 2024-03-14 17:53:05 +08:00
438449f58f Merge pull request #454 from gabsuren/modem/latest_version
feat(modem): host test support of the latest ESP-IDF release (IDF-7828)
2024-03-14 13:49:05 +04:00
a23a0027fa ci(common): updated github actions(checkout, upload, download) v3 to 4, Ubuntu 20.04 to v22.04 2024-03-12 14:22:01 +04:00
3f74b4e8c0 feat(modem): host test support of the latest ESP-IDF release 2024-03-12 12:05:59 +04:00
46a6244c37 Merge pull request #526 from zwx1995esp/fix/mdns_send_answer_while_host_is_invalid
fix(mdns): fix mdns answer append while host is invalid
2024-03-12 10:26:02 +04:00
zwx
7be16bcc88 fix(mdns): fix mdns answer append while host is invalid 2024-03-11 20:26:38 +08:00
1fb02a9a60 fix(websocket): fix esp_event dependency management
Move esp_event from PRIV_REQUIRES to REQUIRES, as it is
included by esp_websocket_client.h, so any code including
that header also requires esp_event.

This resolves the following build error for files not
explicitly requiring esp_event:

ninja: build stopped: subcommand failed.
Compilation failed because esp_websocket_client.h (in "espressif__esp_websocket_client" component) includes esp_event.h, provided by esp_event component(s).
However, esp_event component(s) is in the private requirements list of "espressif__esp_websocket_client".
To fix this, move esp_event from PRIV_REQUIRES into REQUIRES list of idf_component_register call in ...\managed_components\espressif__esp_websocket_client\CMakeLists.txt.
ninja failed with exit code 1, output of the command is in...
2024-03-08 10:10:48 -06:00
b5be844c92 Merge pull request #521 from johanstokking/fix/websocket/reconnect-timeout-warning
fix(websocket): Skip warn on zero timeout and auto reconnect is disabled  (IDFGH-12288)
2024-03-07 11:49:18 +04:00
5b467cbf5c fix(websocket): Skip warn on zero timeout and auto reconnect is disabled 2024-03-06 22:20:48 +01:00
f8a776d8a5 Merge pull request #519 from gabsuren/mdns1.2.5
bump(mdns): 1.2.4 -> 1.2.5
2024-03-06 10:56:24 +04:00
a82c7922aa bump(mdns): 1.2.4 -> 1.2.5
1.2.5
Bug Fixes
- Fixed build issues for targets without WiFi caps (302b46f)
2024-03-06 10:32:17 +04:00
d31ad025c8 Merge pull request #515 from david-cermak/fix/ws_dyn_buffer
[ws-client]: Fix usage of the dynamic buffer
2024-03-05 16:25:51 +01:00
4977f96a61 Merge pull request #517 from david-cermak/fix/examples_format_warn
Fix remaining format warnings
2024-03-05 15:02:44 +01:00
dcdf31187a Merge pull request #518 from gabsuren/mdns_docs_update
fix(mdns): updated the document to clarify self-querying mechanism (IDFGH-7528)
2024-03-05 14:23:06 +04:00
b6bbe47cae fix(mdns): updated the document to clarify self-querying mechanism 2024-03-05 12:38:07 +04:00
302b46f8e2 fix(mdns): Fixed build issues for targets without WiFi caps 2024-03-01 10:24:29 +01:00
45b1597ac3 fix(examples): Fix SLIP example print format warnings 2024-03-01 10:08:27 +01:00
a06de6431b fix(examples): Fix MQTT example print format warnings
Partially addresses https://github.com/espressif/esp-protocols/issues/79
2024-02-28 19:25:28 +01:00
3b80181d30 fix(modem): Fix remaining print format warnings
Partially addresses https://github.com/espressif/esp-protocols/issues/79
2024-02-28 19:24:52 +01:00
9c54b72e1f fix(websocket): Fixed to use int return value in Tx functions 2024-02-28 12:48:06 +01:00
16174470ee fix(websocket): Fixed Tx functions with DYNAMIC_BUFFER 2024-02-28 12:47:59 +01:00
27adbfeb3b feat(mdns): Make including mdns_console KConfigurable
The CLI that mdns_console offers is very useful for debugging
and bootstrapping mDNS onto new projects, but some projects
may not want console CLI in place to reduce binary size.

This gives a KConfig option to do so.
2024-01-26 13:35:47 -05:00
48 changed files with 341 additions and 231 deletions

View File

@ -16,13 +16,13 @@ jobs:
idf_ver: ["latest", "release-v5.0", "release-v5.1"]
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: |
@ -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 }}

View File

@ -16,11 +16,11 @@ jobs:
idf_ver: ["latest", "release-v5.0"]
idf_target: ["esp32"]
test: [ { app: ifconfig-basic, path: "components/console_cmd_ifconfig/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 }}

View File

@ -16,11 +16,11 @@ jobs:
idf_ver: ["latest", "release-v5.0"]
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 }}

View File

@ -16,11 +16,11 @@ jobs:
idf_ver: ["latest", "release-v5.0"]
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 }}

View File

@ -16,11 +16,11 @@ jobs:
idf_ver: ["latest", "release-v5.0"]
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 }}

View File

@ -14,11 +14,11 @@ jobs:
strategy:
matrix:
idf_ver: ["latest", "release-v5.1"]
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: |
@ -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: |

View File

@ -15,18 +15,18 @@ jobs:
matrix:
idf_ver: ["latest", "release-v5.0"]
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

View File

@ -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

View File

@ -27,13 +27,19 @@ jobs:
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 }}
@ -54,11 +60,11 @@ jobs:
idf_ver: ["release-v5.0", "release-v5.1", "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 +82,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"

View File

@ -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 }}

View File

@ -16,11 +16,11 @@ jobs:
idf_ver: ["latest", "release-v5.0"]
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 }}

View File

@ -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

View File

@ -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

View File

@ -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,6 +85,7 @@ 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
@ -86,6 +98,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 +112,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: |

View File

@ -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

View File

@ -15,13 +15,13 @@ jobs:
matrix:
idf_ver: ["release-v5.0", "release-v5.1", "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
@ -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

View File

@ -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()

View File

@ -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 = {

View File

@ -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

View File

@ -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);
}

View File

@ -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);
};

View File

@ -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
}

View File

@ -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
@ -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:

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
dependencies:
espressif/catch2:
version: '*'
idf:
version: ">=5.0"

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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
*/
@ -550,9 +550,13 @@ 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 (esp_websocket_new_buf(client, true) != ESP_OK) {
ESP_LOGE(TAG, "Failed to setup tx buffer");
return -1;
}
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;
@ -629,7 +633,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,33 +1208,27 @@ 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;
int ret = -1;
if (client == NULL || len < 0 || (data == NULL && len > 0)) {
ESP_LOGE(TAG, "Invalid arguments");
return ESP_FAIL;
return -1;
}
if (xSemaphoreTakeRecursive(client->lock, timeout) != pdPASS) {
ESP_LOGE(TAG, "Could not lock ws-client within %" PRIu32 " timeout", timeout);
return ESP_FAIL;
return -1;
}
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");

View File

@ -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)

View File

@ -1,4 +0,0 @@
dependencies:
idf: ">5.2"
protocol_examples_common:
path: ${IDF_PATH}/examples/common_components/protocol_examples_common

View File

@ -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:

View File

@ -1,11 +0,0 @@
components/mdns/examples:
disable:
- if: IDF_TARGET in ["esp32h2"]
components/mdns/tests/unit_test:
disable:
- if: IDF_TARGET in ["esp32h2"]
components/mdns/tests/test_apps:
disable:
- if: IDF_TARGET in ["esp32h2"]

View File

@ -3,6 +3,6 @@ commitizen:
bump_message: 'bump(mdns): $current_version -> $new_version'
pre_bump_hooks: python ../../ci/changelog.py mdns
tag_format: mdns-v$version
version: 1.2.4
version: 1.2.5
version_files:
- idf_component.yml

View File

@ -1,5 +1,11 @@
# Changelog
## [1.2.5](https://github.com/espressif/esp-protocols/commits/mdns-v1.2.5)
### Bug Fixes
- Fixed build issues for targets without WiFi caps ([302b46f](https://github.com/espressif/esp-protocols/commit/302b46f))
## [1.2.4](https://github.com/espressif/esp-protocols/commits/mdns-v1.2.4)
### Bug Fixes

View File

@ -4,6 +4,12 @@ else()
set(MDNS_NETWORKING "mdns_networking_lwip.c")
endif()
if(CONFIG_MDNS_ENABLE_CONSOLE_CLI)
set(MDNS_CONSOLE "mdns_console.c")
else()
set(MDNS_CONSOLE "")
endif()
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
set(dependencies esp_netif_linux esp_timer esp_system)
@ -11,7 +17,7 @@ if(${target} STREQUAL "linux")
else()
set(dependencies lwip console esp_netif)
set(private_dependencies esp_timer esp_wifi)
set(srcs "mdns.c" ${MDNS_NETWORKING} "mdns_console.c")
set(srcs "mdns.c" ${MDNS_NETWORKING} ${MDNS_CONSOLE})
endif()
idf_component_register(

View File

@ -100,6 +100,12 @@ menu "mDNS"
help
Enable for the library to log received and sent mDNS packets to stdout.
config MDNS_ENABLE_CONSOLE_CLI
bool "Enable Command Line Interface on device console"
default y
help
Enable for the console cli to be available on the device.
config MDNS_RESPOND_REVERSE_QUERIES
bool "Enable responding to IPv4 reverse queries"
default n

View File

@ -1,4 +1,4 @@
version: "1.2.4"
version: "1.2.5"
description: mDNS
url: https://github.com/espressif/esp-protocols/tree/master/components/mdns
dependencies:

View File

@ -72,6 +72,7 @@ static bool _mdns_append_host_list(mdns_out_answer_t **destination, bool flush,
static void _mdns_remap_self_service_hostname(const char *old_hostname, const char *new_hostname);
static esp_err_t mdns_post_custom_action_tcpip_if(mdns_if_t mdns_if, mdns_event_actions_t event_action);
static void _mdns_query_results_free(mdns_result_t *results);
typedef enum {
MDNS_IF_STA = 0,
MDNS_IF_AP = 1,
@ -1350,6 +1351,20 @@ static uint8_t _mdns_append_service_ptr_answers(uint8_t *packet, uint16_t *index
*/
static uint8_t _mdns_append_answer(uint8_t *packet, uint16_t *index, mdns_out_answer_t *answer, mdns_if_t tcpip_if)
{
if (answer->host) {
bool is_host_valid = (&_mdns_self_host == answer->host);
mdns_host_item_t *target_host = _mdns_host_list;
while (target_host && !is_host_valid) {
if (target_host == answer->host) {
is_host_valid = true;
}
target_host = target_host->next;
}
if (!is_host_valid) {
return 0;
}
}
if (answer->type == MDNS_TYPE_PTR) {
if (answer->service) {
return _mdns_append_service_ptr_answers(packet, index, answer->service, answer->flush, answer->bye);
@ -5176,7 +5191,7 @@ static void _mdns_scheduler_run(void)
MDNS_SERVICE_UNLOCK();
return;
}
if ((int32_t)(p->send_at - (xTaskGetTickCount() * portTICK_PERIOD_MS)) < 0) {
while (p && (int32_t)(p->send_at - (xTaskGetTickCount() * portTICK_PERIOD_MS)) < 0) {
action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (action) {
action->type = ACTION_TX_HANDLE;
@ -5188,8 +5203,10 @@ static void _mdns_scheduler_run(void)
}
} else {
HOOK_MALLOC_FAILED;
// continue
break;
}
//Find the next unqued packet
p = p->next;
}
MDNS_SERVICE_UNLOCK();
}
@ -5386,13 +5403,13 @@ static inline void set_default_duplicated_interfaces(void)
static inline void unregister_predefined_handlers(void)
{
#if defined(MDNS_ESP_WIFI_ENABLED) && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
#if MDNS_ESP_WIFI_ENABLED && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event);
#endif
#if CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP || CONFIG_MDNS_PREDEF_NETIF_ETH
esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event);
#endif
#if defined(CONFIG_ETH_ENABLED) && CONFIG_MDNS_PREDEF_NETIF_ETH
#if CONFIG_ETH_ENABLED && CONFIG_MDNS_PREDEF_NETIF_ETH
esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event);
#endif
}
@ -5483,7 +5500,7 @@ esp_err_t mdns_init(void)
goto free_queue;
}
#if defined(MDNS_ESP_WIFI_ENABLED) && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
#if MDNS_ESP_WIFI_ENABLED && (CONFIG_MDNS_PREDEF_NETIF_STA || CONFIG_MDNS_PREDEF_NETIF_AP)
if ((err = esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event, NULL)) != ESP_OK) {
goto free_event_handlers;
}
@ -5493,7 +5510,7 @@ esp_err_t mdns_init(void)
goto free_event_handlers;
}
#endif
#if defined(CONFIG_ETH_ENABLED) && CONFIG_MDNS_PREDEF_NETIF_ETH
#if CONFIG_ETH_ENABLED && CONFIG_MDNS_PREDEF_NETIF_ETH
if ((err = esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, mdns_preset_if_handle_system_event, NULL)) != ESP_OK) {
goto free_event_handlers;
}
@ -5586,7 +5603,7 @@ void mdns_free(void)
free(h->proto);
vSemaphoreDelete(h->done_semaphore);
if (h->result) {
mdns_query_results_free(h->result);
_mdns_query_results_free(h->result);
}
free(h);
}
@ -5734,7 +5751,11 @@ esp_err_t mdns_delegate_hostname_set_address(const char *hostname, const mdns_ip
bool mdns_hostname_exists(const char *hostname)
{
return _hostname_is_ours(hostname);
bool ret = false;
MDNS_SERVICE_LOCK();
ret = _hostname_is_ours(hostname);
MDNS_SERVICE_UNLOCK();
return ret;
}
esp_err_t mdns_instance_name_set(const char *instance)
@ -5777,11 +5798,14 @@ esp_err_t mdns_service_add_for_host(const char *instance, const char *service, c
return ESP_ERR_INVALID_ARG;
}
MDNS_SERVICE_LOCK();
if (!_mdns_can_add_more_services()) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_NO_MEM;
}
mdns_srv_item_t *item = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (item) {
return ESP_ERR_INVALID_ARG;
}
@ -5819,12 +5843,18 @@ esp_err_t mdns_service_add_for_host(const char *instance, const char *service, c
size_t start = xTaskGetTickCount();
size_t timeout_ticks = pdMS_TO_TICKS(MDNS_SERVICE_ADD_TIMEOUT_MS);
while (_mdns_get_service_item_instance(instance, service, proto, hostname) == NULL) {
MDNS_SERVICE_LOCK();
mdns_srv_item_t *target = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
while (target == NULL) {
uint32_t expired = xTaskGetTickCount() - start;
if (expired >= timeout_ticks) {
return ESP_FAIL; // Timeout
}
vTaskDelay(MIN(10 / portTICK_PERIOD_MS, timeout_ticks - expired));
MDNS_SERVICE_LOCK();
target = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
}
return ESP_OK;
@ -5841,13 +5871,21 @@ esp_err_t mdns_service_add(const char *instance, const char *service, const char
bool mdns_service_exists(const char *service_type, const char *proto, const char *hostname)
{
return _mdns_get_service_item(service_type, proto, hostname) != NULL;
bool ret = false;
MDNS_SERVICE_LOCK();
ret = _mdns_get_service_item(service_type, proto, hostname) != NULL;
MDNS_SERVICE_UNLOCK();
return ret;
}
bool mdns_service_exists_with_instance(const char *instance, const char *service_type, const char *proto,
const char *hostname)
{
return _mdns_get_service_item_instance(instance, service_type, proto, hostname) != NULL;
bool ret = false;
MDNS_SERVICE_LOCK();
ret = _mdns_get_service_item_instance(instance, service_type, proto, hostname) != NULL;
MDNS_SERVICE_UNLOCK();
return ret;
}
static mdns_txt_item_t *_copy_mdns_txt_items(mdns_txt_linked_item_t *items, uint8_t **txt_value_len, size_t *txt_count)
@ -5987,16 +6025,19 @@ static mdns_result_t *_mdns_lookup_service(const char *instance, const char *ser
}
return results;
handle_error:
mdns_query_results_free(results);
_mdns_query_results_free(results);
return NULL;
}
esp_err_t mdns_service_port_set_for_host(const char *instance, const char *service, const char *proto, const char *hostname, uint16_t port)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto) || !port) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6027,10 +6068,13 @@ esp_err_t mdns_service_port_set(const char *service, const char *proto, uint16_t
esp_err_t mdns_service_txt_set_for_host(const char *instance, const char *service, const char *proto, const char *hostname,
mdns_txt_item_t txt[], uint8_t num_items)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto) || (num_items && txt == NULL)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6073,11 +6117,14 @@ esp_err_t mdns_service_txt_item_set_for_host_with_explicit_value_len(const char
const char *hostname, const char *key,
const char *value, uint8_t value_len)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto) ||
_str_null_or_empty(key) || (!value && value_len)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6146,10 +6193,13 @@ esp_err_t mdns_service_txt_item_set_with_explicit_value_len(const char *service,
esp_err_t mdns_service_txt_item_remove_for_host(const char *instance, const char *service, const char *proto, const char *hostname,
const char *key)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto) || _str_null_or_empty(key)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6185,11 +6235,14 @@ esp_err_t mdns_service_txt_item_remove(const char *service, const char *proto, c
esp_err_t mdns_service_subtype_add_for_host(const char *instance_name, const char *service, const char *proto,
const char *hostname, const char *subtype)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto) ||
_str_null_or_empty(subtype)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance_name, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6218,13 +6271,17 @@ esp_err_t mdns_service_subtype_add_for_host(const char *instance_name, const cha
esp_err_t mdns_service_instance_name_set_for_host(const char *instance_old, const char *service, const char *proto, const char *hostname,
const char *instance)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
if (_str_null_or_empty(instance) || strlen(instance) > (MDNS_NAME_BUF_LEN - 1)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance_old, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6260,10 +6317,13 @@ esp_err_t mdns_service_instance_name_set(const char *service, const char *proto,
esp_err_t mdns_service_remove_for_host(const char *instance, const char *service, const char *proto, const char *hostname)
{
MDNS_SERVICE_LOCK();
if (!_mdns_server || !_mdns_server->services || _str_null_or_empty(service) || _str_null_or_empty(proto)) {
MDNS_SERVICE_UNLOCK();
return ESP_ERR_INVALID_ARG;
}
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance, service, proto, hostname);
MDNS_SERVICE_UNLOCK();
if (!s) {
return ESP_ERR_NOT_FOUND;
}
@ -6295,9 +6355,12 @@ esp_err_t mdns_service_remove_all(void)
if (!_mdns_server) {
return ESP_ERR_INVALID_ARG;
}
MDNS_SERVICE_LOCK();
if (!_mdns_server->services) {
MDNS_SERVICE_UNLOCK();
return ESP_OK;
}
MDNS_SERVICE_UNLOCK();
mdns_action_t *action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
if (!action) {
@ -6315,8 +6378,14 @@ esp_err_t mdns_service_remove_all(void)
/*
* MDNS QUERY
* */
void mdns_query_results_free(mdns_result_t *results)
{
MDNS_SERVICE_LOCK();
_mdns_query_results_free(results);
MDNS_SERVICE_UNLOCK();
}
static void _mdns_query_results_free(mdns_result_t *results)
{
mdns_result_t *r;
mdns_ip_addr_t *a;

View File

@ -47,6 +47,10 @@ mDNS can advertise information about network services that your device offers. E
* ``port``: (required) network port that the service runs on
* ``txt``: ``{var, val}`` array of strings, used to define properties for your service
Please note:
1. Self-querying names is not supported in Espressif's mDNS library, a deliberate design choice to simplify implementation, preventing local network pollution and addressing WiFi multicast behavior)
2. Setting your own hostname is a prerequisite(mandatory) for advertising services or delegating other names.
Example method to add a few services and different properties::
void add_mdns_services()

View File

@ -5,4 +5,3 @@ idf_component_register(
INCLUDE_DIRS "include"
REQUIRES esp_netif driver
)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

View File

@ -1,10 +1,11 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include <inttypes.h>
#include "slip_modem.h"
#include "esp_netif.h"
@ -176,7 +177,7 @@ static esp_err_t slip_modem_transmit(void *slip_driver, void *buffer, size_t len
int32_t res = uart_write_bytes(slip_modem->uart.uart_dev, (char *)buffer, len);
if (res < 0) {
// Handle errors
ESP_LOGE(TAG, "%s: uart_write_bytes error %i", __func__, res);
ESP_LOGE(TAG, "%s: uart_write_bytes error %" PRId32, __func__, res);
return ESP_FAIL;
}
return ESP_OK;
@ -212,7 +213,7 @@ static void slip_modem_uart_rx_task(void *arg)
slip_modem_handle slip_modem = (slip_modem_handle) arg;
ESP_LOGD(TAG, "Start SLIP modem RX task (slip_modem %p filter: %p)", slip_modem, slip_modem->rx_filter);
ESP_LOGD(TAG, "Uart: %d, buffer: %p (%d bytes)", slip_modem->uart.uart_dev, slip_modem->buffer, slip_modem->buffer_len);
ESP_LOGD(TAG, "Uart: %d, buffer: %p (%" PRIu32 " bytes)", slip_modem->uart.uart_dev, slip_modem->buffer, slip_modem->buffer_len);
while (slip_modem->running == true) {
// Read data from the UART

View File

@ -5,4 +5,3 @@ idf_component_register(
INCLUDE_DIRS "."
REQUIRES esp_netif slip_modem driver
)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

View File

@ -121,7 +121,7 @@ static void slip_set_prefix(slip_modem_handle slip)
{
uint8_t buff[10] = {0};
const esp_ip6_addr_t addr = slip_modem_get_ipv6_address(slip);
ESP_LOGI(TAG, "%s: prefix set (%08x:%08x)", __func__,
ESP_LOGI(TAG, "%s: prefix set (%08" PRIx32 ":%08" PRIx32 ")", __func__,
lwip_ntohl(addr.addr[0]), lwip_ntohl(addr.addr[1]));
// Build slip set message

View File

@ -1,4 +1,2 @@
idf_component_register(SRCS "app_main.cpp"
INCLUDE_DIRS ".")
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@ -40,8 +40,8 @@ static void log_error_if_nonzero(const char *message, int error_code)
*/
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_LOGD(TAG, "Event dispatched from event loop base=%s, event_id=%" PRIi32 "", base, event_id);
auto 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) {
@ -95,7 +95,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
}
}
static void mqtt_app_start(void)
static void mqtt_app_start()
{
esp_mqtt_client_config_t mqtt_cfg = {};
mqtt_cfg.broker.address.uri = CONFIG_BROKER_URL;
@ -111,7 +111,7 @@ static void mqtt_app_start(void)
extern "C" 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] Free memory: %" PRIu32 " bytes", esp_get_free_heap_size());
ESP_LOGI(TAG, "[APP] IDF version: %s", esp_get_idf_version());
esp_log_level_set("*", ESP_LOG_INFO);