diff options
| author | Cedric Van den Bergh <[email protected]> | 2026-06-16 23:28:07 +0100 |
|---|---|---|
| committer | Cedric Van den Bergh <[email protected]> | 2026-06-16 23:28:07 +0100 |
| commit | 6d3d33d997cd73a565e8355c84b67f0366d752ce (patch) | |
| tree | c2799f70dcaa4f3c889054f0e2e9db24494e3433 /src/class/net/ncm_device.c | |
| parent | d9f736dcf9c6b71aac470d281cd2fc05a3f7e793 (diff) | |
ncm: add weak callback for initial link state
netd_init resets link_is_up to a compile-time default, which is
incorrect when the host reboots without power-cycling the device.
Add tud_network_default_link_state_cb() so applications can return
the actual physical link state. The weak default preserves existing
CFG_TUD_NCM_DEFAULT_LINK_UP behaviour.
Diffstat (limited to 'src/class/net/ncm_device.c')
| -rw-r--r-- | src/class/net/ncm_device.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/class/net/ncm_device.c b/src/class/net/ncm_device.c index a78e472c2..e5f441300 100644 --- a/src/class/net/ncm_device.c +++ b/src/class/net/ncm_device.c @@ -152,6 +152,14 @@ TU_ATTR_WEAK void tud_network_set_packet_filter_cb(uint16_t packet_filter) { (void) packet_filter; } +TU_ATTR_WEAK bool tud_network_default_link_state_cb(void) { + #ifdef CFG_TUD_NCM_DEFAULT_LINK_UP + return CFG_TUD_NCM_DEFAULT_LINK_UP; + #else + return true; + #endif +} + /** * This is the NTB parameter structure * @@ -852,12 +860,7 @@ void netd_init(void) { for (int i = 0; i < RECV_NTB_N; ++i) { ncm_interface.recv_free_ntb[i] = &ncm_epbuf.recv[i].ntb; } - // Default link state - can be configured via CFG_TUD_NCM_DEFAULT_LINK_UP - #ifdef CFG_TUD_NCM_DEFAULT_LINK_UP - ncm_interface.link_is_up = CFG_TUD_NCM_DEFAULT_LINK_UP; - #else - ncm_interface.link_is_up = true; // Default to link up if not set. - #endif + ncm_interface.link_is_up = tud_network_default_link_state_cb(); } // netd_init /** |
