1
1
/*
2
- * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2
+ * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
14
14
#include " cxx_include/esp_modem_dte.hpp"
15
15
#include " esp_netif_ppp.h"
16
16
17
-
18
17
namespace esp_modem {
19
18
20
19
void Netif::on_ppp_changed (void *arg, esp_event_base_t event_base,
@@ -39,6 +38,7 @@ esp_err_t Netif::esp_modem_dte_transmit(void *h, void *buffer, size_t len)
39
38
return ESP_FAIL;
40
39
}
41
40
41
+ #ifdef CONFIG_ESP_MODEM_USE_PPP_MODE
42
42
esp_err_t Netif::esp_modem_post_attach (esp_netif_t *esp_netif, void *args)
43
43
{
44
44
auto d = (ppp_netif_driver *) args;
@@ -62,6 +62,7 @@ esp_err_t Netif::esp_modem_post_attach(esp_netif_t *esp_netif, void *args)
62
62
63
63
return ESP_OK;
64
64
}
65
+ #endif // CONFIG_ESP_MODEM_USE_PPP_MODE
65
66
66
67
void Netif::receive (uint8_t *data, size_t len)
67
68
{
@@ -73,12 +74,16 @@ Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
73
74
{
74
75
driver.base .netif = ppp_netif;
75
76
driver.ppp = this ;
77
+ #ifdef CONFIG_ESP_MODEM_USE_PPP_MODE
76
78
driver.base .post_attach = esp_modem_post_attach;
77
79
ESP_MODEM_THROW_IF_ERROR (esp_event_handler_register (NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed, (void *) this ));
80
+ #endif
78
81
ESP_MODEM_THROW_IF_ERROR (esp_event_handler_register (IP_EVENT, IP_EVENT_PPP_GOT_IP, esp_netif_action_connected, ppp_netif));
79
82
ESP_MODEM_THROW_IF_ERROR (
80
83
esp_event_handler_register (IP_EVENT, IP_EVENT_PPP_LOST_IP, esp_netif_action_disconnected, ppp_netif));
84
+ #ifdef CONFIG_ESP_MODEM_USE_PPP_MODE
81
85
ESP_MODEM_THROW_IF_ERROR (esp_netif_attach (ppp_netif, &driver));
86
+ #endif
82
87
}
83
88
84
89
void Netif::start ()
@@ -120,7 +125,9 @@ Netif::~Netif()
120
125
signal.clear (PPP_STARTED);
121
126
signal.wait (PPP_EXIT, 30000 );
122
127
}
128
+ #ifdef CONFIG_ESP_MODEM_USE_PPP_MODE
123
129
esp_event_handler_unregister (NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed);
130
+ #endif
124
131
esp_event_handler_unregister (IP_EVENT, IP_EVENT_PPP_GOT_IP, esp_netif_action_connected);
125
132
esp_event_handler_unregister (IP_EVENT, IP_EVENT_PPP_LOST_IP, esp_netif_action_disconnected);
126
133
}
0 commit comments