completed iris kit status FSM
This commit is contained in:
@@ -37,17 +37,24 @@
|
|||||||
#define IR_SERIES_MAX (1024)
|
#define IR_SERIES_MAX (1024)
|
||||||
#define IR_END_CODE (10000)
|
#define IR_END_CODE (10000)
|
||||||
|
|
||||||
const uint8_t k_timeout = 50;
|
|
||||||
// as this program is a special purpose capture/decoder, let us use a larger
|
// external variable declaratoins
|
||||||
// than normal buffer so we can handle Air Conditioner remote codes
|
extern iris_kit_status_t g_iris_kit_status;
|
||||||
const uint16_t k_capture_buffer_size = IR_SERIES_MAX;
|
|
||||||
|
|
||||||
|
// public variable definitions
|
||||||
|
|
||||||
|
|
||||||
|
// private variable definitions
|
||||||
static IRsend * ir_send = nullptr;
|
static IRsend * ir_send = nullptr;
|
||||||
static IRrecv * ir_recv = nullptr;
|
static IRrecv * ir_recv = nullptr;
|
||||||
|
static 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
|
||||||
|
static const uint16_t k_capture_buffer_size = IR_SERIES_MAX;
|
||||||
|
|
||||||
int g_study_key_id = -1;
|
|
||||||
String g_study_key_name = "";
|
|
||||||
String g_study_remote_index = "";
|
|
||||||
|
|
||||||
|
// public function definitions
|
||||||
bool sendIR(String file_name) {
|
bool sendIR(String file_name) {
|
||||||
String save_path = SAVE_PATH + file_name;
|
String save_path = SAVE_PATH + file_name;
|
||||||
if (LittleFS.exists(save_path)) {
|
if (LittleFS.exists(save_path)) {
|
||||||
@@ -161,27 +168,19 @@ void sendStatus(String file, t_remote_ac_status status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareRecvIR(int key_id, String key_name, String remote_index) {
|
void prepareRecvIR() {
|
||||||
g_study_key_id = key_id;
|
|
||||||
g_study_key_name = key_name;
|
|
||||||
g_study_remote_index = remote_index;
|
|
||||||
removeReceived();
|
removeReceived();
|
||||||
enableIRIn();
|
enableIRIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelRecvIR() {
|
void cancelRecvIR() {
|
||||||
g_study_remote_index = "";
|
|
||||||
g_study_key_name = "";
|
|
||||||
g_study_key_id = -1;
|
|
||||||
disableIRIn();
|
disableIRIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void completedRecvIR(int key_id, String key_name) {
|
int completeRecvIR(String &ir_data) {
|
||||||
// called unsolicited
|
// called unsolicited
|
||||||
g_study_remote_index = "";
|
|
||||||
g_study_key_name = "";
|
|
||||||
g_study_key_id = -1;
|
|
||||||
disableIRIn();
|
disableIRIn();
|
||||||
|
return loadReceived(ir_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void recvIR() {
|
void recvIR() {
|
||||||
@@ -195,6 +194,11 @@ void recvIR() {
|
|||||||
ir_recv->resume();
|
ir_recv->resume();
|
||||||
INFOLN(raw_data.c_str());
|
INFOLN(raw_data.c_str());
|
||||||
saveReceived(results);
|
saveReceived(results);
|
||||||
|
processStatusChange(IRIS_KIT_STATUS_STUDIED,
|
||||||
|
g_iris_kit_status.console_id,
|
||||||
|
g_iris_kit_status.key_id,
|
||||||
|
g_iris_kit_status.key_name,
|
||||||
|
g_iris_kit_status.remote_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,11 +206,11 @@ bool saveReceived(decode_results& results) {
|
|||||||
String save_path = SAVE_PATH;
|
String save_path = SAVE_PATH;
|
||||||
String file_name = "";
|
String file_name = "";
|
||||||
|
|
||||||
if (g_study_remote_index.isEmpty()) {
|
if (g_iris_kit_status.remote_index.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_name = "ir_" + g_study_remote_index + RECEIVED_SUFFIX;
|
file_name = "ir_" + g_iris_kit_status.remote_index + RECEIVED_SUFFIX;
|
||||||
save_path += file_name;
|
save_path += file_name;
|
||||||
INFOF("Save received code to: %s\n", save_path.c_str());
|
INFOF("Save received code to: %s\n", save_path.c_str());
|
||||||
File cache = LittleFS.open(save_path, "w");
|
File cache = LittleFS.open(save_path, "w");
|
||||||
@@ -225,10 +229,10 @@ bool removeReceived() {
|
|||||||
String save_path = SAVE_PATH;
|
String save_path = SAVE_PATH;
|
||||||
String file_name = "";
|
String file_name = "";
|
||||||
|
|
||||||
if (g_study_remote_index.isEmpty()) {
|
if (g_iris_kit_status.remote_index.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file_name = "ir_" + g_study_remote_index + RECEIVED_SUFFIX;
|
file_name = "ir_" + g_iris_kit_status.remote_index + RECEIVED_SUFFIX;
|
||||||
save_path += file_name;
|
save_path += file_name;
|
||||||
INFOF("Delete received code file: %s\n", save_path.c_str());
|
INFOF("Delete received code file: %s\n", save_path.c_str());
|
||||||
LittleFS.remove(save_path);
|
LittleFS.remove(save_path);
|
||||||
@@ -236,6 +240,29 @@ bool removeReceived() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int loadReceived(String &ir_data) {
|
||||||
|
String save_path = SAVE_PATH;
|
||||||
|
String file_name = "";
|
||||||
|
|
||||||
|
if (g_iris_kit_status.remote_index.isEmpty()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_name = "ir_" + g_iris_kit_status.remote_index + RECEIVED_SUFFIX;
|
||||||
|
save_path += file_name;
|
||||||
|
INFOF("Load received code from: %s\n", save_path.c_str());
|
||||||
|
|
||||||
|
File cache = LittleFS.open(save_path, "r");
|
||||||
|
if (!cache) {
|
||||||
|
ERRORF("Failed to open file\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ir_data = cache.readString();
|
||||||
|
cache.close();
|
||||||
|
|
||||||
|
return ir_data.length();
|
||||||
|
}
|
||||||
|
|
||||||
void initAC(String file) {
|
void initAC(String file) {
|
||||||
ACStatus[file]["power"] = 0;
|
ACStatus[file]["power"] = 0;
|
||||||
ACStatus[file]["temperature"] = 8;
|
ACStatus[file]["temperature"] = 8;
|
||||||
|
|||||||
@@ -46,18 +46,20 @@ 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);
|
||||||
|
|
||||||
void prepareRecvIR(int key_id, String key_name, String remote_index);
|
void prepareRecvIR();
|
||||||
|
|
||||||
void cancelRecvIR();
|
void cancelRecvIR();
|
||||||
|
|
||||||
void completedRecvIR(int key_id, String key_name);
|
int completeRecvIR(String &ir_data);
|
||||||
|
|
||||||
void recvIR();
|
void recvIR();
|
||||||
|
|
||||||
bool saveReceived(decode_results& results);
|
bool saveReceived(decode_results &results);
|
||||||
|
|
||||||
bool removeReceived();
|
bool removeReceived();
|
||||||
|
|
||||||
|
int loadReceived(String &ir_data);
|
||||||
|
|
||||||
void initAC(String);
|
void initAC(String);
|
||||||
|
|
||||||
#endif // IR_DRV_CTRL_H
|
#endif // IR_DRV_CTRL_H
|
||||||
@@ -62,11 +62,17 @@ char iris_password[PASSWORD_MAX] = { 0 };
|
|||||||
static int processEvent(String event_name, String product_key, String device_name, String content);
|
static int processEvent(String event_name, String product_key, String device_name, String content);
|
||||||
static String buildConnect();
|
static String buildConnect();
|
||||||
static String buildHeartBeat();
|
static String buildHeartBeat();
|
||||||
|
static void buildGeneralResponse(String notify_name);
|
||||||
|
static void buildGeneralIndication(String notify_name);
|
||||||
|
static String buildTestResponse();
|
||||||
|
static String buildRecvPreparedResponse();
|
||||||
|
static String buildRecvCompletedIndication(String ir_data);
|
||||||
|
static String buildRecvErrorIndication();
|
||||||
|
static String buildRecvCancelledResponse();
|
||||||
static int handleConnected(String product_key, String device_name, String content);
|
static int handleConnected(String product_key, String device_name, String content);
|
||||||
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);
|
static int handleNotifyStatus(String product_key, String device_name, String content);
|
||||||
static int processStatusChange(int status, int console_id, int key_id, String key_name, String remote_index);
|
|
||||||
|
|
||||||
static int hb_count = 0;
|
static int hb_count = 0;
|
||||||
|
|
||||||
@@ -243,6 +249,79 @@ void handleIrisKitMessage(const char* data, int length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int processStatusChange(int status, int console_id, int key_id, String key_name, String remote_index) {
|
||||||
|
switch(status) {
|
||||||
|
case IRIS_KIT_STATUS_READY_TO_STUDY:
|
||||||
|
{
|
||||||
|
// enter into IR receive mode and send response
|
||||||
|
updateIrisKitStatus(IRIS_KIT_STATUS_READY_TO_STUDY, console_id, remote_index, key_id, key_name);
|
||||||
|
prepareRecvIR();
|
||||||
|
String recvPreparedResponseData = buildRecvPreparedResponse();
|
||||||
|
sendData(g_upstream_topic.c_str(), (uint8_t*) recvPreparedResponseData.c_str(), recvPreparedResponseData.length());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IRIS_KIT_STATUS_STUDIED:
|
||||||
|
{
|
||||||
|
// after IR data are received, load saved IR data and send to IRIS server
|
||||||
|
updateIrisKitStatus(IRIS_KIT_STATUS_STUDIED, console_id, remote_index, key_id, key_name);
|
||||||
|
String ir_data = "";
|
||||||
|
String recvCompletedIndicationData = "";
|
||||||
|
if (completeRecvIR(ir_data) > 0) {
|
||||||
|
recvCompletedIndicationData = buildRecvCompletedIndication(ir_data);
|
||||||
|
} else {
|
||||||
|
recvCompletedIndicationData = buildRecvErrorIndication();
|
||||||
|
}
|
||||||
|
sendData(g_upstream_topic.c_str(), (uint8_t*) recvCompletedIndicationData.c_str(), recvCompletedIndicationData.length());
|
||||||
|
updateIrisKitStatus(IRIS_KIT_STATUS_UPLOADED, console_id, remote_index, key_id, key_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IRIS_KIT_STATUS_CANCEL_STUDY:
|
||||||
|
{
|
||||||
|
// cancel IR receiving and reset
|
||||||
|
cancelRecvIR();
|
||||||
|
String studyCancelledResponseData = buildRecvCancelledResponse();
|
||||||
|
sendData(g_upstream_topic.c_str(), (uint8_t*) studyCancelledResponseData.c_str(), studyCancelledResponseData.length());
|
||||||
|
resetIrisKitStatus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IRIS_KIT_STATUS_TEST:
|
||||||
|
{
|
||||||
|
// send response for test notification
|
||||||
|
updateIrisKitStatus(IRIS_KIT_STATUS_TEST, console_id, remote_index, key_id, key_name);
|
||||||
|
String testResponseData = buildTestResponse();
|
||||||
|
sendData(g_upstream_topic.c_str(), (uint8_t*) testResponseData.c_str(), testResponseData.length());
|
||||||
|
resetIrisKitStatus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateIrisKitStatus(status_t status,
|
||||||
|
int console_id,
|
||||||
|
String remote_index,
|
||||||
|
int key_id, String
|
||||||
|
key_name) {
|
||||||
|
g_iris_kit_status.status = status;
|
||||||
|
g_iris_kit_status.console_id = console_id;
|
||||||
|
g_iris_kit_status.remote_index = remote_index;
|
||||||
|
g_iris_kit_status.key_id = key_id;
|
||||||
|
g_iris_kit_status.key_name = key_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetIrisKitStatus() {
|
||||||
|
g_iris_kit_status.status = IRIS_KIT_STATUS_IDLE;
|
||||||
|
g_iris_kit_status.console_id = 0;
|
||||||
|
g_iris_kit_status.remote_index = "";
|
||||||
|
g_iris_kit_status.key_id = 0;
|
||||||
|
g_iris_kit_status.key_name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// private function definitions
|
// private function definitions
|
||||||
static int processEvent(String event_name, String product_key, String device_name, String content) {
|
static int processEvent(String event_name, String product_key, String device_name, String content) {
|
||||||
@@ -281,30 +360,69 @@ static String buildHeartBeat() {
|
|||||||
return heartBeatMessage;
|
return heartBeatMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String buildGeneralResponse(int console_id, String notify_payload) {
|
static void buildGeneralResponse(String notify_name) {
|
||||||
String notification = "";
|
|
||||||
iris_msg_doc.clear();
|
iris_msg_doc.clear();
|
||||||
iris_msg_doc["eventName"] = String(EVENT_NOTIFY_RESP);
|
iris_msg_doc["eventName"] = String(EVENT_NOTIFY_RESP);
|
||||||
iris_msg_doc["productKey"] = g_product_key;
|
iris_msg_doc["productKey"] = g_product_key;
|
||||||
iris_msg_doc["deviceName"] = g_device_name;
|
iris_msg_doc["deviceName"] = g_device_name;
|
||||||
iris_msg_doc["appId"] = g_app_id;
|
iris_msg_doc["appId"] = g_app_id;
|
||||||
iris_msg_doc["consoleId"] = console_id;
|
iris_msg_doc["consoleId"] = g_iris_kit_status.console_id;
|
||||||
iris_msg_doc["resp"] = String(notify_payload);
|
iris_msg_doc["resp"] = String(notify_name);
|
||||||
serializeJson(iris_msg_doc, notification);
|
|
||||||
|
|
||||||
return notification;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String buildTestResponse(int console_id) {
|
static void buildGeneralIndication(String notify_name) {
|
||||||
return buildGeneralResponse(console_id, NOTIFY_RESP_TEST);
|
iris_ind_doc.clear();
|
||||||
|
iris_ind_doc["eventName"] = String(EVENT_NOTIFY_RESP);
|
||||||
|
iris_ind_doc["productKey"] = g_product_key;
|
||||||
|
iris_ind_doc["deviceName"] = g_device_name;
|
||||||
|
iris_ind_doc["appId"] = g_app_id;
|
||||||
|
iris_ind_doc["consoleId"] = g_iris_kit_status.console_id;
|
||||||
|
iris_ind_doc["remoteIndex"] = g_iris_kit_status.remote_index;
|
||||||
|
iris_ind_doc["keyId"] = g_iris_kit_status.key_id;
|
||||||
|
iris_ind_doc["keyName"] = g_iris_kit_status.key_name;
|
||||||
|
iris_ind_doc["resp"] = String(notify_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String buildRecvPreparedResponse(int console_id) {
|
static String buildTestResponse() {
|
||||||
return buildGeneralResponse(console_id, NOTIFY_RECV_PREPARED);
|
String testReponse = "";
|
||||||
|
buildGeneralResponse(NOTIFY_RESP_TEST);
|
||||||
|
serializeJson(iris_msg_doc, testReponse);
|
||||||
|
|
||||||
|
return testReponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String buildStudyCancelledResponse(int console_id) {
|
static String buildRecvPreparedResponse() {
|
||||||
return buildGeneralResponse(console_id, NOTIFY_STUDY_CANCELLED);
|
String recvPreparedResponse = "";
|
||||||
|
buildGeneralResponse(NOTIFY_RECV_PREPARED);
|
||||||
|
serializeJson(iris_msg_doc, recvPreparedResponse);
|
||||||
|
|
||||||
|
return recvPreparedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String buildRecvCompletedIndication(String ir_data) {
|
||||||
|
String recvCompletedIndication = "";
|
||||||
|
buildGeneralIndication(NOTIFY_RECV_COMPLETED);
|
||||||
|
iris_ind_doc["payload"] = ir_data;
|
||||||
|
serializeJson(iris_ind_doc, recvCompletedIndication);
|
||||||
|
|
||||||
|
return recvCompletedIndication;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String buildRecvErrorIndication() {
|
||||||
|
String recvErrorIndication = "";
|
||||||
|
buildGeneralIndication(NOTIFY_RECV_COMPLETED);
|
||||||
|
iris_ind_doc["payload"] = "error";
|
||||||
|
serializeJson(iris_ind_doc, recvErrorIndication);
|
||||||
|
|
||||||
|
return recvErrorIndication;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String buildRecvCancelledResponse() {
|
||||||
|
String recvCancelledResponse = "";
|
||||||
|
buildGeneralResponse(NOTIFY_RECV_CANCELLED);
|
||||||
|
serializeJson(iris_msg_doc, recvCancelledResponse);
|
||||||
|
|
||||||
|
return recvCancelledResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handleConnected(String product_key, String device_name, String content) {
|
static int handleConnected(String product_key, String device_name, String content) {
|
||||||
@@ -318,7 +436,7 @@ 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) {
|
||||||
INFOF("Received emit code : %s, %s, %s\n", product_key.c_str(), device_name.c_str(), content.c_str());
|
INFOF("Received emit code : %s, %s, %s\n", product_key.c_str(), device_name.c_str(), content.c_str());
|
||||||
g_iris_kit_status = IRIS_KIT_STATUS_EMITTING;
|
updateIrisKitStatus(IRIS_KIT_STATUS_EMITTING, 0, "", 0, "");
|
||||||
emit_code_doc.clear();
|
emit_code_doc.clear();
|
||||||
if (DeserializationError::Ok == deserializeJson(emit_code_doc, content)) {
|
if (DeserializationError::Ok == deserializeJson(emit_code_doc, content)) {
|
||||||
int remote_id = emit_code_doc["remoteId"];
|
int remote_id = emit_code_doc["remoteId"];
|
||||||
@@ -329,7 +447,7 @@ static int handleEmit(String product_key, String device_name, String content) {
|
|||||||
} else {
|
} else {
|
||||||
INFOF("Deserialize failed\n");
|
INFOF("Deserialize failed\n");
|
||||||
}
|
}
|
||||||
g_iris_kit_status = IRIS_KIT_STATUS_IDLE;
|
resetIrisKitStatus();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,39 +466,5 @@ static int handleNotifyStatus(String product_key, String device_name, String con
|
|||||||
} else {
|
} else {
|
||||||
INFOF("Deserialize failed\n");
|
INFOF("Deserialize failed\n");
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int processStatusChange(int status, int console_id, int key_id, String key_name, String remote_index) {
|
|
||||||
switch(status) {
|
|
||||||
case IRIS_KIT_STATUS_TEST:
|
|
||||||
{
|
|
||||||
// send response for test notification
|
|
||||||
String testResponseData = buildTestResponse(console_id);
|
|
||||||
sendData(g_upstream_topic.c_str(), (uint8_t*) testResponseData.c_str(), testResponseData.length());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IRIS_KIT_STATUS_READY_TO_STUDY:
|
|
||||||
{
|
|
||||||
// enter into IR receive mode and send response
|
|
||||||
prepareRecvIR(key_id, key_name, remote_index);
|
|
||||||
String recvPreparedResponseData = buildRecvPreparedResponse(console_id);
|
|
||||||
sendData(g_upstream_topic.c_str(), (uint8_t*) recvPreparedResponseData.c_str(), recvPreparedResponseData.length());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IRIS_KIT_STATUS_CANCEL_STUDY:
|
|
||||||
{
|
|
||||||
// cancel IR receiving and reset
|
|
||||||
cancelRecvIR();
|
|
||||||
String studyCancelledResponseData = buildStudyCancelledResponse(console_id);
|
|
||||||
sendData(g_upstream_topic.c_str(), (uint8_t*) studyCancelledResponseData.c_str(), studyCancelledResponseData.length());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -39,6 +39,14 @@ typedef enum {
|
|||||||
|
|
||||||
IRIS_KIT_STATUS_NOT_CONNECTED = 62,
|
IRIS_KIT_STATUS_NOT_CONNECTED = 62,
|
||||||
IRIS_KIT_STATUS_MAX = 63,
|
IRIS_KIT_STATUS_MAX = 63,
|
||||||
|
} status_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int console_id;
|
||||||
|
String remote_index;
|
||||||
|
int key_id;
|
||||||
|
String key_name;
|
||||||
|
status_t status;
|
||||||
} iris_kit_status_t;
|
} iris_kit_status_t;
|
||||||
|
|
||||||
// web http call URL list
|
// web http call URL list
|
||||||
@@ -59,7 +67,8 @@ typedef enum {
|
|||||||
|
|
||||||
#define NOTIFY_RESP_TEST "test_ok"
|
#define NOTIFY_RESP_TEST "test_ok"
|
||||||
#define NOTIFY_RECV_PREPARED "recv_prepared"
|
#define NOTIFY_RECV_PREPARED "recv_prepared"
|
||||||
#define NOTIFY_STUDY_CANCELLED "study_cancelled"
|
#define NOTIFY_RECV_CANCELLED "recv_cancelled"
|
||||||
|
#define NOTIFY_RECV_COMPLETED "recv_completed"
|
||||||
|
|
||||||
typedef int (*eventHandler)(String, String, String);
|
typedef int (*eventHandler)(String, String, String);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -85,4 +94,18 @@ void sendIrisKitHeartBeat();
|
|||||||
|
|
||||||
void handleIrisKitMessage(const char* data, int length);
|
void handleIrisKitMessage(const char* data, int length);
|
||||||
|
|
||||||
|
int processStatusChange(int status,
|
||||||
|
int console_id,
|
||||||
|
int key_id,
|
||||||
|
String key_name,
|
||||||
|
String remote_index);
|
||||||
|
|
||||||
|
void updateIrisKitStatus(status_t status,
|
||||||
|
int console_id,
|
||||||
|
String remote_index,
|
||||||
|
int key_id, String
|
||||||
|
key_name);
|
||||||
|
|
||||||
|
void resetIrisKitStatus();
|
||||||
|
|
||||||
#endif // IRIS_KIT_IR_BABY_H
|
#endif // IRIS_KIT_IR_BABY_H
|
||||||
@@ -61,7 +61,13 @@ int credential_init_retry = 0;
|
|||||||
int g_runtime_env = RUNTIME_RELEASE;
|
int g_runtime_env = RUNTIME_RELEASE;
|
||||||
iris_kit_settings_t iriskit_settings;
|
iris_kit_settings_t iriskit_settings;
|
||||||
bool iris_kit_settings_loaded = false;
|
bool iris_kit_settings_loaded = false;
|
||||||
iris_kit_status_t g_iris_kit_status = IRIS_KIT_STATUS_NOT_CONNECTED;
|
iris_kit_status_t g_iris_kit_status = {
|
||||||
|
console_id: 0,
|
||||||
|
remote_index: "",
|
||||||
|
key_id: 0,
|
||||||
|
key_name: "",
|
||||||
|
status: IRIS_KIT_STATUS_IDLE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// private variable definitions
|
// private variable definitions
|
||||||
@@ -189,7 +195,7 @@ void setup() {
|
|||||||
iriskit_settings.password = String(iris_password);
|
iriskit_settings.password = String(iris_password);
|
||||||
setIrisKitSettings(iriskit_settings);
|
setIrisKitSettings(iriskit_settings);
|
||||||
|
|
||||||
g_iris_kit_status = IRIS_KIT_STATUS_IDLE;
|
resetIrisKitStatus();
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
@@ -232,8 +238,11 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (IRIS_KIT_STATUS_READY_TO_STUDY == g_iris_kit_status) {
|
// process unsolicited FSM state change
|
||||||
|
if (IRIS_KIT_STATUS_READY_TO_STUDY == g_iris_kit_status.status) {
|
||||||
recvIR();
|
recvIR();
|
||||||
|
} else if (IRIS_KIT_STATUS_UPLOADED == g_iris_kit_status.status) {
|
||||||
|
resetIrisKitStatus();
|
||||||
}
|
}
|
||||||
keepAliveIot();
|
keepAliveIot();
|
||||||
yield();
|
yield();
|
||||||
|
|||||||
Reference in New Issue
Block a user