Skip to content
FantomJAC edited this page Dec 28, 2014 · 1 revision

Device Discovery

Example: Find IEEEAddress

ZigBeeAddress address = packet.getAddress();
if (!(address instanceof IEEEAddress)) {
    ZigBeeDevice zdo = BekkoConnector.getSharedZigBeeDevice();
    ZDPClientService zdp = new ZDPClientService(zdo);
    AddrRsp addrRsp = zdp.zdpIEEEAddressRequest(address, (NetworkAddress) address, false, 0);
    System.out.println("IEEEAddress is: " + addrRsp.getIEEEAddress().toString());
}

Service Discovery

Example: Discover devices has BasicCluster(0x0000) server on HA profile(0x0104)

ZigBeeDevice zdo = BekkoConnector.getSharedZigBeeDevice();
zdo.addDiscoveryListener(listener);

MatchDescReq matchReq = new MatchDescReq();
matchReq.setNetworkAddr(NetworkAddress.BROADCAST_MROWI);    // Broadcast
matchReq.setProfileID((short) 0x0104);
matchReq.setInClusterList(new short [] {(short) 0x0000});
        
int tsn = zdo.sendZDPCommand(
    NetworkAddress.BROADCAST_MROWI,
    ZDPCommand.ZDP_MATCH_DESC_REQ,
    matchReq, ZigBeeDataConnection.OPTION_ACK, 0);

On DiscoveryListener:

@Override
public void deviceMatched(int tsn, NetworkAddress nwkAddress, int[] matchList) {
    if (matchList.length > 0) {
        System.out.println("Matched Device: " + nwkAddress);
    }
}

Clone this wiki locally