File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
targets/ESP32/_nanoCLR/System.Device.Wifi Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,14 @@ static const CLR_RT_MethodHandler method_lookup[] =
3333 NULL ,
3434 NULL ,
3535 NULL ,
36+ NULL ,
3637 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::DisposeNative___VOID,
3738 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeInit___VOID,
3839 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeConnect___SystemDeviceWifiWifiConnectionStatus__STRING__STRING__SystemDeviceWifiWifiReconnectionKind,
3940 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeDisconnect___VOID,
4041 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeScanAsync___VOID,
4142 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::GetNativeScanReport___SZARRAY_U1,
43+ Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeSetDeviceName___VOID__STRING,
4244 NULL ,
4345 Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::NativeFindWirelessAdapters___STATIC__SZARRAY_U1,
4446 NULL ,
@@ -81,7 +83,7 @@ static const CLR_RT_MethodHandler method_lookup[] =
8183const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_System_Device_Wifi =
8284{
8385 " System.Device.Wifi" ,
84- 0x00A058C6 ,
86+ 0x030E2768 ,
8587 method_lookup,
8688 { 100 , 0 , 6 , 4 }
8789};
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ struct Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter
6666 NANOCLR_NATIVE_DECLARE (NativeDisconnect___VOID );
6767 NANOCLR_NATIVE_DECLARE (NativeScanAsync___VOID );
6868 NANOCLR_NATIVE_DECLARE (GetNativeScanReport___SZARRAY_U1 );
69+ NANOCLR_NATIVE_DECLARE (NativeSetDeviceName___VOID__STRING );
6970 NANOCLR_NATIVE_DECLARE (NativeFindWirelessAdapters___STATIC__SZARRAY_U1 );
7071
7172 //--//
Original file line number Diff line number Diff line change 88#include < nf_rt_events_native.h>
99#include < esp_wifi_types.h>
1010#include < NF_ESP32_Network.h>
11+ #include < esp_netif.h>
1112
1213// //////////////////////////////////////////////////////////////////////////////////
1314// !!! KEEP IN SYNC WITH System.Device.Wifi (in managed code) !!! //
@@ -21,6 +22,36 @@ struct ScanRecord
2122 uint8_t cypherType;
2223};
2324
25+ HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::
26+ NativeSetDeviceName___VOID__STRING (CLR_RT_StackFrame &stack)
27+ {
28+ NANOCLR_HEADER ();
29+ {
30+ // Get deviceName from args
31+ const char *hostname = stack.Arg1 ().RecoverString ();
32+ FAULT_ON_NULL (hostname);
33+
34+ // Optional: ensure this adapter index is valid
35+ int netIndex;
36+ NANOCLR_CHECK_HRESULT (GetNetInterfaceIndex (stack, &netIndex));
37+
38+ // Get the default Wi-Fi STA esp_netif
39+ // This is the default key used by ESP-IDF for the station interface
40+ esp_netif_t *sta_netif = esp_netif_get_handle_from_ifkey (" WIFI_STA_DEF" );
41+ if (sta_netif == nullptr )
42+ {
43+ NANOCLR_SET_AND_LEAVE (CLR_E_FAIL);
44+ }
45+
46+ esp_err_t err = esp_netif_set_hostname (sta_netif, hostname);
47+ if (err != ESP_OK)
48+ {
49+ NANOCLR_SET_AND_LEAVE (CLR_E_FAIL);
50+ }
51+ }
52+ NANOCLR_NOCLEANUP ();
53+ }
54+
2455HRESULT Library_sys_dev_wifi_native_System_Device_Wifi_WifiAdapter::DisposeNative___VOID (CLR_RT_StackFrame &stack)
2556{
2657 NANOCLR_HEADER ();
You can’t perform that action at this time.
0 commit comments