Turn off specific USB port programmatically - java

I use an hardware device that goes in standby after it is not used for several minutes.
The only way to reactivate it is to unplug it from the USB port and reconnect it.
So I would like to know if there is a way to turn off (and then turn on) that specific USB port.
Thanks in advance!

Related

Get Devices connected to same wifi network in android programmatically?

I am developing an app in which the first thing i need is how to get devices that are connected to my wifi network or same wifi network .ie ip adress,device name etc.
I don't have any idea how to do that have searched alot but there are no examples available.
I have done one thing that i will ping 255 ips and whichever will respond will be the connected ips but the problem here is that there are virtual ips already assigned to some websites so i need to detect only the real device ip addresses.
I want to do the same thing as done in the app WifiTalkie
Follow Any one of the following:
Way1:
If you mean you want to see all the devices connected to your current WiFi connection (and you are not trying to do Ad Hoc networking), then you are essentially wanting to run a network scanner.
There are a bunch of these around. This one has the source available on github
http://rorist.github.com/android-network-discovery/
Way2:
Refer How to detect all the Devices connected in a WiFi network from Android App

How to reconnect to the network using Cordova/phoneGap/Ionic without rebooting the phone?

Is there a Cordova plugin which resets the network interface?
I'd like to create an app which runs in the background and periodically (from a remote call) does a few things:
Reboots mobile hotspot (there's a Cordova plugin for that, easy enough)
Autostarts the "monitor" software (there's a Cordova plugin for that too, easy enough)
Reboots the phone.
So think of it as a remote-controlled drone.
Rebooting turns out to be a problem as apps don't have this authority unless the phone is rooted. Rooting it is an option but I'd like to avoid it if I can as I don't know Java very well (and the app has to do a variety of other stuff as I mentioned)
When a reboot happens, the part I'm most interested in is the network reconnect at which point the phone receives a new IP. This is where, momentarily, there's no signal and no bars. So I'm thinking if I can trigger that somehow without actually rebooting the phone, I don't need to reboot the phone, as all I want is a fresh IP.
I can't find a Cordova plugin which RESETS the connection to a cell tower.
I don't care if it crashes the network interface or reboots or just sets it to a wrong value which then autocorrects - so long as the phone gets a new IP "on demand," I don't care.
Is there a Cordova plugin which resets the network interface?
I know it's possible as I've had issues with my Android where it had to reconnect; but perhaps there's no API to do so on demand.
This is going to be hard as the element assigning the IP addresses is not under your control.
Mobile networks are generally set up to have the PDP context, the connection that carries the IP connection, resilient so that they do not just reset when you temporarily lose coverage.
Hence even if you reboot the phone you may be inside the timeout window and still get the same PDP context.
In addition to this, network operators may have an IP address allocation scheme in place, sometimes in association with their NAT tables, that attempts to assign the same IP address to the same device even if it has been idle for some time.
You'll notice on WiFi also that many routers will remember the MAC address and the IP and simply assign the same IP address when they see the same device again.

Can we distinguish Blackberry is in USB mode or charge mode?

I am new to blackberry-7. In my application when I plug my phone into the cable (by means of the USB cable) I want to find if my blackberry connected with USB is in charging mode or transfer mode. How is it possible?
The USB can be detected asynchronously using SystemListener2 and also synchronously using DeviceInfo.getBatteryStatus.
For what you need the battery status won't work because it probably charges in both normal and transfer modes, and then there's the problem of detecting the cable when the battery is full. So I'd try registering a SystemListener2 instance and hopefully the callback usbConnectionStateChange will be passed the flag SystemListener2.USB_STATE_CABLE_CONNECTED as argument. When it is transferring, I'd expect the flags USB_STATE_ENUMERATED and USB_STATE_MS_INTERFACE_ENUMERATED to be received in the callback as well, but I've never tested it on a real device.
And I don't know what would happen if the device is already connected when the listener is registered.
To register the listener, call
Application.getApplication().addSystemListener(mySysListener2);

Check automatically in background if Wi-Fi network connection is enabled

I am working on an application that is going to need to communicate with electrical plugs. These electrical plugs will be inside a specific network called "EPlugs Network" (for example).
I need to check automatically and continously if the connection to this network is still enabled.
If a Wi-Fi network is available, I need to check if this is the good one. I suppose it will be enough to just catch the name of said network.
If it is not the good one or if no Wi-Fi connection is enabled, I will need to create a pop-up and ask the user to connect to this specific network. Otherwise, the application should not be able to continue working.
Is there a native way to check Wi-Fi connection's presence?
Thank you for your help.

Bluetooth comport programming very slow

this is Dharmesh i developed one application of gps. my gps connected via Bluetooth but my program take too much time identify comport. but if i connected my gps with usb cable it run easily any one face this issue and how to overcome this issue.
thanking you......
This may be a side effect of the fact that you let the bluetooth port go between attempts. Bluetooth connections setup and teardown are very expensive, so if you connect to the GPS, you should remain connected. Of course, that doesn't help during dev, so once you know the bluetooth connection works, it probably makes sense to use the USB cable except when testing the connection for regressions.

Categories

Resources