### Check for lwipcfg.h Configuration File Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/win32/example_app/CMakeLists.txt Checks if the 'lwipcfg.h' file exists in the example application directory. If not, it issues a warning suggesting to copy and edit the example configuration file. ```cmake if(NOT EXISTS ${LWIP_DIR}/contrib/examples/example_app/lwipcfg.h) message(WARNING "${LWIP_DIR}/contrib/examples/example_app is missing lwipcfg.h Copy ${LWIP_DIR}/contrib/examples/example_app/lwipcfg.h.example to ${LWIP_DIR}/contrib/examples/example_app/lwipcfg.h and edit appropriately") endif() ``` -------------------------------- ### PPP Notify Phase Callback Example Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt A callback function that is invoked on each PPP internal state change. This example demonstrates setting an LED pattern based on the PPP session's current phase, such as initializing, running, or dead states. ```c static void ppp_notify_phase_cb(ppp_pcb *pcb, u8_t phase, void *ctx) { switch (phase) { /* Session is down (either permanently or briefly) */ case PPP_PHASE_DEAD: led_set(PPP_LED, LED_OFF); break; /* We are between two sessions */ case PPP_PHASE_HOLDOFF: led_set(PPP_LED, LED_SLOW_BLINK); break; /* Session just started */ case PPP_PHASE_INITIALIZE: led_set(PPP_LED, LED_FAST_BLINK); break; /* Session is running */ case PPP_PHASE_RUNNING: led_set(PPP_LED, LED_ON); break; default: break; } } ``` -------------------------------- ### MDNS Service TXT Record Callback Example Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt An example callback function to generate TXT records for an MDNS service. It adds a "path=/" record. Ensure individual TXT items are max 63 bytes and total length is under 255 bytes. ```c static void srv_txt(struct mdns_service *service, void *txt_userdata) { res = mdns_resp_add_service_txtitem(service, "path=/", 6); LWIP_ERROR("mdns add service txt failed\n", (res == ERR_OK), return); } ``` -------------------------------- ### Add 'example_app' Executable Target Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/win32/example_app/CMakeLists.txt Defines the 'example_app' executable, setting its source files, include directories, compiler options, and linked libraries. This target is used for the example application. ```cmake add_executable(example_app ${LWIP_DIR}/contrib/examples/example_app/test.c default_netif.c) target_include_directories(example_app PRIVATE ${LWIP_INCLUDE_DIRS}) target_compile_options(example_app PRIVATE ${LWIP_COMPILER_FLAGS}) target_compile_definitions(example_app PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS}) target_link_libraries(example_app ${LWIP_SANITIZER_LIBS} lwipallapps lwipcontribexamples lwipcontribapps lwipcontribaddons lwipcontribportwindows lwipcore lwipmbedtls) ``` -------------------------------- ### PPP Status Callback Example Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Callback function to handle PPP status changes. It prints connection status and IP information. Called from the lwIP core thread. ```c static void status_cb(ppp_pcb *pcb, int err_code, void *ctx) { struct netif *pppif = ppp_netif(pcb); LWIP_UNUSED_ARG(ctx); switch(err_code) { case PPPERR_NONE: { #if LWIP_DNS const ip_addr_t *ns; #endif /* LWIP_DNS */ printf("status_cb: Connected\n"); #if PPP_IPV4_SUPPORT printf(" our_ipaddr = %s\n", ipaddr_ntoa(&pppif->ip_addr)); printf(" his_ipaddr = %s\n", ipaddr_ntoa(&pppif->gw)); printf(" netmask = %s\n", ipaddr_ntoa(&pppif->netmask)); #if LWIP_DNS ns = dns_getserver(0); printf(" dns1 = %s\n", ipaddr_ntoa(ns)); ns = dns_getserver(1); printf(" dns2 = %s\n", ipaddr_ntoa(ns)); #endif /* LWIP_DNS */ #endif /* PPP_IPV4_SUPPORT */ #if PPP_IPV6_SUPPORT printf(" our6_ipaddr = %s\n", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); #endif /* PPP_IPV6_SUPPORT */ break; } case PPPERR_PARAM: { printf("status_cb: Invalid parameter\n"); break; } case PPPERR_OPEN: { printf("status_cb: Unable to open PPP session\n"); break; } case PPPERR_DEVICE: { printf("status_cb: Invalid I/O device for PPP\n"); break; } case PPPERR_ALLOC: { printf("status_cb: Unable to allocate resources\n"); break; } case PPPERR_USER: { printf("status_cb: User interrupt\n"); break; } case PPPERR_CONNECT: { printf("status_cb: Connection lost\n"); break; } case PPPERR_AUTHFAIL: { printf("status_cb: Failed authentication challenge\n"); break; } case PPPERR_PROTOCOL: { printf("status_cb: Failed to meet protocol\n"); break; } case PPPERR_PEERDEAD: { printf("status_cb: Connection timeout\n"); break; } case PPPERR_IDLETIMEOUT: { printf("status_cb: Idle Timeout\n"); break; } case PPPERR_CONNECTTIME: { printf("status_cb: Max connect time reached\n"); break; } case PPPERR_LOOPBACK: { printf("status_cb: Loopback detected\n"); break; } default: { printf("status_cb: Unknown error code %d\n", err_code); break; } } /* * This should be in the switch case, this is put outside of the switch * case for example readability. */ if (err_code == PPPERR_NONE) { return; } /* ppp_close() was previously called, don't reconnect */ if (err_code == PPPERR_USER) { /* ppp_free(); -- can be called here */ return; } /* * Try to reconnect in 30 seconds, if you need a modem chatscript you have * to do a much better signaling here ;-) */ ppp_connect(pcb, 30); /* OR ppp_listen(pcb); */ } ``` -------------------------------- ### MDNS Responder Initialization and Netif Registration Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Initialize the MDNS responder and register a network interface to start responding to mDNS queries. ```APIDOC ## MDNS Responder Initialization and Netif Registration ### Initialize MDNS Responder Call `mdns_resp_init()` during system initialization to open UDP sockets on port 5353 for IPv4 and IPv6. ### Register Netif To start responding on a netif, run: ```c mdns_resp_add_netif(struct netif *netif, const char *hostname) ``` This function copies the hostname, joins multicast groups, and handles mDNS/DNS requests for the specified netif. It answers queries for `.local` (A, AAAA, ANY) and reverse lookups. ### Announce IP Address Change Call `mdns_resp_announce()` whenever the IP address on the netif changes. ### Restart MDNS Responder Call `mdns_resp_restart()` when the network interface comes back up after being down (e.g., cable connected, interface administratively enabled, or device wakes from sleep). ### Remove Netif To stop responding on a netif, run: ```c mdns_resp_remove_netif(struct netif *netif) ``` ``` -------------------------------- ### MQTT Client Initialization and Connection Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt Demonstrates how to initialize an MQTT client, either statically or dynamically, and establish a connection to an MQTT server. Ensure MEMP_NUM_SYS_TIMEOUT is increased by one. ```c mqtt_client_t static_client; example_do_connect(&static_client); ``` ```c mqtt_client_t *client = mqtt_client_new(); if(client != NULL) { example_do_connect(&client); } ``` ```c void example_do_connect(mqtt_client_t *client) { struct mqtt_connect_client_info_t ci; err_t err; /* Setup an empty client info structure */ memset(&ci, 0, sizeof(ci)); /* Minimal amount of information required is client identifier, so set it here */ ci.client_id = "lwip_test"; /* Initiate client and connect to server, if this fails immediately an error code is returned otherwise mqtt_connection_cb will be called with connection result after attempting to establish a connection with the server. For now MQTT version 3.1.1 is always used */ err = mqtt_client_connect(client, ip_addr, MQTT_PORT, mqtt_connection_cb, 0, &ci); /* For now just print the result code if something goes wrong */ if(err != ERR_OK) { printf("mqtt_connect return %d\n", err); } } ``` -------------------------------- ### Build example_app Executable with lwIP Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/unix/example_app/CMakeLists.txt Adds the 'example_app' executable, linking it with necessary lwIP libraries and setting compile options and definitions. ```cmake add_executable(example_app ${LWIP_DIR}/contrib/examples/example_app/test.c default_netif.c) target_include_directories(example_app PRIVATE ${LWIP_INCLUDE_DIRS}) target_compile_options(example_app PRIVATE ${LWIP_COMPILER_FLAGS}) target_compile_definitions(example_app PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS}) target_link_libraries(example_app ${LWIP_SANITIZER_LIBS} lwipcontribexamples lwipcontribapps lwipcontribaddons lwipallapps lwipcontribportunix lwipcore lwipmbedtls ``` -------------------------------- ### Configure lwIP Include Directories Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/unix/example_app/CMakeLists.txt Sets the include directories for lwIP. Ensure LWIP_DIR is correctly defined in your CMakeLists.txt. ```cmake set (LWIP_INCLUDE_DIRS "${LWIP_DIR}/src/include" "${LWIP_DIR}/contrib/" "${LWIP_DIR}/contrib/ports/unix/port/include" "${LWIP_DIR}/contrib/examples/example_app" ) ``` -------------------------------- ### Configure PPP Client DNS and Authentication Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Configures the PPP client to request DNS server addresses from the peer and sets up authentication credentials. These settings can only be applied when the PPP session is in the dead state. ```c ppp_set_usepeerdns(ppp, 1); ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "login", "password"); ``` -------------------------------- ### Configure lwIP Include Directories Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/win32/example_app/CMakeLists.txt Sets the include directories for the lwIP project. Ensure these paths are correctly set relative to the LWIP_DIR variable. ```cmake set (LWIP_INCLUDE_DIRS "${LWIP_DIR}/src/include" "${LWIP_DIR}/contrib/" "${LWIP_DIR}/contrib/ports/win32/include" "${LWIP_DIR}/contrib/examples/example_app" ) ``` -------------------------------- ### Initiate PPP Server Listener Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Initiates a PPP server listener, causing it to wait for incoming connections. This function can only be called when the PPP session is disconnected. ```c ppp_listen(ppp); ``` -------------------------------- ### PPP Server Listener API Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt APIs for configuring and initiating a PPP server listener. ```APIDOC ## PPP Server Listener API ### Description APIs to configure and initiate a PPP server listener. ### Method `ppp_set_ipcp_ouraddr`, `ppp_set_ipcp_hisaddr`, `ppp_set_ipcp_dnsaddr`, `ppp_set_auth`, `ppp_set_auth_required`, `ppp_set_silent`, `ppp_listen` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c ip4_addr_t addr; IP4_ADDR(&addr, 192,168,0,1); ppp_set_ipcp_ouraddr(ppp, &addr); IP4_ADDR(&addr, 192,168,0,2); ppp_set_ipcp_hisaddr(ppp, &addr); IP4_ADDR(&addr, 192,168,10,20); ppp_set_ipcp_dnsaddr(ppp, 0, &addr); IP4_ADDR(&addr, 192,168,10,21); ppp_set_ipcp_dnsaddr(ppp, 1, &addr); ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "login", "password"); ppp_set_auth_required(ppp, 1); ppp_set_silent(pppos, 1); ppp_listen(ppp); ``` ### Response #### Success Response (200) Initiates the PPP listener. #### Response Example None ``` -------------------------------- ### Include Common CMake Files Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/unix/example_app/CMakeLists.txt Includes common CMake files for lwIP configuration and file lists. ```cmake include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake) include(${LWIP_DIR}/src/Filelists.cmake) include(${LWIP_DIR}/contrib/Filelists.cmake) include(${LWIP_DIR}/contrib/ports/unix/Filelists.cmake) ``` -------------------------------- ### Create PPPoS Interface Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Creates a new PPPoS interface. Requires a netif for the PPP link and an output callback function for serial data. ```c static u32_t output_cb(ppp_pcb *pcb, const void *data, u32_t len, void *ctx) { return uart_write(UART, data, len); } ppp = pppos_create(&ppp_netif, output_cb, status_cb, ctx_cb); ``` -------------------------------- ### Archive lwIP Release (tar.gz) Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Create a gzipped tar archive of the lwIP release directory. This is a common format for distributing source code. ```bash tar czvf lwip-1.4.1.tar.gz lwip-1.4.1 ``` -------------------------------- ### Initiate PPP Client Connection Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Initiates a PPP client connection. The holdoff parameter determines the delay before initiating negotiation. This can only be called when the PPP session is disconnected. ```c u16_t holdoff = 0; ppp_connect(ppp, holdoff); ``` -------------------------------- ### Create PPPoE Interface Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Creates a new PPPoE interface. Requires a netif for the PPP link and an existing Ethernet interface for communication. Service and concentrator names are not yet supported. ```c #include "netif/ppp/pppoe.h" ppp = pppoe_create(&ppp_netif, ðif, service_name, concentrator_name, status_cb, ctx_cb); ``` -------------------------------- ### Initialize MDNS Responder Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Call this function during system initialization to open UDP sockets for MDNS communication on port 5353 for IPv4 and IPv6. ```c mdns_resp_init(); ``` -------------------------------- ### PPP Client Connection API Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt APIs for configuring and initiating a PPP client connection. ```APIDOC ## PPP Client Connection API ### Description APIs to configure and initiate a PPP client connection. ### Method `ppp_set_default`, `ppp_set_usepeerdns`, `ppp_set_auth`, `ppp_connect` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c ppp_set_default(ppp); ppp_set_usepeerdns(ppp, 1); ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "login", "password"); u16_t holdoff = 0; ppp_connect(ppp, holdoff); ``` ### Response #### Success Response (200) Initiates the PPP connection process. #### Response Example None ``` -------------------------------- ### Create PPPoL2TP Interface Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Creates a new PPPoL2TP interface. Requires a netif for the PPP link, an optional output netif, IP address, UDP port, and L2TP secret. ```c #include "netif/ppp/pppol2tp.h" ppp = pppol2tp_create(&ppp_netif, struct netif *netif, ip_addr_t *ipaddr, u16_t port, u8_t *secret, u8_t secret_len, ppp_link_status_cb_fn link_status_cb, void *ctx_cb); ``` -------------------------------- ### Archive lwIP Release (zip) Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Create a zip archive of the lwIP release directory. This is a widely compatible archive format. ```bash zip -r lwip-1.4.1.zip lwip-1.4.1 ``` -------------------------------- ### Build makefsdata Executable Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/unix/example_app/CMakeLists.txt Adds the 'makefsdata' executable and configures its compile options, include directories, and linked libraries. ```cmake add_executable(makefsdata ${lwipmakefsdata_SRCS}) target_compile_options(makefsdata PRIVATE ${LWIP_COMPILER_FLAGS}) target_include_directories(makefsdata PRIVATE ${LWIP_INCLUDE_DIRS}) target_link_libraries(makefsdata ${LWIP_SANITIZER_LIBS}) ``` -------------------------------- ### Archive lwIP Release (tar.bz2) Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Create a bzip2 compressed tar archive of the lwIP release directory. This offers better compression than gzip. ```bash tar cjvf lwip-1.4.1.tar.bz2 lwip-1.4.1 ``` -------------------------------- ### Incoming Publish and Data Callbacks Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt Processes incoming MQTT publish messages. The `mqtt_incoming_publish_cb` demultiplexes topics to set a reference, which is then used in `mqtt_incoming_data_cb` to handle the payload. ```c static int inpub_id; static void mqtt_incoming_publish_cb(void *arg, const char *topic, u32_t tot_len) { printf("Incoming publish at topic %s with total length %u\n", topic, (unsigned int)tot_len); /* Decode topic string into a user defined reference */ if(strcmp(topic, "print_payload") == 0) { inpub_id = 0; } else if(topic[0] == 'A') { /* All topics starting with 'A' might be handled at the same way */ inpub_id = 1; } else { /* For all other topics */ inpub_id = 2; } } ``` ```c static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t flags) { printf("Incoming publish payload with length %d, flags %u\n", len, (unsigned int)flags); if(flags & MQTT_DATA_FLAG_LAST) { /* Last fragment of payload received (or whole part if payload fits receive buffer See MQTT_VAR_HEADER_BUFFER_LEN) */ /* Call function or do action depending on reference, in this case inpub_id */ if(inpub_id == 0) { /* Don't trust the publisher, check zero termination */ if(data[len-1] == 0) { printf("mqtt_incoming_data_cb: %s\n", (const char *)data); } } else if(inpub_id == 1) { /* Call an 'A' function... */ } else { printf("mqtt_incoming_data_cb: Ignoring payload...\n"); } } else { /* Handle fragmented payload, store in buffer, write to file or whatever */ } } ``` -------------------------------- ### Configure PPP Server Authentication Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Configures PPP server authentication settings, allowing any authentication type and specifying login credentials. It also enforces that the peer must authenticate. ```c ppp_set_auth(ppp, PPPAUTHTYPE_ANY, "login", "password"); ppp_set_auth_required(ppp, 1); ``` -------------------------------- ### Archive lwIP Release using Git Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Create a tar.gz archive of a specific Git tag. This method uses Git's built-in archiving functionality. ```bash git archive -o lwip-1.4.1.tar.gz --prefix lwip-1.4.1/ STABLE-1_4_1 ``` -------------------------------- ### Enabling MDNS Responder Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt To enable the MDNS responder, set LWIP_MDNS_RESPONDER to 1 in lwipopts.h and include mdns.c in your build. Ensure necessary configurations for IPv4 and IPv6 are met. ```APIDOC ## Enabling MDNS Responder To enable MDNS responder, set `LWIP_MDNS_RESPONDER = 1` in `lwipopts.h` and add `src/apps/mdns/mdns.c` to your list of files to build. **Configuration Notes:** - Increase `MEMP_NUM_UDP_PCB` by 1. - Increase `LWIP_NUM_NETIF_CLIENT_DATA` by 1. - MDNS with IPv4 requires `LWIP_IGMP = 1` and preferably `LWIP_AUTOIP = 1`. - MDNS with IPv6 requires `LWIP_IPV6_MLD = 1` and a link-local address. - The MDNS code may use up to 1kB of stack. - Ensure a `strncasecmp()` implementation is available or define `lwip_strnicmp`. ``` -------------------------------- ### Upload Release Files via SCP Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Securely copy the release archives and their signatures to the Savannah release server using SCP. ```bash scp lwip-1.4.1.* @dl.sv.nongnu.org:/releases/lwip/ ``` -------------------------------- ### PPPoE Creation API Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt API for creating a new PPPoE (PPP over Ethernet) session. ```APIDOC ## PPPoE Creation API ### Description Creates a new PPPoE session. ### Method `pppoe_create` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c ppp = pppoe_create(&ppp_netif, ðif, service_name, concentrator_name, status_cb, ctx_cb); ``` ### Response #### Success Response (200) Returns a pointer to the created PPP control block. #### Response Example ```c ppp_pcb *ppp; ``` ``` -------------------------------- ### Publish MQTT Message Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt Call this function to publish a message to a specified topic. Ensure the client is connected and valid before calling. The callback function will be invoked upon completion. ```c err = mqtt_publish(client, "pub_topic", pub_payload, strlen(pub_payload), qos, retain, mqtt_pub_request_cb, arg); if(err != ERR_OK) { printf("Publish err: %d\n", err); } ``` -------------------------------- ### MQTT Connection Status Callback Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt Handles the result of the MQTT connection attempt. If successful, it sets up callbacks for incoming publishes and subscribes to a topic. If disconnected, it attempts to reconnect. ```c static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection_status_t status) { err_t err; if(status == MQTT_CONNECT_ACCEPTED) { printf("mqtt_connection_cb: Successfully connected\n"); /* Setup callback for incoming publish requests */ mqtt_set_inpub_callback(client, mqtt_incoming_publish_cb, mqtt_incoming_data_cb, arg); /* Subscribe to a topic named "subtopic" with QoS level 1, call mqtt_sub_request_cb with result */ err = mqtt_subscribe(client, "subtopic", 1, mqtt_sub_request_cb, arg); if(err != ERR_OK) { printf("mqtt_subscribe return: %d\n", err); } } else { printf("mqtt_connection_cb: Disconnected, reason: %d\n", status); /* Its more nice to be connected, so try to reconnect */ example_do_connect(client); } } ``` ```c static void mqtt_sub_request_cb(void *arg, err_t result) { /* Just print the result code here for simplicity, normal behaviour would be to take some action if subscribe fails like notifying user, retry subscribe or disconnect from server */ printf("Subscribe result: %d\n", result); } ``` -------------------------------- ### Clone lwIP via SSH Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Clone the lwIP repository using SSH protocol for authenticated access. Replace 'your_login' with your Savannah username. ```bash git clone your_login@git.sv.gnu.org:/srv/git/lwip.git ``` -------------------------------- ### PPPoL2TP Creation API Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt API for creating a new PPPoL2TP (PPP over Layer 2 Tunneling Protocol) session. ```APIDOC ## PPPoL2TP Creation API ### Description Creates a new PPPoL2TP interface. ### Method `pppol2tp_create` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c ppp = pppol2tp_create(&ppp_netif, netif, ipaddr, port, secret, secret_len, link_status_cb, ctx_cb); ``` ### Response #### Success Response (200) Returns a pointer to the created PPP control block. #### Response Example ```c ppp_pcb *ppp; ``` ``` -------------------------------- ### PPPoS Creation API Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt API for creating a new PPPoS (PPP over Serial) interface. ```APIDOC ## PPPoS Creation API ### Description Creates a new PPPoS interface. ### Method `pppos_create` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c ppp = pppos_create(&ppp_netif, output_cb, status_cb, ctx_cb); ``` ### Response #### Success Response (200) Returns a pointer to the created PPP control block. #### Response Example ```c ppp_pcb *ppp; ``` ``` -------------------------------- ### Add Service to MDNS Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Register a service with the MDNS responder on a specific netif. This enables queries for the service type and instance. The name and service pointers are copied. ```c mdns_resp_add_service(netif, "myweb", "_http", DNSSD_PROTO_TCP, 80, srv_txt, NULL); ``` -------------------------------- ### Tag lwIP Release Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Create an annotated Git tag for a new release. Replace 'STABLE-1_4_1' with the actual release tag name. ```bash git tag -a STABLE-1_4_1 ``` -------------------------------- ### Include CMake Common and Filelists Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/win32/example_app/CMakeLists.txt Includes common CMake modules and file lists for the lwIP project. These are essential for setting up build configurations and defining source files. ```cmake include(${LWIP_DIR}/contrib/ports/CMakeCommon.cmake) include(${LWIP_DIR}/src/Filelists.cmake) include(${LWIP_DIR}/contrib/Filelists.cmake) include(${LWIP_DIR}/contrib/ports/win32/Filelists.cmake) ``` -------------------------------- ### Configure PPP Server IP Addresses Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Configures the IP addresses for the PPP server, including its own address, the peer's address, and primary/secondary DNS server addresses. These settings are applied when the PPP session is inactive. ```c ip4_addr_t addr; IP4_ADDR(&addr, 192,168,0,1); ppp_set_ipcp_ouraddr(ppp, &addr); IP4_ADDR(&addr, 192,168,0,2); ppp_set_ipcp_hisaddr(ppp, &addr); IP4_ADDR(&addr, 192,168,10,20); ppp_set_ipcp_dnsaddr(ppp, 0, &addr); IP4_ADDR(&addr, 192,168,10,21); ppp_set_ipcp_dnsaddr(ppp, 1, &addr); ``` -------------------------------- ### Checkout Master Branch Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Switch your local Git repository to the master branch. This is typically done before merging development changes. ```bash git checkout master ``` -------------------------------- ### Adding and Removing Services Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Register and deregister services with the MDNS responder to make them discoverable on the network. ```APIDOC ## Adding and Removing Services ### Add Service Register a service with the MDNS responder using: ```c mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, service_get_txt_fn_t txt_fn, void *txt_userdata) ``` - **`netif`**: The network interface to register the service on. - **`name`**: The instance name of the service (e.g., "myweb"). - **`service`**: The type of service (e.g., "_http"). - **`proto`**: The protocol, either `DNSSD_PROTO_UDP` or `DNSSD_PROTO_TCP`. - **`port`**: The port number the service is running on. - **`txt_fn`**: A callback function to generate TXT records. - **`txt_userdata`**: User data for the `txt_fn` callback. This function answers queries for `_services._dns-sd..local`, `..local`, and provides SRV and TXT records for the specific service instance. **TXT Record Callback (`txt_fn`)**: This callback populates TXT items using `mdns_resp_add_service_txtitem()`. Each item is max 63 bytes, and the total TXT length is max 255 bytes. Example TXT callback: ```c static void srv_txt(struct mdns_service *service, void *txt_userdata) { res = mdns_resp_add_service_txtitem(service, "path=/", 6); LWIP_ERROR("mdns add service txt failed\n", (res == ERR_OK), return); } ``` ### Remove Service To remove a service from a netif, run: ```c mdns_resp_del_service(struct netif *netif, u8_t slot) ``` - **`netif`**: The network interface. - **`slot`**: The slot index of the service to remove. ``` -------------------------------- ### Push Release Tag Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Share the newly created release tag with the remote repository. This makes the tag visible to others. ```bash git push origin STABLE-1_4_1 ``` -------------------------------- ### Set PPP as Default Route Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Sets the PPP interface as the default route for the network. This is typically done after the PPP connection is established. ```c ppp_set_default(ppp); ``` -------------------------------- ### Handle PPPoS Input Data Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Processes received data on the serial port for PPPoS. Use pppos_input() if NO_SYS is 1 and PPP_INPROC_IRQ_SAFE is 0 (main loop only). If PPP_INPROC_IRQ_SAFE is 1, pppos_input() is IRQ safe. Use pppos_input_tcpip() for thread-safe input to the lwIP core thread when NO_SYS is 0. ```c void pppos_input(ppp, buffer, buffer_len); ``` ```c void pppos_input_tcpip(ppp, buffer, buffer_len); ``` -------------------------------- ### Test SSH Login to Savannah Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Attempt to log in to the Savannah server via SSH to verify your access. This command is for testing and interactive shell login is not permitted. ```bash ssh -v your_login@git.sv.gnu.org ``` -------------------------------- ### Generate SSH Key Pair Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Command to generate an SSH key pair on UNIX-like systems. This is a prerequisite for secure Git access. ```bash ssh-keygen ``` -------------------------------- ### Sign Archive with GPG Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Create a detached GPG signature for an archive file. This is used to verify the authenticity of the release files. ```bash gpg -b lwip-1.4.1.tar.gz ``` ```bash gpg -b lwip-1.4.1.tar.bz2 ``` ```bash gpg -b lwip-1.4.1.zip ``` -------------------------------- ### MQTT Publish Callback Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt This callback function is invoked after a publish request completes, either successfully or with an error. It receives the result code indicating the outcome. ```c static void mqtt_pub_request_cb(void *arg, err_t result) { if(result != ERR_OK) { printf("Publish result: %d\n", result); } } ``` -------------------------------- ### Add Netif for MDNS Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Register a network interface with the MDNS responder. This function copies the hostname and enables handling of MDNS/DNS requests for the specified netif. Ensure the netif is already up. ```c mdns_resp_add_netif(netif, "myhostname"); ``` -------------------------------- ### Free PPP Connection Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Frees the PPP control block. This function can only be called when the PPP session is in the 'dead' state, meaning it must be disconnected first by calling ppp_close(). ```c ppp_free(ppp); ``` -------------------------------- ### Add TXT Item to MDNS Service Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Helper function called within a service_get_txt_fn_t callback to add a single text string item to an MDNS service's TXT record. The item must not exceed 63 bytes. ```c mdns_resp_add_service_txtitem(service, "path=/", 6); ``` -------------------------------- ### Outgoing MQTT Publish Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt Publishes a message to an MQTT topic with specified Quality of Service (QoS) and retain flags. The payload is provided as a string. ```c void example_publish(mqtt_client_t *client, void *arg) { const char *pub_payload= "PubSubHubLubJub"; err_t err; u8_t qos = 2; /* 0 1 or 2, see MQTT specification */ u8_t retain = 0; /* No don't retain such crappy payload... */ ``` -------------------------------- ### Restart MDNS Responder on Netif Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Call this function when a network interface comes back online after being down (e.g., cable connected, interface administratively enabled, or device wakes from sleep). ```c mdns_resp_restart(netif); ``` -------------------------------- ### Add 'makefsdata' Executable Target Source: https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/win32/example_app/CMakeLists.txt Defines the 'makefsdata' executable, specifying its source files, compiler options, include directories, and linked libraries. This target is typically used for file system data generation. ```cmake add_executable(makefsdata ${lwipmakefsdata_SRCS}) target_compile_options(makefsdata PRIVATE ${LWIP_COMPILER_FLAGS}) target_include_directories(makefsdata PRIVATE ${LWIP_INCLUDE_DIRS}) target_link_libraries(makefsdata ${LWIP_SANITIZER_LIBS} lwipcore lwipcontribportwindows) ``` -------------------------------- ### Clone Specific lwIP Release Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Obtain a specific, fixed release of the lwIP project by cloning a release branch. ```bash git clone --branch STABLE-1_4_1 git://git.savannah.nongnu.org/lwip.git ``` -------------------------------- ### Push Commits Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Upload your local commits to the remote repository. This command pushes changes after a merge or other modifications. ```bash git push ``` -------------------------------- ### Disconnect MQTT Client Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mqtt_client.txt Call this function to gracefully disconnect the MQTT client from the broker. Ensure the client object is valid. ```c mqtt_disconnect(client); ``` -------------------------------- ### PPPoS Serial Output Callback Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Callback function for PPPoS serial output. It is called by the PPP core to send data to the serial port. ```c #include "netif/ppp/pppos.h" /* * PPPoS serial output callback * * ppp_pcb, PPP control block * data, buffer to write to serial port ``` -------------------------------- ### PPP Close Connection API Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt API for closing an active PPP connection. ```APIDOC ## PPP Close Connection API ### Description Initiates the end of the PPP session. ### Method `ppp_close` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c u8_t nocarrier = 0; ppp_close(ppp, nocarrier); ``` ### Response #### Success Response (200) Closes the PPP connection. #### Response Example None ``` -------------------------------- ### Announce IP Address Change Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Call this function whenever the IP address on a registered netif changes to ensure MDNS is aware of the update. ```c mdns_resp_announce(netif); ``` -------------------------------- ### Close PPP Connection Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Initiates the graceful closure of a PPP session. The nocarrier flag determines if a carrier lost signal is simulated. This function can be called at any time. ```c u8_t nocarrier = 0; ppp_close(ppp, nocarrier); ``` -------------------------------- ### Clone lwIP Master Branch Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Use this command to clone the master branch of the lwIP repository for anonymous Git access. This branch receives bug fixes and incremental enhancements. ```bash git clone git://git.savannah.nongnu.org/lwip.git ``` -------------------------------- ### Configure PPPoS Silent Mode Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/ppp.txt Enables silent mode for a PPPoS interface. This is relevant for passive modes and affects how the PPP session behaves regarding carrier signals. ```c ppp_set_silent(pppos, 1); ``` -------------------------------- ### Clone lwIP Stable Branch Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Clone a specific stable branch of the lwIP repository. This branch is updated with bug fixes only. ```bash git clone --branch DEVEL-1_4_1 git://git.savannah.nongnu.org/lwip.git ``` -------------------------------- ### Commit Merge Result Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Stage and commit the changes resulting from a merge operation. The '-a' flag stages all tracked, modified files. ```bash git commit -a ``` -------------------------------- ### Merge Development Branch Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/savannah.txt Merge changes from a development branch into the current branch (e.g., master). You may need to resolve conflicts afterward. ```bash git merge your-development-branch ``` -------------------------------- ### Remove Netif from MDNS Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Stop the MDNS responder from handling requests on a specific network interface. ```c mdns_resp_remove_netif(netif); ``` -------------------------------- ### Remove Service from MDNS Source: https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Remove a previously registered service from an MDNS netif using its slot identifier. ```c mdns_resp_del_service(netif, slot); ```