Skip to content

Commit f5c13b9

Browse files
committed
fix(modem): Examples: use local configs for MQTT topic/data
To avoid issues in CI, as we're using public server and could receive data by people playing with the example
1 parent f8ae7de commit f5c13b9

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

components/esp_modem/examples/simple_cmux_client/main/Kconfig.projbuild

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,16 @@ menu "Example Configuration"
129129
help
130130
URL of an mqtt broker which this example connects to.
131131

132+
config EXAMPLE_MQTT_TEST_TOPIC
133+
string "MQTT topic to publish/subscribe"
134+
default "/topic/esp-pppos"
135+
help
136+
MQTT topic, which we subscribe on and publish to.
137+
138+
config EXAMPLE_MQTT_TEST_DATA
139+
string "MQTT data to publish/receive"
140+
default "esp32-pppos"
141+
help
142+
MQTT data message, which we publish and expect to receive.
143+
132144
endmenu

components/esp_modem/examples/simple_cmux_client/main/simple_cmux_client_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ extern "C" void app_main(void)
234234
}
235235
std::cout << "Connected" << std::endl;
236236

237-
mqtt.subscribe("/topic/esp-modem");
238-
mqtt.publish("/topic/esp-modem", "Hello modem");
237+
mqtt.subscribe(CONFIG_EXAMPLE_MQTT_TEST_TOPIC);
238+
mqtt.publish(CONFIG_EXAMPLE_MQTT_TEST_TOPIC, CONFIG_EXAMPLE_MQTT_TEST_DATA);
239239
if (!handler.wait_for(StatusHandler::MQTT_Data, 60000)) {
240240
ESP_LOGE(TAG, "Didn't receive published data within specified timeout... exiting");
241241
return;

components/esp_modem/examples/simple_cmux_client/pytest_cmux.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
1+
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: Unlicense OR CC0-1.0
33
from __future__ import print_function, unicode_literals
44

@@ -10,8 +10,17 @@ def test_cmux_connection(dut):
1010
2. checks we get an IP
1111
3. checks for the MQTT events
1212
"""
13+
# Get topic and data from Kconfig
14+
topic = ''
15+
data = ''
16+
try:
17+
topic = dut.app.sdkconfig.get('EXAMPLE_MQTT_TEST_TOPIC')
18+
data = dut.app.sdkconfig.get('EXAMPLE_MQTT_TEST_DATA')
19+
except Exception:
20+
print('ENV_TEST_FAILURE: Cannot find broker url in sdkconfig')
21+
raise
1322
# Check the sequence of connecting, publishing, disconnecting
1423
dut.expect('Modem has correctly entered multiplexed')
1524
# Check for MQTT connection and the data event
16-
dut.expect('TOPIC: /topic/esp-modem')
17-
dut.expect('DATA: Hello modem')
25+
dut.expect(f'TOPIC: {topic}')
26+
dut.expect(f'DATA: {data}')

components/esp_modem/examples/simple_cmux_client/sdkconfig.ci.sim800_cmux

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ CONFIG_ESP32_PANIC_PRINT_HALT=y
1515
CONFIG_COMPILER_CXX_EXCEPTIONS=y
1616
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
1717
CONFIG_EXAMPLE_CLOSE_CMUX_AT_END=y
18+
CONFIG_EXAMPLE_MQTT_TEST_TOPIC="/ci/esp-modem/pppos-client"

0 commit comments

Comments
 (0)