mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-29 18:27:31 +02:00
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
This commit is contained in:
@ -129,4 +129,16 @@ menu "Example Configuration"
|
|||||||
help
|
help
|
||||||
URL of an mqtt broker which this example connects to.
|
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
|
endmenu
|
||||||
|
@ -234,8 +234,8 @@ extern "C" void app_main(void)
|
|||||||
}
|
}
|
||||||
std::cout << "Connected" << std::endl;
|
std::cout << "Connected" << std::endl;
|
||||||
|
|
||||||
mqtt.subscribe("/topic/esp-modem");
|
mqtt.subscribe(CONFIG_EXAMPLE_MQTT_TEST_TOPIC);
|
||||||
mqtt.publish("/topic/esp-modem", "Hello modem");
|
mqtt.publish(CONFIG_EXAMPLE_MQTT_TEST_TOPIC, CONFIG_EXAMPLE_MQTT_TEST_DATA);
|
||||||
if (!handler.wait_for(StatusHandler::MQTT_Data, 60000)) {
|
if (!handler.wait_for(StatusHandler::MQTT_Data, 60000)) {
|
||||||
ESP_LOGE(TAG, "Didn't receive published data within specified timeout... exiting");
|
ESP_LOGE(TAG, "Didn't receive published data within specified timeout... exiting");
|
||||||
return;
|
return;
|
||||||
|
@ -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
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
@ -10,8 +10,17 @@ def test_cmux_connection(dut):
|
|||||||
2. checks we get an IP
|
2. checks we get an IP
|
||||||
3. checks for the MQTT events
|
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
|
# Check the sequence of connecting, publishing, disconnecting
|
||||||
dut.expect('Modem has correctly entered multiplexed')
|
dut.expect('Modem has correctly entered multiplexed')
|
||||||
# Check for MQTT connection and the data event
|
# Check for MQTT connection and the data event
|
||||||
dut.expect('TOPIC: /topic/esp-modem')
|
dut.expect(f'TOPIC: {topic}')
|
||||||
dut.expect('DATA: Hello modem')
|
dut.expect(f'DATA: {data}')
|
||||||
|
@ -15,3 +15,4 @@ CONFIG_ESP32_PANIC_PRINT_HALT=y
|
|||||||
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192
|
||||||
CONFIG_EXAMPLE_CLOSE_CMUX_AT_END=y
|
CONFIG_EXAMPLE_CLOSE_CMUX_AT_END=y
|
||||||
|
CONFIG_EXAMPLE_MQTT_TEST_TOPIC="/ci/esp-modem/pppos-client"
|
||||||
|
Reference in New Issue
Block a user