I need to enroll fingerprint from fingerprint scanner (also recognize it in the future) from U.are.U 4500.
Currently I`m trying to develop C# Windows application using Verifinger SDK. I still can not understand how to enroll fingerprint using scanner. I also could not figure it out after looking to simple apps provided here and searching on the web.
If there is anyone who knows how to capture fingerprint, kindly explain it to me.
Below is the part of the code where as far as I understood scans fingerprint from scanner:
private async void ScanButtonClickAsync(object sender, EventArgs e)
{
if (_biometricClient.FingerScanner == null)
{
MessageBox.Show(#"Please select a scanner from the list.");
}
else
{
EnableControls(true);
lblQuality.Text = String.Empty;
// Create a finger
_subjectFinger = new NFinger();
// Set Manual capturing mode if not automatic selected
if (!chbScanAutomatically.Checked)
{
_subjectFinger.CaptureOptions = NBiometricCaptureOptions.Manual;
}
// Add finger to the subject and fingerView
_subject = new NSubject();
_subject.Fingers.Add(_subjectFinger);
_subjectFinger.PropertyChanged += OnAttributesPropertyChanged;
fingerView.Finger = _subjectFinger;
fingerView.ShownImage = ShownImage.Original;
// Begin capturing
_biometricClient.FingersReturnBinarizedImage = true;
NBiometricTask task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.CreateTemplate, _subject);
var performedTask = await _biometricClient.PerformTaskAsync(task);
OnEnrollCompleted(performedTask);
}
}
Today, I was trying to make an adb client in C# with a decent GUI.
So, i 've done some research and found SharpAdbClient.
To do a file push, I use var file = openFileDialog2.ShowDialog(); to select a file.
But if I try pushing a big file, the GUI stops responding (how it's supposed to be).
So, to solve this issue, I've set up a thread that does the push but I've got a ThreadStateException when I try to launch the OpenFileDialog.
Here's an example code:
private void button4_Click(object sender, EventArgs e)
{
Thread pushFile = new Thread(push);
pushFile.Start();
}
private void push()
{
var device = AdbClient.Instance.GetDevices().First();
var file = openFileDialog2.ShowDialog();
var p = new Progress<int>(Progress_Bar);
String newPath = textBox2.Text;
if (file == DialogResult.OK)
{
String filePath = openFileDialog2.InitialDirectory + openFileDialog2.FileName;
using (SyncService service = new SyncService(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort)), device))
using (Stream stream = File.OpenRead(filePath))
{
service.Push(stream, newPath, 444, DateTime.Now, p, CancellationToken.None);
}
}
}
You can't invoke UI-methods on threads that are not the GUI thread. You'll have to dispatch that to the correct thread. In WinForms, you'd use Invoke, BeginInvoke and similar to do that.
Have a look at the Control.Invoke documentation for more information on this.
I am trying to transfer a file to my iphone using 32feet bluetooth, but cannot seem to get past the ObexWebResponse.
I have read many post on this but none of the solutions seem to work for me.
The Error i get is
// Connect failed
// The requested address is not valid in its context "address:Guid"
private BluetoothClient _bluetoothClient;
private BluetoothComponent _bluetoothComponent;
private List<BluetoothDeviceInfo> _inRangeBluetoothDevices;
private BluetoothDeviceInfo _hlkBoardDevice;
private EventHandler<BluetoothWin32AuthenticationEventArgs> _bluetoothAuthenticatorHandler;
private BluetoothWin32Authentication _bluetoothAuthenticator;
public BTooth() {
_bluetoothClient = new BluetoothClient();
_bluetoothComponent = new BluetoothComponent(_bluetoothClient);
_inRangeBluetoothDevices = new List<BluetoothDeviceInfo>();
_bluetoothAuthenticatorHandler = new EventHandler<BluetoothWin32AuthenticationEventArgs>(_bluetoothAutenticator_handlePairingRequest);
_bluetoothAuthenticator = new BluetoothWin32Authentication(_bluetoothAuthenticatorHandler);
_bluetoothComponent.DiscoverDevicesProgress += _bluetoothComponent_DiscoverDevicesProgress;
_bluetoothComponent.DiscoverDevicesComplete += _bluetoothComponent_DiscoverDevicesComplete;
ConnectAsync();
}
public void ConnectAsync() {
_inRangeBluetoothDevices.Clear();
_hlkBoardDevice = null;
_bluetoothComponent.DiscoverDevicesAsync(255, true, true, true, false, null);
}
private void PairWithBoard() {
Console.WriteLine("Pairing...");
bool pairResult = BluetoothSecurity.PairRequest(_hlkBoardDevice.DeviceAddress, null);
if (pairResult) {
Console.WriteLine("Success");
Console.WriteLine($"Authenticated equals {_hlkBoardDevice.Authenticated}");
} else {
Console.WriteLine("Fail"); // Instantly fails
}
}
private void _bluetoothComponent_DiscoverDevicesProgress(object sender, DiscoverDevicesEventArgs e) { _inRangeBluetoothDevices.AddRange(e.Devices); }
private void _bluetoothComponent_DiscoverDevicesComplete(object sender, DiscoverDevicesEventArgs e) {
for (int i = 0; i < _inRangeBluetoothDevices.Count; ++i) {
if (_inRangeBluetoothDevices[i].DeviceName == "Uranus") {
_hlkBoardDevice = _inRangeBluetoothDevices[i];
PairWithBoard();
TransferFile();
return;
}
}
// no devices found
}
private void _bluetoothAutenticator_handlePairingRequest(object sender, BluetoothWin32AuthenticationEventArgs e) {
e.Confirm = true; // Never reach this line
}
// not working
// transfers a file to the phone
public void TransferFile() {
string file = "E:\\test.txt",
filename = System.IO.Path.GetFileName(file);
string deviceAddr = _hlkBoardDevice.DeviceAddress.ToString();
BluetoothAddress addr = BluetoothAddress.Parse(deviceAddr);
_bluetoothClient.Connect(BluetoothAddress.Parse(deviceAddr), BluetoothService.SerialPort);
Uri u = new Uri($"obex://{deviceAddr}/{file}");
ObexWebRequest owr = new ObexWebRequest(u);
owr.ReadFile(file);
// error:
// Connect failed
// The requested address is not valid in its context ...
var response = (ObexWebResponse)owr.GetResponse();
Console.WriteLine("Response Code: {0} (0x{0:X})", response.StatusCode);
response.Close();
}
The pairing and authentication works just fine, and I can get the BluetoothService.Handsfree to make a call for me but the transferring of the file fails. Not knowing what the actual error is, I tried almost every service available with no luck.
Can you help me figure out what is going on? This is my first attempt working with Bluetooth services so I still have a ton to learn.
Is it possible to transfer a file from iPhone to Windows desktop via Bluetooth?
However, in case you need to transfer media files (images, videos, etc) from Android device, you can use ObexListener class provided by 32Feet library for this purpose, and then you can simply call _obexListener.GetContext() method that will block and wait for incoming connections.
Once a new connection is received, you can save the received file to local storage, as shown in the below example:
ObexListener _listener = new ObexListener();
_listener.Start();
// This method will block and wait for incoming connections
ObexListenerContext _context = _listener.GetContext();
// Once new connection is received, you can save the file to local storage
_context.Request.WriteFile(#"c:\sample.jpg");
NOTE: When working with OBEX on Windows, make sure to disable the "Bluetooth OBEX Service" Windows service, in order not to let it handle the incoming OBEX requests instead of the desired application.
I walked away from this for a while. and started Trying to use xamiren but then had to create a virtual Mac so that I could have the apple store to just load software on my phone. From there xamerin 'should' work well but its another field and tons more to firgure out.
I am trying to record audio and play it directly (I want to hear my voice in the headphone without saving it) however the MediaElement and the MediaCapture seems non to work at the same time.
I initialized my MediaCapture so:
_mediaCaptureManager = new MediaCapture();
var settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
settings.MediaCategory = MediaCategory.Other;
settings.AudioProcessing = AudioProcessing.Default;
await _mediaCaptureManager.InitializeAsync(settings);
However I don't really know how to proceed; I am wonderign if one of these ways could work (I tryied implement them without success, and I have not found examples):
Is there a way to use StartPreviewAsync() recording Audio, or it only works for Videos? I noticed that I get the following error:"The specified object or value does not exist" while setting my CaptureElement Source; it only happens if I write "settings.StreamingCaptureMode = StreamingCaptureMode.Audio;" while everyting works for .Video.
How can I record to a stream using StartRecordToStreamAsync(); I mean, how have I to initialize the IRandomAccessStream and read from it? Can I write on a stream while I keep reading for it?
I read that changing AudioCathegory of the MediaElement and the MediaCathegory of the MediaCapture to Communication there is a possibility it could work. However, while my code works (it just have to record and save in a file) with the previous setting, it don't works if I wrote "settings.MediaCategory = MediaCategory.Communication;" instead of "settings.MediaCategory = MediaCategory.Other;". Can you tell me why?
Here is my current program that just record, save and play:
private async void CaptureAudio()
{
try
{
_recordStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName);
MediaEncodingProfile recordProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Auto);
await _mediaCaptureManager.StartRecordToStorageFileAsync(recordProfile, this._recordStorageFile);
_recording = true;
}
catch (Exception e)
{
Debug.WriteLine("Failed to capture audio:"+e.Message);
}
}
private async void StopCapture()
{
if (_recording)
{
await _mediaCaptureManager.StopRecordAsync();
_recording = false;
}
}
private async void PlayRecordedCapture()
{
if (!_recording)
{
var stream = await _recordStorageFile.OpenAsync(FileAccessMode.Read);
playbackElement1.AutoPlay = true;
playbackElement1.SetSource(stream, _recordStorageFile.FileType);
playbackElement1.Play();
}
}
If you have any suggestion I'll be gratefull.
Have a good day.
Would you consider targeting Windows 10 instead? The new AudioGraph API allows you to do just this, and the Scenario 2 (Device Capture) in the SDK sample demonstrates it well.
First, the sample populates all output devices into a list:
private async Task PopulateDeviceList()
{
outputDevicesListBox.Items.Clear();
outputDevices = await DeviceInformation.FindAllAsync(MediaDevice.GetAudioRenderSelector());
outputDevicesListBox.Items.Add("-- Pick output device --");
foreach (var device in outputDevices)
{
outputDevicesListBox.Items.Add(device.Name);
}
}
Then it gets to building the AudioGraph:
AudioGraphSettings settings = new AudioGraphSettings(AudioRenderCategory.Media);
settings.QuantumSizeSelectionMode = QuantumSizeSelectionMode.LowestLatency;
// Use the selected device from the outputDevicesListBox to preview the recording
settings.PrimaryRenderDevice = outputDevices[outputDevicesListBox.SelectedIndex - 1];
CreateAudioGraphResult result = await AudioGraph.CreateAsync(settings);
if (result.Status != AudioGraphCreationStatus.Success)
{
// TODO: Cannot create graph, propagate error message
return;
}
AudioGraph graph = result.Graph;
// Create a device output node
CreateAudioDeviceOutputNodeResult deviceOutputNodeResult = await graph.CreateDeviceOutputNodeAsync();
if (deviceOutputNodeResult.Status != AudioDeviceNodeCreationStatus.Success)
{
// TODO: Cannot create device output node, propagate error message
return;
}
deviceOutputNode = deviceOutputNodeResult.DeviceOutputNode;
// Create a device input node using the default audio input device
CreateAudioDeviceInputNodeResult deviceInputNodeResult = await graph.CreateDeviceInputNodeAsync(MediaCategory.Other);
if (deviceInputNodeResult.Status != AudioDeviceNodeCreationStatus.Success)
{
// TODO: Cannot create device input node, propagate error message
return;
}
deviceInputNode = deviceInputNodeResult.DeviceInputNode;
// Because we are using lowest latency setting, we need to handle device disconnection errors
graph.UnrecoverableErrorOccurred += Graph_UnrecoverableErrorOccurred;
// Start setting up the output file
FileSavePicker saveFilePicker = new FileSavePicker();
saveFilePicker.FileTypeChoices.Add("Pulse Code Modulation", new List<string>() { ".wav" });
saveFilePicker.FileTypeChoices.Add("Windows Media Audio", new List<string>() { ".wma" });
saveFilePicker.FileTypeChoices.Add("MPEG Audio Layer-3", new List<string>() { ".mp3" });
saveFilePicker.SuggestedFileName = "New Audio Track";
StorageFile file = await saveFilePicker.PickSaveFileAsync();
// File can be null if cancel is hit in the file picker
if (file == null)
{
return;
}
MediaEncodingProfile fileProfile = CreateMediaEncodingProfile(file);
// Operate node at the graph format, but save file at the specified format
CreateAudioFileOutputNodeResult fileOutputNodeResult = await graph.CreateFileOutputNodeAsync(file, fileProfile);
if (fileOutputNodeResult.Status != AudioFileNodeCreationStatus.Success)
{
// TODO: FileOutputNode creation failed, propagate error message
return;
}
fileOutputNode = fileOutputNodeResult.FileOutputNode;
// Connect the input node to both output nodes
deviceInputNode.AddOutgoingConnection(fileOutputNode);
deviceInputNode.AddOutgoingConnection(deviceOutputNode);
Once all of that is done, you can record to a file while at the same time playing the recorded audio like so:
private async Task ToggleRecordStop()
{
if (recordStopButton.Content.Equals("Record"))
{
graph.Start();
recordStopButton.Content = "Stop";
}
else if (recordStopButton.Content.Equals("Stop"))
{
// Good idea to stop the graph to avoid data loss
graph.Stop();
TranscodeFailureReason finalizeResult = await fileOutputNode.FinalizeAsync();
if (finalizeResult != TranscodeFailureReason.None)
{
// TODO: Finalization of file failed. Check result code to see why, propagate error message
return;
}
recordStopButton.Content = "Record";
}
}
I'm trying to rename a Bluetooth device from a Windows Phone 8 app. I know the AT commands to send to the device but i belive I connecto to the device somhow wrong.
I have an old PDA program that can rename my device, and that program is the source of my AT commands som I'm pretty sure they are correct.
If I start a Datalogger and rename my device from my PDA no data appears in the log, if I do the same from my phone I get all the commands in my Datalogger.
Here is how I connect to my device in my windows phone App:
public void Rename()
{
var info = GetPeerInfo();
/*
GetPeerInfo() gives me the PeerInformation of my device and it works as expected.
*/
if (info == null)
return;
socket = new StreamSocket();
Task.Run(async () => { await socket.ConnectAsync(info.HostName, "1"); }).Wait();
var dataWriter = new DataWriter(socket.OutputStream);
/*
Note
"to" is an internal class containg the new name of my bluetooth device, its bluetooth config etc.
"newLaneNumber" is an integer indicading a postfix to the new name
*/
UpdateDisplayName(dataWriter, to, newLaneNumber);
Task.Run(async () => { await dataWriter.StoreAsync(); }).Wait();
socket.Dispose();
socket = null;
return;
}
This is the method sending the AT commands
private void UpdateDisplayName_Other(DataWriter dataWriter, InspectionTester newDisplayname, int newLaneNumber)
{
//Login
Thread.Sleep(6000);
dataWriter.WriteString("///");
Thread.Sleep(6000);
var bluetoothDefault = new string[]
{
"AT*AGLC=0,1",
"AT*AGCM=2,1",
"AT*AGDM=3,1",
"AT*AGPM=2,1", // pairable (not pairable: "AT*AGPM=1,1")
"AT*AGFP="+'"'+"0"+'"'+",1",
"AT*AGSM=1,1",
"AT*ADDSP=0,1",
"AT*AGMSP=1,1",
"AT*ADDCP=255,1",
"AT*ADNRP=0,1",
"AT*AMSIT=1,1",
"AT*AMET=5000,5000,1",
"AT*AMLP=0,0,1",
"AT*AMMP=255,1",
"AT*AMWFM=1,6,1",
"AT*AMPM=1,1",
"AT*ACCB=1,1",
"AT*AMDS=1,1,1",
"AT*AMWS=0,0,0,0,0,1"
};
var tmpString = string.Empty;
foreach (var element in bluetoothDefault)
{
tmpString = element + "\r";
dataWriter.WriteString(tmpString);
Thread.Sleep(100);
}
//Name
tmpString = "AT*AGLN=\"" + to.BluetoothName + newLaneNumber.ToString("D2") + "\",1\r";
dataWriter.WriteString(tmpString);
Thread.Sleep(100);
//Baudrate
tmpString = "AT*AMRS=" + to.BluetoothConfig + "\r";
dataWriter.WriteString(tmpString);
//Logout
tmpString = "AT*AMWS=0,0,0,0,1,0\r";
dataWriter.WriteString(tmpString);
}
Some where I'm doing something wrong, I belive I connect the wrong way but I can't find any information about how else to do it.
Here is a log taken from an update attempt from the phone :
///AT*AGLC=0,1
AT*AGCM=2,1
AT*AGDM=3,1
AT*AGPM=2,1
AT*AGFP="0",1
AT*AGSM=1,1
AT*ADDSP=0,1
AT*AGMSP=1,1
AT*ADDCP=255,1
AT*ADNRP=0,1
AT*AMSIT=1,1
AT*AMET=5000,5000,1
AT*AMLP=0,0,1
AT*AMMP=255,1
AT*AMWFM=1,6,1
AT*AMPM=1,1
AT*ACCB=1,1
AT*AMDS=1,1,1
AT*AMWS=0,0,0,0,0,1
AT*AGLN="BMGTMGA1-01",1
AT*AMRS=5,1,2,2,2,1,1
AT*AMWS=0,0,0,0,1,0
If you need some more information please say so.
1point: most of the device don,t support the rename. Some of them just support it by saving the infomation in the RAM ,not the flash or EEPROM .