How to generate specific IDs for USB ports in Java? - java

I am developing an application using Java. I am connecting 10 USB devices through external USB ports. I want a specific ID when I connect a device with a specific port. So, for example, if I connect a device on 10th port, I should get a specific ID for that port; which will help me in showing that device in 10th position only. I tried Jusb and other similar third party APIs but they didn't work out. Please suggest some techniques to accomplish this.

Did you tried The JSR-80 API (javax.usb) as explain here http://www.ibm.com/developerworks/library/j-usb/index.html

Related

How to access directly internet on WearOS app

I am looking for My data on wear OS app to send to my external apache server with php and mysql.
Ultimately I need watch sensor data in MySQL database, So i created a POST request page using php. How do I send POST request?
Note: I am not using mobile phone between WearOS app and My server. WearOS is connected to internet via WiFI
Please if you know any solution help me
FYI: I tried basic things given at https://developer.android.com/training/wearables
Using Smart Watch with API level 23
Regards
Unfortunately your watch system version is too old. I strongly recommend you to buy a new watch or try update to Wear OS 2.x (API25) if your device is still under maintain.
If you insist on using current device the only way to access the Internet is via mobile phone. You can not send HTTP requests directly.
But the old version system should not be able to connect the WiFi. Please confirm your version at first. If your API level equal or larger than 25, you can access the Internet as same as phone using OkHttp or others you like.

How do I detect the COM port number of a usb dongle?

I have created an application which sends SMS using Java.
Whith this, I must enter the com port number of dongle manually to code segment.
I would like to do this automatically using code.
How can I do this?
You may want to have a look at jUSB, which provides an API for USB programming. Get a Host from a HostFactory, iterate over it's Buses, and walk the device tree (you can get the number of devices from each Device, #0 is usually the device itself). Then you just need to find out what kind of Configuration your device has and search by that.

Java: Get USB Mass Storage Device Information

is there a possibility to get USB mass storage information like the serial of an USB device in Java on Windows?
I tried to achieve that with USB4Java (low and high-level API) and it works, but the problem is that I have to install a customized driver to get access to the information from my Java app (described in the FAQ at http://usb4java.org/). When that special driver (created with Zadig) is installed I don't have any further access to the device from the Windows explorer (just from my Java app).
I would like to detect when a new USB device is attached and if it was attached, I would like to get some information like the serial number of the device, the device name, the drive letter that was assigned etc.
That app should be used by other users and I couldn't force them to create a customized driver for each device ...
Do you have any hints how to achieve that?
Thanks.
Edit: Is it possible to get the usb-port of a connected device with Java-built-in methods?
I've tried sth with FileSystemView.getFileSystemView().getSystemDisplayName() but there are no such options. Is there another possibility to get vendor id's or sth. similiar with Java?
Or is it possible to get the drive letter with USB4Java?
Thanks.

Is it possible to establish more than one bluetooth communication in android

I have android application the scan a Bluetooth device around, and connect them to start exchanging text.
I want the application to establish a communication with each Bluetooth device in the surrounding area and send text to all of them at once.
Is that possible to have multiple communication in android ? and if you have any examples ?
For sure it is possible. You are talking about Bluetooth BR/EDR (2.x, 3.0) or Bluetooth low energy(4.0)?
For Bluetooth BR/EDR, use the official documentation to get started.
Just do a SDP to find all devices in range that support your UUID. Here is how.
Then connect to each of them using a RFCOMM Connection as a client.
Obviously, the other devices should accept this connection. If those are Android as well, see the 'connecting as a server' chapter. (Basically it means waiting for a connection...).
For things not covered in the Android Official Documentation, see this.
You can also just take all paired devices, and try to connect to them(obviously only those in range will connect).

Can Android support Zeroconf/Bonjour over Bluetooth? How about TCP/IP?

On iPhone if I create custom service for example "_test._tcp.local." in Bonjour I can seek/broadcast this service through WiFi or/and Bluetooth.
It is possible on Android ?
I know that there is jmDNS but from what I understand it works only through WiFi/Network,
not Bluetooth.
Thanks
EDIT by Seva Alekseyev, who offered the bounty: I'm not after workarounds (like Zeroconf sans Bluetooth or Bluetooth sans Zeroconf). I'm after the real thing.
Not on bluetooth, because Android currently doesn't support TCP/IP over bluetooth, and Android's native NSD support (network service discovery) works over IP.
It DOES, however, work over Wi-Fi. Also, Android supports service discovery over Wi-Fi Direct, which gives you greater range and battery efficiency than bluetooth. For a guide on how to integrate service discovery into a wi-fi direct enabled application, check out the Android Training lesson.
Portions of this answer are duplicated from our Dear Android video response to this question
You can use BluetoothSocket and BluetoothServerSocket to create TCP like sockets over Bluetooth.
Here is a sample of android dnssd :
https://github.com/twitwi/AndroidDnssdDemo
You may need to modify the jmdns library such that it creates bluetooth sockets if bluetooth is ON, otherwise creates simple sockets. Encapsulate the socket communication in a different class that creates socket conditionally.
There's a couple of reasons why this is not possible currently. The one most related to your question is that - as you probably experienced - jmDNS requires a TCP/IP link to publish or browse services (it requires an IP address to bind to). As the other answers & comments state, you'd need an established PANU link for that, which Android currently doesn't provide.
The other reasons it will not work are:
Apple uses a couple of mechanisms to assure iOS devices will only talk to other iOS devices. So even if you'd get Android into talking Bonjour-over-Bluetooth, it would only work Android-to-Android.
Apple certified devices in the MFi program have a special crypto chip which is supplied by Apple. I'm not sure if this applies to Bonjour-over-Bluetooth connections as well, but I'd assume it does.
You could instead look into using Bluetooth 4 LE - at least there's an Apple API for that starting in iOS 5 providing a Slave profile, and extended to support a Master profile in iOS 6.

Categories