o1iver
V2EX  ›  问与答

有大佬会 BACNet 协议获取同网段下设备信息吗

  •  1
     
  •   o1iver · May 11, 2023 · 1395 views
    This topic created in 1111 days ago, the information mentioned may be changed or developed.
    怎样用 Java 通过 BACNet 协议获取同局域网下的所有设备信息,具体流程
    Eiden
        1
    Eiden  
       May 11, 2023
    发送 whois 消息, 这个消息是个广播, 正常设备收到后会回复 i-am 消息, 这个流程一般 bacnet 的包都实现了的, 看看文档吧
    o1iver
        2
    o1iver  
    OP
       May 11, 2023
    @Eiden 我就是在 bacnet 包中找不到发送 whois 消息的方法,一般是用哪个版本的 bacnet 包呀
    Eiden
        3
    Eiden  
       May 12, 2023   ❤️ 1

    https://github.com/Code-House/bacnet4j-wrapper
    ```
    BacNetClient client = new BacNetIpClient("<bind ip>", "<broadcast ip>", <client device id>);
    client.start();
    Set<Device> devices = client.discoverDevices(5000); // given number is timeout in millis
    for (Device device : devices) {
    System.out.println(device);

    for (Property property : client.getDeviceProperties(device)) {
    System.out.println(property.getName() + " " + client.getPropertyValue(property));
    }
    }

    client.stop();
    ```
    这个 discoverDevices 就是
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5744 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 64ms · UTC 06:12 · PVG 14:12 · LAX 23:12 · JFK 02:12
    ♥ Do have faith in what you're doing.