From 07d47ba4876dbb07ba9fd9ee19eca11a7ccd467d Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 22 Nov 2024 20:21:12 +0700 Subject: [PATCH] fix ncm incorrect length for notify connection --- src/class/net/ncm_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/class/net/ncm_device.c b/src/class/net/ncm_device.c index aeb2c3cf1..c97c66a4e 100644 --- a/src/class/net/ncm_device.c +++ b/src/class/net/ncm_device.c @@ -202,8 +202,9 @@ static void notification_xmit(uint8_t rhport, bool force_next) { notify_speed_change.uplink = 12000000; } + uint16_t notif_len = sizeof(notify_speed_change.header) + notify_speed_change.header.wLength; ncm_epbuf.epnotif = notify_speed_change; - usbd_edpt_xfer(rhport, ncm_interface.ep_notif, (uint8_t*) &ncm_epbuf.epnotif, sizeof(ncm_notify_t)); + usbd_edpt_xfer(rhport, ncm_interface.ep_notif, (uint8_t*) &ncm_epbuf.epnotif, notif_len); ncm_interface.notification_xmit_state = NOTIFICATION_CONNECTED; ncm_interface.notification_xmit_is_running = true; @@ -223,8 +224,9 @@ static void notification_xmit(uint8_t rhport, bool force_next) { }, }; + uint16_t notif_len = sizeof(notify_connected.header) + notify_connected.header.wLength; ncm_epbuf.epnotif = notify_connected; - usbd_edpt_xfer(rhport, ncm_interface.ep_notif, (uint8_t *) &ncm_epbuf.epnotif, sizeof(ncm_notify_t)); + usbd_edpt_xfer(rhport, ncm_interface.ep_notif, (uint8_t *) &ncm_epbuf.epnotif, notif_len); ncm_interface.notification_xmit_state = NOTIFICATION_DONE; ncm_interface.notification_xmit_is_running = true;