Howto Xbee API command

I am trying to understand the how to construct api commands

I have 2 type 1 radios configured with api 2

Remote unit has address 13A200 405C420C

I want to check the status of D1 on the remote unit

Using assemble packet of XCTU to send this line

7E 00 0F 17 01 00 7D 33 A2 00 40 5C 42 0C FF FE 00 44 31 D2

I just get no response

Richard

It is all in the Digi XBee doc but not very clearly the first time reading it.

API=2 I believe is API command mode with escape sequence (read the XBee doc, page 57). You may be better to use API=1.

There have been a few threads here and in the PIC programming forum that would be worth your time to find and read.

A few other links I have would help:

http://www.jsjf.demon.co.uk/xbee/xbee.html

http://www.humboldt.edu/~cm19/XBee%20setup.pdf

http://www.digi.com/support/forum/listf … sible=true

So your API frame decodes as following (see page 60 of the 90000982_B.pdf doc):

7E ;start delimiter

00 0F ;length

17 ;frame type identifier

01 ;frame ID

00 7D 33 A2 00 40 5C 42 ;64bit Destination address

0C FF ;16bit destination network address

FE ;command options

00 44 ;command name (ASCII)

31 ;command data

D2 ;checksum

So the first thing I see is that the remote’s address is not in the API frame.

Second is there are no values escaped (there aren’t any that need it however).

Third the payload length is mis-counted, should be0x10.

forth, the check sum is wrong (should be 0x39).

Any one of these error will cause the API frame to be ignored.

I believe the frame should be:

7E

00 10

17

01

00 13 A2 00 40 5C 42 0C

FF FE

02

44 31

04 ;output D1 high (see page 41)

D0

If this works then go back to the Doc and learn why yours didn’t.

I called myself “reading” the digi docs

My original api frame is

7E 00 0F 17 01 00 13 A2 00 40 5C 42 0C FF FE 00 44 31 D2

but I understood that 0x13 had to be escaped hence the 7D 33

I will read a bit more

Richard

Ah…7D 33

well at least the 64bit address is there.

I’ve never used the escaped API mode. This is rarely needed. Start with the API=1 mode mode to get everything working. Then if you really need to escape go to the API=2 mode.

Good luck.

config it to not use the escaped bytes mode. Too complex.

Sorry bout that

It was a bad checksum

Should be D6

Richard

Now I send request for status of D1

7E 00 0F 17 01 00 7D 33 A2 00 40 5C 42 0C FF FE 00 44 31 D6

It returns

7e 00 10 97 01 00 7d 33 a2 00 40 5c 42 0c ff ff 44 31 00 02 53

Good, I have D1 set for ADC

Now I send resuest to force sampling ‘IS’

7E 00 0F 17 01 00 7D 33 A2 00 40 5C 42 0C FF FE 00 49 53 AF

It returns

7e 00 14 97 01 00 7d 33 a2 00 40 5c 42 0c ff ff 49 53 00 01 04 00 03 87 9f

This is where I am confused

01 - number of samples

04 - io mask

00 - dio data

03 87 - adc data

Since I have D1 set for ADC should not the io mask be 40

Richard

rray:
Now I send request for status of D1

7E 00 0F 17 01 00 7D 33 A2 00 40 5C 42 0C FF FE 00 44 31 D6

It returns

7e 00 10 97 01 00 7d 33 a2 00 40 5c 42 0c ff ff 44 31 00 02 53

Good, I have D1 set for ADC

Now I send resuest to force sampling ‘IS’

7E 00 0F 17 01 00 7D 33 A2 00 40 5C 42 0C FF FE 00 49 53 AF

It returns

7e 00 14 97 01 00 7d 33 a2 00 40 5c 42 0c ff ff 49 53 00 01 04 00 03 87 9f

This is where I am confused

01 - number of samples

04 - io mask

00 - dio data

03 87 - adc data

Since I have D1 set for ADC should not the io mask be 40

Richard

OK I think I understand

04 00 is the io mask and there is no dio data since no lines are set

My apoligies

I’ll keep reading

Richard

Richard,

You are progressing very well. It took me a bit longer to figure out the ‘IS’ returned data format.

Hello,

Here is the full example i hope it is help if somebody starter as i am :slight_smile:

This is working for me!

I have one coordinator and one end point.

My coordinator device short address (MY) 1111

Coordinator serial number high (SH) 13A200

Coordinator serial number low (SL) 4031BEF6

Node identifier (NI) Coordinator

Api enable (AP) 1

Coodrinator enable (CE) 1 - Coordinator

My end device short address is(MY) 2222

End device serial number high (SH) 13A200

End device serial number low (SL) 4031BEF1

Node identifier (NI) Enddevice

Api enable (AP) 1

Coodrinator enable (CE) 0 End - device

channel (CH) value is C on the coordinator and the end device too

PAN ID (ID) value is 3332 on the coordinator and the end device too

DH and DL is not set nowhere.

Data about the modules(same on the coordinator and the end point):

Mode type: XB24

Function set XBEE 802.15.4

Version 10E6

I have this radio and adapter: http://www.adafruit.com/images/large/xb … er_LRG.jpg

Here is the command what i used (Get the D1 pinout settings):

7E 00 0F 17 01 00 00 00 00 00 00 00 00 22 22 00 44 31 2E

The description:

7E start delimiter

00 0F Data length MSB LSB (dec 15 0x000F) Calclate as 90000982_B.pdf page 59, bottom of the AT Command section signaled with star

17 API identifier (Remote AT command request) 90000982_B.pdf page 60

01 I wait for an response

00 00 00 00 00 00 00 00 the long address, i dont use this, i going to use the short address

22 22 the short address of the end device

44 32 the D1 characters in ASCII

2E this is the checksum

Checksum calculated: 90000982_B.pdf 58 page at the top

17+01+22+22+44+31=D1

FF-D1 = 2E

Zsotya

Hi, I’m trying to use xbee DigiMesh with API. Is it necessary to use the API w/escape when the 64bit destination address is 0013A200? Like rray did or it isn’t, like waltr & stevech said?

I’m trying with broadcast to avoid API=2 but I have no answer.

The frame is:

7E 000F

17 01

000000000000FFFF (Broadcast Dest)

FFFE (Broadcast Net)

02

4430 (D0)

76

With AT command ATND (not API) I have the answer.

Any suggestions?

API=2 is not needed in most cases. The only reason I know of is if the serial uses Xon/Xoff Flow control, a particular character stops data transmission and another character starts data transmission.

I use 64 bit addressing without the escape sequence without problems.

I’m trying with broadcast to avoid API=2 but I have no answer.

Broadcast and API=2 (escaped) are two different and independent things.

Do triple check your API frames. If there is any little thing wrong then the frame is silently ignored.

Thanx waltr for your answer.

I know Broadcast and API=2 are different things, I mean I tried to use broadcast address to avoid the “13” of the 64 bit address in the frame.

Anyway with API=2 and the 7D33 to avoid the 13 I had responce.

Now I’m coding in C this to use it in a PIC.

I’m sure I’ll need your help and I hope I can help you.

See you