Energia

Reference Language | Libraries | Comparison | Changes

## AIR430Boost (ETSI/FCC)

### Overview

The AIR430Boost (ETSI/FCC) library is a proprietary-RF driver for the 430Boost-CC110L Boosterpack. It provides a simple public interface for the application to interact with the CC110L transceiver and create Point-to-Point (PPP) or Star networks.

### Library methods

#### begin()

##### Description

Sets up the SPI peripheral and I/O, radio (GDO0) interrupt I/O, and initialize the radio session.

##### Syntax

Radio.begin(address, channel, power)

##### Parameters

address: default device address used for hardware message filtering - uint8_t
channel: default frequency to receive/transmit on. Valid values are:

- CHANNEL_1 - ETSI 868.3MHz; FCC/IC 903MHz
- CHANNEL_2 - ETSI 868.8MHz; FCC/IC 904MHz
- CHANNEL_3 - ETSI 869.3MHz; FCC/IC 905MHz
- CHANNEL_4 - ETSI 869.8MHz; FCC/IC 906MHz

power: default output power level to transmit at. Valid values are:

- POWER_4_DBM - 4dBm
- POWER_4_DBM - 4dBm
- POWER_3_DBM - 3dBm
- POWER_2_DBM - 2dBm
- POWER_1_DBM - 1dBm
- POWER_0_DBM - 0dBm

##### Returns

Nothing

##### Example

    void setup()
    {
    	Radio.begin(0x01, CHANNEL_1, POWER_MAX);
    }

#### end()

##### Description

Closes the radio session.

##### Syntax

Radio.end()

##### Parameters

None

##### Returns

Nothing

#### busy()

##### Description

Radio busy indicator (transmitter active flag).

##### Syntax

Radio.busy()

##### Parameters

None

##### Returns

True if the transmitter is currently in use; false otherwise.

##### Example

    void loop()
    {
    	// ...
    	if (!Radio.busy())
    	{
    		// Transmit a message if the radio isn't busy transmitting something already.
    		Radio.transmit(...);
    	}
    	// ...
    }

#### setAddress()

##### Description

Sets device address. This address is used for hardware message filtering. If a message is received but does not match the device address and is not a broadcast (message sent to broadcast address of 0x00), the message is automatically discarded; the radio driver is never notified.

##### Syntax

Radio.setAddress(address)

##### Parameters

address: the device address of the receiving node - uint8_t

##### Returns

Nothing

#### setChannel()

##### Description

Sets the operating frequency.

##### Syntax

Radio.setChannel(channel)

##### Parameters

channel: frequency to receive/transmit on. Valid values are:

- CHANNEL_1 - ETSI 868.3MHz; FCC/IC 903MHz
- CHANNEL_2 - ETSI 868.8MHz; FCC/IC 904MHz
- CHANNEL_3 - ETSI 869.3MHz; FCC/IC 905MHz
- CHANNEL_4 - ETSI 869.8MHz; FCC/IC 906MHz

##### Returns

Nothing

#### setPower()

##### Description

Sets the operating transmit output power.

##### Syntax

Radio.setPower(power)

##### Parameters

power: output power level to transmit at. Valid values are:

- POWER_4_DBM - 4dBm
- POWER_4_DBM - 4dBm
- POWER_3_DBM - 3dBm
- POWER_2_DBM - 2dBm
- POWER_1_DBM - 1dBm
- POWER_0_DBM - 0dBm

##### Returns

Nothing

#### getRssi()

##### Description

Read the receive signal strength indicator (RSSI) for the last received data stream.

##### Syntax

Radio.getRssi()

##### Parameters

None

##### Returns

RSSI value in absolute dBm increments - int8_t

#### getLqi()

##### Description

Read the link quality indicator (LQI) for the last received data stream.

##### Syntax

Radio.getLqi()

##### Parameters

None

##### Returns

LQI value - uint8_t

#### getCrcBit()

##### Description

Read the cyclic redundancy check (CRC) bit for the last received data stream.

##### Syntax

Radio.getCrcBit()

##### Parameters

None

##### Returns

CRC bit value. 1 if valid, 0 otherwise - uint8_t

#### transmit()

##### Description

Build a data stream from the data field provided and transmit the resulting message over-the-air to a specified address.

