Search in sources :

Example 6 with ZigBeePort

use of com.zsmartsystems.zigbee.transport.ZigBeePort in project com.zsmartsystems.zigbee by zsmartsystems.

the class TelegesisFirmwareUpdateHandlerTest method getTransferResponse.

private int getTransferResponse(String packet) {
    ByteArrayInputStream stream = new ByteArrayInputStream(packet.getBytes());
    ZigBeePort port = new TestPort(stream);
    TelegesisFirmwareUpdateHandler firmwareHandler = new TelegesisFirmwareUpdateHandler(null, null, port, null);
    Method privateMethod;
    try {
        privateMethod = TelegesisFirmwareUpdateHandler.class.getDeclaredMethod("getTransferResponse");
        privateMethod.setAccessible(true);
        return (int) privateMethod.invoke(firmwareHandler);
    } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return 0;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Method(java.lang.reflect.Method) ZigBeePort(com.zsmartsystems.zigbee.transport.ZigBeePort) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with ZigBeePort

use of com.zsmartsystems.zigbee.transport.ZigBeePort in project com.zsmartsystems.zigbee by zsmartsystems.

the class AshFrameHandlerTest method getPacket.

private int[] getPacket(int[] data) {
    AshFrameHandler frameHandler = new AshFrameHandler(null);
    byte[] bytedata = new byte[data.length];
    int cnt = 0;
    for (int value : data) {
        bytedata[cnt++] = (byte) value;
    }
    ByteArrayInputStream stream = new ByteArrayInputStream(bytedata);
    ZigBeePort port = new TestPort(stream, null);
    Method privateMethod;
    try {
        Field field = frameHandler.getClass().getDeclaredField("port");
        field.setAccessible(true);
        field.set(frameHandler, port);
        privateMethod = AshFrameHandler.class.getDeclaredMethod("getPacket");
        privateMethod.setAccessible(true);
        return (int[]) privateMethod.invoke(frameHandler);
    } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : Method(java.lang.reflect.Method) ZigBeePort(com.zsmartsystems.zigbee.transport.ZigBeePort) InvocationTargetException(java.lang.reflect.InvocationTargetException) Field(java.lang.reflect.Field) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 8 with ZigBeePort

use of com.zsmartsystems.zigbee.transport.ZigBeePort in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberFirmwareUpdateHandlerTest method getTransferResponse.

private int getTransferResponse(String packet) {
    ByteArrayInputStream stream = new ByteArrayInputStream(packet.getBytes());
    ZigBeePort port = new TestPort(stream);
    EmberFirmwareUpdateHandler firmwareHandler = new EmberFirmwareUpdateHandler(null, null, port, null);
    Method privateMethod;
    try {
        privateMethod = EmberFirmwareUpdateHandler.class.getDeclaredMethod("getTransferResponse");
        privateMethod.setAccessible(true);
        return (int) privateMethod.invoke(firmwareHandler);
    } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return 0;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Method(java.lang.reflect.Method) ZigBeePort(com.zsmartsystems.zigbee.transport.ZigBeePort) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with ZigBeePort

use of com.zsmartsystems.zigbee.transport.ZigBeePort in project com.zsmartsystems.zigbee by zsmartsystems.

the class XBeeFrameHandlerTest method getPacket.

private int[] getPacket(String packet) {
    String[] split = packet.split(" ");
    byte[] response = new byte[split.length];
    int cnt = 0;
    for (String val : split) {
        response[cnt++] = (byte) Integer.parseInt(val, 16);
    }
    XBeeFrameHandler frameHandler = new XBeeFrameHandler();
    ByteArrayInputStream stream = new ByteArrayInputStream(response);
    ZigBeePort port = new TestPort(stream, null);
    Method privateMethod;
    try {
        Field field = frameHandler.getClass().getDeclaredField("serialPort");
        field.setAccessible(true);
        field.set(frameHandler, port);
        privateMethod = XBeeFrameHandler.class.getDeclaredMethod("getPacket");
        privateMethod.setAccessible(true);
        return (int[]) privateMethod.invoke(frameHandler);
    } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : Method(java.lang.reflect.Method) ZigBeePort(com.zsmartsystems.zigbee.transport.ZigBeePort) InvocationTargetException(java.lang.reflect.InvocationTargetException) Field(java.lang.reflect.Field) ByteArrayInputStream(java.io.ByteArrayInputStream)

Aggregations

ZigBeePort (com.zsmartsystems.zigbee.transport.ZigBeePort)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 Method (java.lang.reflect.Method)7 Field (java.lang.reflect.Field)3 ExtendedPanId (com.zsmartsystems.zigbee.ExtendedPanId)1 ZigBeeKey (com.zsmartsystems.zigbee.ZigBeeKey)1 ZigBeeNetworkManager (com.zsmartsystems.zigbee.ZigBeeNetworkManager)1 ZigBeeNetworkMeshMonitor (com.zsmartsystems.zigbee.ZigBeeNetworkMeshMonitor)1 ZigBeeNetworkStateSerializer (com.zsmartsystems.zigbee.ZigBeeNetworkStateSerializer)1 ZigBeeConsoleCommand (com.zsmartsystems.zigbee.console.ZigBeeConsoleCommand)1 EmberConsoleNcpChildrenCommand (com.zsmartsystems.zigbee.console.ember.EmberConsoleNcpChildrenCommand)1 EmberConsoleNcpCountersCommand (com.zsmartsystems.zigbee.console.ember.EmberConsoleNcpCountersCommand)1 EmberConsoleNcpStateCommand (com.zsmartsystems.zigbee.console.ember.EmberConsoleNcpStateCommand)1 EmberConsoleNcpVersionCommand (com.zsmartsystems.zigbee.console.ember.EmberConsoleNcpVersionCommand)1 EmberConsoleNetworkStateCommand (com.zsmartsystems.zigbee.console.ember.EmberConsoleNetworkStateCommand)1 EmberConsoleSecurityStateCommand (com.zsmartsystems.zigbee.console.ember.EmberConsoleSecurityStateCommand)1 ZigBeeDongleTiCc2531 (com.zsmartsystems.zigbee.dongle.cc2531.ZigBeeDongleTiCc2531)1 ZToolPacket (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket)1 ZToolPacketStream (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacketStream)1