Javelin Stamp - receive data w/ Zigbee
Hi all,
hoping someone could provide some insight as far as using the Javelin stamp in coordination with the Zigbee modules.
Is there any sample code showing how to receive data using the Javelin stamp? I've found samples on how to transmit , and those were quite helpful.
Any help or direction is greatly appreciated.
PS: A little background information: for now, just to get familiar with the Javelin stamp and the Zigbee's, I'm trying to create a simple wireless chat client (just using the terminal to enter messages to be sent, and show messages being received.).
Thanks.
hoping someone could provide some insight as far as using the Javelin stamp in coordination with the Zigbee modules.
Is there any sample code showing how to receive data using the Javelin stamp? I've found samples on how to transmit , and those were quite helpful.
Any help or direction is greatly appreciated.
PS: A little background information: for now, just to get familiar with the Javelin stamp and the Zigbee's, I'm trying to create a simple wireless chat client (just using the terminal to enter messages to be sent, and show messages being received.).
Thanks.
Comments
http://forums.parallax.com/showthread.php?p=705802
regards peter
A general question here when receiving data via the XBee and Javelin.
For my application, I will be receiving both int and Strings as data. I am stuck as to how to determine which one is in the buffer before actually manipulating it. As of now, my code in the main application looks like:
while (true)
{
while (!node1.byteAvailable())
{
}
System.out.println("Data Available! \n");
System.out.println("message: " + node1.getStringData() + "\n");
}
}
My question is, if there is an integer in the buffer, how would I know, so that i can call node1.getIntData() instead of the getStringData method.
As each character is held in the buffer, the easiest way to check if it is an digit (or part of the integer) I do something like this...
where the isDigit function is as follows...
You may have to modify this slightly if you do not know whether it is going to be an int or a string, as the code above is expecting a chunk of digits to come at a specific point.·
What i am trying to say is that I just use everthing as chars then convert them to ints or stings (or stringbuffers) as needed.
Hopefully that will help.
---
As a side not don't do things like
as that will cause overflows eventually use a stingbuffer or if just using for terminal use...
Hope this didn't confuse you more...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Jon
www.jonkeinath.com
I've got another idea...... Please tell me if you think this would work, or would eventually fail due to timing/xmit issues.
I can include a header in the transmitted data that tells what it's going to be. for example:
int!xyz = an integer is everything that comes after the !
str!abc = everything after the ! is going to be a string
Please share your thoughts!
use the protocol dictated by the transmtter.
If you·have full control on how the transmitter formats its data,
like when you have the source for the transmitter program,
then you can choose whatever protocol you like.
For example: you can decide that numbers are transmitted
in hex digits like Jon said, or just decimal digits. Put a '#' in front
of numbers to mark the start of a number. Put a '$' in front of a text message.
It just means you cannot use # and $ in text messages.
If that is a problem you can use some control character (ascii code < 32),
like STX and ETX surrounding a text message, or use a escape character like \,
so to use \, # or $ in a text message, send \\, \# or \$ respectively.
regards peter