gpt4 book ai didi

com.zsmartsystems.zigbee.security.ZigBeeKey类的使用及代码示例

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

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

ZigBeeKey介绍

[英]Represents a 128 bit ZigBee key
[中]表示128位ZigBee密钥

代码示例

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

@Override
public ZigBeeKey getTcLinkKey() {
  return new ZigBeeKey();
}

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

builder.append(channel.toString());
builder.append('>');
builder.append(networkKey.toString());
builder.append('>');
if (networkKey.hasSequenceNumber()) {
  builder.append(String.format("%02X", networkKey.getSequenceNumber()));
if (networkKey.hasIncomingFrameCounter()) {
  builder.append(String.format("%08X", networkKey.getIncomingFrameCounter()));
if (networkKey.hasOutgoingFrameCounter()) {
  builder.append(String.format("%08X", networkKey.getOutgoingFrameCounter()));
builder.append(linkKey.toString());
builder.append('>');
if (linkKey.hasSequenceNumber()) {
  builder.append(String.format("%02X", linkKey.getSequenceNumber()));
if (linkKey.hasIncomingFrameCounter()) {
  builder.append(String.format("%08X", linkKey.getIncomingFrameCounter()));
if (linkKey.hasOutgoingFrameCounter()) {
  builder.append(String.format("%08X", linkKey.getOutgoingFrameCounter()));

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

/**
 * Process the adding of an install code
 *
 * @param installCode the string representation of the install code
 * @param transportConfig the {@link TransportConfig} to populate with the configuration
 */
private void addInstallCode(String installCode) {
  if (installCode == null || installCode.isEmpty()) {
    return;
  }
  // Split the install code and the address
  String[] codeParts = installCode.split(":");
  if (codeParts.length != 2) {
    logger.warn("{}: Incorrectly formatted install code configuration {}", nodeIeeeAddress, installCode);
    return;
  }
  MmoHash mmoHash = new MmoHash(codeParts[1].replace("-", ""));
  ZigBeeKey key = new ZigBeeKey(mmoHash.getHash());
  key.setAddress(new IeeeAddress(codeParts[0]));
  networkManager.setZigBeeInstallKey(key);
}

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

private ZigBeeKey parseKey(int secondsSinceBackup, String keyString, String sequence, String incount,
    String outcount) {
  ZigBeeKey key = new ZigBeeKey(keyString);
  try {
    if (!sequence.isEmpty()) {
      key.setSequenceNumber(Integer.parseInt(sequence, 16));
    }
    if (!incount.isEmpty()) {
      key.setIncomingFrameCounter(Integer.parseInt(incount, 16) + secondsSinceBackup);
    }
    if (!outcount.isEmpty()) {
      key.setOutgoingFrameCounter(Integer.parseInt(outcount, 16) + secondsSinceBackup);
    }
  } catch (NumberFormatException e) {
    throw new IllegalArgumentException("Error parsing key parameters");
  }
  return key;
}

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

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out)
    throws IllegalArgumentException {
  if (args.length < 2 || args.length > 3) {
    throw new IllegalArgumentException("Incorrect number of arguments.");
  }
  ZigBeeKey key;
  if (args.length == 2) {
    key = new ZigBeeKey(args[1]);
  } else if (args.length == 3 && args[1].equalsIgnoreCase("mmo")) {
    MmoHash hash;
    try {
      hash = new MmoHash(args[2]);
      key = new ZigBeeKey(hash.getHash());
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException("MMO key is incorrect format.");
    }
  } else {
    throw new IllegalArgumentException("Invalid arguments.");
  }
  ZigBeeStatus result = networkManager.setZigBeeLinkKey(key);
  out.println("Link key " + key.toString() + " was " + (result == ZigBeeStatus.SUCCESS ? "" : "not") + " set.");
}

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

@Test
public void testOutgoingFrameCounter() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertFalse(key.hasOutgoingFrameCounter());
  assertNull(key.getOutgoingFrameCounter());
  key.setOutgoingFrameCounter(1);
  assertTrue(key.hasOutgoingFrameCounter());
  assertEquals(Integer.valueOf(1), key.getOutgoingFrameCounter());
}

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

networkKey = new ZigBeeKey(networkKeyString);
} catch (IllegalArgumentException e) {
  networkKey = new ZigBeeKey();
  logger.debug("Network Key String has invalid format. Revert to default key.");
if (!networkKey.isValid()) {
  networkKey = ZigBeeKey.createRandom();
  logger.debug("Network key initialised {}", networkKey);
  linkKey = new ZigBeeKey(linkKeyString);
} catch (IllegalArgumentException e) {
  linkKey = KEY_ZIGBEE_ALLIANCE_O9;
    configuration.put(CONFIGURATION_LINKKEY, linkKey.toString());
    configuration.put(CONFIGURATION_NETWORKKEY, networkKey.toString());
    configuration.put(CONFIGURATION_INITIALIZE, false);
    updateConfiguration(configuration);

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

@Test
public void testIncomingFrameCounter() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertFalse(key.hasIncomingFrameCounter());
  assertNull(key.getIncomingFrameCounter());
  key.setIncomingFrameCounter(1);
  assertTrue(key.hasIncomingFrameCounter());
  assertEquals(Integer.valueOf(1), key.getIncomingFrameCounter());
}

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

@Test
public void testSequenceNumber() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertFalse(key.hasSequenceNumber());
  assertNull(key.getSequenceNumber());
  key.setSequenceNumber(2);
  assertTrue(key.hasSequenceNumber());
  assertEquals(Integer.valueOf(2), key.getSequenceNumber());
}

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

@Test
public void testAddress() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertFalse(key.hasAddress());
  assertNull(key.getAddress());
  key.setAddress(new IeeeAddress("1234567890ABCDE"));
  assertTrue(key.hasAddress());
  assertEquals(new IeeeAddress("1234567890ABCDE"), key.getAddress());
}

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

out.println("Channel                      :");
out.println("Network Key                  :" + networkKey);
if (networkKey.hasSequenceNumber()) {
  out.println("Network Key Sequence         :" + networkKey.getSequenceNumber());
if (networkKey.hasIncomingFrameCounter()) {
  out.println("Network Key Incoming Counter :" + networkKey.getIncomingFrameCounter());
if (networkKey.hasIncomingFrameCounter()) {
  out.println("Network Key Outgoing Counter :" + networkKey.getOutgoingFrameCounter());
if (linkKey.hasSequenceNumber()) {
  out.println("Link Key Sequence            :" + linkKey.getSequenceNumber());
if (linkKey.hasIncomingFrameCounter()) {
  out.println("Link Key Incoming Counter    :" + linkKey.getIncomingFrameCounter());
if (linkKey.hasIncomingFrameCounter()) {
  out.println("Link Key Outgoing Counter    :" + linkKey.getOutgoingFrameCounter());

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

@Test
public void testValid() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertTrue(key.isValid());
  key = new ZigBeeKey("00000000000000000000000000000000");
  assertFalse(key.isValid());
}

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

@Test
public void testHash() {
  ZigBeeKey key1 = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  ZigBeeKey key2 = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertEquals(key1.hashCode(), key2.hashCode());
}

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

@Test
public void testEquals() {
  ZigBeeKey key1 = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  ZigBeeKey key2 = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertTrue(key1.equals(key2));
}

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

@Test
public void testRandom() {
  ZigBeeKey key = ZigBeeKey.createRandom();
  assertTrue(key.isValid());
}

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

nwkKey = new ZigBeeKey(cmdline.getOptionValue("nwkkey"));
  } else {
    nwkKey = ZigBeeKey.createRandom();
    linkKey = new ZigBeeKey(cmdline.getOptionValue("linkkey"));
  } else {
    linkKey = new ZigBeeKey(new int[] { 0x5A, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6C, 0x6C, 0x69, 0x61,
        0x6E, 0x63, 0x65, 0x30, 0x39 });
    nwkKey.setOutgoingFrameCounter(parseDecimalOrHexInt(cmdline.getOptionValue("nwkkeyoutcnt")));
    linkKey.setOutgoingFrameCounter(parseDecimalOrHexInt(cmdline.getOptionValue("linkkeyoutcnt")));
  System.out.println("  * Extended PAN ID        = " + extendedPan);
  System.out.println("  * Link Key               = " + linkKey);
  if (nwkKey.hasOutgoingFrameCounter()) {
    System.out.println("  * Link Key Frame Cnt     = " + linkKey.getOutgoingFrameCounter());
  if (nwkKey.hasOutgoingFrameCounter()) {
    System.out.println("  * Network Key Frame Cnt  = " + nwkKey.getOutgoingFrameCounter());
transportOptions.addOption(TransportConfigOption.TRUST_CENTRE_LINK_KEY, new ZigBeeKey(new int[] { 0x5A, 0x69,
    0x67, 0x42, 0x65, 0x65, 0x41, 0x6C, 0x6C, 0x69, 0x61, 0x6E, 0x63, 0x65, 0x30, 0x39 }));

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

@Test
public void testConstructorString() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
  key = new ZigBeeKey("11 22 33 44 55 66 77 88 99 00 AA BB CC DD EE FF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
  key = new ZigBeeKey("11,22,33,44,55,66,77,88,99,00,AA,BB,CC,DD,EE,FF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
  key = new ZigBeeKey("11:22:33:44:55:66:77:88:99:00:AA:BB:CC:DD:EE:FF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
  key = new ZigBeeKey("0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 0x99 0x00 0xAA 0xBB 0xCC 0xDD 0xEE 0xFF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
  key = new ZigBeeKey("0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0x00,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
  key = new ZigBeeKey("0x11:0x22:0x33:0x44:0x55:0x66:0x77:0x88:0x99:0x00:0xAA:0xBB:0xCC:0xDD:0xEE:0xFF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
}

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

/**
 * Create a {@link ZigBeeKey} with a random key
 *
 * @return {@link ZigBeeKey} containing a random 128 bit key
 */
public static ZigBeeKey createRandom() {
  int key[] = new int[16];
  for (int cnt = 0; cnt < 16; cnt++) {
    key[cnt] = (int) Math.floor((Math.random() * 255));
  }
  return new ZigBeeKey(key);
}

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

@Test
public void testToString() {
  ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
  assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
}

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

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out)
    throws IllegalArgumentException {
  if (args.length < 2 || args.length > 3) {
    throw new IllegalArgumentException("Incorrect number of arguments.");
  }
  IeeeAddress partner;
  try {
    partner = new IeeeAddress(args[1]);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Partner address is incorrect format.");
  }
  MmoHash hash;
  ZigBeeKey installKey;
  try {
    hash = new MmoHash(args[2]);
    installKey = new ZigBeeKey(hash.getHash());
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("Install key is incorrect format.");
  }
  installKey.setAddress(partner);
  ZigBeeStatus result = networkManager.setZigBeeInstallKey(installKey);
  out.println("Install key " + hash.toString() + " for address " + partner + " was "
      + (result == ZigBeeStatus.SUCCESS ? "" : "not") + " set.");
}

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