public static IOBluetoothDevice GetDeviceWithAddress (BluetoothDeviceAddress address) { var addressPtr = Marshal.AllocHGlobal (Marshal.SizeOf (address)); try { Marshal.StructureToPtr (address, addressPtr, false); return getDeviceWithAddress (addressPtr); } finally { Marshal.FreeHGlobal (addressPtr); } }
public static IOBluetoothDevice GetDeviceWithAddress(BluetoothDeviceAddress address) { var addressPtr = Marshal.AllocHGlobal(Marshal.SizeOf(address)); try { Marshal.StructureToPtr(address, addressPtr, false); return(getDeviceWithAddress(addressPtr)); } finally { Marshal.FreeHGlobal(addressPtr); } }
public IOBluetoothDeviceSearchDeviceAttributes( BluetoothDeviceAddress address, string name, BluetoothServiceClassMajor serviceClassMajor, BluetoothDeviceClassMajor deviceClassMajor, BluetoothDeviceClassMinor deviceClassMinor) { if (name == null) { throw new ArgumentNullException("name"); } if (Encoding.UTF8.GetByteCount(name) > 256) { throw new ArgumentOutOfRangeException("name is too long"); } this.address = address; this.name = new byte[256]; Encoding.UTF8.GetBytes(name, 0, name.Length, this.name, 0); this.serviceClassMajor = serviceClassMajor; this.deviceClassMajor = deviceClassMajor; this.deviceClassMinor = deviceClassMinor; }
public static NSString ToNSString(this BluetoothDeviceAddress deviceAddress) { return((NSString)Runtime.GetNSObject(IOBluetoothNSStringFromDeviceAddress(deviceAddress))); }
extern static IntPtr IOBluetoothNSStringFromDeviceAddress([MarshalAs(UnmanagedType.LPStruct)] BluetoothDeviceAddress deviceAddress);
extern static IOReturn IOBluetoothNSStringToDeviceAddress(IntPtr inNameString, out BluetoothDeviceAddress outDeviceAddress);
extern static IOReturn IOBluetoothNSStringToDeviceAddress (IntPtr inNameString, out BluetoothDeviceAddress outDeviceAddress);
public IOBluetoothDeviceSearchDeviceAttributes ( BluetoothDeviceAddress address, string name, BluetoothServiceClassMajor serviceClassMajor, BluetoothDeviceClassMajor deviceClassMajor, BluetoothDeviceClassMinor deviceClassMinor) { if (name == null) throw new ArgumentNullException ("name"); if (Encoding.UTF8.GetByteCount (name) > 256) throw new ArgumentOutOfRangeException ("name is too long"); this.address = address; this.name = new byte[256]; Encoding.UTF8.GetBytes (name, 0, name.Length, this.name, 0); this.serviceClassMajor = serviceClassMajor; this.deviceClassMajor = deviceClassMajor; this.deviceClassMinor = deviceClassMinor; }