Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(usb): add change NCM network status (IEC-48) #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions usb/esp_tinyusb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,11 @@ menu "TinyUSB Stack"
BTH ISO ALT COUNT.
endmenu # "Bluetooth Host Device Class"

menu "Network driver (ECM/NCM/RNDIS)"
choice TINYUSB_NET_MODE
prompt "Network mode"
default TINYUSB_NET_MODE_NONE
menu "Network driver (NCM)"
config TINYUSB_NET_MODE_NCM
bool "Enable TinyUSB Network feature(NCM)"
default n
help
Select network driver you want to use.

config TINYUSB_NET_MODE_ECM_RNDIS
tore-espressif marked this conversation as resolved.
Show resolved Hide resolved
bool "ECM/RNDIS"

config TINYUSB_NET_MODE_NCM
bool "NCM"

config TINYUSB_NET_MODE_NONE
bool "None"
endchoice
endmenu # "Network driver (ECM/NCM/RNDIS)"
Enable TinyUSB NCM feature. NCM is already supported on Linux/MAC/Windows11
endmenu # "Network driver (NCM)"
endmenu # "TinyUSB Stack"
2 changes: 1 addition & 1 deletion usb/esp_tinyusb/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ url: https://github.com/espressif/idf-extra-components/tree/master/usb/esp_tinyu
dependencies:
idf: '>=5.0' # IDF 4.x contains TinyUSB as submodule
tinyusb:
version: '>=0.14.2'
version: '>=0.15.0~3'
public: true
targets:
- esp32s2
Expand Down
15 changes: 15 additions & 0 deletions usb/esp_tinyusb/include/tinyusb_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ esp_err_t tinyusb_net_send_sync(void *buffer, uint16_t len, void *buff_free_arg,
*/
esp_err_t tinyusb_net_send_async(void *buffer, uint16_t len, void *buff_free_arg);

/**
* @brief TinyUSB NET driver notify HOST that the device is connected to AP,
* @note This interface should be called when WiFi connected
* @return ESP_OK on success notify
* ESP_FAIL on fail notify
*/
esp_err_t tinyusb_net_connect(void);

/**
* @brief TinyUSB NET driver notify HOST that the device is disconnected to AP,
* @note This interface should be called when WiFi disconnected
* @return esp_err_t
*/
esp_err_t tinyusb_net_disconnect(void);

#endif // (CONFIG_TINYUSB_NET_MODE_NONE != 1)

#ifdef __cplusplus
Expand Down
5 changes: 0 additions & 5 deletions usb/esp_tinyusb/include/tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ extern "C" {
# define CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED 0
#endif

#ifndef CONFIG_TINYUSB_NET_MODE_ECM_RNDIS
# define CONFIG_TINYUSB_NET_MODE_ECM_RNDIS 0
#endif

#ifndef CONFIG_TINYUSB_NET_MODE_NCM
# define CONFIG_TINYUSB_NET_MODE_NCM 0
#endif
Expand Down Expand Up @@ -137,7 +133,6 @@ extern "C" {
#define CFG_TUD_HID CONFIG_TINYUSB_HID_COUNT
#define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_COUNT
#define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED
#define CFG_TUD_ECM_RNDIS CONFIG_TINYUSB_NET_MODE_ECM_RNDIS
#define CFG_TUD_NCM CONFIG_TINYUSB_NET_MODE_NCM
#define CFG_TUD_DFU CONFIG_TINYUSB_DFU_MODE_DFU
#define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_MODE_DFU_RUNTIME
Expand Down
18 changes: 18 additions & 0 deletions usb/esp_tinyusb/tinyusb_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ esp_err_t tinyusb_net_init(tinyusb_usbdev_t usb_dev, const tinyusb_net_config_t
return ESP_OK;
}

esp_err_t tinyusb_net_connect(void)
{
if (tud_network_connect()) {
return ESP_OK;
} else {
return ESP_FAIL;
}
}

esp_err_t tinyusb_net_disconnect(void)
{
if (tud_network_disconnect()) {
return ESP_OK;
} else {
return ESP_FAIL;
}
}

//--------------------------------------------------------------------+
// tinyusb callbacks
//--------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion usb/esp_tinyusb/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const char *descriptor_str_kconfig[] = {
"",
#endif

#if CONFIG_TINYUSB_NET_MODE_ECM_RNDIS || CONFIG_TINYUSB_NET_MODE_NCM
#if CONFIG_TINYUSB_NET_MODE_NCM
"USB net", // 6. NET Interface
"", // 7. MAC
#endif
Expand Down
Loading