diff options
| author | hathach <[email protected]> | 2020-04-16 11:13:54 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2020-04-16 11:13:54 +0700 |
| commit | 2eed58d0962849014ab3166d4a3f0d3677d32c01 (patch) | |
| tree | 11950a260c8bfc543f33cdaa592870afceb43473 /src/class/net | |
| parent | 86ff5651ad94b6134aca0805b48d255da4786eef (diff) | |
per review
Diffstat (limited to 'src/class/net')
| -rw-r--r-- | src/class/net/net_device.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/class/net/net_device.c b/src/class/net/net_device.c index 8cb2e2e0b..0f2ccbd44 100644 --- a/src/class/net/net_device.c +++ b/src/class/net/net_device.c @@ -255,20 +255,26 @@ bool netd_control_request(uint8_t rhport, tusb_control_request_t const * request switch ( request->bRequest ) { case TUSB_REQ_GET_INTERFACE: + { + uint8_t const req_itfnum = (uint8_t) request->wIndex; + TU_VERIFY(_netd_itf.itf_num+1 == req_itfnum); + tud_control_xfer(rhport, request, &_netd_itf.itf_data_alt, 1); + } break; case TUSB_REQ_SET_INTERFACE: { uint8_t const req_itfnum = (uint8_t) request->wIndex; + uint8_t const req_alt = (uint8_t) request->wValue; - // Request to enable/disable network activities on ACM-ECM only - TU_ASSERT(_netd_itf.ecm_mode); + // Only valid for Data Interface with Alternate is either 0 or 1 + TU_VERIFY(_netd_itf.itf_num+1 == req_itfnum && req_alt < 2); - // Only valid for Data Interface - TU_ASSERT(_netd_itf.itf_num+1 == req_itfnum); + // ACM-ECM only: qequest to enable/disable network activities + TU_VERIFY(_netd_itf.ecm_mode); - _netd_itf.itf_data_alt = (uint8_t) request->wValue; + _netd_itf.itf_data_alt = req_alt; if ( _netd_itf.itf_data_alt ) { |
