Android/iPhone device connection via USB in NodeJS - javascript

I need to connect android/iPhone device via USB with a PC. An program written in NodeJS should be able to detect the device and get information and perform some operation on the device like reboot and reset.
Anyway, I've tried some libraries like node-usb but I'm not able to send command to the device or perform any task like that.
For iOS there's some library libimobiledevice but couldn't find any nodeJs wrapper.
Maybe I'm missing something here, any help will be appreciated.
Thanks is advance.

Don't know for iOs, but I don't think it is possible in Android. The reason is with permissions: it would rather be a bug then a feature if someone could just plug in a USB and shutdown your device without asking.
So, maybe if you would ask permissions for access and such, maybe.
Android App with Popup is possible.
And that is with Apps, not with NodeJS, it's not native to either iOs or Android.

Related

Remote Debugging On Android Browser

Sorry for the question.
I'm current creating Phaser games for mobile using web browsers.
I can remote debugging on my android device using Google Chrome Browser of my android device also similar to Mozilla Firefox Browser and check if any error in javascript/html/css using the desktop developer tools of the browser.
Here is what i follow to use remote debugging for chrome
https://developer.chrome.com/devtools/docs/remote-debugging
Here for Mozilla Firefox
https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Firefox_for_Android
Already installed Android SDK
I'm currently developing on windows platform.
Using XAMPP
But i want to test now my app on the native browser of android phones gives me hard time to do it. and don't have any idea on how to do it.
If anyone has done it before.. Kindly please share knowledge on how you to do it and make it easy and comfortable for yourself to remote debugging native android browser.
thanks in advance
Ok, this will only work if you have a local version of the website deployed... and your phone must be connected to the same network.
For reference, I used this website: http://www.broken-links.com/2013/06/28/remote-debugging-with-weinre/
First, you'll need to install NodeJS as weinre is a NodeJS app.
After you install Node, you can use NPM to install weinre.
npm install -g weinre
Then you start weinre server on your local machine
weinre --boundHost -all-
Then paste the following code in your webpage that you want to debug. Change your_private_ip to the private IP of your local server. It probably starts with 192.168.x.x.
<script src="http://your_private_ip:8080/target/target-script-min.js#anonymous"></script>
Now on your desktop, go to http://localhost:8080/client/#anonymous to see a WebKit-style web inspector.
You should see something like this:
Now you can use the other tabs like the Console to view the javascript console, or the elements to look at their styling, etc... just like on chrome or firefox.
I don't know if you still need help, but for those who are having this trouble can try this, it worked for me:
Do the exact same thing like you were to debug from google chrome, in the "chrome://inspect/#devices" tab look for this: WebView in com.android.browser (Version/4.0 Chrome/30.0.0.0) (in my case, i'm using a huawei p7)see image
Sorry for my english

Discover devices vendor and model on a local network

I need to find out if it's possible and if so, what is the API for that.
The required scenario:
connect to a wifi network.
from an android app or using javascript from a webpage find out the make and model of devices that are connected to the same router.
I found a way to find the IP addresses, and I saw that Find app can see the manufacturers, but can't tell if it's a mobile device, a tablet, a laptop or a printer.
I thought that a possible way would be to use jmDNS (which I can't get my android project to compile with), and service discovery, but I'm not sure that it will tell me if the device is a tablet or a smartphone.
For Android I can also think of the linux build number to search against a device list compatible with that build. However, I'm not sure about Apple devices.
Is there a way to do that or am I wasting my time?
If there is, will it work in Android or with JS?
Thanks.

Continuous read of USB attached device using JavaScript?

Right now we have a Windows app that continuously reads a USB-attached scale and displays (and uses) the value.
Can I do this via a web page? Someone mentioned a "javascript input event listener", maybe? Does anyone have a simple HTML example?
thanks
I doubt you would be able to get information from hardware using a browser without using a java applet or something similar.
You could write a web interface that communicates with a process running on the machine, but you would not be able to access the hardware directly through the browser.
For more information regarding the protections surrounding browsers, look here:
http://www.australianscience.com.au/research/google/35779.pdf
My suggestion:
If you have a windows application but you want to run the interface in the browser, do something like VLC (http://www.howtogeek.com/117261/how-to-activate-vlcs-web-interface-control-vlc-from-a-browser-use-any-smartphone-as-a-remote/)

Javascript to access usb HID (usb game controller)

Im looking to use Javascript to read events from a usb device other than a keyboard or mouse. Specifically, I want to use a usb gaming controller to read events. If this isnt possible with Javascript, is there anything else thats on the browser and client side that would allow me to do this? Im not above having the user accept permission for something, install a plugin, or limit them to a particular browser.
Thanks in advance
You can use the Gamepad API that exists for this very reason.

Phonegap app working locally, not working on phone

I have written a phonegap application, and it performs a pretty simple task, it gets some JSON from a YQL link, and then displays it nicely to the user. This works excellently when I run it using Google Chrome on a Desktop, but, my client tells me that it does not work on his device which is Android 2.3. What can be going wrong? I'm using phonegap build to build to app, and they tell me that it is given internet permission, but, when my client puts the APK on the phone (its not on the market yet), does he need to do something special for it to access the internet?
Thanks a lot,
Dhaivat
in phonegap, allow external host : Open phonegap.plist -> external host and add your url or * to allow all
within the phonegap app the webapp runs under the file:// protocol - this might affect things.
you should test this at least on an emulator yourself - clients usually screw up anything some might screw up when testing ;) best would be to test on an actual device tho.
I'm not sure if this will help but I had a similar problem testing my app here:
https://stackoverflow.com/questions/17496104/json-wordpress-feed-not-appearing-in-android-studio-emulator-using-phonegap
I needed to change access origin to ="*"/ in my config.xml

Categories

Resources