I am trying to get data from app running on android device and plot it in a browser running on PC.
I considered below methods
Method 1
Write data from android app to cirular files[ file1.txt -> file2.txt -> file3.txt -> file1.txt ] at regular intervals, in my case 1 sec.
Pull the files using adb in circular order.
Again use the same circular order in reading files in browser using XMLHttpRequest and plot using some javascript.
Here I am facing some error while reading the file using XMLHttpRequest, there may be a issue of synchronisation -> reading and writing of the files.
I think this is very naive approach.
Method 2
I considered one more option of using USB tethering to establish a TCP connection between device and PC and get data from the APP from client-socket running on PC. ( This method sounds better than writing data into files in the device and pulling files using adb ).
Still unable to find a way to send the data received from device to browser for plotting.
Constraints
I am not allowed to use any kind of webserver on the device side.
Any method I think of has some kind of ping-pong/circular approach somewhere in the process, which I think is not a good option.
I know this sounds like pretty simple problem to many of you.
It will be of great help, if anybody gives some elegant approach.
I could able to find answer in some form.
Open TCP/UDP connection from the app running on Device to PC to which it is connected (using USB) and send data.
a) If data has to be processed, process that data in another application and send the processed data to node.js running on PC
b) If there is no processing required directly send data from Device to node.js
Open websocket in node.js and send that data to browser running on another PC.
Related
I am developing an application in which some data should be available from phone to PC as soon as its available in phone(e.g. user types something in app or user press at some coordinate in app and App record the coordinate but we need to pass the coordinates to PC).
The data may be string of character ,integers etc.
Actually we can pass data in "save and send " manner where I can run adb pull command to get data but it's not desirable.
Because we have some simulator app at PC which need the data just in time when it's produced at phone side.
So its should be like continuous streaming from device to PC(PC may be windows,linux or nay other OS)...
It's also acceptable if we can just update some data file which is at PC's harddisk just in time manner whenever new data available at phone so that simulator can read new changes and act accordingly.
I searched a lot in internet and what I can find is as below:
adb shell port-forward
adb shell ppp
I found port-forward somewhat related to this task but I am not quite sure if it will be useful and am I going in right direction?
Also if port-forward option is right to do the task,do I require to write client application for socket connection at PC side and also at phone side in app?
I would appreciate your efforts.
Thanks..
am new to this application developer, first I'll describe the setup of my system. I've one mechanical machine, it connected with a PC via PLC, now I've some data ( decimal numbers) in PC (which is from machine), now
I need to develop an application to display contents (decimal numbers) in the android mobile, which is in PC via WiFi.
And i need to send some command back to PC,
Is it possible with simple application developer with simple coding?
Please help.
You can easily use TCP sockets which are based on IP protocol and will allow you to communicate over any IP network.
For your Server/PC
you can write a simple java tcp server on your PC.
Tutorials:
TCP Server
All About Sockets ... great starting point.
For your Android/Client
you will have to understand the basics on android development and take a look at couple of networking example.
follow these links:
Your First Android App
Android TCP Client Example
Extra :
TCP on Wikipedia no need to read the implimentation details just understand the concept.
If you want to do it only with your PC<->Mobile, you could expose the data-file via a webserver and then let the mobile read that file and expose in a desired manner. This is not a suggested way to do it, as it has several draw backs e.g. limiting exposed data etc.
Assuming that the data you want to expose is not trivial and may contain multiple data sources, Doing it in more-interoperable way will be a bit more work.
Write webservices (REST/SOAP) that expose the data from the server
Write an mobile app that consume the data from the webservice (via a REST client)
Once the app has consumed the data, you can write your
desired ui to display it on the mobile app.
I'm having the following scenario:
On the PC i will have a program running: java or .net, haven't decided yet.
When a certain event happens on PC i want to notify the android device.
I want a solution as independent and reliable as possible.
Opening a server on the PC/Android i think is out of the question because the user might be behind a router or on GSM internet (as far as i know it can't open ports as server)
The solution i have at this moment is to have a web server on the internet and have it handle the job, but i'd like not to use this because the delay between checks should be around 5 seconds, and i expect to have about 2-3k users simultaneously, and that will probably know down a regular web server.
So, any ideas how this communication can be made?
You may consider the option of Bluetooth client server application since PC and Android device usually have Bluetooth. You will have a Java server running on the PC and an Android client on the device. Check out this post: Send text through Bluetooth from Java Server to Android Client
You can handle the situation where Bluetooth is not available by creating a failover mechanism using REST API & JSON.
If you're already a web developer, I think creating a light HTTP based REST or JSON service would be a great solution. You've already said you don't want to do that which leaves the option of rolling your own client/server set up.
On the Android side of things, one way to do it would be to use TCP sockets. You can learn more about them here: http://developer.android.com/reference/java/net/Socket.html
I'm trying to learn android and for my app i have few questions.
If i type a computer name on the EditText in my android phone, I
should be able to ping the device (So basically i need to first
resolve the ARP to get the mac address of the device which I want to
ping and then send the ping as an ICMP request).
I believe there is some command to retrieve the computer name and
send this ping command, but i would like to do it the hard way so
that i can learn stuffs better - It would be nice if you can show me
some pointers to some tutorial apps and open source code which does
similar tasks.
Once I have identified and connected to the device. I should be able
to start a chat with the device.
Assume the second device is also an android device, how can I
establish basic message sending from one android device to another.
Basically my app will be a client and server (I guess 2 services - service listening to sockets for incoming messages and client can send out messages).
Does anyone know any sample app / tutorials [basically code examples] which does this in android.
To Nr.1
I'm not quite sure why you first need to ping the device, as you could simply try to connect to the given device (using a timeout) and see if it can be connected.
I found some informations on this, here.
To Nr.2
So, if you want your Devices to communicate to each other, you'll want to use Sockets.
But, if your App is only for chatting and you don't need to know if the last send package was successfully send, you could also use UDP instead of TCP (So you don't need your application to run both the Server and the Client-Socket).
Although, all your questions could have been answered by doing a little googleing...
My development team and I, are working on an application that uses a sql database, we try to transfer a database from our application to a server using tcp sockets, we made some research about sockets, the server program is written on java language using netbeans, and the application is written on eclipse.
We made several conectivity tests between the application and server programs, using the android emulator, we tried to made it local (running both programs on the same computer) and the server conects with the application, but it doesn´t receive all packages, it receives aproximately 2Kb (we want to transfer a 25Kb file), the same happens when we run the server on other computer in the same network, we made some tests using wireshark to capture all the packagesincoming from the application to the server and viceversa, we´ve noticed that the server receives all the data, but first it receives a 2Kb packet, after that server application receives an end ack, and then, the application receives the missing packages, and then discards them.
We also made some conectivity tests using a coby kyros tablet instead of the emulator, and we have no problem, the application running on the tablet, sends all the data, and the server receives it.
We want know if there are an error on the emulator, and how to solve it.
Please help us or send us yout feedback
This sounds like you are running into a configuration problem with your emulator environment. Take a look at the network configuration info for the emulator.
The fact that its working fine from the actual device suggests to me you have an emulator network configuration issue. There could be a number of issues. I imagine that wireshark can show the packets reaching the machine the emulator is on, but that doesn't mean they are making it into the virtual network the emulator is in.
To verify you'll probably need to use something like
telnet localhost <emulator port>
network capture start
... run test ...
network capture stop
and then look at the capture file. That seems like it should capture your traffic inside the emulator environment to give you an idea of whats happening.