What user inputs are required for a Digital TV Device Selection? - visual-c++

In the process of building a Digital TV graph, I need:
Network Provider -> Tuner -> Capture -> MPEG2-Demux -> MPEG2 TIF
-> MPEG2 Sections
-> Video Decoder -> VMR9
-> Audio Decoder -> DirectSound
It's obvious to me that I can hard-code in the name of the provider (Microsoft Network Provider), but do I need to prompt the user to select both a tuner and a capture device from the list of available devices, or can I somehow query for the tuner that corresponds to the capture device that the user has selected?
Basically I'm asking whether an API call exists similar to:
IMoniker *pTuner = GetTunerForCaptureDevice(pIMonikerSelectedCaptureDevice);
or whether it's standard to make the user choose both the tuner and the capture devices in their config.

The way that it seems that most applications deal with this problem is to go in the reverse direction. For the purposes of configuration, they provide list of all devices in the category KSCATEGORY_BDA_NETWORK_TUNER and allow the user to select one of the tuners.
After that device has been added to the graph, all devices are enumerated for the category of KSCATEGORY_BDA_RECEIVER_COMPONENT. For each item returned, the capture device item is added to the graph, and connect is called between the tuner output pin and capture input pin. Rough code: (without the necessary Releases()'s)
for (fFound=FALSE; !fFound; )
{
IMoniker *pIMoniker;
IBaseFilter *ppIBaseFilter;
hr = pIEnumMoniker->Next(1, &pIMoniker, NULL);
if (hr!=S_OK)
break;
hr = pIMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter),
(void **)&ppIBaseFilter);
hr = m_pIGraphBuilder->AddFilter(*ppIBaseFilter, L"Capture filter");
hr = ConnectFilters(m_pIGraphBuilder, pITunerFilter, ppIBaseFilter)));
if (hr != S_OK)
{
m_pIGraphBuilder->RemoveFilter(ppIBaseFilter);
goto NextMoniker;
}
fFound = TRUE;
NextMoniker:
// release things here.
}
If any of the capture devices successfully connect pins, then the loop ends and that capture filter is used in the graph.
I went this direction of starting with a user selection of a tuner because I was seeing several products that returned more than one tuner device, and when attempting connections in the reverse order (capture, then tuner), I seemed to always be successfully connecting the wrong tuner.

Related

How can I enumerate supported services, or talk via GATT, once I connect to a Bluetooth device via the Bluez DBUS API on Linux?

I am looking to connect to Bluetooth devices on Linux and store information about them in a database. I have used the code from here as the starting point. It uses
prop_changed = g_dbus_connection_signal_subscribe(con,
"org.bluez",
"org.freedesktop.DBus.Properties",
"PropertiesChanged",
NULL,
"org.bluez.Adapter1",
G_DBUS_SIGNAL_FLAGS_NONE,
bluez_signal_adapter_changed,
NULL,
NULL);
to be notified when new Bluetooth devices appear. And I reuse its bluez_device_call_method() function to call the DBUS Connect() method documented in the BlueZ D-Bus Device API on every new device that appears:
bluez_device_call_method(object, "Connect");
Most devices just time out, but some devices appear to connect sucessfully. My question is, for those devices which I've connected successfully to, how do I get more information about the device I'm talking to?
The only other APIs documented in the BlueZ D-Bus Device API that seem like they'd let me retrieve more information are "void ConnectProfile(string uuid)" and "void Pair()". For ConnectProfile() how am I supposed to know the UUID? Is it just what's printed out via entries like the below?
[ /org/bluez/hci0/dev_48_57_DE_00_AA_09 ]
Address : s : 48:57:DE:00:AA:09
AddressType : s : random
Name : s : Blood Pressure
Alias : s : Blood Pressure
Paired : b : 0
Trusted : b : 0
Blocked : b : 0
LegacyPairing : b : 0
RSSI : n : -65
Connected : b : 0
UUIDs : a :
0000180a-0000-1000-8000-00805f9b34fb
00001810-0000-1000-8000-00805f9b34fb
And if it succeeds, where would I find the returned data?
And for Pair(), it says "This method will connect to the remote device, initiate pairing and then retrieve all SDP records (or GATT primary services).", but if it succeeds, where would I find the returned data?
So far I've tried:
ret = bluez_device_call_method(object, "Connect");
if(ret == -1){
bluez_device_call_method(object, "Pair");
}
else{
printf("Connect() succeeded! Now what?!\n");
}
But I don't think Pair() has ever succeeded, whereas Connect() has succeeded occasionally with some devices.

How to take Usb slot in the hub immediately after plugging it in?

I am implementing a scenario where I should take the slot of a Usb immediately after I plug it in. 15 is what I want to take.
The code works fine after plugging in the 1st Usb. When I plug the 2nd Usb earlier than 1 minute after the 1st was plugged, I do not get any information for the 2nd Usb which is already plugged in. I will show you the code which handles the retrieve of the slot information. This method is executed after a fired event when a USB is plugged in.
Main thing: I have to wait more than 1 minute, then I can plug the 2nd Usb and take the slot. If I plug it in before waiting 1 minute after the 1st is plugged I do not take any information for the last Usb plugged.
static int GetPhysicalPort()
{
try
{
devices = new List<USBDeviceInfo>();
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(#"Select * From Win32_PnPSignedDriver WHERE DeviceId LIKE 'USB\\VID%' AND Description = 'USB Mass Storage Device' "))
{
collection = searcher.Get();
searcher.Dispose();
}
foreach (var device in collection)
{
devices.Add(new USBDeviceInfo(
(string)device.GetPropertyValue("DeviceId"),
(string)device.GetPropertyValue("Description"),
(string)device.GetPropertyValue("Location")
));
}
collection.Dispose();
string LastAdded = devices[0].Location.Substring(6, 4);
Console.WriteLine(LastAdded);
return Convert.ToInt32(LastAdded);
}
catch (Exception e)
{
Console.WriteLine(e);
return 0;
}
As per WMI Win32_PnPSignedDriver class it would be the application which would be taking that much time to query or give results for the USB inserted second time. This depends on application to application as the pole rate or response rate of that application running this WMI query would be designed it such a way to give results in 1-2 min.
We could check the same in terms of OS level or WMI level to see if WMI as a whole is taking time to give query results on the machine.
Open Run command and type WBEMTEST.
Click on connect as it will connect the CIMV2 Namespace. Under this namespace lies the class Win32_PnPSignedDriver
As an when we query this class with the query select * from win32_PnPSignedDriver it would shows us some results instantly like for eg 60-70.
Now when you close it and again run he same query it would show some more or the same results depending on the OS etc.
The above will show us that WMI query or WMI as a whole is working the way it should be on the machine.
The issue could be caused by the application which is taking this much time to read the contents of the second USB as per the WMI query it is querying.

How can I see the gateway connected individual device data in the IBM-watson-IoT dashboard?

How can I see the gateway connected individual device data in the IBM-watson-IoT dashboard ? Is there any specific way see that?
Right now I am sending data as:
//publishing device events with deviceType 'Raspi' and deviceId 'pi01' using the default quality of service
gatewayClient.publishDeviceEvent("Raspi","pi01", "status","json",'{"d" : { "cpu" : 60, "mem" : 50 }}');
console.log('event published');
But I am not able to see this data stream anywhere in the IBM-watson-IoT dashboard. It's showing the event as received but no data stream of device "pi01".
When data is sent as:
gatewayClient.publishGatewayEvent("status","json",'{"d" : { "cpu" : 40, "mem" : 50 }}');
this means as gateway. It shows "received data" when I am creating the card. But I dont want this, I have a different device connected with the gateway, so I want the new device data in a different data stream.
Please let me know if I am doing it right, and if yes then where can I see all that data.
The only way to do this in the Dashboard is in a Card. No other way in the Dashboard (though there are other ways outside of the dashboard). Your code looks fine. If you select your device in a Device centric card you can see the stream of values for just that gw-device in the properties or make graphs etc if they would help. It is its own stream of data; should not be mixed up with any other device even if they share the same gateway. Here is one gateway sending data for 2 devices using:
gatewayClient.publishDeviceEvent('SenseHat','sen-pi-xxx-gw' ,'event', 'json', '{"sugar":5, "salt":2}', 1);
gatewayClient.publishDeviceEvent('SenseHat','xx-gw-device' ,'event', 'json', '{"sugar":9, "salt":12}', 1);

How can I calculate the signal strength of my wifi and 3g using android SDK?

I try to make an application that will calculate the signal strenth of my wifi, or 3g and let the user know about his distance from that access point.
For instance, I have here a sample of my code that will calculate the distance, in kilometers, between device and a wifi access point:
public double calculateDistance(double signalLevelInDb, double freqInMHz)
{
double exp = (27.55 - (20 * Math.log10(freqInMHz)) + Math.abs(signalLevelInDb)) / 20.0;
return Math.pow(10.0, exp);
}
but, when i call the function in android studio, I don't know how to calculate the signalLevelInDb (=dbm) and freqInMhz (=mHz) so I can send them to the function to display my distance. How can I make android studio give me these 2 values? Can I use the same function for the 3g and how?
Please find this information in the offical documentation of the Android SDK:
Android SDK API documentation, SignalStrength.
With this class you have the methods
int getCdmaDbm()
Get the CDMA RSSI value in dBm
or:
int getEvdoDbm()
Get the EVDO RSSI value in dBm
As an alternative you could have a look at the TelephonyManager class which is supported since API level 1. With this at your side you can find out in which network state (public int getNetworkType ()) your mobile device is at the moment (2G, 3G,...) and thus find out or at least translate to a corresponding "frequency".
Hope this helps you for your distance calculation.

How to get Device Display Name in VC++?

I can successfully query my system with GetRawInputDeviceList to get a list of raw devices and GetRawInputDeviceInfo to get detailed info on individual devices.
However GetRawInputDeviceInfo returns the "device path" when the name is queried. What I would like to get is the "display name" as show in the
Device Manager -> Mice and Other Pointing devices -> (mouse device) -> Properties -> Details -> Display Name
How is this possible?
TIA
Looks like the "RIDI_DEVICENAME" is a path in the registry. So I can use this to do a Registry look up and grab the last delimted element form the 'DeviceDesc' key.
Thanks - I hope helps someone else.
UINT WINAPI GetRawInputDeviceInfo(
__in_opt HANDLE hDevice,
__in UINT uiCommand,
__inout_opt LPVOID pData,
__inout PUINT pcbSize
);
Did you try, uiCommand = RIDI_DEVICENAME ?
GetRawInputDeviceInfo Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/ms645597(v=VS.85).aspx

Resources