Ejemplo n.º 1
0
 public void RssiRead(CBPeripheral peripheral, NSNumber rssi, NSError error)
 {
     if (error == null)
     {
         RSSIUpdated?.Invoke(rssi.Int32Value);
         _updatingRSSI = false;
     }
 }
Ejemplo n.º 2
0
        void MessagePump()
        {
            while (BoardValueChanged == null)
            {
                Thread.Sleep(100);
            }

            OWBoardEvent previousEvent = null;
            OWBoardEvent currentEvent  = null;

            try
            {
                using (FileStream fs = new FileStream(_logFilename, FileMode.Open, FileAccess.Read))
                {
                    do
                    {
                        previousEvent = currentEvent;
                        currentEvent  = OWBoardEvent.Parser.ParseDelimitedFrom(fs);

                        if (previousEvent != null)
                        {
                            long sleepDuration = currentEvent.Timestamp - previousEvent.Timestamp;
                            Thread.Sleep((int)sleepDuration);
                        }

                        if (currentEvent.Uuid == RSSIKey)
                        {
                            RSSIUpdated?.Invoke(BitConverter.ToInt32(currentEvent.Data.ToByteArray()));
                        }
                        else
                        {
                            BoardValueChanged.Invoke(currentEvent.Uuid, currentEvent.Data.ToByteArray());
                        }
                    }while (fs.Position < fs.Length);
                }
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine("ERROR: " + err.Message);
            }
        }
Ejemplo n.º 3
0
 public void OnReadRemoteRssi(BluetoothGatt gatt, int rssi, [GeneratedEnum] GattStatus status)
 {
     RSSIUpdated?.Invoke(rssi);
     _updatingRSSI = false;
 }