Skip to content

Commit ab5afb3

Browse files
committed
cherryusb:Fixed the issue where the USB device in the cdc_rndis_template example could not enable DHCP.
1 parent e5556be commit ab5afb3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

components/drivers/usb/cherryusb/demo/cdc_rndis_template.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ void usbd_rndis_data_send_done(uint32_t len)
189189
#error rndis must enable RT_LWIP_DHCP
190190
#endif
191191

192-
#ifndef LWIP_USING_DHCPD
193-
#error rndis must enable LWIP_USING_DHCPD
192+
#ifdef LWIP_USING_DHCPD
193+
#include <dhcp_server.h>
194194
#endif
195195

196196
#include <rtthread.h>
197197
#include <rtdevice.h>
198198
#include <netif/ethernetif.h>
199-
#include <dhcp_server.h>
199+
#include <netdev.h>
200200

201201
struct eth_device rndis_dev;
202202

@@ -250,7 +250,14 @@ void rndis_lwip_init(void)
250250
eth_device_init(&rndis_dev, "u0");
251251

252252
eth_device_linkchange(&rndis_dev, RT_TRUE);
253+
#ifdef LWIP_USING_DHCPD
253254
dhcpd_start("u0");
255+
#else
256+
struct netdev *netdev = netdev_get_by_name("u0");
257+
if (netdev) {
258+
netdev_dhcp_enabled(netdev, RT_TRUE);
259+
}
260+
#endif
254261
}
255262

256263
void usbd_rndis_data_recv_done(uint32_t len)

0 commit comments

Comments
 (0)