void Update() { MainThreadWait.WaitOne(); MainThreadWait.Reset(); if (mainThreadCallback != null) { try { mainThreadCallback(); } catch (Exception e) { Debug.Log(e); } mainThreadCallback = null; } if (useReceiveEvents) { lock (readQueue) { if (readQueue.Count > 0) { ValueReceivedEvent.Invoke(readQueue.Dequeue()); } } } ChildThreadWait.Set(); }
public void Connect() { logger.LogInformation($"Connecting KEBA on {ip}:{port}"); sender.Connect(IPAddress.Parse(ip), port); logger.LogInformation("Connected"); connected = true; Task.Run(async() => { while (connected) { var receivedResults = await listener.ReceiveAsync(); var message = Encoding.ASCII.GetString(receivedResults.Buffer); logger.LogTrace($"Message received: {message}"); ValueReceived?.Invoke(this, message); } logger.LogInformation("Connection closed."); }); Send(InformationCommand); Send(Report2Command); Send(Report3Command); report3Timer.Start(); report2Timer.Start(); }
public override void ProcessNetworkData(string id, string value) { BindingValue bound = new BindingValue(value); _value.SetValue(bound, false); _receivedTrigger.FireTrigger(bound); ValueReceived?.Invoke(this, new Value { Text = value }); }
private void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args) { if (!_valueReceived) { _valueReceived = true; var tet = args.CharacteristicValue.ToString(); var byteArray = args.CharacteristicValue.ToArray(); var strValue = Encoding.UTF8.GetString(byteArray); var buttonId = strValue.Split(";")[0]; var buttonPressCount = strValue.Split(";")[1]; ValueReceived?.Invoke(this, new ValueReceivedEventArgs(buttonId, ushort.Parse(buttonPressCount))); _signal.Set(); } }
private void OnValueReceived(Reading value) { Console.WriteLine(value); ValueReceived?.Invoke(this, value); }