本文整理了Java中com.zsmartsystems.zigbee.security.ZigBeeKey.<init>()
方法的一些代码示例,展示了ZigBeeKey.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZigBeeKey.<init>()
方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.security.ZigBeeKey
类名称:ZigBeeKey
方法名:<init>
[英]Default constructor. Creates a network key of 0
[中]默认构造函数。创建0的网络密钥
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Override
public ZigBeeKey getTcLinkKey() {
return new ZigBeeKey();
}
代码示例来源: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
public ZigBeeKey getZigBeeNetworkKey() {
ZB_READ_CONFIGURATION_RSP response = (ZB_READ_CONFIGURATION_RSP) sendSynchronous(
new ZB_READ_CONFIGURATION(ZB_WRITE_CONFIGURATION.CONFIG_ID.ZCD_NV_PRECFGKEY));
if (response != null && response.Status == 0) {
return new ZigBeeKey(Arrays.copyOfRange(response.Value, 0, 16));
} else {
logger.error("Error reading zigbee network key: " + ResponseStatus.getStatus(response.Status));
return new ZigBeeKey();
}
}
代码示例来源: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
@Test(expected = IllegalArgumentException.class)
public void testConstructorArrayShort() {
new ZigBeeKey(
new int[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE });
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test(expected = IllegalArgumentException.class)
public void testConstructorStringShort() {
new ZigBeeKey("11223344556677889900AABBCCDDEE");
}
代码示例来源: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 testHash() {
ZigBeeKey key1 = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
ZigBeeKey key2 = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
assertEquals(key1.hashCode(), key2.hashCode());
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void setZigBeeLinkKey() {
ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
ZigBeeKey key = new ZigBeeKey();
manager.setZigBeeLinkKey(key);
Mockito.verify(transport, Mockito.times(1)).setTcLinkKey(key);
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void setZigBeeNetworkKey() {
ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
ZigBeeKey key = new ZigBeeKey();
manager.setZigBeeNetworkKey(key);
Mockito.verify(transport, Mockito.times(1)).setZigBeeNetworkKey(key);
}
代码示例来源: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 getZigBeeLinkKey() {
ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
ZigBeeKey key = new ZigBeeKey();
Mockito.when(transport.getTcLinkKey()).thenReturn(key);
assertEquals(key, manager.getZigBeeLinkKey());
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void getZigBeeNetworkKey() {
ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
ZigBeeKey key = new ZigBeeKey();
Mockito.when(transport.getZigBeeNetworkKey()).thenReturn(key);
assertEquals(key, manager.getZigBeeNetworkKey());
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void testToString() {
ZigBeeKey key = new ZigBeeKey("11223344556677889900AABBCCDDEEFF");
assertEquals("11223344556677889900AABBCCDDEEFF", key.toString());
}
代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee
@Test
public void testConstructorArray() {
ZigBeeKey key = new ZigBeeKey(new int[] { 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
@Test
public void setZigBeeInstallKey() {
ZigBeeTransportTransmit transport = Mockito.mock(ZigBeeTransportTransmit.class);
ZigBeeNetworkManager manager = new ZigBeeNetworkManager(transport);
ZigBeeKey key = new ZigBeeKey();
assertEquals(ZigBeeStatus.INVALID_ARGUMENTS, manager.setZigBeeInstallKey(key));
key.setAddress(new IeeeAddress());
manager.setZigBeeInstallKey(key);
}
代码示例来源: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 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: 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());
}
内容来源于网络,如有侵权,请联系作者删除!