//package com.yzt.airconditionersystem.bean.mqtt;
//
//import org.eclipse.paho.client.mqttv3.MqttClient;
//import org.eclipse.paho.client.mqttv3.MqttException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author TzZach
// * @since 2022-05-10 21:19
// */
//@Component
//@ConditionalOnProperty(value = "spring.mqtt.enable", havingValue = "true")
//public class MqttProducer{
//
//    @Value("${spring.mqtt.producerTopic}")
//    private String producerTopic;
//
//    @Value("${spring.mqtt.defaultQos}")
//    private int defaultProducerQos;
//
//    @Value("${spring.mqtt.defaultRetained}")
//    private boolean defaultRetained;
//
//    @Autowired
//    private MqttClient mqttClient;
//
//    public void send(String payload) {
//        this.send(producerTopic, payload);
//    }
//
//    public void send(String topic, String payload) {
//        this.send(topic, defaultProducerQos, payload);
//    }
//
//    public void send(String topic, int qos, String payload) {
//        this.send(topic, qos, defaultRetained, payload);
//    }
//
//    public void send(String topic, int qos, boolean retained, String payload) {
//        try {
//            mqttClient.publish(topic, payload.getBytes(), qos, retained);
//        } catch (MqttException e) {
//            System.out.println(e.getMessage());
//        }
//    }
//
//}
