// Path: se.bitcraze.crazyflie.lib/src/main/java/se/bitcraze/crazyflie/lib/usb/CrazyUsbInterface.java
// public interface CrazyUsbInterface {
// 
//     /**
//      * Init device
//      *
//      * @param usbVid
//      * @param usbPid
//      */
//     public void initDevice(int usbVid, int usbPid) throws IOException, SecurityException;
// 
//     /**
//      * Release UsbInterface
//      *
//      */
//     public void releaseInterface();
// 
//     /**
//      * Returns the state of the USB connection
//      *
//      * @return true if USB device is connected, else false
//      */
//     public boolean isUsbConnected();
// 
//     /**
//      * Send control data
//      *
//      * @param requestType
//      * @param request
//      * @param value
//      * @param index
//      * @param data
//      * @return
//      */
//     public int sendControlTransfer(int requestType, int request, int value, int index, byte[] data);
// 
//     /**
//      * Sends bulk data
//      *
//      * @param data
//      * @param receiveData
//      * @return
//      */
//     public int sendBulkTransfer(byte[] data, byte[] receiveData);
// 
//     /**
//      * Returns a list of CrazyRadio devices currently connected to the computer
//      *
//      * @param usbVid
//      * @param usbPid
//      * @return
//      */
//     public List<UsbDevice> findDevices(int usbVid, int usbPid);
// 
//     /**
//      * Returns the firmware version of the USB device
//      *
//      * @return firmware version
//      */
//     public float getFirmwareVersion();
// 
//     /**
//      * Returns the serial number of the USB device
//      *
//      * @return serial number
//      */
//     public String getSerialNumber();
// 
//     public void bulkWrite(byte[] data);
// 
//     public byte[] bulkRead();
// 
// }


import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.bitcraze.crazyflie.lib.usb.CrazyUsbInterface;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
/**
 *    ||          ____  _ __
 * +------+      / __ )(_) /_______________ _____  ___
 * | 0xBC |     / __  / / __/ ___/ ___/ __ `/_  / / _ \
 * +------+    / /_/ / / /_/ /__/ /  / /_/ / / /_/  __/
 *  ||  ||    /_____/_/\__/\___/_/   \__,_/ /___/\___/
 *
 * Copyright (C) 2013 Bitcraze AB
 *
 * Crazyflie Nano Quadcopter Client
 *
 * 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

package se.bitcraze.crazyflie.lib.crazyradio;




/**
 * Used for communication with the Crazyradio USB dongle
 *
 */
public class Crazyradio {

    protected final Logger mLogger = LoggerFactory.getLogger(this.getClass().getSimpleName());

    // USB parameters
    public static final int CRADIO_VID = 0x1915; //Vendor ID
    public static final int CRADIO_PID = 0x7777; //Product ID

    // Dongle configuration requests
    // See http://wiki.bitcraze.se/projects:crazyradio:protocol for documentation
    private static final int SET_RADIO_CHANNEL = 0x01;
    private static final int SET_RADIO_ADDRESS = 0x02;
    private static final int SET_DATA_RATE = 0x03;
    private static final int SET_RADIO_POWER = 0x04;
    private static final int SET_RADIO_ARD = 0x05;
    private static final int SET_RADIO_ARC = 0x06;
    //private static final int ACK_ENABLE = 0x10;
    private static final int SET_CONT_CARRIER = 0x20;
    private static final int SCAN_CHANNELS = 0x21;
    //private static final int LAUNCH_BOOTLOADER = 0xFF;

    // configuration constants
    public static final int DR_250KPS = 0;
    public static final int DR_1MPS = 1;
    public static final int DR_2MPS = 2;

