removed decode lib which is unused in iris-kit

This commit is contained in:
strawmanbobi
2025-12-09 16:40:14 +08:00
parent 162ab23f27
commit 0d45f6173c
29 changed files with 3 additions and 6269 deletions

View File

@@ -31,8 +31,8 @@ typedef short int16_t;
typedef unsigned char uint8_t;
/* ----------------- version defs ----------------- */
#define FIRMWARE_VERSION "1.3.0"
#define VERSION_CODE (2)
#define FIRMWARE_VERSION "1.5.1"
#define VERSION_CODE (1)
/* ----------------- log settings ----------------- */
#define BAUD_RATE (115200)

View File

@@ -1,104 +0,0 @@
/**
*
* Copyright (c) 2020-2025 IRext Opensource Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "global.h"
#include "serials.h"
#include "high_availability.h"
void returnACStatus(String filename, t_remote_ac_status ac_status) {
send_msg_doc.clear();
String chip_id = String(ESP.getChipId(), HEX);
chip_id.toUpperCase();
String topic_head = "/IRbaby/" + chip_id + "/state/" + filename + "/";
const char* mode[] = {"cool", "heat", "auto", "fan_only", "dry"};
const char* fan[] = {"auto", "low", "medium", "high", "max"};
const char* swing[] = {"on", "off"};
if (ac_status.ac_power == AC_POWER_OFF) {
// mqttPublish(topic_head + "mode", "off");
} else {
// mqttPublish(topic_head + "mode", mode[(int)ac_status.ac_mode]);
// mqttPublish(topic_head + "temperature", String((int)ac_status.ac_temp + 16));
// mqttPublish(topic_head + "fan", fan[(int)ac_status.ac_wind_speed]);
// mqttPublish(topic_head + "swing", swing[(int)ac_status.ac_swing]);
}
}
// save current AC status
void registAC(String filename, bool flag) {
send_msg_doc.clear();
String chip_id = String(ESP.getChipId(), HEX);
chip_id.toUpperCase();
String reg_topic_head = "homeassistant/climate/IRbaby-" + chip_id + "_climate_" + filename +
"/config";
String reg_content;
if (flag) {
send_msg_doc["platform"] = "mqtt";
send_msg_doc["name"] = filename;
JsonArray modes = send_msg_doc.createNestedArray("modes");
modes.add("auto");
modes.add("heat");
modes.add("cool");
modes.add("fan_only");
modes.add("dry");
modes.add("off");
JsonArray swing_modes = send_msg_doc.createNestedArray("swing_modes");
swing_modes.add("on");
swing_modes.add("off");
send_msg_doc["max_temp"] = 30;
send_msg_doc["min_temp"] = 16;
JsonArray fan_modes = send_msg_doc.createNestedArray("fan_modes");
fan_modes.add("auto");
fan_modes.add("low");
fan_modes.add("medium");
fan_modes.add("high");
String cmd_head_topic = "/IRbaby/" + chip_id + "/send/ir/local/" + filename + "/";
String state_head_topic = "/IRbaby/" + chip_id + "/state/" + filename + "/";
send_msg_doc["mode_command_topic"] = cmd_head_topic + "mode";
send_msg_doc["mode_state_topic"] = state_head_topic + "mode";
send_msg_doc["temperature_command_topic"] = cmd_head_topic + "temperature";
send_msg_doc["temperature_state_topic"] = state_head_topic + "temperature";
send_msg_doc["fan_mode_command_topic"] = cmd_head_topic + "fan";
send_msg_doc["fan_mode_state_topic"] = state_head_topic + "fan";
send_msg_doc["swing_mode_command_topic"] = cmd_head_topic + "swing";
send_msg_doc["swing_mode_state_topic"] = state_head_topic + "swing";
send_msg_doc["precision"] = 0.1;
send_msg_doc["unique_id"] = "IRbaby-" + chip_id + "_climate_" + filename;
JsonObject device = send_msg_doc.createNestedObject("device");
JsonArray device_identifiers = device.createNestedArray("identifiers");
device_identifiers.add("IRbaby-" + chip_id);
device["name"] = "IRbaby-" + chip_id;
device["manufacturer"] = "espressif";
device["model"] = "ESP8266";
device["sw_version"] = "IRbaby " + String(FIRMWARE_VERSION);
}
if (flag) {
serializeJson(send_msg_doc, reg_content);
}
INFOLN(reg_topic_head);
// mqttPublishRetained(reg_topic_head, reg_content);
}

View File

@@ -1,35 +0,0 @@
/**
*
* Copyright (c) 2020-2025 IRext Opensource Organization
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef IRIS_KIT_HA_H
#define IRIS_KIT_HA_H
#include <WString.h>
#include "ir_ac_control.h"
void returnACStatus(String filename, t_remote_ac_status ac_status);
void registAC(String filename, bool flag);
#endif // IRIS_KIT_HA_H

View File

@@ -23,8 +23,6 @@
#include <LittleFS.h>
#include "defines.h"
#include "global.h"
#include "serials.h"
#include "user_settings.h"
@@ -38,7 +36,7 @@
#define IR_END_CODE (10000)
// external variable declaratoins
// external variable declarations
extern iris_kit_status_t g_iris_kit_status;
@@ -99,78 +97,6 @@ bool emitIR(String timing) {
return true;
}
bool sendCommand(String file_name, int key) {
String save_path = SAVE_PATH;
save_path += file_name;
if (LittleFS.exists(save_path)) {
File cache = LittleFS.open(save_path, "r");
if (cache) {
UINT16 content_size = cache.size();
INFOF("Send command, content size = %d\n", content_size);
if (content_size != 0) {
UINT8 *content = (UINT8 *)malloc(content_size * sizeof(UINT8));
cache.seek(0L, fs::SeekSet);
cache.readBytes((char *)content, content_size);
ir_binary_open(2, 1, content, content_size);
UINT16 *user_data = (UINT16 *)malloc(IR_SERIES_MAX * sizeof(UINT16));
UINT16 data_length = ir_decode(0, user_data, NULL, FALSE);
INFOF("Send command, data_length = %d\n", data_length);
if (LOG_DEBUG) {
for (int i = 0; i < data_length; i++)
Serial.printf("%d ", *(user_data + i));
Serial.println();
}
ir_recv->disableIRIn();
ir_send->sendRaw(user_data, data_length, 38);
ir_close();
free(user_data);
free(content);
} else
ERRORF("Open %s is empty\n", save_path.c_str());
}
cache.close();
}
return true;
}
void sendStatus(String file, t_remote_ac_status status) {
String save_path = SAVE_PATH + file;
String url = String(DOWNLOAD_PREFIX) + file + String(DOWNLOAD_SUFFIX);
if (!LittleFS.exists(save_path)) {
downLoadFile(url, file, SAVE_PATH);
}
if (LittleFS.exists(save_path)) {
File cache = LittleFS.open(save_path, "r");
if (cache) {
UINT16 content_size = cache.size();
INFOF("Send status, content size = %d\n", content_size);
if (content_size != 0) {
UINT8 *content = (UINT8 *)malloc(content_size * sizeof(UINT8));
cache.seek(0L, fs::SeekSet);
cache.readBytes((char *)content, content_size);
ir_binary_open(REMOTE_CATEGORY_AC, 1, content, content_size);
UINT16 *user_data = (UINT16 *)malloc(IR_SERIES_MAX * sizeof(UINT16));
UINT16 data_length = ir_decode(0, user_data, &status, FALSE);
INFOF("Send status, data_length = %d\n", data_length);
ir_recv->disableIRIn();
ir_send->sendRaw(user_data, data_length, 38);
ir_close();
free(user_data);
free(content);
saveACStatus(file, status);
} else
ERRORF("Open %s is empty\n", save_path.c_str());
}
cache.close();
}
}
void prepareStudyIR() {
#if defined STORE_RECEIVED_IR_DATA
removeReceived();

View File

@@ -28,8 +28,6 @@
#include <IRsend.h>
#include <IRrecv.h>
#include "ir_decode.h"
void loadIRPin(uint8_t send_pin, uint8_t recv_pin);
void enableIRIn();
@@ -42,10 +40,6 @@ bool sendIR(String file_name);
bool emitIR(String timing);
bool sendCommand(String file_name, int key);
void sendStatus(String file_name, t_remote_ac_status status);
void prepareStudyIR();
void cancelStudyIR();

View File

@@ -143,31 +143,6 @@ bool loadSettings() {
return ret;
}
bool saveACStatus(String file, t_remote_ac_status status) {
bool ret = true;
ACStatus[file]["power"] = (int)status.ac_power;
ACStatus[file]["temperature"] = (int)status.ac_temp;
ACStatus[file]["mode"] = (int)status.ac_mode;
ACStatus[file]["swing"] = (int)status.ac_swing;
ACStatus[file]["speed"] = (int)status.ac_wind_speed;
return ret;
}
t_remote_ac_status getACStatus(String file) {
t_remote_ac_status status;
int power = (int) ACStatus[file]["power"];
int temperature = (int) ACStatus[file]["temperature"];
int mode = (int) ACStatus[file]["mode"];
int swing = (int) ACStatus[file]["swing"];
int wind_speed = (int) ACStatus[file]["speed"];
status.ac_power = (t_ac_power)power;
status.ac_temp = (t_ac_temperature)temperature;
status.ac_mode = (t_ac_mode)mode;
status.ac_swing = (t_ac_swing)swing;
status.ac_wind_speed = (t_ac_wind_speed)wind_speed;
return status;
}
bool setIrisKitSettings(iris_kit_settings_t& iriskit_settings) {
IrisKitSettings["server_address"] = iriskit_settings.server_address;
IrisKitSettings["token"] = iriskit_settings.credential_token;

View File

@@ -28,17 +28,12 @@
#include "iris_kit.h"
#include "ir_ac_control.h"
/* save settings */
bool saveSettings();
/* load settings */
bool loadSettings();
bool saveACStatus(String file, t_remote_ac_status status);
t_remote_ac_status getACStatus(String file);
bool setIrisKitSettings(iris_kit_settings_t& iriskit_settings);
iris_kit_settings_t getIrisKitSettings();