package org.josast.app.amicalsat.cli.option;

import org.josast.ModuleSoundModem.SoundModemClient;
import org.josast.amicalsat.Frame;
import org.josast.amicalsat.FrameFactory;
import org.josast.amicalsat.FrameTlmAmicalsat;

import io.kaitai.struct.ByteBufferKaitaiStream;

public class receiveDataCmd implements Cmd {

	@Override
	public void excute() {
		
		
		FrameFactory ff = new FrameFactory();

		SoundModemClient sm = new SoundModemClient("configFile");

		while (true) {

			byte[] temp = sm.receivedRawData();

			FrameTlmAmicalsat cube = new FrameTlmAmicalsat(new ByteBufferKaitaiStream(temp));

			System.out.print(
					"Source : " + cube.frameTlmEntrySat().ax25Header().srcCallsignRaw().srcCallsignRor().srcCallsign());
			System.out.print("destination : "
					+ cube.frameTlmEntrySat().ax25Header().destCallsignRaw().destCallsignRor().destCallsign());
			System.out.print("PID : " + cube.frameTlmEntrySat().payload().pid());
			System.out.println(" SSID : " + cube.frameTlmEntrySat().ax25Header().srcSsidRaw());
			String tlmArea = cube.frameTlmEntrySat().payload().tlmArea();
			String typeFrame = cube.frameTlmEntrySat().payload().tlmType();
			System.out.println(tlmArea + " " + typeFrame);
			Frame fm = ff.creerFrame(tlmArea, typeFrame);
			fm.setUp(cube);

			System.out.println(fm.toString());

	}

}
}

