Milestone 1
All function implemented in OOP except WebServer Function. Most missing documentation and comments
This commit is contained in:
parent
e1f0fd5651
commit
d62ffa3606
|
@ -60,6 +60,9 @@ void ClimateIoT::publishClimate() {
|
|||
}
|
||||
|
||||
void ClimateIoT::publishRoomTemperature() {
|
||||
if (this->card->getSensorType() == AC_SENSOR_TYPE_NONE ) {
|
||||
return;
|
||||
}
|
||||
char payload[5];
|
||||
itoa(this->card->getRoomTemperature(), payload, 10);
|
||||
this->publishRelative(AC_ROOM_TEMPERATURE_REPORT_TOPIC, payload);
|
||||
|
|
|
@ -100,14 +100,8 @@ void ESPMegaIoT::registerCard(uint8_t card_id)
|
|||
components[card_id]->begin(card_id, cards[card_id], &mqtt, this->mqtt_config.base_topic);
|
||||
if (mqtt_connected)
|
||||
{
|
||||
Serial.println("Subscribing to Input Topics");
|
||||
components[card_id]->subscribe();
|
||||
mqtt.loop();
|
||||
Serial.println(mqtt.connected()? "MQTT Connected" : "MQTT Not Connected");
|
||||
Serial.println("Publishing Input report");
|
||||
components[card_id]->publishReport();
|
||||
mqtt.loop();
|
||||
Serial.println(mqtt.connected()? "MQTT Connected" : "MQTT Not Connected");
|
||||
}
|
||||
break;
|
||||
case CARD_TYPE_DIGITAL_OUTPUT:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Reserve FRAM address 0 - 1000 for ESPMegaPRO Internal Use
|
||||
// (34 Bytes) Address 0-33 for Built-in Digital Output Card
|
||||
// () Address 34-300 for ESPMegaPRO IoT Module
|
||||
// (266 Bytes) Address 34-300 for ESPMegaPRO IoT Module
|
||||
|
||||
ESPMegaPRO::ESPMegaPRO() {
|
||||
|
||||
|
|
|
@ -82,29 +82,17 @@ void InternalDisplay::saveNetworkConfig()
|
|||
// dns_set -> a text input to set the dns
|
||||
// host_set -> a text input to set the hostname
|
||||
|
||||
Serial.println("Saving network config");
|
||||
this->sendStopBytes();
|
||||
|
||||
// Save the ip address
|
||||
IPAddress ip;
|
||||
// 000.000.000.000, 16 characters, 3 dots, 3 characters per octet, 1 null terminator
|
||||
char ip_buffer[30];
|
||||
Serial.println("Getting ip_set.txt");
|
||||
this->sendStopBytes();
|
||||
if(!this->getStringToBuffer("ip_set.txt", ip_buffer, 30))
|
||||
{
|
||||
Serial.println("Failed to get ip_set.txt");
|
||||
this->sendStopBytes();
|
||||
return;
|
||||
}
|
||||
Serial.println("Got ip_set.txt");
|
||||
this->sendStopBytes();
|
||||
|
||||
// Validate the ip address
|
||||
if (!ip.fromString(ip_buffer)) {
|
||||
Serial.println("Invalid ip address");
|
||||
Serial.print("The recieved IP is: ");
|
||||
Serial.println(ip_buffer);
|
||||
this->sendStopBytes();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -187,8 +175,6 @@ void InternalDisplay::saveMQTTConfig()
|
|||
|
||||
// Save the mqtt use auth
|
||||
uint8_t use_auth = this->getNumber("use_auth.val");
|
||||
Serial.print("use_auth: ");
|
||||
Serial.println(use_auth);
|
||||
this->mqttConfig->mqtt_useauth = use_auth == 1 ? true : false;
|
||||
this->iot->saveMqttConfig();
|
||||
ESP.restart();
|
||||
|
@ -372,7 +358,7 @@ void InternalDisplay::setInputMarker(uint8_t pin, bool state)
|
|||
this->displayAdapter->print("I");
|
||||
this->displayAdapter->print(pin);
|
||||
this->displayAdapter->print(".val=");
|
||||
this->displayAdapter->print(state ? 0 : 1);
|
||||
this->displayAdapter->print(state ? 1 : 0);
|
||||
this->sendStopBytes();
|
||||
}
|
||||
|
||||
|
@ -709,7 +695,6 @@ void InternalDisplay::handleACStateChange(uint8_t mode, uint8_t fan_speed, uint8
|
|||
{
|
||||
// If the climate card is binded to the display and the current page is the AC page
|
||||
// then update the respective AC component
|
||||
Serial.println("AC state changed");
|
||||
if (this->climateCard == nullptr || this->currentPage != INTERNAL_DISPLAY_AC_PAGE)
|
||||
return;
|
||||
this->sendStopBytes();
|
||||
|
|
|
@ -10,7 +10,6 @@ void IoTComponent::publishRelative(const char *topic, const char *payload) {
|
|||
ESP_LOGD("IoTComponent", "Publishing to %s : %s", absolute_topic, payload);
|
||||
mqtt->publish(absolute_topic, payload);
|
||||
mqtt->loop();
|
||||
delay(50);
|
||||
}
|
||||
|
||||
void IoTComponent::subscribeRelative(const char *topic) {
|
||||
|
|
|
@ -31,4 +31,4 @@ lib_deps = adafruit/Adafruit PWM Servo Driver Library@^2.4.1
|
|||
https://github.com/me-no-dev/ESPAsyncWebServer.git
|
||||
#esphome/ESPAsyncWebServer-esphome@^3.1.0
|
||||
monitor_speed = 115200
|
||||
build_flags = -DCORE_DEBUG_LEVEL=5
|
||||
build_flags = -DCORE_DEBUG_LEVEL=1
|
|
@ -8,7 +8,7 @@
|
|||
// #define WRITE_DEFAULT_NETCONF
|
||||
#define CLIMATE_CARD_ENABLE
|
||||
#define MQTT_CARD_REGISTER
|
||||
// #define DISPLAY_ENABLE
|
||||
#define DISPLAY_ENABLE
|
||||
|
||||
// Demo PLC firmware using the ESPMegaPRO OOP library
|
||||
|
||||
|
@ -17,8 +17,8 @@ ESPMegaPRO espmega = ESPMegaPRO();
|
|||
#ifdef CLIMATE_CARD_ENABLE
|
||||
// Climate Card
|
||||
const uint16_t irCode[15][4][4][1] = {0};
|
||||
const char *mode_names[] = {"Off", "Fan-only", "Cool"};
|
||||
const char *fan_speed_names[] = {"Auto", "Low", "Medium", "High"};
|
||||
const char *mode_names[] = {"off", "fan_only", "cool"};
|
||||
const char *fan_speed_names[] = {"auto", "low", "medium", "high"};
|
||||
|
||||
size_t getInfraredCode(uint8_t mode, uint8_t fan_speed, uint8_t temperature, const uint16_t **codePtr)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue