001/* 002 * Copyright 2017-2019, Digi International Inc. 003 * 004 * This Source Code Form is subject to the terms of the Mozilla Public 005 * License, v. 2.0. If a copy of the MPL was not distributed with this 006 * file, you can obtain one at http://mozilla.org/MPL/2.0/. 007 * 008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 015 */ 016package com.digi.xbee.api; 017 018import com.digi.xbee.api.connection.IConnectionInterface; 019import com.digi.xbee.api.connection.serial.SerialPortParameters; 020import com.digi.xbee.api.connection.serial.SerialPortRxTx; 021 022/** 023 * Helper class used to create a serial port connection interface. 024 */ 025public class XBee { 026 027 /** 028 * Returns a serial port connection interface for the provided port with 029 * the given baud rate. 030 * 031 * @param port Serial port name. 032 * @param baudRate Serial port baud rate. 033 * 034 * @return The serial port connection interface. 035 * 036 * @throws IllegalArgumentException if {@code baudRate < 0}. 037 * @throws NullPointerException if {@code port == null}. 038 * 039 * @see #createConnectiontionInterface(String, SerialPortParameters) 040 * @see com.digi.xbee.api.connection.IConnectionInterface 041 */ 042 public static IConnectionInterface createConnectiontionInterface(String port, int baudRate) { 043 return new SerialPortRxTx(port, baudRate); 044 } 045 046 /** 047 * Returns a serial port connection interface for the provided port with 048 * the given serial port parameters. 049 * 050 * @param port Serial port name. 051 * @param serialPortParameters Serial port parameters. 052 * 053 * @return The serial port connection interface. 054 * 055 * @throws NullPointerException if {@code port == null} or 056 * if {@code serialPortParameters == null}. 057 * 058 * @see #createConnectiontionInterface(String, int) 059 * @see com.digi.xbee.api.connection.IConnectionInterface 060 * @see com.digi.xbee.api.connection.serial.SerialPortParameters 061 */ 062 public static IConnectionInterface createConnectiontionInterface(String port, SerialPortParameters serialPortParameters) { 063 return new SerialPortRxTx(port, serialPortParameters); 064 } 065}