    public static final int P_M18DBM = 0;
    public static final int P_M12DBM = 1;
    public static final int P_M6DBM = 2;
    public static final int P_0DBM = 3;

// Path: se.bitcraze.crazyflie.lib/src/main/java/se/bitcraze/crazyflie/lib/usb/CrazyUsbInterface.java
// public interface CrazyUsbInterface {
// 
//     /**
//      * Init device
//      *
//      * @param usbVid
//      * @param usbPid
//      */
//     public void initDevice(int usbVid, int usbPid) throws IOException, SecurityException;
// 
//     /**
//      * Release UsbInterface
//      *
//      */
//     public void releaseInterface();
// 
//     /**
//      * Returns the state of the USB connection
//      *
//      * @return true if USB device is connected, else false
//      */
//     public boolean isUsbConnected();
// 
//     /**
//      * Send control data
//      *
//      * @param requestType
//      * @param request
//      * @param value
//      * @param index
//      * @param data
//      * @return
//      */
//     public int sendControlTransfer(int requestType, int request, int value, int index, byte[] data);
// 
//     /**
//      * Sends bulk data
//      *
//      * @param data
//      * @param receiveData
//      * @return
//      */
//     public int sendBulkTransfer(byte[] data, byte[] receiveData);
// 
//     /**
//      * Returns a list of CrazyRadio devices currently connected to the computer
//      *
//      * @param usbVid
//      * @param usbPid
//      * @return
//      */
//     public List<UsbDevice> findDevices(int usbVid, int usbPid);
// 
//     /**
//      * Returns the firmware version of the USB device
//      *
//      * @return firmware version
//      */
//     public float getFirmwareVersion();
// 
//     /**
//      * Returns the serial number of the USB device
//      *
//      * @return serial number
//      */
//     public String getSerialNumber();
// 
//     public void bulkWrite(byte[] data);
// 
//     public byte[] bulkRead();
// 
// }


// Path: se.bitcraze.crazyflie.lib/src/main/java/se/bitcraze/crazyflie/lib/crazyradio/Crazyradio.java
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import se.bitcraze.crazyflie.lib.usb.CrazyUsbInterface;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

/**
 *    ||          ____  _ __
 * +------+      / __ )(_) /_______________ _____  ___
 * | 0xBC |     / __  / / __/ ___/ ___/ __ `/_  / / _ \
 * +------+    / /_/ / / /_/ /__/ /  / /_/ / / /_/  __/
 *  ||  ||    /_____/_/\__/\___/_/   \__,_/ /___/\___/
 *
 * Copyright (C) 2013 Bitcraze AB
 *
 * Crazyflie Nano Quadcopter Client
 *
 * 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

package se.bitcraze.crazyflie.lib.crazyradio;




/**
 * Used for communication with the Crazyradio USB dongle
 *
 */
public class Crazyradio {

    protected final Logger mLogger = LoggerFactory.getLogger(this.getClass().getSimpleName());

    // USB parameters
    public static final int CRADIO_VID = 0x1915; //Vendor ID
    public static final int CRADIO_PID = 0x7777; //Product ID

    // Dongle configuration requests
    // See http://wiki.bitcraze.se/projects:crazyradio:protocol for documentation
    private static final int SET_RADIO_CHANNEL = 0x01;
    private static final int SET_RADIO_ADDRESS = 0x02;
    private static final int SET_DATA_RATE = 0x03;
    private static final int SET_RADIO_POWER = 0x04;
    private static final int SET_RADIO_ARD = 0x05;
    private static final int SET_RADIO_ARC = 0x06;
    //private static final int ACK_ENABLE = 0x10;
    private static final int SET_CONT_CARRIER = 0x20;
    private static final int SCAN_CHANNELS = 0x21;
    //private static final int LAUNCH_BOOTLOADER = 0xFF;

    // configuration constants
    public static final int DR_250KPS = 0;
    public static final int DR_1MPS = 1;
    public static final int DR_2MPS = 2;

    public static final int P_M18DBM = 0;
    public static final int P_M12DBM = 1;
    public static final int P_M6DBM = 2;
    public static final int P_0DBM = 3;

    private CrazyUsbInterface mUsbInterface;