Network Service Interface
Provides interfaces for managing robot network connections (WiFi), including scanning for WiFi, connecting/disconnecting WiFi, and getting WiFi status.
Feature Support List
| Function | C# |
|---|---|
| Start Wifi Scan | ✔ |
| Get Available Wifi List | ✔ |
| Connect Wifi | ✔ |
| Disconnect Wifi | ✔ |
| Get Wifi Status | ✔ |
RobotNetworkClient
The RobotNetworkClient class provides the following functional interfaces.
void StartWifiScan(WifiScanCallback callback)
Function Description
Starts a WiFi scan. The scanning process is asynchronous and notifies the result via a callback function. It is recommended to call this interface before calling GetAvailableWifiList.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
callback | WifiScanCallback | Required | Scan result callback function, signature: void WifiScanCallback(bool success, string message). |
Return Value
| Type | Description |
|---|---|
void | No return value. |
Usage Example
_robotNetworkClient.StartWifiScan((success, message) =>
{
if (success)
{
Debug.Log("WiFi scan completed successfully");
}
else
{
Debug.LogError($"WiFi scan failed: {message}");
}
});Task<AvailableWifiListResponse> GetAvailableWifiList()
Function Description
Gets the list of available WiFi networks found during the scan. Usually called after StartWifiScan callback returns success.
Parameter Description
None.
Return Value
| Type | Description |
|---|---|
AvailableWifiListResponse | Response object containing Wifi24GList and Wifi5GList. |
Usage Example
var response = await _robotNetworkClient.GetAvailableWifiList();
if (response != null)
{
foreach (var wifi in response.Wifi24GList)
{
Debug.Log($"[2.4G] SSID: {wifi.Ssid}, RSSI: {wifi.Rssi}");
}
}Task<SnmpResponse> ConnectWifi(string ssid, string password, int wifiType = 0, int encryption = 1)
Function Description
Connects to a specified WiFi network.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
ssid | string | Required | WiFi Name (SSID). |
password | string | Required | WiFi Password. |
wifiType | int | 0 | WiFi Frequency Band: 0: 2.4GHz, 1: 5GHz. |
encryption | int | 1 | Encryption Type: 0: None, 1: wpa-psk/wpa2-psk, 2: wpa/wpa2. |
Return Value
| Type | Description |
|---|---|
SnmpResponse | Operation result response, containing Success and Message. |
Usage Example
var response = await _robotNetworkClient.ConnectWifi("MyWiFi", "12345678", 0, 1);
if (response.Success)
{
Debug.Log("Connected to WiFi successfully");
}Task<SnmpResponse> DisconnectWifi(int wifiType = 0)
Function Description
Disconnects the current WiFi connection.
Parameter Description
| Parameter Name | Type | Required/Default | Description |
|---|---|---|---|
wifiType | int | 0 | WiFi Frequency Band to disconnect: 0: 2.4GHz, 1: 5GHz. |
Return Value
| Type | Description |
|---|---|
SnmpResponse | Operation result response, containing Success and Message. |
Usage Example
var response = await _robotNetworkClient.DisconnectWifi(0);
if (response.Success)
{
Debug.Log("Disconnected from WiFi successfully");
}Task<WifiStatusResponse> GetWifiStatus()
Function Description
Gets the robot's current WiFi connection status.
Parameter Description
None.
Return Value
| Type | Description |
|---|---|
WifiStatusResponse | WiFi status response, containing information such as IsLinked, Wifi24GName, Wifi5GName, etc. |
Usage Example
var status = await _robotNetworkClient.GetWifiStatus();
if (status != null)
{
Debug.Log($"Is Connected: {status.IsLinked}");
Debug.Log($"Connected SSID (2.4G): {status.Wifi24GName}");
}