diff --git a/.vscode/settings.json b/.vscode/settings.json index b5d7d27..9798d19 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,7 @@ "optional": "cpp", "memory_resource": "cpp", "system_error": "cpp", - "*.tcc": "cpp" + "*.tcc": "cpp", + "functional": "cpp" } } \ No newline at end of file diff --git a/src/IRbaby.cpp b/src/IRbaby.cpp index fc3c894..ad35709 100644 --- a/src/IRbaby.cpp +++ b/src/IRbaby.cpp @@ -194,7 +194,6 @@ void setup() { void loop() { recvIR(); - // downloadBin(); yield(); aliotKeepAlive(); } diff --git a/src/IRbabyIR.cpp b/src/IRbabyIR.cpp index 6870e6b..7f601a4 100644 --- a/src/IRbabyIR.cpp +++ b/src/IRbabyIR.cpp @@ -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() { diff --git a/src/IRbabyIR.h b/src/IRbabyIR.h index 151fce3..d44669c 100644 --- a/src/IRbabyIR.h +++ b/src/IRbabyIR.h @@ -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); diff --git a/src/IRbabyIRIS.cpp b/src/IRbabyIRIS.cpp index 1daaf0c..d904fb7 100644 --- a/src/IRbabyIRIS.cpp +++ b/src/IRbabyIRIS.cpp @@ -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; } \ No newline at end of file