File Transfer (peer to peer) using two motes

After receiving requests from so many people, I thought of writing this simple application which can transfer file between two computers

Assumptions:
  1. Environment used is: TinyOS 2.1.0 with Ubuntu
  2. Knowledge to compile "BaseStation" application (coming with TinyOS) with a modification in Makefile : CFLAGS += - TOSH_DATA_LENGTH
  3. Basic understanding of file operations in Java
  4. No other nodes are in the vicinity which are transmitting data at that time
  5. Run SerialForwarder with Java applications in TinyOS
  6. Transfer is only for "text files"
If not, please refer my previous posts on these topics or read from tinyos wiki/documentation

Steps:
General
  1. Download the code from here
  2. Install BaseStation in two motes
  3. Put one mote in computer 1 and other in computer 2.
  4. Run the SerialForwarder

Sender /Receiver
  1. ECopy the FileSender folder
  2. Open a shell, navigate to this above folder
  3. Type in CLASSPATH=/opt/tinyos-2.1.0/support/sdk/java/tinyos.jar:.
  4. Type in make
  5. Type in java FileSender
  6. Repeat the same with Receiver
  7. Enter the file name with absolute path and extension at sender side
  8. Wait for the message "File ended"
That is all folks :-)

PS:
  1. Please come up with a reliable file transfer (like ftp)
  2. Please fix this code for any (byte) file instead of text files
  3. If you do any/both, please upload and post the link here

15 comments:

n said...

Sir,Can U give us the changed program that work for audio files rather then txt files....

Gireesan said...

@n
i do post in my blog 2 encourage beginners !!! if i post what u wan, u miss the fun of learning. Pl try t for urself and pls.. pls blog it for others 2 follow

n said...

Hi sir,
Sir actually I know the concept th8 audio file need to be read bitwise rather than txt file...bt still cant implement it....My presentation is on 7th...so pls help me

Anonymous said...

Sir do we need to instll Basestation in bot the nodes or only in receivor node

Gireesan said...

@anonyms
i guess you read the line after "download the code from here"

Shreyas said...

sir I am facing a problem. I have followed all the instructions. At the sender node everything is going fine,we are getting the result "File transfer ended "

we used the command
java FileSender -comm serial@/dev/ttyUSB0:telos

however using the same at the receiver end nothing is happening
java FileReceiver -comm serial@/dev/ttyUSB0:telos

The terminal stays in resynchronization

Gireesan said...

@Shreyas

I am not sure
Pl run it in two diff machines (if u have not done t like that) and pl use 2 devices.

Anonymous said...

Just seeking a confirmation, am I correct in assuming that I could use this system to transfer arbitrary binary data *after* suitable encoding (say uuencode/yEnc/base64 etc.)

Gireesan said...

@ anonims
it could read only text/ascii
Please read the PS part
If you improve this code, please post it back, it will be a great help for others

Anonymous said...

@Gireesh: Yes, I did get the idea from the "Please fix this code for any (byte) file instead of text files" point in "PS" part. I haven't looked at the code yet, it was just a suggestion from my side.

Vinh said...

It's very useful for me.
Thank for sharing!

Nirmala said...

Sir , Where will the received files be stored?

Gireesan said...

@nirmala
you can figure it out from the source code

all the best :)

Nirmala said...

NeaaHi sir,i tried to figure it out but i couldn't get sir.so pls tell me as soon as possible so that i can continue with my work.

Gireesan said...

@nirmala
I do not know what is so complicated!!!


String fname=msg.getString_message();
fname=fname+".bak";
fpr=new PrintWriter(new FileWriter(fname));

Whatever filename sent will be used and will be stored accordingly
Print the value of fname and you will see