### Build ESP-IDF PPP Example Source: https://github.com/espressif/esp-protocols/blob/master/components/net_connect/examples/ppp_connect_example/README.md Navigate to the example directory and build the PPP connect example using the idf.py tool. This command compiles the project for the ESP32. ```bash cd examples/ppp_connect_example idf.py build ``` -------------------------------- ### Flash and Monitor ESP-IDF Example Source: https://github.com/espressif/esp-protocols/blob/master/components/net_connect/examples/ppp_connect_example/README.md Flash the built example to the ESP32 and start the serial monitor. Ensure the pppd server is running on the host before or immediately after flashing. ```bash idf.py flash monitor ``` -------------------------------- ### Build and Flash Example Source: https://github.com/espressif/esp-protocols/blob/master/components/asio/examples/asio_chat/README.md Builds, flashes, and monitors the example on the ESP board. Ensure the correct port is specified. ```bash idf.py -p PORT flash monitor ``` -------------------------------- ### Build Example with idf.py Source: https://github.com/espressif/esp-protocols/blob/master/components/asio/examples/async_request/README.md This example requires no configuration and can be built directly using the idf.py build command. ```bash idf.py build ``` -------------------------------- ### Build and Run libsrtp Example Source: https://github.com/espressif/esp-protocols/blob/master/components/libsrtp/examples/get_started/README.md Builds and flashes the libsrtp example to a target device, then monitors its output. Ensure you set the target device first. ```bash idf.py set-target esp32p4 # or esp32, esp32s3, esp32c3, esp32c6 idf.py build idf.py -p flash monitor ``` -------------------------------- ### MQTT Connection Examples Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/examples/mqtt_ssl_auth_console/README.md Examples demonstrating various ways to connect to an MQTT broker, including different security configurations. ```APIDOC ## MQTT Connection Examples ### Connect without Validating the Broker (Insecure) ``` mqtt -h mqtts://test.mosquitto.org -C mqtt -h mqtts://mqtt.eclipseprojects.io -C ``` ### Validate the Broker using the Internal Certificate Bundle ``` mqtt -h mqtts://mqtt.eclipseprojects.io -C --use-internal-bundle mqtt -h mqtts://test.mosquitto.org -C --use-internal-bundle ``` ### Validate the Broker using a Provided CA Certificate ``` mqtt -h mqtts://test.mosquitto.org -C --cafile ``` ### SSL Mutual Authentication (Encrypted, Client Certificate Required) ``` mqtt -h mqtts://test.mosquitto.org:8884 -C --cert --key --cafile mqtt -h mqtts://test.mosquitto.org:8884 -C --cert --key --use-internal-bundle ``` ``` -------------------------------- ### Example Output Log Source: https://github.com/espressif/esp-protocols/blob/master/components/mdns/examples/query_advertise/README.md This is an example of the serial output you can expect when running the mDNS example. It shows system initialization, WiFi connection, and mDNS query results. ```log I (0) cpu_start: Starting scheduler on APP CPU. I (276) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE I (276) mdns-test: mdns hostname set to: [esp32-mdns] I (286) wifi: wifi driver task: 3ffc2fa4, prio:23, stack:3584, core=0 I (286) wifi: wifi firmware version: a3be639 I (286) wifi: config NVS flash: enabled I (296) wifi: config nano formating: disabled I (296) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE I (306) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE I (336) wifi: Init dynamic tx buffer num: 32 I (336) wifi: Init data frame dynamic rx buffer num: 32 I (336) wifi: Init management frame dynamic rx buffer num: 32 I (346) wifi: Init static rx buffer size: 1600 I (346) wifi: Init static rx buffer num: 10 I (346) wifi: Init dynamic rx buffer num: 32 I (356) mdns-test: Setting WiFi configuration SSID myssid... I (426) phy: phy_version: 4000, b6198fa, Sep 3 2018, 15:11:06, 0, 0 I (426) wifi: mode : sta (30:ae:a4:80:FF:FF) I (426) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (1756) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1 I (2736) wifi: state: init -> auth (b0) I (2756) wifi: state: auth -> assoc (0) I (2766) wifi: state: assoc -> run (10) I (2786) wifi: connected with myssid, channel 11 I (2786) wifi: pm start, type: 1 I (4786) event: sta ip: 192.168.0.139, mask: 255.255.255.0, gw: 192.168.0.2 I (21126) mdns-test: Query A: esp32.local W (23176) mdns-test: ESP_ERR_NOT_FOUND: Host was not found! I (23176) mdns-test: Query PTR: _arduino._tcp.local W (26276) mdns-test: No results found! I (26276) mdns-test: Query PTR: _http._tcp.local 1: Interface: STA, Type: V6 PTR : HP Color LaserJet MFP M277dw (7C2E10) SRV : NPI7C2E10.local:80 A : 254.128.0.0 2: Interface: STA, Type: V4 PTR : switch4e4919 SRV : switch4e4919.local:80 TXT : [1] path=/config/authentication_page.htm; A : 192.168.0.118 I (29396) mdns-test: Query PTR: _printer._tcp.local 1: Interface: STA, Type: V6 PTR : HP Color LaserJet MFP M277dw (7C2E10) SRV : NPI7C2E10.local:515 A : 254.128.0.0 2: Interface: STA, Type: V4 PTR : HP Color LaserJet MFP M277dw (7C2E10) ``` -------------------------------- ### Install Modem Simulator Component Source: https://github.com/espressif/esp-protocols/blob/master/common_components/modem_sim/README.md Run this script to install the modem simulator component. It sets up the necessary environment for building and using the component. ```bash cd common_components/modem_sim ./install.sh source export.sh idf.py build ``` -------------------------------- ### Basic Client Configuration Example Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/detailed_description.md Example of configuring and connecting a client using UART transport. Sets up network interface initialization, event loop, and specific UART parameters. ```c void app_main(void) { ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); eppp_config_t config = EPPP_DEFAULT_CLIENT_CONFIG(); config.transport = EPPP_TRANSPORT_UART; config.uart.tx_io = 25; config.uart.rx_io = 26; config.uart.baud = 921600; esp_netif_t *netif = eppp_connect(&config); if (netif == NULL) { ESP_LOGE(TAG, "Failed to connect"); return; } ESP_LOGI(TAG, "Connected successfully"); // Use network interface for communication } ``` -------------------------------- ### Install ppp on Linux Source: https://github.com/espressif/esp-protocols/blob/master/components/net_connect/examples/ppp_connect_example/README.md Install the ppp package on your Linux host machine. This is required to run the PPP server. ```bash # Ubuntu/Debian sudo apt-get install ppp # Fedora/RHEL sudo dnf install ppp ``` -------------------------------- ### Basic Server Configuration Example Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/detailed_description.md Example of configuring and setting up a server using UART transport. Includes network interface initialization, event loop, WiFi initialization, and specific UART parameters. ```c void app_main(void) { ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); // Initialize WiFi or other network interface init_wifi(); eppp_config_t config = EPPP_DEFAULT_SERVER_CONFIG(); config.transport = EPPP_TRANSPORT_UART; config.uart.tx_io = 26; // Crossed with client config.uart.rx_io = 25; // Crossed with client config.uart.baud = 921600; esp_netif_t *netif = eppp_listen(&config); if (netif == NULL) { ESP_LOGE(TAG, "Failed to setup server"); return; } // Enable NAT to share WiFi connection ESP_ERROR_CHECK(esp_netif_napt_enable(netif)); ESP_LOGI(TAG, "Server ready"); } ``` -------------------------------- ### Install Modem Simulator for Custom Platform Source: https://github.com/espressif/esp-protocols/blob/master/common_components/modem_sim/README.md Use this command to install the modem simulator for a specific platform and module, such as ESP32S3 with a WROOM-32 module. ```bash ./install.sh PLATFORM_ESP32S3 WROOM-32 ``` -------------------------------- ### Receiving MQTT Data Event Example Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/examples/mqtt_ssl_auth_console/README.md Example output showing the reception of data from an MQTT topic. ```APIDOC ## Receiving MQTT Data Event Example **Output:** ``` esp> I (999999) console_mqtt: MQTT_EVENT_DATA I (999999) console_mqtt: TOPIC=test0 I (999999) console_mqtt: DATA=Hello, Testing 123 ``` ``` -------------------------------- ### Example Output on ESP_PLATFORM Source: https://github.com/espressif/esp-protocols/blob/master/components/sock_utils/examples/simple/README.md This output shows network interface information and connection status when the example is run on an ESP platform. ```text I (8073) esp_netif_handlers: example_netif_sta ip: 192.168.0.32, mask: 255.255.255.0, gw: 192.168.0.1 I (8073) example_connect: Got IPv4 event: Interface "example_netif_sta" address: 192.168.0.32 I (8073) example_common: Connected to example_netif_sta I (8083) example_common: - IPv4 address: 192.168.0.32, I (8093) example_common: - IPv6 address: fe80:0000:0000:0000:XXXX, type: ESP_IP6_ADDR_IS_LINK_LOCAL I (8103) sock_utils_example: Received signal: IP4 I (8103) sock_utils_example: IPv4 address of interface "sta": 192.168.0.32 I (8113) main_task: Returned from app_main() ``` -------------------------------- ### Initialize and Start MQTT Console Commands Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/README.md Initialize the console command system, register all available plugin commands (including MQTT), and then start the console. Alternatively, only MQTT commands can be registered. ```c ESP_ERROR_CHECK(console_cmd_init()); // Initialize console // Register all plugin command added to your project ESP_ERROR_CHECK(console_cmd_all_register()); // To register only mqtt command skip calling console_cmd_all_register() ESP_ERROR_CHECK(console_cmd_mqtt_register()); ESP_ERROR_CHECK(console_cmd_start()); // Start console ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/examples/target/README.md Installs the necessary Python packages for the project. Ensure you have Python and pip installed. ```bash pip install -r esp-protocols/ci/requirements.txt ``` -------------------------------- ### MQTT Publish Example Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/examples/mqtt_ssl_auth_console/README.md Example of publishing a message to an MQTT topic. ```APIDOC ## MQTT Publish Example **Command:** ``` esp> mqtt_pub -t test0 -m "Hello, Testing 123" ``` **Output:** ``` I (999469) console_mqtt: Publish successful, msg_id=55776, topic=test0, data=Hello, Testing 123 I (1000009) console_mqtt: MQTT_EVENT_PUBLISHED, msg_id=55776 esp> ``` ``` -------------------------------- ### Initialize and Start Console Commands Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_ping/README.md Initializes, registers, and starts the console command interface. This includes registering all available plugin commands. ```c ESP_ERROR_CHECK(console_cmd_init()); // Initialize console // Register all plugin command added to your project ESP_ERROR_CHECK(console_cmd_all_register()); // To register only ping/dns command skip calling console_cmd_all_register() ESP_ERROR_CHECK(console_cmd_ping_register()); ESP_ERROR_CHECK(console_cmd_getaddrinfo_register()); ESP_ERROR_CHECK(console_cmd_setdnsserver_register()); ESP_ERROR_CHECK(console_cmd_getdnsserver_register()); ESP_ERROR_CHECK(console_cmd_start()); // Start console ``` -------------------------------- ### Initialize and Start Console Commands Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_ifconfig/README.md Initializes the console command system, registers all available plugin commands, and then starts the console. Alternatively, specific commands like ifconfig can be registered individually. ```c ESP_ERROR_CHECK(console_cmd_init()); // Initialize console // Register all plugin command added to your project ESP_ERROR_CHECK(console_cmd_all_register()); // To register only ifconfig command skip calling console_cmd_all_register() ESP_ERROR_CHECK(console_cmd_ifconfig_register()); ESP_ERROR_CHECK(console_cmd_start()); // Start console ``` -------------------------------- ### Start Autobahn Fuzzing Server Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/tests/autobahn-testsuite/README.md Use this command to start the Autobahn testsuite server and its web interface. Ensure you are in the 'autobahn-testsuite' directory. ```bash cd autobahn-testsuite docker-compose up -d ``` -------------------------------- ### Expected Output of PPP Connection Example Source: https://github.com/espressif/esp-protocols/blob/master/components/net_connect/examples/ppp_connect_example/README.md This log output shows the successful initialization and establishment of a PPP connection over USB CDC, including network interface details and IP address assignment. Ensure 'pppd' is running on the host machine for this example to succeed. ```log I (301) ppp_connect_example: Starting PPP connection example... I (301) ppp_connect_example: This example demonstrates PPP connection over serial I (311) ppp_connect_example: PPP device: USB CDC I (341) ppp_connect_example: Network stack initialized I (361) ppp_connect_example: IPv6 support enabled I (361) ppp_connect_example: Connecting to PPP server... I (361) ppp_connect_example: Make sure pppd is running on the host machine I (371) net_connect: Initializing PPP interface... I (371) example_connect_ppp: Start example_connect. I (381) example_connect_ppp: USB initialization W (381) tusb_desc: No Device descriptor provided, using default. W (391) tusb_desc: No FullSpeed configuration descriptor provided, using default. W (391) tusb_desc: No String descriptors provided, using default. I (401) tusb_desc: ┌─────────────────────────────────┐ │ USB Device Descriptor Summary │ ├───────────────────┬─────────────┤ │bDeviceClass │ 239 │ ├───────────────────┼─────────────┤ │bDeviceSubClass │ 2 │ ├───────────────────┼─────────────┤ │bDeviceProtocol │ 1 │ ├───────────────────┼─────────────┤ │bMaxPacketSize0 │ 64 │ ├───────────────────┼─────────────┤ │idVendor │ 0x303a │ ├───────────────────┼─────────────┤ │idProduct │ 0x4001 │ ├───────────────────┼─────────────┤ │bcdDevice │ 0x100 │ ├───────────────────┼─────────────┤ │iManufacturer │ 0x1 │ ├───────────────────┼─────────────┤ │iProduct │ 0x2 │ ├───────────────────┼─────────────┤ │iSerialNumber │ 0x3 │ ├───────────────────┼─────────────┤ │bNumConfigurations │ 0x1 │ └───────────────────┴─────────────┘ I (571) TinyUSB: TinyUSB Driver installed I (571) example_connect_ppp: Waiting for IP address I (9501) example_connect_ppp: Line state changed on channel 0 I (12601) esp-netif_lwip-ppp: net_connect_netif_ppp: Connected I (12601) example_connect_ppp: Got IPv6 event: Interface "net_connect_netif_ppp" address: fe80:0000:0000:0000:bcda:18a9:27fd:39e4, type: ESP_IP6_ADDR_IS_LINK_LOCAL I (12611) esp-netif_lwip-ppp: net_connect_netif_ppp: Connected I (12611) example_connect_ppp: Got IPv4 event: Interface "net_connect_netif_ppp" address: 192.168.11.2 I (12611) example_connect_ppp: Connected! I (12631) example_connect_ppp: Main DNS server : 8.8.8.8 I (12641) net_connect: PPP interface initialized successfully I (12641) net_connect: Connected to net_connect_netif_ppp I (12651) net_connect: - IPv4 address: 192.168.11.2, I (12651) net_connect: - IPv6 address: fe80:0000:0000:0000:bcda:18a9:27fd:39e4, type: ESP_IP6_ADDR_IS_LINK_LOCAL I (12661) ppp_connect_example: PPP connection established successfully! I (12671) ppp_connect_example: PPP netif retrieved: net_connect_netif_ppp I (12671) ppp_connect_example: IPv4 Address: 192.168.11.2 I (12681) ppp_connect_example: IPv4 Netmask: 255.255.255.255 I (12681) ppp_connect_example: IPv4 Gateway: 192.168.11.1 I (12691) ppp_connect_example: DNS Server: 8.8.8.8 I (12691) ppp_connect_example: IPv6 Address: fe80:0000:0000:0000:bcda:18a9:27fd:39e4 I (12701) ppp_connect_example: PPP connection active. Waiting 30 seconds... I (12711) ppp_connect_example: You can now test network connectivity from the ESP32 I (42721) ppp_connect_example: Disconnecting PPP connection... I (42721) net_connect: Disconnecting network interfaces... I (42721) net_connect: Deinitializing PPP interface... I (42721) net_connect: PPP interface deinitialized I (42721) net_connect: All network interfaces disconnected I (42731) ppp_connect_example: PPP connection disconnected successfully I (42741) ppp_connect_example: Example finished I (42741) main_task: Returned from app_main() ``` -------------------------------- ### Example Output on Linux Platform Source: https://github.com/espressif/esp-protocols/blob/master/components/sock_utils/examples/simple/README.md This output displays network interface details, including local and assigned IP addresses, when the example is run on a Linux system. ```text I[sock_utils_example]: Received signal: IP4 I[sock_utils_example]: IPv4 address of interface "lo": 127.0.0.1 I[sock_utils_example]: IPv4 address of interface "en0": 192.168.0.28 I[sock_utils_example]: IPv4 address of interface "docker0": 172.17.0.1 ``` -------------------------------- ### Flask WebSocket Echo Server Installation Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/examples/target/README.md Install the Flask-sock package required for running the Flask WebSocket echo server. ```bash pip install flask-sock ``` -------------------------------- ### Configure PPP Server Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/test/target_ota/README.md Use this command to start a PPP server on your host machine. Ensure the correct serial port and baud rate are specified. ```bash sudo pppd /dev/ttyUSB1 115200 192.168.11.1:192.168.11.2 ms-dns 8.8.8.8 modem local noauth debug nocrtscts nodetach +ipv6 ``` -------------------------------- ### CMake Project Setup for Asio Build Test Source: https://github.com/espressif/esp-protocols/blob/master/components/asio/tests/build_test/CMakeLists.txt Configures the minimum CMake version, includes the project setup script, and defines the project name. This is standard practice for CMake projects. ```cmake cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(asio_build_test) ``` -------------------------------- ### Install and Use mkcert for Local Certificates Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/examples/target/README.md Install mkcert and use it to generate local certificates. This is an alternative to manual OpenSSL commands for local development. ```bash install mkcert mkcert -install mkcert localhost ``` -------------------------------- ### Initialize and Register Console Commands Source: https://github.com/espressif/esp-protocols/blob/master/components/console_simple_init/README.md Initializes the console, registers a user-defined command, registers all plugin commands, and starts the console. ```c ESP_ERROR_CHECK(console_cmd_init()); // Initialize console // Define the function prototype for do_user_cmd // It's a function that takes an integer (argc) and a pointer to a pointer to char (argv) int do_user_cmd(int argc, char **argv); // Register the do_user_cmd function as a command callback function for "user" command // This allows you to execute the do_user_cmd function when the "user" command is invoked ESP_ERROR_CHECK(console_cmd_user_register("user", do_user_cmd)); // Register any other plugin command added to your project ESP_ERROR_CHECK(console_cmd_all_register()); ESP_ERROR_CHECK(console_cmd_start()); // Start console ``` -------------------------------- ### Example MQTT Broker Output Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/examples/broker/README.md This console output shows the typical logs when the MQTT broker example runs, including connection details and client activity. ```console I (477) main_task: Calling app_main() 0: mosquitto version 0.1.0 starting 0: Using default config. 0: Opening ipv4 listen socket on port 1883. 0: mosquitto version 0.1.0 running I (1507) test: Other event id:7 1: New connection from 127.0.0.1:56424 on port 1883. 1: New client connected from 127.0.0.1:56424 as ESP32_d58788 (p2, c1, k120). I (1528) mqtt_broker: MQTT_EVENT_CONNECTED I (1528) mqtt_broker: sent subscribe successful, msg_id=54859 I (1538) mqtt_broker: MQTT_EVENT_SUBSCRIBED, msg_id=54859 I (1538) mqtt_broker: sent publish successful, msg_id=0 I (1548) mqtt_broker: MQTT_EVENT_DATA I (1548) mqtt_broker: TOPIC=/topic/qos0 I (1548) mqtt_broker: DATA=data ``` -------------------------------- ### Start Mosquitto Broker on ESP32 Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/README.md Call this function with a configured settings structure to start the Mosquitto broker. Ensure the task has at least 4 kB of stack size. ```c mosq_broker_run(&config); ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/espressif/esp-protocols/blob/master/CONTRIBUTING.md Installs and configures pre-commit hooks for ensuring code quality and commit message standards. Run this command in your local repository. ```bash pip install pre-commit && pre-commit install-hooks && pre-commit install --hook-type commit-msg --hook-type pre-push ``` -------------------------------- ### MQTT Subscribe/Unsubscribe Example Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/examples/mqtt_ssl_auth_console/README.md Demonstrates how to subscribe to and unsubscribe from an MQTT topic. ```APIDOC ## MQTT Subscribe/Unsubscribe Example **Subscribe:** ``` esp> mqtt_sub -t test0 I (897289) console_mqtt: Subscribe successful, msg_id=57425, topic=test0 esp> I (897799) console_mqtt: MQTT_EVENT_SUBSCRIBED, msg_id=57425 esp> ``` **Unsubscribe:** ``` esp> mqtt_sub -U -t test0 I (902009) console_mqtt: Unsubscribe successful, msg_id=27663, topic=test0 esp> I (902509) console_mqtt: MQTT_EVENT_UNSUBSCRIBED, msg_id=27663 ``` ``` -------------------------------- ### Start PPP Network Interface Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/README.md Starts the network interface for the PPP link. This can be called after initial startup or to re-establish a connection if it's lost. ```c esp_eppp_link_netif_start(); ``` -------------------------------- ### Connect using Netcat Source: https://github.com/espressif/esp-protocols/blob/master/components/asio/examples/asio_chat/README.md An example of how to connect to the chat server using netcat. Messages are prefixed with their ASCII size. ```bash nc IP PORT 4ABC ``` -------------------------------- ### Register and Transmit on Channels Example Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/detailed_description.md Demonstrates registering channel callbacks and then transmitting data on a specific channel using the provided transmit function. ```c // Register channels eppp_channel_fn_t tx_func; eppp_add_channels(netif, &tx_func, channel_receive, user_context); // Transmit on specific channel tx_func(netif, 1, "Hello", 5); // Send to channel 1 ``` -------------------------------- ### Setup SLIP Interface Source: https://github.com/espressif/esp-protocols/blob/master/examples/esp_netif/slip_custom_netif/README.md Use this command to set up a SLIP interface on a Linux device. Ensure the serial port and baud rate match your hardware configuration. ```bash slattach -v -L -s 115200 -p slip /dev/ttyAMA0 ``` -------------------------------- ### Display Help for Commands Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/examples/mqtt_ssl_auth_console/README.md Use the 'help' command to view available commands or get details on a specific command. ```shell esp> help ``` ```shell help [] Print the summary of all registered commands if no arguments are given, otherwise print summary of given command. Name of command ``` ```shell mqtt [-CsD] [-h ] [-u ] [-P ] [--cert] [--key] [--cafile] mqtt command -C, --connect Connect to a broker (flag, no argument) -h, --host= Specify the host uri to connect to -s, --status Displays the status of the mqtt client (flag, no argument) -u, --username= Provide a username to be used for authenticating with the broker -P, --password= Provide a password to be used for authenticating with the broker --cert Define the PEM encoded certificate for this client, if required by the broker (flag, no argument) --key Define the PEM encoded private key for this client, if required by the broker (flag, no argument) --cafile Define the PEM encoded CA certificates that are trusted (flag, no argument) --use-internal-bundle Use the internal certificate bundle for TLS (flag, no argument) -D, --disconnect Disconnect from the broker (flag, no argument) ``` ```shell mqtt_pub [-t ] [-m ] mqtt publish command -t, --topic= Topic to Subscribe/Publish -m, --message= Message to Publish ``` ```shell mqtt_sub [-U] [-t ] mqtt subscribe command -t, --topic= Topic to Subscribe/Publish -U, --unsubscribe Unsubscribe from a topic ``` -------------------------------- ### MQTT Disconnect Example Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_mqtt/examples/mqtt_ssl_auth_console/README.md Example of how to disconnect the MQTT client from the broker. ```APIDOC ## MQTT Disconnect Example **Command:** ``` esp> mqtt -D ``` **Output:** ``` I (1189949) console_mqtt: mqtt client disconnected ``` ``` -------------------------------- ### Setup Dummy Network Interfaces Source: https://github.com/espressif/esp-protocols/blob/master/components/mdns/tests/host_test/README.md Configure two dummy network interfaces for use as source and destination addresses. Ensure the interface is brought up and multicast is enabled. ```bash sudo ip link add eth2 type dummy sudo ip addr add 192.168.1.200/24 dev eth2 sudo ip addr add 192.168.1.201/24 dev eth2 sudo ip link set eth2 up sudo ifconfig eth2 multicast ``` -------------------------------- ### Example Performance Summary Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/test/target_iperf/README.md This is an example of the network performance summary logged by pytest. It shows TCP and UDP throughput in Mbps. ```log 2023-11-29 18:28:25 INFO [Performance][tcp_tx_throughput]: 0.75 Mbps 2023-11-29 18:28:25 INFO [Performance][tcp_rx_throughput]: 0.70 Mbps 2023-11-29 18:28:25 INFO [Performance][udp_tx_throughput]: 0.73 Mbps 2023-11-29 18:28:25 INFO [Performance][udp_rx_throughput]: 0.70 Mbps ``` -------------------------------- ### Configure, Build, and Flash ESP-IDF Project Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/examples/target/README.md Configures the project using `menuconfig` (e.g., for WiFi/Ethernet and WebSocket URI), builds the project, and flashes it to the ESP32 device. Monitor the output using `idf.py monitor`. ```bash idf.py menuconfig # Configure WiFi/Ethernet and WebSocket URI idf.py build idf.py -p PORT flash monitor ``` -------------------------------- ### Main Project Setup and Unit Test Configuration Source: https://github.com/espressif/esp-protocols/blob/master/components/mdns/tests/host_unit_test/CMakeLists.txt Sets up the main project for the mDNS host unit test and configures the unit testing framework. It defines the UNIT_TESTS variable and enables testing if it's set. ```cmake project(mdns_host_unit_test C) # Set ENABLE_UNIT_TESTS with a default of OFF if(NOT DEFINED UNIT_TESTS) set(UNIT_TESTS "OFF" CACHE STRING "Unit tests: OFF, test_receiver, test_sender") else() set(ENABLE_UNIT_TESTS 1) message(STATUS "Unit testing enabled with UNIT_TESTS=${UNIT_TESTS}") endif() ``` -------------------------------- ### Initialize and Listen as PPP Server Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/README.md Use this simplified API to initialize the PPP server, start its task, and block until a client connects. Ensure the transport layer and network interface are configured beforehand. ```c #include "esp_netif.h" #include "esp_netif_ppp.h" #include "esp_eppp_link.h" void app_main(void) { // ... initialization ... esp_eppp_link_listen(); // ... application logic ... } ``` -------------------------------- ### Start mDNS Service with Hostname and Instance Source: https://github.com/espressif/esp-protocols/blob/master/docs/mdns/en/index.rst Initializes the mDNS service and sets the hostname and default instance name for the device. Ensure mDNS is initialized before setting hostnames or advertising services. ```c void start_mdns_service() { //initialize mDNS service esp_err_t err = mdns_init(); if (err) { printf("MDNS Init failed: %d\n", err); return; } //set hostname mdns_hostname_set("my-{IDF_TARGET_PATH_NAME}"); //set default instance mdns_instance_name_set("Jhon's {IDF_TARGET_NAME} Thing"); } ``` -------------------------------- ### Example Conventional Commit Message Source: https://github.com/espressif/esp-protocols/blob/master/CONTRIBUTING.md An example of a commit message following the conventional commits format, specifying the type, scope, and a descriptive message. ```text feat(console): Added fully operational ifconfig command ``` -------------------------------- ### Start Mosquitto Broker Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/api.md Starts the Mosquitto broker in the current thread. This function blocks until the broker is stopped. It requires a configuration structure as input. ```c int mosq_broker_run ( struct mosq_broker_config *config ) ``` -------------------------------- ### Create a Basic Custom Module in C++ Source: https://github.com/espressif/esp-protocols/blob/master/docs/esp_modem/en/customization.rst This example demonstrates how to create a custom modem module by inheriting from the GenericModule class. It shows how to add a new command 'get_custom_info' and override the existing 'get_signal_quality' command. ```cpp #include "cxx_include/esp_modem_api.hpp" #include "cxx_include/esp_modem_command_library_utils.hpp" class MyCustomModule: public GenericModule { using GenericModule::GenericModule; public: // Add a new command command_result get_custom_info(std::string &info) { return esp_modem::dce_commands::generic_get_string( dte.get(), "AT+CUSTOM?\r", info); } // Override an existing command command_result get_signal_quality(int &rssi, int &ber) override { // Custom implementation return esp_modem::dce_commands::generic_get_string( dte.get(), "AT+CSQ\r", rssi, ber); } }; ``` -------------------------------- ### Initialize and Connect as PPP Client Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/README.md Use this simplified API to initialize the PPP client, start its task, and block until a connection is established. Ensure the transport layer and network interface are configured beforehand. ```c #include "esp_netif.h" #include "esp_netif_ppp.h" #include "esp_eppp_link.h" void app_main(void) { // ... initialization ... esp_eppp_link_connect(); // ... application logic ... } ``` -------------------------------- ### ESP Websocket Client Example Output Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/examples/linux/README.md Log output from the ESP websocket client example demonstrating connection, data reception, and sending messages. ```log I (76826192) websocket: [APP] Startup.. I (76826193) websocket: [APP] Free memory: 4294967295 bytes I (76826193) websocket: [APP] IDF version: v6.0-dev-2414-gab3feab1d13 I (76826195) websocket: Connecting to wss://echo.websocket.org... W (76826195) websocket_client: `reconnect_timeout_ms` is not set, or it is less than or equal to zero, using default time out 10000 (milliseconds) W (76826195) websocket_client: `network_timeout_ms` is not set, or it is less than or equal to zero, using default time out 10000 (milliseconds) I (76826195) websocket: WEBSOCKET_EVENT_BEGIN I (76826196) websocket_client: Started I (76826294) esp-x509-crt-bundle: Certificate validated I (76827230) websocket: WEBSOCKET_EVENT_CONNECTED I (76827239) websocket: WEBSOCKET_EVENT_DATA I (76827239) websocket: Received opcode=1 W (76827239) websocket: Received=Request served by 4d896d95b55478 W (76827239) websocket: Total payload length=32, data_len=32, current payload offset=0 I (76828198) websocket: Sending hello 0000 I (76828827) websocket: WEBSOCKET_EVENT_DATA I (76828827) websocket: Received opcode=1 W (76828827) websocket: Received=hello 0000 W (76828827) websocket: Total payload length=10, data_len=10, current payload offset=0 I (76829207) websocket: Sending fragmented text message ``` -------------------------------- ### Create Ethernet Interface Source: https://github.com/espressif/esp-protocols/blob/master/components/console_cmd_ifconfig/README.md Demonstrates the console commands to initialize an ethernet interface and then create a network interface associated with it. ```shell esp> ifconfig eth init Internal(IP101): pins: 23,18, Id: 0 esp> ifconfig netif create 0 ``` -------------------------------- ### Manual Network Interface Start and Stop Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/detailed_description.md Provides functions for manually starting and stopping the network interface. Useful for dynamic connection management and error recovery scenarios. ```c esp_err_t eppp_netif_start(esp_netif_t *netif); esp_err_t eppp_netif_stop(esp_netif_t *netif, int stop_timeout_ms); ``` -------------------------------- ### View ESP-TLS Documentation Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/examples/broker/README.md Use this command to view the ESP-TLS documentation for setting up TLS configuration, including certificates and keys. ```bash idf.py docs -sp api-reference/protocols/esp_tls.html ``` -------------------------------- ### Websocket Client Example Output Source: https://github.com/espressif/esp-protocols/blob/master/components/libwebsockets/examples/client/README.md Serial output from the LWS websocket client example, showing connection status, data transmission, and received messages. This output is for demonstration purposes. ```text I (18208) lws-client: LWS minimal ws client echo 219868: lws_create_context: LWS: 4.3.99-v4.3.0-424-ga74362ff, MbedTLS-3.6.2 NET CLI SRV H1 H2 WS SS-JSON-POL ConMon IPv6-absent 219576: mem: platform fd map: 20 bytes 217880: __lws_lc_tag: ++ [wsi|0|pipe] (1) 216516: __lws_lc_tag: ++ [vh|0|default||-1] (1) I (18248) lws-client: connect_cb: connecting 210112: __lws_lc_tag: ++ [wsicli|0|WS/h1/default/echo.websocket.org] (1) 204800: [wsicli|0|WS/h1/default/echo.websocket.org]: lws_client_connect_3_connect: trying 13.248.241.119 180776: lws_ssl_client_bio_create: allowing selfsigned I (19998) wifi:idx:0 (ifx:0, b4:89:01:63:9d:08), tid:0, ssn:321, winSize:64 I (20768) lws-client: WEBSOCKET_EVENT_CONNECTED I (20768) lws-client: Sending hello 0000 I (20778) lws-client: WEBSOCKET_EVENT_DATA W (20778) lws-client: Received=echo.websocket.org sponsored by Lob.com I (20968) lws-client: WEBSOCKET_EVENT_DATA W (20968) lws-client: Received=hello 0000 I (22978) lws-client: Sending hello 0001 I (23118) lws-client: WEBSOCKET_EVENT_DATA W (23118) lws-client: Received=hello 0001 I (23778) lws-client: Sending hello 0002 I (23938) lws-client: WEBSOCKET_EVENT_DATA W (23938) lws-client: Received=hello 0002 I (25948) lws-client: Sending hello 0003 I (26088) lws-client: WEBSOCKET_EVENT_DATA W (26088) lws-client: Received=hello 0003 I (26948) lws-client: Sending hello 0004 I (27118) lws-client: WEBSOCKET_EVENT_DATA W (27118) lws-client: Received=hello 0004 ``` -------------------------------- ### URC Handler Logic Example Source: https://github.com/espressif/esp-protocols/blob/master/docs/esp_modem/en/advanced_api.rst An example of an enhanced URC handler function. It receives URC buffer information and returns consumption details, allowing for precise control over buffer management. ```cpp esp_modem::DTE::UrcConsumeInfo MyDte::my_urc_handler(const esp_modem::DTE::UrcBufferInfo &urc_buffer_info, const char *urc_str) { // Process URC and decide how much to consume if (is_complete_http_chunk(urc_buffer_info)) { return esp_modem::DTE::UrcConsumeInfo(true); } return esp_modem::DTE::UrcConsumeInfo(false); } ``` -------------------------------- ### Run 'help' command Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/examples/modem_console/README.md Use the 'help' command to see the list of supported commands for the modem device. ```shell help ``` -------------------------------- ### ESP32 WebSocket Client Example Output Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_websocket_client/examples/target/README.md Example output from an ESP32 WebSocket client connecting to a server and exchanging messages. Shows connection status, IP addresses, and message exchange. ```text I (482) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE I (2492) example_connect: Ethernet Link Up I (4472) tcpip_adapter: eth ip: 192.168.2.137, mask: 255.255.255.0, gw: 192.168.2.2 I (4472) example_connect: Connected to Ethernet I (4472) example_connect: IPv4 address: 192.168.2.137 I (4472) example_connect: IPv6 address: fe80:0000:0000:0000:bedd:c2ff:fed4:a92b I (4482) WEBSOCKET: Connecting to wss://echo.websocket.org... I (5012) WEBSOCKET: WEBSOCKET_EVENT_CONNECTED I (5492) WEBSOCKET: Sending hello 0000 I (6052) WEBSOCKET: WEBSOCKET_EVENT_DATA W (6052) WEBSOCKET: Received=hello 0000 I (6492) WEBSOCKET: Sending hello 0001 I (7052) WEBSOCKET: WEBSOCKET_EVENT_DATA W (7052) WEBSOCKET: Received=hello 0001 I (7492) WEBSOCKET: Sending hello 0002 I (8082) WEBSOCKET: WEBSOCKET_EVENT_DATA W (8082) WEBSOCKET: Received=hello 0002 I (8492) WEBSOCKET: Sending hello 0003 I (9152) WEBSOCKET: WEBSOCKET_EVENT_DATA W (9162) WEBSOCKET: Received=hello 0003 ``` -------------------------------- ### Project Initialization Source: https://github.com/espressif/esp-protocols/blob/master/examples/mqtt/CMakeLists.txt Sets the minimum CMake version required and defines the project name for the ESP-MQTT demo. ```cmake cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(esp_mqtt_demo) ``` -------------------------------- ### Channel Receive Handler Example Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/detailed_description.md An example implementation of a channel receive callback function. It processes incoming data based on the channel number, forwarding control messages or WiFi data. ```c // Channel 0: Default network traffic (handled automatically) // Channel 1: Control/chat messages // Channel 2: WiFi data forwarding static esp_err_t channel_receive(esp_netif_t *netif, int channel, void *buffer, size_t len) { switch(channel) { case 1: // Control channel process_control_message(buffer, len); break; case 2: // WiFi channel forward_to_wifi(buffer, len); break; default: ESP_LOGE(TAG, "Unknown channel %d", channel); return ESP_FAIL; } return ESP_OK; } ``` -------------------------------- ### Registering a Component with Source Files Source: https://github.com/espressif/esp-protocols/blob/master/components/asio/tests/unit/main/CMakeLists.txt Use this macro to register a component, specifying source files, required components, and include directories. Ensure all paths are relative to the component directory. ```c idf_component_register(SRCS "test_asio_ssl.cpp" # REQUIRES test_utils INCLUDE_DIRS ".") # PRIV_REQUIRES unity asio) ``` -------------------------------- ### Conditional ESP-PEER Setup in CMake Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/examples/serverless_mqtt/CMakeLists.txt This snippet sets up ESP-PEER from a GitHub repository, but it's only supported on specific targets. It includes a check for compatible targets and executes a setup script if supported. ```cmake set(ESP_PEER_COMPATIBLE_TARGETS "esp32s2" "esp32s3" "esp32p4" "esp32") if(IDF_TARGET IN_LIST ESP_PEER_COMPATIBLE_TARGETS) execute_process(COMMAND ${CMAKE_BINARY_DIR}/../esp_peer_setup/install.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} RESULT_VARIABLE script_result) if(script_result) message(FATAL_ERROR "Script esp_peer_setup.sh failed with exit code ${script_result}") endif() list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_BINARY_DIR}/esp-peer/components/") else() message(STATUS "ESP-PEER is not compatible with this target") endif() project(serverless_mqtt) ``` -------------------------------- ### Build and Run ESP-IDF Project Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/test/target_urc/README.md Standard commands to build, flash, and monitor an ESP-IDF project. Ensure your environment is set up correctly before running. ```bash idf.py build idf.py flash monitor ``` -------------------------------- ### Generate all default ESP-MODEM files Source: https://github.com/espressif/esp-protocols/blob/master/docs/esp_modem/en/development.rst Run the main generate script to create all default source files for ESP-MODEM. ```bash ./scripts/generate.sh ``` -------------------------------- ### Basic ESP-IDF CMake Project Setup Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/examples/linux_modem/CMakeLists.txt This snippet shows the fundamental CMake configuration for an ESP-IDF project targeting Linux. It includes setting the minimum CMake version, including project setup scripts, defining extra component directories, and specifying the main components. ```cmake cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) set(EXTRA_COMPONENT_DIRS ../../port/linux) set(COMPONENTS main) project(linux_modem) ``` -------------------------------- ### ESP-IDF CMake Boilerplate Setup Source: https://github.com/espressif/esp-protocols/blob/master/components/eppp_link/test/test_app/CMakeLists.txt This boilerplate must be included in your project's CMakeLists.txt in the specified order for CMake to function correctly with ESP-IDF. It sets the minimum CMake version, includes project setup scripts, and configures test component directories based on the IDF version. ```cmake cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "6.0") set(test_component_dir $ENV{IDF_PATH}/tools/test_apps/components) else() set(test_component_dir $ENV{IDF_PATH}/tools/unit-test-app/components) endif() set(EXTRA_COMPONENT_DIRS ${test_component_dir}) project(test_app) ``` -------------------------------- ### HTTP GET command Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/examples/modem_console/README.md The 'httpget' command connects to a specified URL and retrieves its content. ```shell httpget ``` -------------------------------- ### Configure Build for ESP32 Roles Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/examples/serverless_mqtt/README.md Use this command to configure, build, and flash one of the ESP32 devices. Ensure you specify unique build directories and SDK configurations for each role (PEER1 and PEER2) if using libjuice. ```bash idf.py -B build1 -DSDKCONFIG=build1/sdkconfig menuconfig build flash monitor ``` -------------------------------- ### mosq_broker_run Source: https://github.com/espressif/esp-protocols/blob/master/components/mosquitto/api.md Starts the Mosquitto broker. This function is blocking and will run the broker in the calling thread until it exits. ```APIDOC ## function `mosq_broker_run` _Start mosquitto broker._ ```c int mosq_broker_run ( struct mosq_broker_config *config ) ``` This API runs the broker in the calling thread and blocks until the mosquitto exits. **Parameters:** * `config` Mosquitto configuration structure **Returns:** int Exit code (0 on success) ``` -------------------------------- ### Build and Run Host Test App Source: https://github.com/espressif/esp-protocols/blob/master/components/esp_modem/test/host_test_app/README.md Commands to build the modem simulator and the test application, followed by instructions to run both. Environment variables MODEM_SIM_PORT and TEST_TIMEOUT can be used to override default values. ```bash # 1. Build the modem simulator (plain CMake, no IDF) cmake -S modem_sim -B modem_sim/build && cmake --build modem_sim/build # 2. Build the test app (IDF, Linux target) source $IDF_PATH/export.sh idf.py --preview set-target linux idf.py build # 3. Run both (simulator + tests) ./run_test.sh ```