# 有线网唤醒设备

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /:
    get:
      summary: 有线网唤醒设备
      deprecated: false
      description: |-
        # 🌐 网络唤醒说明（Wake-on-LAN）

        ZIDOO 设备支持通过 **Wake-on-LAN（WOL）** 功能实现远程唤醒。  
        唤醒时需要使用设备的 **有线网卡 MAC 地址**。

        ---

        ## 🛠️ 使用说明

        - 唤醒参数：设备的 **MAC 地址**（例如：`80:0a:80:5d:5e:fe`）
        - 广播端口：**9517**
        - 广播地址：**255.255.255.255**

        ---

        ## 💻 Java 示例代码

        以下为 Java 实现的网络唤醒线程代码：

        ```java
        new WakeThread("80:0a:80:5d:5e:fe").start();

        public class WakeThread extends Thread {
            String macAddr;

            public WakeThread(String macAddr) {
                this.macAddr = macAddr;
            }

            @Override
            public void run() {
                super.run();
                wakeOnLan(macAddr);
            }

            public void wakeOnLan(String macAddr) {
                DatagramSocket datagramSocket = null;
                try {
                    byte[] mac = getMacBytes(macAddr);
                    if (mac == null) return;

                    byte[] magic = new byte[6 + 16 * mac.length];

                    // 1. 写入6个FF
                    for (int i = 0; i < 6; i++) {
                        magic[i] = (byte) 0xFF;
                    }

                    // 2. 写入16次MAC地址
                    for (int i = 6; i < magic.length; i += mac.length) {
                        System.arraycopy(mac, 0, magic, i, mac.length);
                    }

                    datagramSocket = new DatagramSocket();
                    DatagramPacket packet = new DatagramPacket(
                        magic, magic.length,
                        InetAddress.getByName("255.255.255.255"), 9517
                    );
                    datagramSocket.send(packet);

                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    if (datagramSocket != null) {
                        datagramSocket.close();
                    }
                }
            }

            private byte[] getMacBytes(String macStr) {
                byte[] bytes = new byte[6];
                String[] hex = macStr.split("[:\\-]");
                if (hex.length != 6) return null;

                try {
                    for (int i = 0; i < 6; i++) {
                        bytes[i] = (byte) Integer.parseInt(hex[i], 16);
                    }
                } catch (NumberFormatException e) {
                    return null;
                }

                return bytes;
            }
        }

        📌 注意事项

        确保设备接入有线网
        广播包应在同一子网内有效
        网络设备（如路由器、交换机）需允许广播数据包转发
      tags:
        - 控制设备/按键控制
      parameters: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
          headers: {}
          x-apifox-name: 成功
      security: []
      x-apifox-folder: 控制设备/按键控制
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/6727011/apis/api-319460467-run
components:
  schemas: {}
  securitySchemes: {}
servers: []
security: []

```
