internal void SetParent(BluetoothGattClient parent) { if (!IsRegistered()) { _parentClient = parent; _impl.ReleaseHandleOwnership(); } }
internal BluetoothGattService GetService(BluetoothGattClient client, string uuid) { BluetoothGattAttributeHandle serviceHandle; int err = Interop.Bluetooth.BtGattClientGetService(_handle, uuid, out serviceHandle); if (err.IsFailed()) { GattUtil.Error(err, string.Format("Failed to get service with UUID ({0})", uuid)); return(null); } BluetoothGattService service = new BluetoothGattService(new BluetoothGattServiceImpl(serviceHandle), uuid);; service.SetParent(client); return(service); }
internal IEnumerable <BluetoothGattService> GetServices(BluetoothGattClient client) { List <BluetoothGattService> attribututeList = new List <BluetoothGattService>(); Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) => { BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false); BluetoothGattService service = BluetoothGattServiceImpl.CreateBluetoothGattService(handle, ""); if (service != null) { service.SetParent(client); attribututeList.Add(service); } return(true); }; int err = Interop.Bluetooth.BtGattClientForeachServices(_handle, cb, IntPtr.Zero); GattUtil.Error(err, "Failed to get all services"); return(attribututeList); }
public BluetoothGattClient GattConnect(bool autoConnect) { BluetoothGattClient client = null; if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize) { int ret = BluetoothLeImplAdapter.Instance.GattConnect(_remoteAddress, autoConnect); if (ret != (int)BluetoothError.None) { Log.Error(Globals.LogTag, "Failed to create GATT Connection with remote device- " + (BluetoothError)ret); } else { client = BluetoothGattClient.CreateClient(_remoteAddress); } } else { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled); } return(client); }
internal void UnregisterService() { _parentServer = null; _parentClient = null; _parentService = null; }
internal static BluetoothGattClient CreateClient(string remoteAddress) { BluetoothGattClient client = new BluetoothGattClient(remoteAddress); return(client.Isvalid() ? client : null); }