I can't seem to find this anywhere.
I want to build an Audio Endpoint device that plugs into the Windows Phone Headphone Jack.
I know I need to start with what the phone is capable of receiving and detecting.
Ultimately I would like to use already in existence libraries however I have no heartache about writing my own.
My problem is I can't find any examples of how people access the Audio input on the phone outside of the built in microphone.
Is there a library for this?
You can detect when a headset is plugged in using the VOIP capabilities in Windows Phone 8.
First in the WMAppManifest.xml file, you need to enable ID_CAP_VOIP and ID_CAP_AUDIOROUTING
Then in the App, you need to capture the event
AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;
public void AudioEndpointChanged(AudioRoutingManager sender, object args)
{
var AudioEndPoint = sender.GetAudioEndpoint();
switch (AudioEndPoint)
{
case AudioRoutingEndpoint.WiredHeadset:
MessageBox.Show("Headset connected");
break;
}
}
This will enumerate from this list (no custom endpoints allowed)
http://msdn.microsoft.com/en-us/library/windowsphone/develop/windows.phone.media.devices.audioroutingendpoint(v=vs.105).aspx
Sorry, but I can only answer the first part of your question about detecting the device, I'm not familiar with how the hardware device interfaces with the headphone jack to answer the rest.
Related
I'm building web application for fitness center, they have a barcode scanner to which you are scanning your gym card into. What i'm trying to accomplish is to somehow get the data that the scanner is providing to them (name,surname and time of monthly subscription). My web application is built in ASP.NET C#, this is my first time dealing with this kind of problem.
I would appreciate your help or any other word of advice, feel free to ask more detailed questions.
If gym has barcode scanner like this
, it is seen in the system as a keyboard.
Such a scanner should also be able to set the ending character Tab or Enter. You do not need to confirm the scanned code then.
A card with a barcode as above returns the card number associated with a given person in the database.
You probably don't have access to the barcode scanner from MVC (Core or Framework). To do that you would probably have to run some software on the computer or phone that is scanning the member cards. There might be a solution though since the barcode scanner might be able to copy the id. This way you could input it to an input field in your MVC application and post it to the backend from there.
If i understand your Question correctly you probably need a SerialPort.
its actually pretty easy..
SerialPort serPort = new SerialPort("COM7"); // thats the USB port on which the scanner is connected
serial.DataReceived += new SerialDataReceivedEventHandler(serial_DataReceived);
serPort.Open();
and now you will receive everythig the Scanner has on:
private void serial_DataReceived(object sender, SerialDataReceivedEventArgs e){
string response = serPort.ReadExisting();
//do work
}
also if u dont know which port it is connected on use :
foreach (string sp in SerialPort.GetPortNames())
{
port = new SerialPort(sp)
{
Encoding = Encoding.GetEncoding("Windows-1252")
};
port.DataReceived += new
SerialDataReceivedEventHandler(Port_DataReceived);
port.Open();
}
this will watch over every Port you have see if something is connected and opens a connection to it, obviously if u have something like a mobile phone connected it will open a port with it too. but you can just make a check that if u scan u will only take that port and so on..
IF i did understand your question correctly that u want to know how to communicate with the Scanner thats how you do it.
if that was not your question, please comment and Clarify im working all day with Mobile Scanners Reading Barcodes so i think i will be able to help you.
Almost all handheld barcode scanners have a barcode in it's manual to change the scanner to function as a keyboard wedge. This way the scanner functions exactly like a keyboard device. You'd scan a barcode and keycodes are sent to the cursor location.
So just look up the make/model of your scanner and download its manual and look for a barcode that you can scan to change its emulation mode.
So I am trying to connect to a Polar H7 Heart Rate Monitor, and I need to use a WPF application to do it. I'm using Windows 10.
Now I have done this with a UWP application already and it works perfectly, but I'd like to use WPF (if it is possible) instead to do the same.
I found this post on how to use Windows 10 APIs in WPF/winforms/etc and thought perfect, that's what I need. I successfully added the Bluetooth API to my WPF project and threw in the code that was working for my UWP project, but it doesn't work.
Here's a snippet of my code up to where it stops working:
DeviceInformation _devicePolar = null;
string StatusInformation;
string StatusInformation2;
var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate));
foreach(var d in devices)
{
Debug.WriteLine(d.Name + " " + d.Id);
}
if (null == devices || devices.Count <= 0) return;
foreach (var device in devices.Where(device => device.Name == "Polar H7 DCB16C16"))
{
_devicePolar = device;
StatusInformation = string.Format("Found {0}", _devicePolar.Name);
break;
}
if (_devicePolar == null) return;
var service = await GattDeviceService.FromIdAsync(_devicePolar.Id);
if (service == null) return;
Now, this call
await GattDeviceService.FromIdAsync(_devicePolar.Id)
is returning null. I was actually having the same problem when I made the UWP application and I found out it was because I forgot to throw in this
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="bluetooth" />
</Capabilities>
Into my manifest file. Once I put that in (on my UWP application) it worked fine. But there seems to be no equivalent place for this piece in a WPF application. Now going back to the blog post on how to add Win 10 libraries to WPF, this bit seems to be telling me that was the case all along:
The second set of APIs that you can’t use are ones that depend on an app’s package identity. UWP apps have package identities while PC software does not. Package identity information can be found in the app manifest file.
And looking further into the Microsoft topic linked in the post it does specify about Bluetooth that "Not all APIs are currently supported for packaged apps." Which is terribly non-specific.
Also should mention, before trying this I tried to use the 32feet library, but my device was not showing up at all while other devices (not LE) were, so I am assuming that 32feet just doesn't support BTLE. I found this asking the same about 32feet and that is what led me to try what I have detailed above instead, but I'm still not 100% clear on whether or not I can simply use 32feet to connect to BTLE devices.
So my question is, am I right that what am I trying to do (WPF application using Windows 10 API to connect to Bluetooth device) can't currently be done? If not, what am I doing wrong?
Update after two years the question posted: I think there's still no library supporting WPF Bluetooth LE. A pretty straight forward proof is that, Windows settings, which is under UWP, supports Bluetooth LE devices, while Control Panel on Windows 10 doesn't.
The only solution I can come up with now is buying a Bluetooth dongle which has virtual COM port feature, so ideally I can talk to the BLE device like using serial connection. Haven't tested yet, will update later if this works.
I have a Windows desktop app in C#. I need to estimate how many users are using it on a handheld device - mainly a tablet like Lenovo Yoga tablet or SurfacePro.
I've found answers about using a web browser request which I cannot do as this is a desktop app.
I need an approach to identify if the app is being used on a handheld device.
Thanks in advance.
I have a Windows desktop app in C#. I need to estimate how many users
are using it on a handheld device - mainly a tablet like Lenovo Yoga
tablet or SurfacePro.
If you only want the estimate, i think a better approach would be using google analytics, it can be used with windows apps too Google Analytics for Windows apps
I need an approach to identify if the app is being used on a handheld
device.
If you need to identify the type of device for some functionality, what you need to do is identify the device family.
if you're creating a uwp app, you can read here:
using Windows.UI.Xaml;
using Windows.UI.ViewManagement;
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
// Every view gets an initial SizeChanged, so we will do all our
// work there. This means that our view also responds to dynamic
// changes in user interaction mode.
Window.Current.SizeChanged += SizeChanged;
}
private void SizeChanged(object sender, RoutedEventArgs e)
{
switch(UIViewSettings.GetForCurrentView().UserInteractionMode)
{
case UserInteractionMode.Mouse:
VisualStateManager.GoToState(this, "MouseLayout", true);
break;
case UserInteractionMode.Touch:
default:
VisualStateManager.GoToState(this, "TouchLayout", true);
break;
}
}
}
I have a Surface Pro 4 that is being used in a medical environment and we would like to be able to disable to WiFi on the device when certain applications are running. Is this possible?
Disable is a relative term and as long as the device can't communicate over the wifi, even if technically active, that would meet the requirements. I wasn't able to find any way to do this though.
We could disable Wifi completely but would prefer to have it as an option for the users of the device when the specific applications aren't running.
The application in question is written in C#
You can do this with the Windows.Devices.Radios.Radio class by calling SetStateAsync(...).
There's a full example available at Microsoft's GitHub page, here's a snippet:
private async void SetRadioState(bool isRadioOn)
{
var radioState = isRadioOn ? RadioState.On : RadioState.Off;
Disable();
await this.radio.SetStateAsync(radioState);
NotifyPropertyChanged("IsRadioOn");
Enable();
}
So I am trying to connect a bluetooth speakers from a script. I am using 32feet.net and I have successfully found the device but it doesn't work when I try to pair and connect to it.
This is the code im using to pair to device, this always fails not sure why:
private static void connected(BluetoothDeviceInfo[] dev)
{
// dev[foundIndex];
bool paired=false;
paired = BluetoothSecurity.PairRequest(dev[foundIndex].DeviceAddress, "1166");
if (paired)
Console.WriteLine("Passed, Device is connected.");
else
Console.WriteLine("Failed....");
}
Here is the code called after connected to actually connect to the device: bc is my bluetooth client var.
bc.BeginConnect(devInfo[foundIndex].DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), devInfo[foundIndex]);
private static void Connect(IAsyncResult result)
{
if (result.IsCompleted)
{
Console.Write("Connected... ");
}
}
Any help would be appreciated. I am new to 32feet.net so i dont know much about this, i tried following code online to get where im at.
Try BluetoothDeviceInfo.SetServiceState. That will ask Windows to connect to the audio service on the device -- hopefully that'll do the job.
See https://32feet.codeplex.com/wikipage?title=Connecting%20to%20Bluetooth%20Services
Sometimes we don’t want our application to itself send data to/from a remote service but we want instead the local operating system to do so. This is the case for keyboard/mouse/etc with HID, networking with DUN/NAP/PAN/etc, Headset/Handsfree etc.
and then
The short answer in this case is to use BluetoothDeviceInfo.SetServiceState. This is the API equivalent to manually checking the respective checkbox on the “Services” tab of the Device dialog in Bluetooth Control panel.
Also, in these days of Secure Simple Pairing, using PairRequest is fine only if all peer devices will use old style PIN code authentication, otherwise instantiate a BluetoothWin32Authentication and then do the connect (here indirectly via SetServiceState) and handle the authentication in the authentication callback.