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 01: OTA for XBee-DigiMesh

This program shows how build a program which supports Over The Air Programming (OTA) using XBee-Digimesh modules

Required Materials

1 x Waspmote PRO
1 x Battery
1 x MiniUSB wire
1 x XBee-Digimesh
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_01] - OTA basic program with XBee DigiMesh -------- 
 *  
 *  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 <WaspXBeeDM.h>

#define key_access "LIBELIUM"
#define id_mote "WASPMOTE00000003"

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

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

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

void loop()
{
  // Check if new data is available
  if( xbeeDM.available() )
  {
    xbeeDM.treatData();
    // Keep inside this loop while a new program is being received
    while( xbeeDM.programming_ON  && !xbeeDM.checkOtapTimeout() )
    {
      if( xbeeDM.available() )
      {
        xbeeDM.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_01_DM example

Quick Publish: