I have a project and encountered a problem. I want to use both WiFiClientSecure and WiFiClient. My program defines a variable "mqtt_secure", which is true when using WiFiClientSecure and false when using WiFiClient. However, I cannot handle this in the global variable declaration. The following is my code. Can you please help me? Because of the following code:
instances need to be initialized once globally or as a part of another global object.
HADevice device;
HAMqtt mqtt(eClient, device);
HASensorNumber alaSensor("aLaInput", HASensorNumber::PrecisionP1);
It cannot be set in the setup() function, it is declared globally. How can I modify it to switch the eClient part of HAMqtt mqtt(eClient, device) based on my variable "mqtt_secure" in the future?
I have a project and encountered a problem. I want to use both WiFiClientSecure and WiFiClient. My program defines a variable "mqtt_secure", which is true when using WiFiClientSecure and false when using WiFiClient. However, I cannot handle this in the global variable declaration. The following is my code. Can you please help me? Because of the following code:
instances need to be initialized once globally or as a part of another global object.
HADevice device; HAMqtt mqtt(eClient, device); HASensorNumber alaSensor("aLaInput", HASensorNumber::PrecisionP1); It cannot be set in the setup() function, it is declared globally. How can I modify it to switch the eClient part of HAMqtt mqtt(eClient, device) based on my variable "mqtt_secure" in the future?