package hf.lskj.com.carstockcount.utils.UHF;

import android.content.Context;
import android.util.Log;

import uhf.api.CommandType;
import uhf.api.Power;

/**
 * Created by yaoju on 2017/8/2.
 */

public class UHFUtils {
    private Context mContext;
    private int count = 0;

    public UHFUtils(Context context) {
        mContext = context;
        count = 0;
    }

    public void handleSetPower(int int_power_read_temp) {
        Power mPower = new Power();
        mPower.com_type = CommandType.SET_POWER;
        mPower.loop = 0;
        mPower.read = int_power_read_temp;
        mPower.write = int_power_read_temp;

        UHFClient info = UHFClient.getInstance();
        if (info != null) {
            Boolean ret = UHFClient.mUHF.command(CommandType.SET_POWER, mPower);
            if (ret) {
                Log.i("rfid", "Set Power " + int_power_read_temp + " Ok");
            } else {

                if (count < 3) {
                    count++;
                    handleSetPower(int_power_read_temp);
                } else {
                    Log.w("rfid", "Set Power " + int_power_read_temp +" Fail");
                }
            }
        }


    }
}
