package device;

import tlv.TlvItem;

import java.util.ArrayList;

public class Pinpad {

    private class ConfigIni {
        int port = 8888;
        String address = "0.0.0.0";

        void setPort(int netPort){port = netPort;}
        void setAddress(String netAddress){address = netAddress;}

        int getPort(){return port; }
        String getAddress(){return address; }
    }

    private ConfigIni readConfigIni(){
        ConfigIni config = new ConfigIni();
        //TODO: This is an imitation. Implement reading program configuration.
        config.setPort(8888);
        config.setAddress("10.82.13.132");

        return config;
    }

    private ArrayList<tlv.TlvItem> readConfigTlv(){
        ArrayList<tlv.TlvItem> config = new ArrayList<>();
        //TODO: This is an imitation. Implement reading tlv-configuration.
        try {
            config.add(new TlvItem(tlv.Tag.findTag("TAG_TTK_CLIENT_ECR"), "P01386858454".getBytes()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return config;
    }

    public ConfigIni configIni;
    public ArrayList<tlv.TlvItem> configTlv;
    public ttk.Session ttkSession;

    public Pinpad(){
        configIni = readConfigIni();
        configTlv = readConfigTlv();
        ttkSession = new ttk.Session(configIni.getAddress(), configIni.getPort());
    }
}

