gpt4 book ai didi

com.zsmartsystems.zigbee.ZigBeeNetworkManager.setSerializer()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 10:01:31 26 4
gpt4 key购买 nike

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

ZigBeeNetworkManager.setSerializer介绍

[英]Set the serializer class to be used to convert commands and fields into data to be sent to the dongle. The system instantiates a new serializer for each command.
[中]设置用于将命令和字段转换为要发送到加密狗的数据的序列化程序类。系统为每个命令实例化一个新的序列化程序。

代码示例

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

networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
final ZigBeeConsole console = new ZigBeeConsole(networkManager, dongle, commands);

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

private ZigBeeCommand getZigBeeCommand(ZigBeeApsFrame apsFrame) {
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  networkManager.receiveCommand(apsFrame);
  Awaitility.await().until(() -> commandListenerUpdated());
  if (commandListenerCapture.size() == 0) {
    return null;
  }
  return commandListenerCapture.get(0);
}

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

@Test
public void testPermitJoin() {
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  assertEquals(ZigBeeStatus.SUCCESS, networkManager.permitJoin(0));
  assertEquals(ZigBeeStatus.SUCCESS, networkManager.permitJoin(254));
  assertEquals(ZigBeeStatus.INVALID_ARGUMENTS, networkManager.permitJoin(255));
  // Check that the unicast sends 1 frame
  int start = mockedApsFrameListener.getAllValues().size();
  networkManager.permitJoin(new ZigBeeEndpointAddress(1), 1);
  assertEquals(1, mockedApsFrameListener.getAllValues().size() - start);
  // Check that the broadcast sends 2 frames
  start = mockedApsFrameListener.getAllValues().size();
  networkManager.permitJoin(1);
  assertEquals(2, mockedApsFrameListener.getAllValues().size() - start);
}

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

@Test
public void testNodeNetworkAddressUpdate() {
  mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
  mockedApsFrameListener = ArgumentCaptor.forClass(ZigBeeApsFrame.class);
  ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
  ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("12345678990ABCDEF"));
  node.setNetworkAddress(12345);
  ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, 1);
  ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint);
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  Mockito.doNothing().when(mockedTransport).sendCommand(mockedApsFrameListener.capture());
  cluster.onCommand();
  assertEquals(12345, mockedApsFrameListener.getValue().getDestinationAddress());
  node.setNetworkAddress(54321);
  cluster.offCommand();
  assertEquals(54321, mockedApsFrameListener.getValue().getDestinationAddress());
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

networkManager.setSerializer(serializerClass, deserializerClass);
networkManager.addNetworkStateListener(this);
networkManager.addNetworkNodeListener(this);

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

@Test
public void testSendCommandZCL() {
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  ZigBeeEndpointAddress deviceAddress = new ZigBeeEndpointAddress(1234, 56);
  OnCommand cmd = new OnCommand();
  cmd.setClusterId(6);
  cmd.setDestinationAddress(deviceAddress);
  boolean error = false;
  networkManager.sendCommand(cmd);
  assertFalse(error);
  assertEquals(1, mockedApsFrameListener.getAllValues().size());
  ZigBeeApsFrame apsFrame = mockedApsFrameListener.getValue();
  assertEquals(ZigBeeNwkAddressMode.DEVICE, apsFrame.getAddressMode());
  assertEquals(1234, apsFrame.getDestinationAddress());
  assertEquals(0, apsFrame.getSourceAddress());
  assertEquals(0x104, apsFrame.getProfile());
  assertEquals(6, apsFrame.getCluster());
  assertEquals(56, apsFrame.getDestinationEndpoint());
}

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

@Test
public void testReceiveZclCommand() {
  ZigBeeNetworkManager networkManager = mockZigBeeNetworkManager();
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
  apsFrame.setSourceAddress(1234);
  apsFrame.setDestinationAddress(0);
  apsFrame.setApsCounter(1);
  apsFrame.setCluster(6);
  apsFrame.setDestinationEndpoint(2);
  apsFrame.setProfile(0x104);
  apsFrame.setSourceEndpoint(5);
  ZclHeader zclHeader = new ZclHeader();
  zclHeader.setCommandId(0);
  zclHeader.setFrameType(ZclFrameType.ENTIRE_PROFILE_COMMAND);
  zclHeader.setSequenceNumber(1);
  DefaultSerializer serializer = new DefaultSerializer();
  ZclFieldSerializer fieldSerializer = new ZclFieldSerializer(serializer);
  apsFrame.setPayload(zclHeader.serialize(fieldSerializer, new int[] {}));
  networkManager.receiveCommand(apsFrame);
  Awaitility.await().until(() -> commandListenerUpdated());
  ReadAttributesCommand response = (ReadAttributesCommand) commandListenerCapture.get(0);
  assertEquals(6, (int) response.getClusterId());
  assertEquals(0, (int) response.getCommandId());
  assertEquals(1, (int) response.getTransactionId());
  assertEquals(new ZigBeeEndpointAddress(1234, 5), response.getSourceAddress());
}

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