/** * Construct which sets input stream where the packet is read from the and handler * which further processes the received packet. * * @param port the {@link ZigBeePort} * @param packetHandler the packet handler */ public ZToolPacketParser(IZigBeePort port, IZToolPacketHandler packetHandler) { _logger.Trace("Creating ZToolPacketParser"); _port = port; _cancellationToken = new CancellationTokenSource(); _packetHandler = packetHandler; parserTask = new Task(Run); parserTask.Start(); }
public ConBeeInterface(IZigBeePort serialPort) { this.serialPort = serialPort; }
public ZigBeeDongleXBee(IZigBeePort serialPort) { _serialPort = serialPort; }
public ZigBeeDongleTiCc2531(IZigBeePort serialPort) { _networkManager = new NetworkManager(new CommandInterfaceImpl(serialPort), NetworkMode.Coordinator, 2500); }
/// <summary> /// Constructor for configuring the ZigBee Network connection parameters. /// /// <param name="port">the ZigBee transport implementation.</param> /// </summary> public CommandInterfaceImpl(IZigBeePort port) { this._port = port; }
public ZToolPacketStream(IZigBeePort port) { _port = port; }
/// <summary> /// Construct which sets input stream where the packet is read from the and /// handler which further processes the received packet. /// </summary> /// <param name="serialPort">The serial port.</param> public void Start(IZigBeePort serialPort) { Interlocked.Exchange(ref _frameId, 1); _serialPort = serialPort; _timeoutTimer = new Timer(new TimerCallback(TimeoutCallback)); // TODO af: find the equivalent in C# --> maybe ThreadPool-Class is the right one //timeoutScheduler = Executors.newSingleThreadScheduledExecutor(); // Clear anything in the receive buffer before we start EmptyRxBuffer(); // TODO af: find a more elegant way to solve this --> maybe async/await // This might be resolved with a TaskCompletionSource // See the refactored while loop in ZigBeeTransaction.cs line 84 _parserThread = _taskFactory.StartNew(() => { Log.Debug("XBeeFrameHandler task started."); while (!_closeHandler) { try { lock (_commandLock) { if (_sentCommand == null) { SendNextFrame(); } } // Get a packet from the serial port int[] responseData = GetPacket(); if (responseData == null) { lock (_commandLock) { _sentCommand = null; } continue; } StringBuilder builder = new StringBuilder(); foreach (int value in responseData) { builder.Append(string.Format(" 0x{0:X2}", value.ToString())); } Log.Verbose($"RX XBEE Data: {builder}"); // Use the Event Factory to get an event IXBeeEvent xBeeEvent = XBeeEventFactory.GetXBeeFrame(responseData); if (xBeeEvent != null) { NotifyEventReceived(xBeeEvent); } // Use the Response Factory to get a response IXBeeResponse response = XBeeResponseFactory.GetXBeeFrame(responseData); if (response != null && NotifyResponseReceived(response)) { lock (_commandLock) { _sentCommand = null; } } } catch (Exception ex) { Log.Error(ex, "XBeeFrameHandler exception {Exception}", ex.Message); } } Log.Debug("XBeeFrameHandler thread exited."); }); }
public void Start(IZigBeePort port) { _port = port; _parserCancellationToken = new CancellationTokenSource(); _parserTask = Task.Factory.StartNew(ParserTaskLoop, _parserCancellationToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
public ZigbeeDongleConBee(IZigBeePort serialPort) { _conbeeInterface = new ConBeeInterface(serialPort); }
public ZigBeeDongleXBee(IZigBeePort serialPort, IXBeeConfiguration configuration) { _serialPort = serialPort; _configuration = configuration; }