diff --git a/VERSION b/VERSION index be70f71fc48..ba33521819b 100644 --- a/VERSION +++ b/VERSION @@ -2,4 +2,4 @@ VERSION_MAJOR = 3 VERSION_MINOR = 6 PATCHLEVEL = 0 VERSION_TWEAK = 0 -EXTRAVERSION = rc3 +EXTRAVERSION = diff --git a/subsys/usb/device/class/netusb/function_ecm.c b/subsys/usb/device/class/netusb/function_ecm.c index 256cf9b9d1e..1863f98c76b 100644 --- a/subsys/usb/device/class/netusb/function_ecm.c +++ b/subsys/usb/device/class/netusb/function_ecm.c @@ -45,6 +45,17 @@ struct usb_cdc_ecm_config { struct usb_ep_descriptor if1_1_out_ep; } __packed; +struct cdc_ecm_notification { + union { + uint8_t bmRequestType; + struct usb_req_type_field RequestType; + }; + uint8_t bNotificationType; + uint16_t wValue; + uint16_t wIndex; + uint16_t wLength; +} __packed; + USBD_CLASS_DESCR_DEFINE(primary, 0) struct usb_cdc_ecm_config cdc_ecm_cfg = { .iad = { .bLength = sizeof(struct usb_association_descriptor), @@ -158,6 +169,18 @@ USBD_CLASS_DESCR_DEFINE(primary, 0) struct usb_cdc_ecm_config cdc_ecm_cfg = { }, }; +struct cdc_ecm_notification notification = { + .RequestType = { + .direction = USB_REQTYPE_DIR_TO_HOST, + .type = USB_REQTYPE_TYPE_CLASS, + .recipient = USB_REQTYPE_RECIPIENT_INTERFACE, + }, + .bNotificationType = USB_CDC_NETWORK_CONNECTION, + .wValue = sys_cpu_to_le16(1), + .wIndex = sys_cpu_to_le16(1), + .wLength = 0, +}; + static uint8_t ecm_get_first_iface_number(void) { return cdc_ecm_cfg.if0.bInterfaceNumber; @@ -325,6 +348,19 @@ static int ecm_connect(bool connected) usb_cancel_transfer(ecm_ep_data[ECM_OUT_EP_IDX].ep_addr); usb_cancel_transfer(ecm_ep_data[ECM_IN_EP_IDX].ep_addr); } + int ret; + size_t len = sizeof(struct cdc_ecm_notification); + + notification.wValue = sys_cpu_to_le16(1); + notification.wLength = sys_cpu_to_le16(1); + + /* Notify the host */ + ret = usb_write(ecm_ep_data[ECM_INT_EP_IDX].ep_addr, + (uint8_t*)¬ification, len, NULL); + if (ret < 0) { + LOG_ERR("Write failure"); + return -EINVAL; + } return 0; }