diff --git a/components/esp_modem/examples/simple_cmux_client/main/Kconfig.projbuild b/components/esp_modem/examples/simple_cmux_client/main/Kconfig.projbuild index bf733a9ee..b7347303d 100644 --- a/components/esp_modem/examples/simple_cmux_client/main/Kconfig.projbuild +++ b/components/esp_modem/examples/simple_cmux_client/main/Kconfig.projbuild @@ -129,4 +129,16 @@ menu "Example Configuration" help URL of an mqtt broker which this example connects to. + config EXAMPLE_MQTT_TEST_TOPIC + string "MQTT topic to publish/subscribe" + default "/topic/esp-pppos" + help + MQTT topic, which we subscribe on and publish to. + + config EXAMPLE_MQTT_TEST_DATA + string "MQTT data to publish/receive" + default "esp32-pppos" + help + MQTT data message, which we publish and expect to receive. + endmenu diff --git a/components/esp_modem/examples/simple_cmux_client/main/simple_cmux_client_main.cpp b/components/esp_modem/examples/simple_cmux_client/main/simple_cmux_client_main.cpp index a1432b756..f1b8e8439 100644 --- a/components/esp_modem/examples/simple_cmux_client/main/simple_cmux_client_main.cpp +++ b/components/esp_modem/examples/simple_cmux_client/main/simple_cmux_client_main.cpp @@ -234,8 +234,8 @@ extern "C" void app_main(void) } std::cout << "Connected" << std::endl; - mqtt.subscribe("/topic/esp-modem"); - mqtt.publish("/topic/esp-modem", "Hello modem"); + mqtt.subscribe(CONFIG_EXAMPLE_MQTT_TEST_TOPIC); + mqtt.publish(CONFIG_EXAMPLE_MQTT_TEST_TOPIC, CONFIG_EXAMPLE_MQTT_TEST_DATA); if (!handler.wait_for(StatusHandler::MQTT_Data, 60000)) { ESP_LOGE(TAG, "Didn't receive published data within specified timeout... exiting"); return; diff --git a/components/esp_modem/examples/simple_cmux_client/pytest_cmux.py b/components/esp_modem/examples/simple_cmux_client/pytest_cmux.py index 208212838..af82e7798 100644 --- a/components/esp_modem/examples/simple_cmux_client/pytest_cmux.py +++ b/components/esp_modem/examples/simple_cmux_client/pytest_cmux.py @@ -1,4 +1,4 @@ -# 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 from __future__ import print_function, unicode_literals @@ -10,8 +10,17 @@ def test_cmux_connection(dut): 2. checks we get an IP 3. checks for the MQTT events """ + # Get topic and data from Kconfig + topic = '' + data = '' + try: + topic = dut.app.sdkconfig.get('EXAMPLE_MQTT_TEST_TOPIC') + data = dut.app.sdkconfig.get('EXAMPLE_MQTT_TEST_DATA') + except Exception: + print('ENV_TEST_FAILURE: Cannot find broker url in sdkconfig') + raise # Check the sequence of connecting, publishing, disconnecting dut.expect('Modem has correctly entered multiplexed') # Check for MQTT connection and the data event - dut.expect('TOPIC: /topic/esp-modem') - dut.expect('DATA: Hello modem') + dut.expect(f'TOPIC: {topic}') + dut.expect(f'DATA: {data}') diff --git a/components/esp_modem/examples/simple_cmux_client/sdkconfig.ci.sim800_cmux b/components/esp_modem/examples/simple_cmux_client/sdkconfig.ci.sim800_cmux index dcdb2f029..6bf623113 100644 --- a/components/esp_modem/examples/simple_cmux_client/sdkconfig.ci.sim800_cmux +++ b/components/esp_modem/examples/simple_cmux_client/sdkconfig.ci.sim800_cmux @@ -15,3 +15,4 @@ CONFIG_ESP32_PANIC_PRINT_HALT=y CONFIG_COMPILER_CXX_EXCEPTIONS=y CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 CONFIG_EXAMPLE_CLOSE_CMUX_AT_END=y +CONFIG_EXAMPLE_MQTT_TEST_TOPIC="/ci/esp-modem/pppos-client"