API Mode C/C++ Code

Is there a reference implementation, in C/C++, mechanizing API mode? Several other ZigBee vendors provide source level APIs to facilitate integration/application development; I was wondering if Digi has the same or do I have to mechanize API mode myself? TIA.

I’ve just started building my own. I’m going with ANSI C because my code will have to compile and run on a Microchip C18 compiler and VS2003 for the Windows side. I found a Java implementation that is somewhat helpful as a cross check when creating/parsing the messages. I’m principally working from the maxstream_90000991_a.pdf as my reference.

Did either of you create the API interface in C? If so, would you be willing to share it?

Hi, yes I wrote an API in C for dsPIC32 with most commands of the XBee card. The API is generic C with static memory allocation so it can be used on any CPU/microcontroller:

It is part of the open-source project Aeropic:
http://svn.gna.org/viewcvs/aeropic/trunk/lib/?dir_pagestart=50 (see license)

The module files are xbee_api.c, xbee_api.h, xbee_api_def.h, it uses function pointers for call-back functions (packet or status received) and to send data, thus xbee_Init(…) must be called at the beginning. Dont hesitate to contact me if you need further details.

Message was edited by: Habersaat

Here is a link to another C library for XBee. Its written for a Arduino processor but should not be hard to port to any other processor.
http://code.google.com/p/xbee-arduino/

Is there another way to use the API mode without a microcontroleer? Only with the XBee module?

Eliã Lima

All messages sent to and read frm a radio in API mode will be in the API data frame. This frame either needs to be composed or interpreted. An external host device is required in order to do this. The host can be a micro or a program running on a PC.

Using the Terminal in the X-CTU software, click the Show hex button. This will display the Hex data packet coming from the radio. You can use the Assemble Packet button to compose your own API packet to send to the radio if you wish as well.