This is my code so far...Code:
/*
* ----- wasp_start_program_full_ZB_v1------
*
* Explanation:
*
* Waspmote starting program for XBee ZB module. This program
* initializes the XBee module, prepares the frame to send and every
* second it sends it.
*
* Remarks: This code shall work with a XBeeZB-router, so before
* executing this example, A ZB-Coordinator must be plugged in your Gateway
* and your ZB-router must have: JV parameter set to '1'; BD parameter set to 5;
* and AP parameter set to 2.
*
*
* Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 0.1
* Design: David Gascón
* Implementation: Marcos Yarza, Alberto Bielsa, Yuri Carmona
*/
packetXBee* paq_sent;
int8_t state=0;
long previous=0;
char aux[200];
char* macHigh=" ";
char* macLow=" ";
int aux_1 = 0;
int aux_2 = 0;
#define key_access "WaspmoteNetwKey!"
uint8_t direccion[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};
void setup(){
//Store key access in EEPROM
for(int i=0;i<8;i++){
Utils.writeEEPROM(i+107,key_access[i]);
}
// Opening UART to show messages using 'Serial Monitor'
USB.begin();
RTC.ON();
ACC.ON();
XBee.setMode(XBEE_ON);
XBee.begin(38400);
delay(1000);
// XBee.print("+++");
// delay(2000);
// XBee.println("ATBD5,AP2,WR,CN");
// delay(1500);
XBee.setMode(XBEE_OFF);
XBee.close();
Utils.setLED(LED0, LED_ON);
Utils.setLED(LED1, LED_ON);
delay(5000);
Utils.setLED(LED0, LED_OFF);
Utils.setLED(LED1, LED_OFF);
for (int i=0;i<24;i++){
Utils.blinkLEDs(125);
}
xbeeZB.setAPI(0);
// Inits the XBee XSC library
xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
// Powers XBee
xbeeZB.ON();
// Get the XBee MAC address
delay(500);
int counter = 0;
while(xbeeZB.getOwnMac()==1&&counter<4){
xbeeZB.getOwnMac();
counter++;
}
Utils.hex2str(xbeeZB.sourceMacHigh,macHigh,4);
Utils.hex2str(xbeeZB.sourceMacLow,macLow,4);
}
void loop(){
sprintf(aux,"-mac:%s%s -x:%d,y:%d,z:%d -temp:%d -bat: %d%c%c%c",macHigh,macLow,ACC.getX(),ACC.getY(),ACC.getZ(),RTC.getTemperature(),PWR.getBatteryLevel(),'%','\r','\n');
/* paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
paq_sent->mode=UNICAST;
paq_sent->MY_known=0;
paq_sent->packetID=0x52;
paq_sent->opt=0;
xbeeZB.hops=0;
xbeeZB.setOriginParams(paq_sent,MAC_TYPE);
xbeeZB.setDestinationParams(paq_sent, "0013A200406B0712", aux, MAC_TYPE, DATA_ABSOLUTE);*/
xbeeZB.send("0013A200406B0712", aux);
/*free(paq_sent);
paq_sent = NULL;*/
delay(1000);
}
I've been using xbeeZB.setAPI(0) for API = 0, all comments disable the configuration for using xbeeZB.sendXBee() and AT commands... I should use Only send function?...
xbee model: Xbee PRO s2 - 2.4 ghz