internal void UnregisterGattService(BluetoothGattService service) { int err = Interop.Bluetooth.BtGattServerUnregisterService(_handle, service.GetHandle()); GattUtil.ThrowForError(err, "Failed to Unregister service"); service.UnregisterService(); }
internal void RegisterGattService(BluetoothGattServer server, BluetoothGattService service) { int err = Interop.Bluetooth.BtGattServerRegisterService(_handle, service.GetHandle()); GattUtil.ThrowForError(err, "Failed to Register service"); service.SetParent(server); }
internal IEnumerable <BluetoothGattService> GetIncludeServices(BluetoothGattService parentService) { 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(parentService); attribututeList.Add(service); } return(true); }; int err = Interop.Bluetooth.BtGattServiceForeachIncludedServices(parentService.GetHandle(), cb, IntPtr.Zero); GattUtil.Error(err, "Failed to get all services"); return(attribututeList); }
internal IEnumerable <BluetoothGattCharacteristic> GetCharacteristics(BluetoothGattService service) { List <BluetoothGattCharacteristic> attribututeList = new List <BluetoothGattCharacteristic>(); Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) => { BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false); BluetoothGattCharacteristic Characteristic = BluetoothGattCharacteristicImpl.CreateBluetoothGattGattCharacteristic(handle, ""); if (Characteristic != null) { Characteristic.SetParent(service); attribututeList.Add(Characteristic); } return(true); }; int err = Interop.Bluetooth.BtGattServiceForeachCharacteristics(service.GetHandle(), cb, IntPtr.Zero); GattUtil.Error(err, "Failed to get all Characteristic"); return(attribututeList); }
internal void AddIncludeService(BluetoothGattService includedService) { int err = Interop.Bluetooth.BtGattServiceAddIncludedService(_handle, includedService.GetHandle()); GattUtil.ThrowForError(err, string.Format("Failed to add service with UUID ({0})", includedService.Uuid)); }