Example #1
0
                private HardwareSubRegister[] BuildSubregisterList(DiscoveredPeripheral peripheral)
                {
                    if (OriginalField.Subregisters == null)
                    {
                        return(null);
                    }

                    var qualifyingSubregisters = OriginalField.Subregisters.Where(sr => SubregisterMatchesContext(sr, peripheral)).OrderBy(r => r.Subregister.Offset).ToArray();

                    ulong coveredMask = 0;
                    List <HardwareSubRegister> result = new List <HardwareSubRegister>();

                    foreach (var r in qualifyingSubregisters)
                    {
                        if ((coveredMask & r.Subregister.Mask) != 0)
                        {
                            continue;   //Overlap with previous values
                        }
                        coveredMask |= r.Subregister.Mask;

                        result.Add(new HardwareSubRegister
                        {
                            FirstBit   = r.Subregister.Offset,
                            SizeInBits = r.Subregister.BitCount,
                            Name       = r.SubregisterName
                        });
                    }

                    if (result.Count == 0)
                    {
                        return(null);
                    }

                    return(result.ToArray());
                }
Example #2
0
        private static void OnDiscoveredPeripheral(CBCentralManager central, CBPeripheral peripheral, NSDictionary advertisementData, NSNumber RSSI)
        {
            DiscoveredPeripheral?.Invoke(central, new CBDiscoveredPeripheralEventArgs(peripheral, advertisementData, RSSI));
            System.Diagnostics.Debug.WriteLine($"{peripheral.Identifier} {RSSI}");
            var e = new BluetoothAdvertisingEvent(peripheral, advertisementData, RSSI);

            AdvertisementReceived?.Invoke(central, e);
            _foundDevices.Add(peripheral);
        }
Example #3
0
 public HardwareRegister ToHardwareRegister(DiscoveredPeripheral peripheral)
 {
     return(new HardwareRegister
     {
         Address = $"0x{peripheral.ResolvedBaseAddress + Offset:x8}",
         Name = Name,
         ReadOnly = IsReadOnly,
         SizeInBits = SizeInBytes * 8,
         SubRegisters = BuildSubregisterList(peripheral)
     });
 }
Example #4
0
                private bool SubregisterMatchesContext(SubregisterWithConstraints sr, DiscoveredPeripheral peripheral)
                {
                    if (sr.PeripheralInstanceFilter != null && sr.PeripheralInstanceFilter != peripheral.Name)
                    {
                        return(false);
                    }

                    if (sr.RegisterInstanceFilter != null && sr.RegisterInstanceFilter != ZeroBasedIndex)
                    {
                        return(false);
                    }

                    return(true);
                }