progress on iris-kit

This commit is contained in:
strawmanbobi
2023-01-17 09:59:00 +08:00
parent 7a13b08bb8
commit 6f0e949830
5 changed files with 19 additions and 10 deletions

View File

@@ -14,6 +14,7 @@
"optional": "cpp",
"memory_resource": "cpp",
"system_error": "cpp",
"*.tcc": "cpp"
"*.tcc": "cpp",
"functional": "cpp"
}
}

View File

@@ -194,7 +194,6 @@ void setup() {
void loop() {
recvIR();
// downloadBin();
yield();
aliotKeepAlive();
}

View File

@@ -37,9 +37,6 @@
#define IR_SERIES_MAX (1024)
#define IR_END_CODE (10000)
bool saveSignal();
decode_results results; // Somewhere to store the results
const uint8_t k_timeout = 50;
// As this program is a special purpose capture/decoder, let us use a larger
// than normal buffer so we can handle Air Conditioner remote codes.
@@ -167,11 +164,12 @@ void sendStatus(String file, t_remote_ac_status status) {
}
void recvIR() {
decode_results results;
if (ir_recv->decode(&results)) {
DEBUGF("raw length = %d\n", results.rawlen - 1);
String raw_data;
for (int i = 1; i < results.rawlen; i++) {
raw_data += String(*(results.rawbuf + i) * kRawTick) + " ";
raw_data += String(*(results.rawbuf + i) * kRawTick) + ",";
}
ir_recv->resume();
send_msg_doc.clear();
@@ -180,8 +178,7 @@ void recvIR() {
send_msg_doc["params"]["length"] = results.rawlen;
send_msg_doc["params"]["value"] = raw_data.c_str();
DEBUGLN(raw_data.c_str());
// sendUDP(&send_msg_doc, remote_ip);
saveSignal();
saveIR(results);
}
}
@@ -191,7 +188,7 @@ bool saveIR(String file_name) {
return LittleFS.rename("/bin/test", save_path);
}
bool saveSignal() {
bool saveIR(decode_results& results) {
String save_path = SAVE_PATH;
save_path += "test";
DEBUGF("save raw data as %s\n", save_path.c_str());
@@ -226,7 +223,7 @@ void loadIRPin(uint8_t send_pin, uint8_t recv_pin) {
DEBUGF("Load IR send pin at %d\n", send_pin);
ir_send->begin();
ir_recv = new IRrecv(recv_pin, k_capture_buffer_size, k_timeout, true);
disableIR();
enableIR();
}
void disableIR() {

View File

@@ -41,6 +41,8 @@ bool sendIR(String file_name);
bool emitIR(String timing);
bool saveIR(decode_results &results);
bool sendCommand(String file_name, int key);
void sendStatus(String file_name, t_remote_ac_status status);

View File

@@ -60,6 +60,7 @@ static String buildConnect();
static String buildHeartBeat();
static int handleHartBeat(String product_key, String device_name, String content);
static int handleEmit(String product_key, String device_name, String content);
static int handleNotifyStatus(String product_key, String device_name, String content);
// private variable definitions
event_handler_t event_handler_table[] = {
@@ -70,6 +71,10 @@ event_handler_t event_handler_table[] = {
{
"__emitCode",
handleEmit,
},
{
"__notifyStatus",
handleNotifyStatus,
}
};
@@ -278,4 +283,9 @@ static int handleEmit(String product_key, String device_name, String content) {
INFOF("deserialize failed\n");
}
return 0;
}
static int handleNotifyStatus(String product_key, String device_name, String content) {
INFOF("received emit code : %s, %s, %s\n", product_key.c_str(), device_name.c_str(), content.c_str());
return 0;
}