Is it possible to provide an `ncm_open`, `ncm_close` API interface to control the connection and disconnection of USB?
tswen opened this issue · comments
Tian Sen Wen commented
Related area
net class
Hardware specification
esp32-S2, esp32-S3
Is your feature request related to a problem?
None
Describe the solution you'd like
None
I have checked existing issues, dicussion and documentation
- I confirm I have checked existing issues, dicussion and documentation.
Tian Sen Wen commented
Such as
void ecm_close(void)
{
printf("Ecm close\n");
tusb_control_request_t notify_data =
{
.bmRequestType = 0xA1,
.bRequest = 0 /* NETWORK_CONNECTION aka NetworkConnection */,
.wValue = 0 /* Disconnected */,
.wLength = 0,
};
notify_data.wIndex = _netd_itf.itf_num;
netd_report((uint8_t *)¬ify_data, sizeof(notify_data));
}
void ecm_open(void)
{
printf("Ecm OPEN\n");
tusb_control_request_t notify_data =
{
.bmRequestType = 0xA1,
.bRequest = 0 /* NETWORK_CONNECTION aka NetworkConnection */,
.wValue = 1 /* Connected */,
.wLength = 0,
};
notify_data.wIndex = _netd_itf.itf_num;
netd_report((uint8_t *)¬ify_data, sizeof(notify_data));
}
Lars Pötter commented
you could use the already defined tu_static struct ncm_notify_t ncm_notify_connected
to implement these functions, right?
Wouldn't it also make sense to define the startup behavior? Currently it just automatically is connected. That is a good default behavior. But in a scenario where the firmware wants to change the connected state it might also want to start out in disconnected state, right?