001/**
002 * Copyright (c) 2014 Digi International Inc.,
003 * All rights not expressly granted are reserved.
004 *
005 * This Source Code Form is subject to the terms of the Mozilla Public
006 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
007 * You can obtain one at http://mozilla.org/MPL/2.0/.
008 *
009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
010 * =======================================================================
011 */
012package com.digi.xbee.api;
013
014import com.digi.xbee.api.connection.IConnectionInterface;
015import com.digi.xbee.api.connection.serial.SerialPortParameters;
016import com.digi.xbee.api.connection.serial.SerialPortRxTx;
017
018/**
019 * Helper class used to create a serial port connection interface.
020 */
021public class XBee {
022        
023        /**
024         * Retrieves a serial port connection interface for the provided port with 
025         * the given baud rate.
026         * 
027         * @param port Serial port name.
028         * @param baudRate Serial port baud rate.
029         * 
030         * @return The serial port connection interface.
031         * 
032         * @throws NullPointerException if {@code port == null}.
033         * 
034         * @see #createConnectiontionInterface(String, SerialPortParameters)
035         * @see com.digi.xbee.api.connection.IConnectionInterface
036         */
037        public static IConnectionInterface createConnectiontionInterface(String port, int baudRate) {
038                IConnectionInterface connectionInterface = new SerialPortRxTx(port, baudRate);
039                return connectionInterface;
040        }
041        
042        /**
043         * Retrieves a serial port connection interface for the provided port with 
044         * the given serial port parameters.
045         * 
046         * @param port Serial port name.
047         * @param serialPortParameters Serial port parameters.
048         * 
049         * @return The serial port connection interface.
050         * 
051         * @throws NullPointerException if {@code port == null} or
052         *                              if {@code serialPortParameters == null}.
053         * 
054         * @see #createConnectiontionInterface(String, int)
055         * @see com.digi.xbee.api.connection.IConnectionInterface
056         * @see com.digi.xbee.api.connection.serial.SerialPortParameters
057         */
058        public static IConnectionInterface createConnectiontionInterface(String port, SerialPortParameters serialPortParameters) {
059                IConnectionInterface connectionInterface = new SerialPortRxTx(port, serialPortParameters);
060                return connectionInterface;
061        }
062}