/*
 * vim: set ts=8:
 *
 * Copyright (C) 2007 Speecys Corporation
 *		Toshiaki Nozawa <nozawa@speecys.com>
 * All rights reserved.
 *
 */


package	com.speecys.remoConRT;

import java.nio.*;

class SubCmdPacket extends Packet {
    static final short MOTION		= 0x110;
    static final short MOTION_FILE	= 0x121;
    static final short POSE_FILE	= 0x122;

    private ByteBuffer sbuf = ByteBuffer.allocate(MAX_DATA_LEN);

    /**
     *
     */
    SubCmdPacket(short scmd, int id, String fname)
    throws java.io.IOException
    {
	sbuf.putShort(scmd);
	sbuf.putInt(id);
	sbuf.putShort((short)fname.length());
	sbuf.put(RemoteCtrl.Encoder.encode(CharBuffer.wrap(fname)));

	sbuf.flip();
	setData(Packet.SUBCMD, new byte[] {Packet.FLG1_RET, 0}, sbuf); 
	sbuf = null;	//release sbuf to be stored super-class buffer
    }

    static SubCmdPacket getMotionPacket(int id)
    {
	try {
	    return new SubCmdPacket(MOTION, id, "");
	} catch (java.io.IOException e){
	    e.printStackTrace();
	    return null;
	}
    }
}
