progress on iris-kit
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -14,6 +14,7 @@
|
|||||||
"optional": "cpp",
|
"optional": "cpp",
|
||||||
"memory_resource": "cpp",
|
"memory_resource": "cpp",
|
||||||
"system_error": "cpp",
|
"system_error": "cpp",
|
||||||
"*.tcc": "cpp"
|
"*.tcc": "cpp",
|
||||||
|
"functional": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,6 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
recvIR();
|
recvIR();
|
||||||
// downloadBin();
|
|
||||||
yield();
|
yield();
|
||||||
aliotKeepAlive();
|
aliotKeepAlive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,6 @@
|
|||||||
#define IR_SERIES_MAX (1024)
|
#define IR_SERIES_MAX (1024)
|
||||||
#define IR_END_CODE (10000)
|
#define IR_END_CODE (10000)
|
||||||
|
|
||||||
bool saveSignal();
|
|
||||||
|
|
||||||
decode_results results; // Somewhere to store the results
|
|
||||||
const uint8_t k_timeout = 50;
|
const uint8_t k_timeout = 50;
|
||||||
// As this program is a special purpose capture/decoder, let us use a larger
|
// 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.
|
// 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() {
|
void recvIR() {
|
||||||
|
decode_results results;
|
||||||
if (ir_recv->decode(&results)) {
|
if (ir_recv->decode(&results)) {
|
||||||
DEBUGF("raw length = %d\n", results.rawlen - 1);
|
DEBUGF("raw length = %d\n", results.rawlen - 1);
|
||||||
String raw_data;
|
String raw_data;
|
||||||
for (int i = 1; i < results.rawlen; i++) {
|
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();
|
ir_recv->resume();
|
||||||
send_msg_doc.clear();
|
send_msg_doc.clear();
|
||||||
@@ -180,8 +178,7 @@ void recvIR() {
|
|||||||
send_msg_doc["params"]["length"] = results.rawlen;
|
send_msg_doc["params"]["length"] = results.rawlen;
|
||||||
send_msg_doc["params"]["value"] = raw_data.c_str();
|
send_msg_doc["params"]["value"] = raw_data.c_str();
|
||||||
DEBUGLN(raw_data.c_str());
|
DEBUGLN(raw_data.c_str());
|
||||||
// sendUDP(&send_msg_doc, remote_ip);
|
saveIR(results);
|
||||||
saveSignal();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +188,7 @@ bool saveIR(String file_name) {
|
|||||||
return LittleFS.rename("/bin/test", save_path);
|
return LittleFS.rename("/bin/test", save_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool saveSignal() {
|
bool saveIR(decode_results& results) {
|
||||||
String save_path = SAVE_PATH;
|
String save_path = SAVE_PATH;
|
||||||
save_path += "test";
|
save_path += "test";
|
||||||
DEBUGF("save raw data as %s\n", save_path.c_str());
|
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);
|
DEBUGF("Load IR send pin at %d\n", send_pin);
|
||||||
ir_send->begin();
|
ir_send->begin();
|
||||||
ir_recv = new IRrecv(recv_pin, k_capture_buffer_size, k_timeout, true);
|
ir_recv = new IRrecv(recv_pin, k_capture_buffer_size, k_timeout, true);
|
||||||
disableIR();
|
enableIR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void disableIR() {
|
void disableIR() {
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ bool sendIR(String file_name);
|
|||||||
|
|
||||||
bool emitIR(String timing);
|
bool emitIR(String timing);
|
||||||
|
|
||||||
|
bool saveIR(decode_results &results);
|
||||||
|
|
||||||
bool sendCommand(String file_name, int key);
|
bool sendCommand(String file_name, int key);
|
||||||
|
|
||||||
void sendStatus(String file_name, t_remote_ac_status status);
|
void sendStatus(String file_name, t_remote_ac_status status);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ static String buildConnect();
|
|||||||
static String buildHeartBeat();
|
static String buildHeartBeat();
|
||||||
static int handleHartBeat(String product_key, String device_name, String content);
|
static int handleHartBeat(String product_key, String device_name, String content);
|
||||||
static int handleEmit(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
|
// private variable definitions
|
||||||
event_handler_t event_handler_table[] = {
|
event_handler_t event_handler_table[] = {
|
||||||
@@ -70,6 +71,10 @@ event_handler_t event_handler_table[] = {
|
|||||||
{
|
{
|
||||||
"__emitCode",
|
"__emitCode",
|
||||||
handleEmit,
|
handleEmit,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__notifyStatus",
|
||||||
|
handleNotifyStatus,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -279,3 +284,8 @@ static int handleEmit(String product_key, String device_name, String content) {
|
|||||||
}
|
}
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user