public async Task <ServiceResponse <IEnumerable <byte> > > WriteToCharacteristic(string deviceUuid, string serviceUuid, string characteristicUuid, IEnumerable <byte> buffer) { bool res; var errMessage = ""; var response = new ServiceResponse <IEnumerable <byte> > { Data = buffer, }; try { res = await _bluetoothManager.WriteToCharacteristric(deviceUuid, serviceUuid, characteristicUuid, buffer); } catch (Exception e) { res = false; errMessage = "\n" + e.Message; response.Result = ServiceResponseResult.NotAcceptable; } response.Result = response.Result != ServiceResponseResult.NotSet ? response.Result : res ? ServiceResponseResult.Success : ServiceResponseResult.Fail; if (!res) { response.Message = $"Failed to write to characteristic. device Id: \'{deviceUuid}\' gatt-service Id: \'{serviceUuid}\' characteristic id: \'{characteristicUuid}\' buffer: \'{buffer}\'{errMessage}"; } return(response); }