##### Syntax

Radio.transmit(address, dataField, length)

##### Parameters

address: default device address used for hardware message filtering - uint8_t
dataField: payload for the data stream - uint8_t*
length: number of bytes in the data field buffer - uint8_t

##### Returns

Nothing

##### Example

    // Data to write to radio TX FIFO (60 bytes MAX.)
    unsigned char txData[6] = { 0x30, 'A', 'i', 'r', '!', '\0' };
    // ...

    void loop()
    {
    	// ...
    	// Load the txData into the radio TX FIFO and transmit it to the broadcast
    	// address.
    	Radio.transmit(ADDRESS_BROADCAST, txData, 6);
    	// ...
    }

#### receiverOn()

##### Description

Turn on the radio receiver and listen until a message is received or a timeout occurs.

##### Syntax

Radio.receiverOn(dataField, length, timeout)

##### Parameters

dataField: buffer that stores the data field. This buffer is assumed to be large enough to store the largest expected data field - uint8_t*
length: size of the data field in bytes - uint8_t
timeout: (maximum) period to listen for in milliseconds - uint16_t

##### Returns

Number of bytes read from the RX FIFO that were copied into the data field - uint8_t

##### Example

    // Data to read from radio RX FIFO (60 bytes MAX.)
    unsigned char rxData[6] = { '\0', '\0', '\0', '\0', '\0', '\0' };
    // ...

    void loop()
    {
    	// Turn on the receiver and listen for incoming data. Timeout after 1 seconds.
    	// The receiverOn() method returns the number of bytes copied to rxData.
    	if (Radio.receiverOn(rxData, sizeof(rxData), 1000) > 0)
    	{
    		// Data has been received and has been copied to the rxData buffer provided to
    		// the receiverOn() method.
    	}
    }

### Installation

Download from here: https://github.com/energia/Energia
Note: The AIR430Boost library is provided with the latest version of Energia.

