Android to Laptop file transfer ?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Android to Laptop file transfer ?

Post by Simon Knight » Thu Jul 05, 2012 4:09 pm

I am about to start on a project which will require small amounts of data to be sent from an Android device to a lap top computer (I want to transmit GPS position from time to time). I understand that sockets are not available in the most recent release of Android Livecode but as I've never used sockets I don't understand the significance of this missing feature. I have gained an impression from reading the forums that I could get data from the Android Device using URL commands if the Laptop is running a web server. Am I correct and is there a better way ?

best wishes

Simon
best wishes
Skids

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android to Laptop file transfer ?

Post by Mark » Thu Jul 05, 2012 4:16 pm

Hi Simon,

Yes, you can use LiveCode to create a simple web server and get URL's from this webserver. The webserver can parse the URL and thus read the data.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Android to Laptop file transfer ?

Post by sturgis » Thu Jul 05, 2012 4:27 pm

If you don't have livecode server and want to see an example of an httpd stack in livecode you should check here.. http://andregarzia.com/page/revonrockets

As it says on the page its not a replacement for apache, but if all you want is to transfer small amounts of data back and forth from android to desktop on a small scale its a great place to start.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android to Laptop file transfer ?

Post by Mark » Thu Jul 05, 2012 4:49 pm

Hi,

You really don't want to use LiveCode Server for this. That's way over the top. RevonRockets is a nice idea, but figuring out how it works might be more work than making your own.

All you want is open a socket for listening and parse whatever comes in. If it is something your little server app can understand, then process it, otherwise discard it.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Android to Laptop file transfer ?

Post by mwieder » Thu Jul 05, 2012 6:18 pm

RevonRockets is a nice idea, but figuring out how it works might be more work than making your own.
Maybe. Since there are no sockets on the Android end the best solution would probably be creating a RESTful server, and creating that from scratch without RevOnRockets might be a lot of work that Andre's already done.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android to Laptop file transfer ?

Post by Mark » Thu Jul 05, 2012 7:57 pm

you don't need "sockets" on the Android, since the Android is the client, not the server.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Android to Laptop file transfer ?

Post by mwieder » Thu Jul 05, 2012 8:43 pm

Yes, I realize that. But you have a limited palette of operations using url functions, so you have to set up your own server on the other (non-Android) end. Since the OP says "I've never used sockets" then Andre's library may avoid a lot of trial and error.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Android to Laptop file transfer ?

Post by Mark » Thu Jul 05, 2012 8:52 pm

I would really recommend reading up on sockets and trying to make your own server. The problem is that we're not talking about a file server. The URL needs to be parsed. It is going to be a lot of work to adjust RoR to add the parsing feature and making a simple server really isn't difficult. Although some people say nothing should be done for the first time, I think there's a first time for everything, including making your own little server app.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Android to Laptop file transfer ?

Post by Simon Knight » Thu Jul 05, 2012 9:01 pm

Thanks for the information : I was half expecting that it was not going to be possible due to "missing" features in the Android code base. I'm attracted to the idea of creating my own "server" application as a way of gaining greater understanding.

Thanks again for the pointers and the confirmation that the project can be written in Livecode.
best wishes
Skids

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Android to Laptop file transfer ?

Post by jacque » Thu Jul 05, 2012 9:12 pm

It's a little round-about, but if you have a web server somewhere already you could write a text file there and then read it on the laptop. That would require internet access on both ends though, I don't know if you want that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Android to Laptop file transfer ?

Post by sturgis » Thu Jul 05, 2012 9:15 pm

Writing your own server will allow you to make it efficient and spec'd exactly as you want, but it would still be educational to look at RoR.

For example, I took rev on rockets, added 2 handlers to the libcgi stack, built a stack for android and voila' Suddenly I have a mouse remote control. (I did have to put together an external also to do the actual clicks because lc doesn't include the ability to click a non-lc window programmatically, however it was easy enough to do the external and it works the charm!)

Basically I took the pre-existing RoR stack and added these 2 handlers to the libcgi stack.

Code: Select all

command moveMouse
   put the screenmouseloc into tLoc
   add gRequestA["x"] to item 1 of tLoc
   add gRequestA["y"] to item 2 of tLoc
   set the screenmouseloc to tLoc
   libCGI_Response("moved to" &&  tLoc),"text/plain"
   put gRequestA["x"] && gRequestA["y"] after msg
end moveMouse

command doClick
   clickit
   libCGI_Response ("0"), "text/plain"         
end doClick
Since andre already has things set up to handle passed URL strings and break them into their name/value pairs it was easy to send x and y coords and grab them with gRequestA["x"] and y.

Writing your own is great, but learning from others code, especially something as nifty as this, can be a real boost towards that end.

And of course as jacque said while I was typing, if you have access to a web server, both your android and desktop can hit it to get and add updates or whatever you need to do that way also.

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Android to Laptop file transfer ?

Post by Simon Knight » Fri Jul 06, 2012 11:16 am

Jacque - unfortunately only the laptop will be connected with the internet so I don't think that I will be able to follow your suggestion.

Sturgis I will download RevOnRockets and have a look at the code.

I have also discovered what a socket is - an IP address plus a port number :-)

Thankfully Matt Neuburg has a chapter in his Definitive Guide to RealBasic that describes the structure of both a server and a client using TCP/IP which clarifies many things. I should receive my Android phone soon and be able to start playing with it, then the questions will really start !

Thanks again

Simon
best wishes
Skids

Post Reply