Development v12

Warning - Product Update

All the resources present on this section belong to Waspmote v12, Waspmote Plug & Sense! v12 and Meshlium v3.8.

If you have a Waspmote v15, Waspmote Plug & Sense! v15 or Meshlium v4.0 please go to the new Development Section.

Check what is your version and what are the differences between the old and the new one in this document.

» OTA 05: OTA for XBee-868

This program shows how to build a program which supports Over the Air programming (OTA) using XBee 868 Mhz modules

Required Materials

1 x Waspmote PRO
1 x Battery
1 x MiniUSB wire
1 x XBee-868
1 x SD card

Notes

- For OTA programming it is necessary to learn about OTA shell and know how to request and send data to the nodes (Please check the OTA Programming Guide)
- All XBee modules in the network must be configured with the same parameters
- This example can be executed in Waspmote v12

Code

/*  
 *  ------ [OTA_05] - OTA basic program with XBee 868 -------- 
 *  
 *  Explanation: This program shows how build an program which supports
 *  Over The Air Programming (OTA) using XBee modules
 *  
 *  Copyright (C) 2012 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 3 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:    Yuri Carmona
 */
 


#include <WaspXBee868.h>

#define key_access "LIBELIUM"
#define id_mote "WASPMOTE00000001"

void setup()
{
  USB.ON();
  USB.println("OTA_05_868 example");

  // Write Authentication Key to EEPROM memory
  Utils.setAuthKey(key_access);
  
  // Write Mote ID to EEPROM memory
  Utils.setID(id_mote);

  // Initialize XBee module
  xbee868.ON();
   
  // CheckNewProgram is mandatory in every OTA program
  xbee868.checkNewProgram();  
}

void loop()
{
  // Check if new data is available
  if( xbee868.available() )
  {
    xbee868.treatData();
    // Keep inside this loop while a new program is being received
    while( xbee868.programming_ON  && !xbee868.checkOtapTimeout() )
    {
      if( xbee868.available() )
      {
        xbee868.treatData();
      }
    }
  }
  
  // Blink LED1 while messages are not received
  Utils.setLED(LED1,LED_ON);
  delay(100);
  Utils.setLED(LED1,LED_OFF);
  delay(100);
    
}

Output

E#
OTA_05_868 example

Quick Publish: