package com.jpsoft.shinestar.config;

import com.jpsoft.ehome.config.EHomeParamConfig;
import com.jpsoft.ehome.device.EHomeSDK;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
public class EHomeSDKConfig {
    @Bean
    public EHomeSDK eHomeSDK(){
        return new EHomeSDK();
    }

    @Value("${e-home-sdk.libPath}")
    private String libPath;

    @Value("${e-home-sdk.logPath}")
    private String logPath;

    @Value("${e-home-sdk.picPath}")
    private String picPath;

    @Value("${e-home-sdk.localIP}")
    private String localIP;

    @Value("${e-home-sdk.remoteIP}")
    private String remoteIP;

    @Value("${e-home-sdk.cmsUdpPort}")
    private short cmsUdpPort;

    @Value("${e-home-sdk.alarmUdpPort}")
    private short alarmUdpPort;

    @Value("${e-home-sdk.pictureServerTcpPort}")
    private short pictureServerTcpPort;

    @Value("${e-home-sdk.urlPrefix}")
    private String urlPrefix;

    @Bean
    public EHomeParamConfig eHomeParamConfig(){
        EHomeParamConfig config = new EHomeParamConfig();

        config.setLibPath(this.libPath);
        config.setLogPath(this.logPath);
        config.setPicPath(this.picPath);
        config.setLocalIP(this.localIP);
        config.setRemoteIP(this.remoteIP);
        config.setCmsUdpPort(this.cmsUdpPort);
        config.setAlarmUdpPort(this.alarmUdpPort);
        config.setPictureServerTcpPort(this.pictureServerTcpPort);
        config.setUrlPrefix(this.urlPrefix);

        return config;
    }
}
