赵明涛 9 hours ago
parent
commit
173b9bd74e
  1. 16
      app/src/main/java/com/ouxuan/oxface/device/OxUDP.java

16
app/src/main/java/com/ouxuan/oxface/device/OxUDP.java

@ -302,8 +302,24 @@ public class OxUDP {
// Log.d(TAG, "收到UDP响应: " + response); // Log.d(TAG, "收到UDP响应: " + response);
return response; return response;
} catch (java.io.IOException e) {
Log.e(TAG, "发送UDP命令失败: " + command, e);
// 特别处理网络不可达错误
String errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.contains("ENETUNREACH")) {
String networkError = "网络不可达,请检查网络连接和设备IP地址(" + UDP_IP + ")是否正确\n错误详情: sendto failed: ENETUNREACH (Network is unreachable)";
Log.w(TAG, "网络连接失败: " + networkError);
notifyUDPError(networkError);
} else {
// 其他网络错误
notifyUDPError("UDP通信失败: " + errorMessage);
}
return null;
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "发送UDP命令失败: " + command, e); Log.e(TAG, "发送UDP命令失败: " + command, e);
notifyUDPError("UDP命令发送异常: " + e.getMessage());
return null; return null;
} finally { } finally {
if (socket != null && !socket.isClosed()) { if (socket != null && !socket.isClosed()) {

Loading…
Cancel
Save