gpt4 book ai didi

com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:47:17 37 4
gpt4 key购买 nike

本文整理了Java中com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket类的一些代码示例,展示了ZToolPacket类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZToolPacket类的具体详情如下:
包路径:com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket
类名称:ZToolPacket

ZToolPacket介绍

暂无

代码示例

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Send packet to dongle.
 *
 * @param packet the packet
 * @throws IOException if IO exception occurs while sending packet
 */
@Override
public void sendPacket(final ZToolPacket packet) throws IOException {
  logger.debug("->  {} ({}) ", packet.getClass().getSimpleName(), packet);
  final int[] pck = packet.getPacket();
  sendRaw(pck);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void receivedAsynchronousCommand(ZToolPacket packet) {
  logger.trace("Received a packet {} and waiting for {}", packet.getCMD().get16BitValue(), commandId);
  logger.trace("received {} {}", packet.getClass(), packet.toString());
  if (packet.isError()) {
    return;
  }
  if (packet.getCMD().get16BitValue() != commandId) {
    logger.trace("Received unexpected packet: " + packet.getClass().getSimpleName());
    return;
  }
  synchronized (this) {
    commandPacket = packet;
    logger.trace("Received expected response: {}", packet.getClass().getSimpleName());
    cleanup();
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

public SYS_VERSION_RESPONSE(int[] framedata) {
    this.TransportRev = framedata[0];
    this.Product = framedata[1];
    this.MajorRel = framedata[2];
    this.MinorRel = framedata[3];
    this.HwRev = framedata[4];
    super.buildPacket(new DoubleByte(ZToolCMD.SYS_VERSION_RESPONSE), framedata);
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void receivedAsynchronousCommand(ZToolPacket packet) {
  if (packet.isError()) {
    return;
  }
  if (packet.getCMD().get16BitValue() == ZToolCMD.ZDO_STATE_CHANGE_IND) {
    ZDO_STATE_CHANGE_IND p = ((ZDO_STATE_CHANGE_IND) packet);
    switch (p.getStatus()) {
      case DEV_COORD_STARTED:
        logger.debug("Started as ZigBee Coordinator");
        setState(DriverStatus.NETWORK_READY);
        break;
      default:
        break;
    }
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

if (response.isError()) {
  logger.debug("Received a BAD PACKET {}", response.getPacketString());

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

response = new ZToolPacket(apiId, frameData);
} else {
  frameData = this.readRemainingBytes();
if (fcs != response.getFCS()) {
exceptionResponse.setError(true);
exceptionResponse.setErrorMsg(exception.getMessage());

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Override
public void receivedAsynchronousCommand(ZToolPacket packet) {
  if (packet.isError()) {
    return;
  switch (packet.getCommandSubsystem()) {
    case AF:
      return;
  switch (packet.getCMD().get16BitValue()) {
    case ZToolCMD.ZDO_MSG_CB_INCOMING:
      apsFrame = ZdoCallbackIncoming.create(packet);
      break;
    default:
      logger.debug("Unhandled ZToolPacket type {}", packet.getCMD());
      break;

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Handle parsed packet.
 *
 * @param packet the packet
 */
@Override
public void handlePacket(final ZToolPacket packet) {
  final DoubleByte cmdId = packet.getCMD();
  switch (cmdId.getMsb() & 0xE0) {
    // Received incoming message which can be either message from dongle or remote device.
    case 0x40:
      logger.debug("<-- {} ({})", packet.getClass().getSimpleName(), ByteUtils.toBase16(packet.getPacket()));
      notifyAsynchronousCommand(packet);
      break;
    // Received synchronous command response.
    case 0x60:
      logger.debug("<-  {} ({})", packet.getClass().getSimpleName(), ByteUtils.toBase16(packet.getPacket()));
      notifySynchronousCommand(packet);
      break;
    default:
      logger.error("Received unknown packet. {}", packet.getClass().getSimpleName());
      break;
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

protected ZToolPacket getPacket(String stringData) {
  int[] packet = getPacketData(stringData);
  byte[] byteArray = new byte[packet.length - 1];
  for (int c = 1; c < packet.length; c++) {
    byteArray[c - 1] = (byte) packet[c];
  }
  ByteArrayInputStream stream = new ByteArrayInputStream(byteArray);
  ZigBeePort port = new TestPort(stream, null);
  try {
    ZToolPacket ztoolPacket = new ZToolPacketStream(port).parsePacket();
    assertFalse(ztoolPacket.isError());
    return ztoolPacket;
  } catch (IOException e) {
    return null;
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void testReceive() {
  String packetString = "FE 08 45 85 00 00 00 00 00 02 02 01 C9";
  ZToolPacket data = getPacket(packetString);
  assertEquals(packetString, data.getPacketString());
  ZigBeeApsFrame apsFrame = ZdoActiveEndpoint.create(data);
  assertEquals(0x0000, apsFrame.getSourceAddress());
  assertEquals(0, apsFrame.getProfile());
  assertEquals(0, apsFrame.getDestinationEndpoint());
  assertTrue(Arrays.equals(getPacketData("00 00 00 00 02 02 01"), apsFrame.getPayload()));
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Sends asynchronous command.
 *
 * @param packet the packet.
 * @throws IOException if IO exception occurs in packet sending.
 */
@Override
public void sendAsynchronousCommand(final ZToolPacket packet) throws IOException {
  int value = (packet.getCMD().getMsb() & 0xE0);
  if (value != 0x40) {
    throw new IllegalArgumentException("You are trying to send a non AREQ packet. " + "Evaluated " + value
        + " instead of " + 0x40 + "\nPacket " + packet.getClass().getName() + "\n" + packet);
  }
  sendPacket(packet);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

default:
  return new ZToolPacket(cmdId, payload);

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

if (packet.isError()) {
  return;
if (packet.getCMD().get16BitValue() == ZToolCMD.AF_INCOMING_MSG) {
  AF_INCOMING_MSG msg = (AF_INCOMING_MSG) packet;
  if (listeners.isEmpty()) {

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

/**
 * Notifies listeners about synchronous command response.
 *
 * @param packet the received packet
 */
private void notifySynchronousCommand(final ZToolPacket packet) {
  final DoubleByte cmdId = packet.getCMD();
  synchronized (synchronousCommandListeners) {
    final short id = (short) (cmdId.get16BitValue() & 0x1FFF);
    final SynchronousCommandListener listener = synchronousCommandListeners.get(id);
    if (listener != null) {
      listener.receivedCommandResponse(packet);
      synchronousCommandListeners.remove(id);
      synchronousCommandListeners.notifyAll();
    } else {
      // Notify asynchronous command listeners of unclaimed asynchronous command responses.
      final AsynchronousCommandListener[] listeners;
      synchronized (asynchrounsCommandListeners) {
        listeners = asynchrounsCommandListeners.toArray(new AsynchronousCommandListener[] {});
      }
      for (final AsynchronousCommandListener asynchronousCommandListener : listeners) {
        try {
          asynchronousCommandListener.receivedUnclaimedSynchronousCommandResponse(packet);
        } catch (Throwable e) {
          logger.error("Error in incoming asynchronous message processing: ", e);
        }
      }
    }
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

public ZB_WRITE_CONFIGURATION(int nvItemId, int[] nvItemValue) {
  int[] framedata = new int[nvItemValue.length + 2];
  framedata[0] = nvItemId;
  framedata[1] = nvItemValue.length;
  for (int i = 0; i < nvItemValue.length; i++) {
    framedata[i + 2] = nvItemValue[i];
  }
  super.buildPacket(new DoubleByte(ZToolCMD.ZB_WRITE_CONFIGURATION), framedata);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

public static ZigBeeApsFrame create(ZToolPacket packet) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(packet.getPacket()[7] + (packet.getPacket()[8] << 8));
    apsFrame.setDestinationAddress(packet.getPacket()[11] + (packet.getPacket()[12] << 8));
    apsFrame.setDestinationEndpoint(0);
    apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
    apsFrame.setSourceEndpoint(0);
    apsFrame.setProfile(0);
    apsFrame.setApsCounter(packet.getPacket()[10]);
    apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 12, packet.getPacket().length - 1));

    return apsFrame;
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

final DoubleByte cmdId = packet.getCMD();
final int value = (cmdId.getMsb() & 0xE0);
if (value != 0x20) {

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

public UTIL_SET_SECURITY_LEVEL_RESPONSE(int cmd_status1) {
  this.Status = cmd_status1;
  int[] framedata = new int[1];
  framedata[0] = this.Status;
  super.buildPacket(new DoubleByte(ZToolCMD.UTIL_SET_SECURITY_LEVEL_RESPONSE), framedata);
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

public static ZigBeeApsFrame create(ZToolPacket packet) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(ZdoCommandType.ACTIVE_ENDPOINTS_RESPONSE.getClusterId());
    apsFrame.setDestinationEndpoint(0);
    apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
    apsFrame.setSourceEndpoint(0);
    apsFrame.setProfile(0);
    apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 5, packet.getPacket().length - 1));

    return apsFrame;
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

public ZB_ALLOW_BIND(int num1) {
  this.Timeout = num1;
  int[] framedata = { num1 };
  super.buildPacket(new DoubleByte(ZToolCMD.ZB_ALLOW_BIND), framedata);
}

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com