XBee command mode
Rsadeika
Posts: 3,837
I am trying to get a C program to communicate with the XBee in AT command mode, without much success. Below, in the program, when I type in "+++", I am expecting to see an "OK" on the screen, but that is not happening.
I want to access more than one XBee from a base XBee unit, and I need to give each one of the XBee units some AT commands to have the individual XBee units in the correct receptive mode. Any help would be appreciated, once I get the hang of this, I might develop an XBee command library, if it has not been done yet.
Ray
I want to access more than one XBee from a base XBee unit, and I need to give each one of the XBee units some AT commands to have the individual XBee units in the correct receptive mode. Any help would be appreciated, once I get the hang of this, I might develop an XBee command library, if it has not been done yet.
Ray
/** * @file test_xb_opp.c * This is the main test_xb_opp program start point. */ #include <propeller.h> #include <stdio.h> #include <stdlib.h> FILE *xbee; /** * Main program function. */ int main(void) { char cin[5]; char xin[5]; /* Tx Rx */ xbee = fopen("SSER:9600, 22, 23","r+"); waitcnt(CLKFREQ + CNT); printf("Start program\n"); while(1) { gets(cin); fflush(stdin); fprintf(xbee,"%s",cin); fgets(xin,5,xbee); fflush(xbee); puts(xin); } return 0; }
Comments
Generally my suggestion is to open two separate handles, one for input and one for output (just like the standard C library opens stdin for input and stdout for output), rather than using one with "r+". So I'd suggest replacing the FILE *xbee with FILE *xbeein, *xbeeout and adjusting your code accordingly.
Eric
The other part of the discovery is that 'SSER' does not work as expected for this setup, you have to use 'FDS'. It is starting to look like if you want to deal with some specific project, like the XBee, you just might have to build some specific libs for the project, so when is simpleIDE going to get that functionality? I try to avoid the command line version for building libs, although I have not tried it that just yet. So, does anybody have an example command sequence for setting the destination address?
Ray
Better library support and sharing is in the next release.