### Demo Sketch

    /**
     *  WirelessTest - test transceiver sketch using AIR430Boost FCC driver.
     *  Copyright (C) 2012-2013 Anaren Microwave, Inc.
     *
     *  This library is free software; you can redistribute it and/or
     *  modify it under the terms of the GNU Lesser General Public
     *  License as published by the Free Software Foundation; either
     *  version 2.1 of the License, or (at your option) any later version.
     *
     *  This library 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
     *  Lesser General Public License for more details.
     *
     *  You should have received a copy of the GNU Lesser General Public
     *  License along with this library; if not, write to the Free Software
     *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     *
     *  This example demonstrates usage of the AIR430BoostETSI library which uses
     *  the 430Boost-CC110L AIR Module BoosterPack created by Anaren Microwave, Inc.
     *  and available through the TI eStore, for the European Union.
     *
     *  ----------------------------------------------------------------------------
     *
     *  Note: This file is part of AIR430Boost.
     *
     *  ----------------------------------------------------------------------------
     *
     *  Description
     *  ===========
     *
     *  Each radio will send a message consisting of: 1 byte counter, 5 byte static
     *  text. The counter will count from 0 to 9 and will rollover. Each radio will
     *  wait in receive mode for approximately one second. Upon receiving data, or
     *  timeout of one second, the radio receive function will return. If valid data
     *  was received, the radio's receiverOn() method will return the number of bytes
     *  that were received. In this example, the data can be monitored on the serial
     *  port (please refer to printTxData() and printRxData() functions).
     *
     *  ----------------------------------------------------------------------------
     *
     *  This example assumes that two BoosterPacks will be used to showcase the
     *  wireless radio communication functionality. This same code should be
     *  programmed to both LaunchPad development kits.
     *
     *  This BoosterPack relies on the SPI hardware peripheral and two additional
     *  GPIO lines for SPI chip-select and GDO0 for packet handling. They use pins 18
     *  and 19 respectively.
     *
     *  In the default configuration, this BoosterPack is not compatible with an
     *  external crystal oscillator. This can be changed, if necessary, and would
     *  require reconfiguration of the BoosterPack hardware and changes to the
     *  AIR430BoostFCC library. Refer to the BoosterPack User's Manual if necessary.
     *
     *  For complete information, please refer to the BoosterPack User's Manual available at:
     *  https://www.anaren.com/air/cc110l-air-module-boosterpack-embedded-antenna-module-anaren
     *
     *  To purchase the 430Boost-CC110L AIR module BoosterPack kit, please visit the TI eStore at:
     *  https://estore.ti.com/430BOOST-CC110L-CC110L-RF-Module-BoosterPack-P2734.aspx
     */

    // The AIR430BoostFCC library uses the SPI library internally. Energia does not
    // copy the library to the output folder unless it is referenced here.
    // The order of includes is also important due to this fact.
    #include
    #include

    // -----------------------------------------------------------------------------
    /**
     *  Global data
     */

    // Data to write to radio TX FIFO (60 bytes MAX.)
    unsigned char txData[6] = { 0x30, 'A', 'i', 'r', '!', '\0' };

    // Data to read from radio RX FIFO (60 bytes MAX.)
    unsigned char rxData[6] = { '\0', '\0', '\0', '\0', '\0', '\0' };

    // -----------------------------------------------------------------------------
    // Debug print functions

    void printTxData()
    {
      Serial.print("TX (DATA): ");
      Serial.println((char*)txData);
    }

    void printRxData()
    {
      /**
       *  The following illustrates various information that can be obtained when
       *  receiving a message. This includes: the received data and associated
       *  status information (RSSI, LQI, and CRC_OK bit).
       */
      Serial.print("RX (DATA, RSSI, LQI, CRCBIT): ");
      Serial.print("(");
      Serial.print((char*)rxData);
      Serial.print(", ");
      Serial.print(Radio.getRssi());
      Serial.print(", ");
      Serial.print(Radio.getLqi());
      Serial.print(", ");
      Serial.print(Radio.getCrcBit());
      Serial.println(")");
    }

    // -----------------------------------------------------------------------------
    // Main example

    void setup()
    {
      // The radio library uses the SPI library internally, this call initializes
      // SPI/CSn and GDO0 lines. Also setup initial address, channel, and TX power.
      Radio.begin(0x01, CHANNEL_1, POWER_MAX);

      // Setup serial for debug printing.
      Serial.begin(9600);

      /**
       *  Setup LED for example demonstration purposes.
       *
       *  Note: Set radio first to ensure that GDO2 line isn't being driven by the
       *  MCU as it is an output from the radio.
       */
      pinMode(RED_LED, OUTPUT);
      digitalWrite(RED_LED, LOW);   // set the LED on
    }

    void loop()
    {
      // Load the txData into the radio TX FIFO and transmit it to the broadcast
      // address.
      Radio.transmit(ADDRESS_BROADCAST, txData, 6);
      printTxData();                    // TX debug information

      // Increment tx data sequence number ('0'-'9' ASCII) for next transmission.
      if (txData[0] >= '0' && txData[0] < '9')
      {
        txData[0]++;
      }
      else
      {
        txData[0] = '0';
      }

      /**
       *  The radio transmitter and receiver cannot be operated at the same time.
       *  Wait until transmit completes before turning on the receiver. Please note
       *  that the radio is considered busy when it is transmitting.
       *
       *  WARNING: If busy is not checked between two successive radio operations
       *  receiverOn/transmit, the radio may not perform the specified task. The
       *  radio must be complete with the transmission before it can begin the next
       */
      while (Radio.busy());

      // Turn on the receiver and listen for incoming data. Timeout after 1 seconds.
      // The receiverOn() method returns the number of bytes copied to rxData.
      if (Radio.receiverOn(rxData, sizeof(rxData), 1000) > 0)
      {
        /**
         *  Data has been received and has been copied to the rxData buffer provided
         *  to the receiverOn() method. At this point, rxData is available. See
         *  printRxData() for more information.
         */
        digitalWrite(RED_LED, HIGH);
        printRxData();                  // RX debug information
      }
      digitalWrite(RED_LED, LOW);
    }

### Bugs, Suggestions, Applications

Contact Anaren AIR support at air@anaren.com, or visit the Forum.

Reference Home | Libraries Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Energia Reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Energia reference is based on Arduino reference. Code samples in the reference are released into the public domain.

©Energia | Edit Page | Page History | Printable View | All Recent Site Changes