Using the BlueZ BlueTooth stack, How do I programatiacally enumerate devices that are already paired and not necessarily connected?
Update: The below wasn't as easy as I initially thought to be. adapter_get_devices is only the starting point. It will be helpful, if you could post a sample out of that.
If you don't have enough time, you can as well use the same bt-device tool from command line with appropriate command line params and get the output via pipe. Other choice is to use the ListDevices API in org.bluez.Adapter interface to get a list of paired devices and then I hope some thing in org.bluez.Devices interface will help you.
Update 2: In devices interface you can use, GetProperties method as in this answer
Does this gsoc code sample link help. It is in C now and hope it could be done over Python dbus as well. API is adapter_get_devices. I am yet to try this.
Related
I need a way to determine if a specific USB thumb drive has been inserted. For instance:
if "flash drive named "Records" is present":
copy data to drive
else:
"do something else"
I have all the copytree functions working just fine, I just need a way to check for the specific drive before the operation.
Thank you in advance!
By name, assuming you are looking for label, you could have a few ways. You could call blkid to get the labels of the system. But the tool itself might be limited to superusers. The target users might need to run your script as a superuser.
Other alternative I found with a little Google search is to use DBUS in Python. You might want to look up https://askubuntu.com/questions/437031/finding-volume-label-of-a-usb-mass-storage-device-using-python page.
In short, install python-dbus package and just a few lines of Python code could list you the drive labels.
How about the usbid package? It has the ability to find USB device IDs, so might be just what you need.
NB: I haven't used this myself; I just found this with a quick Google search and thought it might help solve your problem!
Your distro probably has the lsusb util installed. If so, you can have a look at this answer that demonstrated how to read and parse the output of lsusb from a python script.
I was wondering if it is possible to modify the contents of a BLE beacon to include extra information. If you insert an extra bit at the end you could potentially broadcast a boolean in one direction. Theoretically, if you modified your device to read the extra bit of information this would work. Given existing protocols though it sounds like this would be a lot of work. Is there something out there like this already?
For info, I'm working on the mbed platform where you can modify your own bluetooth beacon payload.
Yes, you can do this with the new AltBeacon specification. There is a one byte manufacturer reserved field which you can use for whatever you want (tied to your manufacturer ID).
There are reference implementations of the specification available for Linux to show you how it works, and there is no reason you cannot implement it on the mbed platform.
Currently Roland does not make drivers for Linux, so I am starting a project to write a driver for the Roland GR-55 Guitar Synthesizer, but after looking around, I find I have several options and not sure which is the best or most current method, so I thought I'd ask before waisting a lot of time on this.
This device uses USB, it controls the MIDI and Audio devices in the GR-55.
ALSA or libusb api are two choices; both are new to me; its been years since I wrote a device driver and it was for Unix back in the 80's, but I do know I can figure out how, once I know what tools to use, which I'm guessing both use C still; I have looked at the libusb api; very nice; but I have no idea about ALSA project; seems they are geared into getting modules into the kernel to achieve this.
I would like to find programmers that have worked with Roland like Device Drivers dealing with MIDI and Audio that might be able to help point me in the right direction; I have asked Roland for help; will be waiting for a reply, but not wanting to hold my breath, I think getting started would be my best option; even if they do help, they will only be suppling technical specs, which would be great.
I hope I gave enough details; not much else to say when asking a question about Device drivers.
We are considering using the vendor and product ID of a USB device (obtained via IOKit) to unlock certain features of an application. I'm aware that these values can be spoofed, but I'm not sure how easily it can be done on OSX. What is involved in spoofing the vendor and product ID? Is it something that a non-programmer can do fairly easily?
I suspect it would be fairly easy (for a programmer) to create a kext that creates a reasonably realistic IOUSBDevice object in kernel space. However, once done anyone would be able to load it.
It may also be possible to build a codeless kext using AppleUSBMergeNub to masquerade a device as another (though I haven't tested this, it looks like it might work, assuming you only try to match the IOUSBDevice without actually using it).
It would probably be easier to just hijack your API calls in userspace and give your software the answers it expects.
A non-programmer cannot do that. What you can do is writing a kernel extension (an IOKit driver) for the device, that has a matching dictionary matching the real vendor-/product-ID of the device, which causes the system to automatically load the kernel extension when this device is connected and pass a reference to the device object. The driver is now responsible for initializing the device and create all necessary user space information that is necessary for the IOKit framework (the user space library) to communicate with the device. Usually Apple has default IOKit drivers for most USB device classes (that's why you don't need an extra driver for every USB mouse or keyboard for example), but if there is a more specific driver found, then this driver will be used instead. And when creating the user space data, of course the driver may lie about the vendor-/product-ID, causing the user space program to see false values. Since IOKit is written in C++ and heavily depends upon objects and object inheritance, it is not even necessary to write the driver from scratch, but instead it can inherit from Apple's default driver and just override some methods and otherwise rely upon the super implementation. However, writing IOKit kernel drivers is not that easy and even people developing Mac software for years may have no idea how to do that and the IOKit documentation is one of the worst ones Apple is offering.
So to answer your question: Is it possible? Yes. Is it fairly easy? No. Can non-programmers do it? Certainly not, unless someone else has written a ready to use extension for them, that they only need to install.
It's actually rather EASY, and I'm definitely not a programmer!
Found the guide here
http://rolande.wordpress.com/2012/10/25/getting-the-aten-usb-serial-adapter-working-with-mac-osx-lion
Thanks, Rolande!
I was able to change the IDs of a USB Ethernet adaptor I bought on eBay to use another driver with Mac OS X 10.8.
Since nobody has answered so far, I've stumbled across a page which basically says that you can get an Arduino and program it to return any VID/PID/serial that you want. I still can't find any software-only way to do this.
I can create A OCX in Delphi code to do that
And supply infomation to send/receive data to the USB with other states like:- is it still connected.
Natraly I need a little more detail than that in case that same chip is connected from another product.
example frendly name, device desription.............
I am trying to determine what /dev/input/eventX device is the touchScreen. I am currently looking at the return of EVIOCGNAME to get device name. Looking at the return values of the EVIOCGBIT ioctl I don't think there is a generic way to determine what is the touchscreen. I am interested in any sort of solution to this problem. Thanks in advance for your time!!!
Take a look at:
/dev/input/by-path/
/dev/input/by-id/
/sys/class/input/event?/device/
These might have enough info for your needs. Wish I had a touchscreen to test ;)
If the mask returned by ioctl(EV_ABS) contains ABS_PRESSURE, and ioctl(EV_KEY) contains BTN_TOOL_FINGER, then it's probably a touchscreen.