diff --git a/components/esp_modem/examples/pppos_client/main/Kconfig.projbuild b/components/esp_modem/examples/pppos_client/main/Kconfig.projbuild index 65243a0b5..0c61114fd 100644 --- a/components/esp_modem/examples/pppos_client/main/Kconfig.projbuild +++ b/components/esp_modem/examples/pppos_client/main/Kconfig.projbuild @@ -184,4 +184,22 @@ menu "Example Configuration" endmenu + config EXAMPLE_MQTT_BROKER_URI + string "MQTT Broker URL" + default "mqtt://mqtt.eclipseprojects.io" + help + URL of the 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/pppos_client/main/pppos_client_main.c b/components/esp_modem/examples/pppos_client/main/pppos_client_main.c index 99f669efe..b073847b9 100644 --- a/components/esp_modem/examples/pppos_client/main/pppos_client_main.c +++ b/components/esp_modem/examples/pppos_client/main/pppos_client_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -30,7 +30,6 @@ #define EXAMPLE_FLOW_CONTROL ESP_MODEM_FLOW_CONTROL_HW #endif -#define BROKER_URL "mqtt://mqtt.eclipseprojects.io" static const char *TAG = "pppos_example"; static EventGroupHandle_t event_group = NULL; @@ -68,7 +67,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_ switch ((esp_mqtt_event_id_t)event_id) { case MQTT_EVENT_CONNECTED: ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED"); - msg_id = esp_mqtt_client_subscribe(client, "/topic/esp-pppos", 0); + msg_id = esp_mqtt_client_subscribe(client, CONFIG_EXAMPLE_MQTT_TEST_TOPIC, 0); ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id); break; case MQTT_EVENT_DISCONNECTED: @@ -76,7 +75,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_ 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/esp-pppos", "esp32-pppos", 0, 0, 0); + msg_id = esp_mqtt_client_publish(client, CONFIG_EXAMPLE_MQTT_TEST_TOPIC, CONFIG_EXAMPLE_MQTT_TEST_DATA, 0, 0, 0); ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id); break; case MQTT_EVENT_UNSUBSCRIBED: @@ -271,11 +270,11 @@ void app_main(void) /* Config MQTT */ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) esp_mqtt_client_config_t mqtt_config = { - .broker.address.uri = BROKER_URL, + .broker.address.uri = CONFIG_EXAMPLE_MQTT_BROKER_URI, }; #else esp_mqtt_client_config_t mqtt_config = { - .uri = BROKER_URL, + .uri = CONFIG_EXAMPLE_MQTT_BROKER_URI, }; #endif esp_mqtt_client_handle_t mqtt_client = esp_mqtt_client_init(&mqtt_config); diff --git a/components/esp_modem/examples/pppos_client/pytest_pppos_client.py b/components/esp_modem/examples/pppos_client/pytest_pppos_client.py index 74a45ad2e..2ffb42cab 100644 --- a/components/esp_modem/examples/pppos_client/pytest_pppos_client.py +++ b/components/esp_modem/examples/pppos_client/pytest_pppos_client.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 from __future__ import print_function, unicode_literals @@ -16,7 +16,7 @@ def test_pppos_connect(dut): # Check for MQTT connection and the data event dut.expect('MQTT_EVENT_CONNECTED') dut.expect('MQTT_EVENT_DATA') - dut.expect('TOPIC=/topic/esp-pppos') + dut.expect('TOPIC=/ci/esp-modem/pppos-client') dut.expect('DATA=esp32-pppos') # Check that we have disconnected dut.expect('User interrupted event') diff --git a/components/esp_modem/examples/pppos_client/sdkconfig.ci.sim800 b/components/esp_modem/examples/pppos_client/sdkconfig.ci.sim800 index 98ab7b4be..e06bbd229 100644 --- a/components/esp_modem/examples/pppos_client/sdkconfig.ci.sim800 +++ b/components/esp_modem/examples/pppos_client/sdkconfig.ci.sim800 @@ -9,5 +9,6 @@ CONFIG_EXAMPLE_MODEM_UART_RX_PIN=5 CONFIG_EXAMPLE_MODEM_DEVICE_SIM800=y CONFIG_EXAMPLE_MODEM_DEVICE_BG96=n CONFIG_EXAMPLE_MODEM_PPP_APN="lpwa.vodafone.com" +CONFIG_EXAMPLE_MQTT_TEST_TOPIC="/ci/esp-modem/pppos-client" CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y CONFIG_ESP32_PANIC_PRINT_HALT=y