Пример #1
0
        internal unsafe static void WithArray(Guid [] uuids, string argName, Action <NSArray> action)
        {
            if (uuids == null)
            {
                throw new ArgumentNullException(argName);
            }
            var ptrs = new IntPtr [uuids.Length];

            for (int i = 0; i < uuids.Length; i++)
            {
                var ba = uuids [i].ToByteArray();
                ptrs [i] = CFUUID.CFUUIDCreateWithBytes(IntPtr.Zero, ba [0], ba [1], ba [2], ba [3], ba [4],
                                                        ba [5], ba [6], ba [7], ba [8], ba [9], ba [10], ba [11], ba [12], ba [13], ba [14], ba [15]);
            }
            using (var arr = NSArray.FromIntPtrs(ptrs))
                action(arr);

            foreach (var h in ptrs)
            {
                if (h == IntPtr.Zero)
                {
                    continue;
                }
                CFObject.CFRelease(h);
            }
        }
Пример #2
0
 public void DiscoverCharacteristics(Guid [] charactersticUUIDs, CBService forService)
 {
     if (charactersticUUIDs == null)
     {
         DiscoverCharacteristics((NSArray)null, forService);
     }
     else
     {
         CFUUID.WithArray(charactersticUUIDs, "charactersticUUIDs", x => DiscoverCharacteristics(x, forService));
     }
 }
Пример #3
0
 public void DiscoverIncludedServices(Guid [] includedServiceUUIDs, CBService forService)
 {
     if (includedServiceUUIDs == null)
     {
         DiscoverIncludedServices((NSArray)null, forService);
     }
     else
     {
         CFUUID.WithArray(includedServiceUUIDs, "includedServiceUUIDs", x => DiscoverIncludedServices(x, forService));
     }
 }
Пример #4
0
 public void DiscoverServices(Guid [] services)
 {
     if (services == null)
     {
         DiscoverServices((NSArray)null);
     }
     else
     {
         CFUUID.WithArray(services, "services", x => DiscoverServices(x));
     }
 }
Пример #5
0
 public void ScanForPeripherals(Guid [] serviceUuids, NSDictionary options)
 {
     if (serviceUuids == null)
     {
         ScanForPeripherals((NSArray)null, options);
     }
     else
     {
         CFUUID.WithArray(serviceUuids, "serviceUuids", x => ScanForPeripherals(x, options));
     }
 }
Пример #6
0
        public void RetrievePeripherals(CBUUID [] peripheralUuids)
        {
            if (peripheralUuids == null)
            {
                throw new ArgumentNullException("peripheralUuids");
            }
            var ptrs = new IntPtr [peripheralUuids.Length];

            for (int i = 0; i < peripheralUuids.Length; i++)
            {
                using (var s = new NSString(peripheralUuids[i].ToString(true)))
                    ptrs [i] = CFUUID.CFUUIDCreateFromString(IntPtr.Zero, s.Handle);
            }
            using (var arr = NSArray.FromIntPtrs(ptrs))
                RetrievePeripherals(arr);

            foreach (var p in ptrs)
            {
                CFObject.CFRelease(p);
            }
        }
Пример #7
0
 public void RetrievePeripherals(Guid [] peripheralUuids)
 {
     CFUUID.WithArray(peripheralUuids, "peripheralUuids", x => RetrievePeripherals(x));
 }