absalom-muc / MHI-AC-Ctrl

Reads and writes data (e.g. power, mode, fan status etc.) from/to a Mitsubishi Heavy Industries (MHI) air conditioner (AC) via SPI controlled by MQTT
MIT License
269 stars 61 forks source link

Static ipaddress #54

Closed vergoossen closed 3 years ago

vergoossen commented 3 years ago

Hi,

Can you make it possible to set a static ipaddress for the device? I tried some things myself, but they fail. Im not familiar with arduinoide...

absalom-muc commented 3 years ago

You could insert between row 10 and 11 of support.cpp something similar as:

  IPAddress ip(192, 168, 178, 125);
  IPAddress gateway(192, 168, 178, 1);
  IPAddress subnet(255, 255, 255, 0);
  IPAddress dns(192, 168, 178, 1);
  WiFi.config(ip, dns, gateway, subnet); 

Please find some docu related to WiFi.config() here

edit: the order in WiFi.config is wrong here, see this comment

vergoossen commented 3 years ago

Thankyou. And is it possible to put ip/gateway/dns in support.h? When i try myself i get 'IPAddress' does not name a type

absalom-muc commented 3 years ago

I believe it is not possible to assign a value to a variable from type IPAddress in support.h. If you are interested in details have a look into IPAddress.cpp#L38.

btw: There was a typo in my example above. The right order for WiFi.config is bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000); according to the ESP8266WiFiSTA.h.