Page 200 - MDP2022-2
P. 200

}
                                    }  catch  (MqttException  e)  {
                                            e.printStackTrace();
                                    }
                            });


                            curtain.setOnCheckedChangeListener((compoundButton,  b)  ->  {
                                    try  {
                                            if  (b)  {
                                                    Log.d("iot/curtain",  "on");
                                                    mqtt.publish("iot/curtain",  "on".getBytes(),  0,  false);
                                            }  else  {
                                                    Log.d("iot/curtain",  "off");
                                                    mqtt.publish("iot/curtain",  "off".getBytes(),  0,  false);
                                            }
                                    }  catch  (MqttException  e)  {
                                            e.printStackTrace();
                                    }
                            });


                            heatingPad.setOnCheckedChangeListener((compoundButton,  b)  ->  {
                                    try  {
                                            if  (b)  {
                                                    Log.d("iot/heating_pad",  "on");
                                                    mqtt.publish("iot/heating_pad",  "on".getBytes(),  0,  false);
                                            }  else  {
                                                    Log.d("iot/heating_pad",  "off");
                                                    mqtt.publish("iot/heating_pad",  "off".getBytes(),  0,  false);
                                            }
                                    }  catch  (MqttException  e)  {
                                            e.printStackTrace();
                                    }
                            });


                            door.setOnCheckedChangeListener((compoundButton,  b)  ->  {
                                    try  {
                                            if  (b)  {
                                                    Log.d("iot/door",  "on");
                                                    mqtt.publish("iot/door",  "on".getBytes(),  0,  false);
                                            }  else  {
                                                    Log.d("iot/door",  "off");
                                                    mqtt.publish("iot/door",  "off".getBytes(),  0,  false);
                                            }
                                    }  catch  (MqttException  e)  {
                                            e.printStackTrace();
   195   196   197   198   199   200   201   202   203   204   205