public void open(final InputStream is, final OutputStream os)
            throws BITalinoException {
        try {
            socket = new BITalinoSocket(new DataInputStream(is), os);
            Thread.sleep(SLEEP);
        } catch (Exception e) {
            e.printStackTrace(System.err);
            close();
        }

        // set samplerate on the bluetooth device
        try {
            int command = 0;
            switch (samplerate) {
                case 1000:
                    command = 0x3;
                    break;
                case 100:
                    command = 0x2;
                    break;
                case 10:
                    command = 0x1;
                    break;
                case 1:
                    command = 0x0;
                    break;
            }
            command = (command << 6) | 0x03;
            socket.write(command);
        } catch (Exception e) {
            e.printStackTrace(System.err);
            throw new BITalinoException(BITalinoErrorTypes.LOST_COMMUNICATION);
        }
    }