|
|
View previous topic :: View next topic |
Author |
Message |
mymadi
Joined: 16 Sep 2008 Posts: 4
|
Xbee API Method |
Posted: Wed Sep 17, 2008 2:08 am |
|
|
Dear all
I wrote a source code for Xbee transceiver. I'm using API methods. Luckily, it is working. But, may be my code is look funny. Here i show my source code:
Transmit Request 16-bit:
Code: |
void GXBeeTR()
{
unsigned int8 sd,lmsb,llsb,id,fid,damsb,dalsb,op,gid,data,csm;
sd = 0x7E; // (Byte 1)Start Delimiter
lmsb = 0x00; // (Byte 2)Length MSB
llsb = 0x07; // (Byte 3)Length LSB
id = 0x01; // (Byte 4)API Identifier
fid = 0x00; // (Byte 5)Frame ID
damsb = 0x71; // (Byte 6)Destination Address MSB
dalsb = 0x76; // (Byte 7)Destination Address LSB
op = 0x00; // (Byte 8)Options (Please Refer Datasheet)
gid = 0x02; // (Byte 9)G-Xbee ID
data = value00; // (Byte 10)Gas Sensor Value
// (Byte 11)Checksum
csm = 0xFF - (id + fid + damsb + dalsb + op + gid + data);
putc(sd);putc(lmsb);putc(llsb);putc(id);putc(fid);putc(damsb);
putc(dalsb);putc(op);putc(gid);putc(data);putc(csm);
}
|
Receive Packet 16-Bit:
Code: |
void GXBeeRP()
{
unsigned int8 x;
chksumRP = 0;
for (x=1;x<=11;x++)
{
byteRP[x]=getc();
}
chksumRP = chksumRP + byteRP[4] + byteRP[5] + byteRP[6] + byteRP[7] + byteRP[8] + byteRP[9] + byteRP[10];
chksumRP = 0xFF - chksumRP;
CheckRP();
}
|
Can anyone help me to minimize the source code for both Transmit and Request?
Thank You |
|
|
tottidatunisia
Joined: 12 May 2012 Posts: 1
|
Re: Xbee API Method |
Posted: Sat May 12, 2012 11:09 am |
|
|
the gas sensor that you use have a profile home automation or not? |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sat May 12, 2012 2:58 pm |
|
|
Hi,
Do you realize that this thread is almost 4 years old???
John |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|