renamed source code and completed iris kit auth procedure
This commit is contained in:
@@ -28,15 +28,16 @@
|
||||
#include <Ticker.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "IRbabyIR.h"
|
||||
#include "IRbabyAlink.h"
|
||||
#include "IRbabyHttp.h"
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRbabyIRIS.h"
|
||||
#include "IRbabySerial.h"
|
||||
#include "IRbabyUserSettings.h"
|
||||
#include "IRISKitIR.h"
|
||||
#include "IRISKitIoT.h"
|
||||
#include "IRISKitHttp.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "IRISKitIRbaby.h"
|
||||
#include "IRISKitSerials.h"
|
||||
#include "IRISKitUserSettings.h"
|
||||
#include "IRISKitUtils.h"
|
||||
|
||||
#include "IRbaby.h"
|
||||
#include "IRISKit.h"
|
||||
|
||||
#define CREDENTIAL_INIT_RETRY_MAX (3)
|
||||
#define SYSTEM_DELAY (2000)
|
||||
@@ -44,6 +45,7 @@
|
||||
// external variable declarations
|
||||
extern char iris_server_address[];
|
||||
extern char iris_credential_token[];
|
||||
extern char iris_password[];
|
||||
|
||||
extern String g_product_key;
|
||||
extern String g_device_name;
|
||||
@@ -86,22 +88,26 @@ void setup() {
|
||||
INFOLN("██║██╔══██╗██║╚════██║");
|
||||
INFOLN("██║██║ ██║██║███████║");
|
||||
INFOLN("╚═╝╚═╝ ╚═╝╚═╝╚══════╝");
|
||||
INFOLN("== IRIS Kit [1.2.7] Powered by IRBaby ==");
|
||||
INFOLN("== IRIS Kit [1.3.0] Powered by IRBaby ==");
|
||||
|
||||
// try loading saved iriskit settings
|
||||
iriskit_settings.credential_token.clear();
|
||||
iriskit_settings.server_address.clear();
|
||||
iriskit_settings.password.clear();
|
||||
|
||||
if (loadSettings()) {
|
||||
iriskit_settings = getIrisKitSettings();
|
||||
INFOLN("saved credentials loaded");
|
||||
INFOF("server address is empty ? %s\n", iriskit_settings.server_address.isEmpty() ? "yes" : "no");
|
||||
INFOF("credential is empty ? %s\n", iriskit_settings.credential_token.isEmpty() ? "yes" : "no");
|
||||
INFOF("password is empty ? %s\n", iriskit_settings.password.isEmpty() ? "yes" : "no");
|
||||
}
|
||||
if (!iriskit_settings.credential_token.isEmpty() &&
|
||||
!iriskit_settings.credential_token.equalsIgnoreCase("NULL") &&
|
||||
!iriskit_settings.server_address.isEmpty() &&
|
||||
!iriskit_settings.server_address.equalsIgnoreCase("NULL")) {
|
||||
!iriskit_settings.server_address.equalsIgnoreCase("NULL") &&
|
||||
!iriskit_settings.password.isEmpty() &&
|
||||
!iriskit_settings.password.equalsIgnoreCase("NULL")) {
|
||||
iriskit_settings_loaded = true;
|
||||
}
|
||||
|
||||
@@ -110,53 +116,58 @@ void setup() {
|
||||
// custom parameter for iris credentials
|
||||
WiFiManagerParameter* server_address = NULL;
|
||||
WiFiManagerParameter* credential_token = NULL;
|
||||
WiFiManagerParameter* password = NULL;
|
||||
|
||||
memset(iris_server_address, 0, URL_SHORT_MAX);
|
||||
memset(iris_credential_token, 0, CREDENTIAL_MAX);
|
||||
memset(iris_password, 0, PASSWORD_MAX);
|
||||
|
||||
if (!iriskit_settings_loaded) {
|
||||
if (iriskit_settings_loaded) {
|
||||
INFOLN("iriskit settings loaded");
|
||||
strncpy(iris_server_address, iriskit_settings.server_address.c_str(), URL_SHORT_MAX - 1);
|
||||
strncpy(iris_credential_token, iriskit_settings.credential_token.c_str(), CREDENTIAL_MAX - 1);
|
||||
strncpy(iris_password, iriskit_settings.password.c_str(), PASSWORD_MAX - 1);
|
||||
} else {
|
||||
INFOLN("iriskit settings not loaded, set it from WifiManager");
|
||||
server_address =
|
||||
new WiFiManagerParameter("server_address", "Server Address", "", URL_SHORT_MAX);
|
||||
credential_token =
|
||||
new WiFiManagerParameter("credential_token", "Credential Token", "", CREDENTIAL_MAX);
|
||||
password =
|
||||
new WiFiManagerParameter("password", "User Password", "", PASSWORD_MAX);
|
||||
|
||||
if (NULL == server_address || NULL == credential_token) {
|
||||
if (NULL == server_address || NULL == credential_token || NULL == password) {
|
||||
ERRORLN("not enough memory to create settings");
|
||||
factoryReset();
|
||||
}
|
||||
wifi_manager.addParameter(server_address);
|
||||
wifi_manager.addParameter(credential_token);
|
||||
} else {
|
||||
INFOLN("iriskit settings loaded");
|
||||
strcpy(iris_server_address, iriskit_settings.server_address.c_str());
|
||||
strcpy(iris_credential_token, iriskit_settings.credential_token.c_str());
|
||||
wifi_manager.addParameter(password);
|
||||
}
|
||||
|
||||
wifi_manager.autoConnect();
|
||||
|
||||
if (!iriskit_settings_loaded) {
|
||||
memset(iris_server_address, 0, URL_SHORT_MAX);
|
||||
strcpy(iris_server_address, server_address->getValue());
|
||||
|
||||
memset(iris_credential_token, 0, CREDENTIAL_MAX);
|
||||
strcpy(iris_credential_token, credential_token->getValue());
|
||||
|
||||
delete server_address;
|
||||
delete credential_token;
|
||||
strncpy(iris_server_address, server_address->getValue(), URL_SHORT_MAX - 1);
|
||||
strncpy(iris_credential_token, credential_token->getValue(), CREDENTIAL_MAX - 1);
|
||||
String rawPassword = String(password->getValue());
|
||||
strncpy(iris_password, md5(rawPassword).c_str(), PASSWORD_MAX - 1);
|
||||
}
|
||||
|
||||
// digest password
|
||||
|
||||
// TODO: fix the logic without settings loaded
|
||||
INFOF("Wifi Connected, IRIS server = %s, credential token = %s\n",
|
||||
iris_server_address, iris_credential_token);
|
||||
INFOF("Wifi Connected, IRIS server = %s, credential token = %s, password = %s\n",
|
||||
iris_server_address, iris_credential_token, iris_password);
|
||||
|
||||
do {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
if (0 == fetchIrisCredential(iris_credential_token,
|
||||
g_product_key,
|
||||
g_device_name,
|
||||
g_device_secret,
|
||||
g_app_id)) {
|
||||
if (0 == authIrisKitAccount(iris_credential_token,
|
||||
iris_password,
|
||||
g_product_key,
|
||||
g_device_name,
|
||||
g_device_secret,
|
||||
g_app_id)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +182,8 @@ void setup() {
|
||||
INFOF("credential get : %s\n", iris_credential_token);
|
||||
iriskit_settings.server_address = String(iris_server_address);
|
||||
iriskit_settings.credential_token = String(iris_credential_token);
|
||||
saveIrisKitSettings(iriskit_settings);
|
||||
iriskit_settings.password = String(iris_password);
|
||||
setIrisKitSettings(iriskit_settings);
|
||||
|
||||
saveSettings();
|
||||
|
||||
@@ -186,16 +198,16 @@ void setup() {
|
||||
}
|
||||
INFOF("IR pin config get : %d, %d\n", send_pin, recv_pin);
|
||||
loadIRPin(send_pin, recv_pin);
|
||||
connectToAliyunIoT();
|
||||
connectToIrextIoT();
|
||||
|
||||
alinkCheckTask.attach_scheduled(MQTT_CHECK_INTERVALS, checkAlinkMQTT);
|
||||
alinkCheckTask.attach_scheduled(MQTT_CHECK_INTERVALS, checkIrextIoT);
|
||||
disableIRTask.attach_scheduled(DISABLE_SIGNAL_INTERVALS, disableIR);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
recvIR();
|
||||
yield();
|
||||
aliotKeepAlive();
|
||||
irextIoTKeepAlive();
|
||||
}
|
||||
|
||||
void factoryReset() {
|
||||
@@ -27,6 +27,7 @@
|
||||
typedef struct {
|
||||
String server_address;
|
||||
String credential_token;
|
||||
String password;
|
||||
} t_iriskit_settings;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "defines.h"
|
||||
|
||||
StaticJsonDocument<1024> iris_msg_doc;
|
||||
@@ -21,9 +21,10 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "IRbabyha.h"
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRbabySerial.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "IRISKitSerials.h"
|
||||
|
||||
#include "IRISKitHA.h"
|
||||
|
||||
void returnACStatus(String filename, t_remote_ac_status ac_status) {
|
||||
send_msg_doc.clear();
|
||||
@@ -25,6 +25,7 @@
|
||||
#define IRBABY_HA_H
|
||||
|
||||
#include <WString.h>
|
||||
|
||||
#include "ir_ac_control.h"
|
||||
|
||||
void returnACStatus(String filename, t_remote_ac_status ac_status);
|
||||
@@ -29,10 +29,11 @@
|
||||
#include <ESP8266HTTPClient.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRbabySerial.h"
|
||||
|
||||
#include "IRbabyHttp.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "IRISKitSerials.h"
|
||||
|
||||
#include "IRISKitHttp.h"
|
||||
|
||||
#define HTTP_REQUEST_MAX_RETRY (5)
|
||||
#define HTTP_REQUEST_RETRY_INTERVAL (200)
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRbabySerial.h"
|
||||
#include "IRbabyUserSettings.h"
|
||||
#include "IRbabyIRIS.h"
|
||||
#include "IRbabyHttp.h"
|
||||
#include "IRbabyUtils.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "IRISKitSerials.h"
|
||||
#include "IRISKitUserSettings.h"
|
||||
#include "IRISKitIRbaby.h"
|
||||
#include "IRISKitHttp.h"
|
||||
#include "IRISKitUtils.h"
|
||||
|
||||
#include "IRbabyIR.h"
|
||||
#include "IRISKitIR.h"
|
||||
|
||||
#define IR_SERIES_MAX (1024)
|
||||
#define IR_END_CODE (10000)
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <IRsend.h>
|
||||
#include <IRrecv.h>
|
||||
|
||||
#include "ir_decode.h"
|
||||
|
||||
void loadIRPin(uint8_t send_pin, uint8_t recv_pin);
|
||||
@@ -30,13 +30,14 @@
|
||||
#include <LittleFS.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRbabySerial.h"
|
||||
#include "IRbabyAlink.h"
|
||||
#include "IRbabyHttp.h"
|
||||
#include "IRbabyIR.h"
|
||||
|
||||
#include "IRbabyIRIS.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "IRISKitSerials.h"
|
||||
#include "IRISKitIoT.h"
|
||||
#include "IRISKitHttp.h"
|
||||
#include "IRISKitIR.h"
|
||||
|
||||
#include "IRISKitIRbaby.h"
|
||||
|
||||
|
||||
extern StaticJsonDocument<1024> http_request_doc;
|
||||
@@ -53,6 +54,8 @@ extern int g_app_id;
|
||||
|
||||
char iris_credential_token[CREDENTIAL_MAX] = { 0 };
|
||||
char iris_server_address[URL_SHORT_MAX] = { 0 };
|
||||
char iris_user_name[USER_NAME_MAX] = { 0 };
|
||||
char iris_password[PASSWORD_MAX] = { 0 };
|
||||
|
||||
// private function declarations
|
||||
static int processEvent(String event_name, String product_key, String device_name, String content);
|
||||
@@ -98,11 +101,12 @@ int getDeviceID(char* buffer, int buffer_size) {
|
||||
return strlen(buffer);
|
||||
}
|
||||
|
||||
int fetchIrisCredential(String credential_token,
|
||||
String& product_key,
|
||||
String& device_name,
|
||||
String& device_secret,
|
||||
int& app_id) {
|
||||
int authIrisKitAccount(String credential_token,
|
||||
String password,
|
||||
String& product_key,
|
||||
String& device_name,
|
||||
String& device_secret,
|
||||
int& app_id) {
|
||||
int ret = -1;
|
||||
int tsi = -1;
|
||||
bool protocol_prefix = false;
|
||||
@@ -121,7 +125,7 @@ int fetchIrisCredential(String credential_token,
|
||||
fetch_credential_url = String("http://");
|
||||
fetch_credential_url.concat(iris_server_address);
|
||||
}
|
||||
fetch_credential_url.concat(String(FETCH_CREDENTIAL_SUFFIX));
|
||||
fetch_credential_url.concat(String(GET_IRIS_KIT_ACCOUNT_SUFFIX));
|
||||
device_id.concat(String(ESP.getChipId(), HEX));
|
||||
|
||||
INFOF("fetch credential URL = %s\n", fetch_credential_url.c_str());
|
||||
@@ -139,13 +143,14 @@ int fetchIrisCredential(String credential_token,
|
||||
http_request_doc.clear();
|
||||
http_request_doc["deviceID"] = device_id;
|
||||
http_request_doc["credentialToken"] = credential_token;
|
||||
http_request_doc["password"] = password;
|
||||
serializeJson(http_request_doc, request_data);
|
||||
|
||||
http_ret = httpPost(fetch_credential_url, request_data, response_data);
|
||||
|
||||
if (HTTP_ERROR_SUCCESS == http_ret) {
|
||||
http_response_doc.clear();
|
||||
if (OK == deserializeJson(http_response_doc, response_data)) {
|
||||
if (DeserializationError::Ok == deserializeJson(http_response_doc, response_data)) {
|
||||
int resultCode = http_response_doc["status"]["code"];
|
||||
if (0 == resultCode) {
|
||||
INFOLN("response valid, try getting entity");
|
||||
@@ -196,12 +201,12 @@ bool downloadBin(int remote_id) {
|
||||
|
||||
void sendIrisKitConnect() {
|
||||
String connectMessage = buildConnect();
|
||||
sendRawData(g_upstream_topic.c_str(), (uint8_t*) connectMessage.c_str(), connectMessage.length());
|
||||
sendData(g_upstream_topic.c_str(), (uint8_t*) connectMessage.c_str(), connectMessage.length());
|
||||
}
|
||||
|
||||
void sendIrisKitHeartBeat() {
|
||||
String heartBeatMessage = buildHeartBeat();
|
||||
sendRawData(g_upstream_topic.c_str(), (uint8_t*) heartBeatMessage.c_str(), heartBeatMessage.length());
|
||||
sendData(g_upstream_topic.c_str(), (uint8_t*) heartBeatMessage.c_str(), heartBeatMessage.length());
|
||||
}
|
||||
|
||||
void handleIrisKitMessage(const char* data, int length) {
|
||||
@@ -211,7 +216,7 @@ void handleIrisKitMessage(const char* data, int length) {
|
||||
strncpy(payload, data, length);
|
||||
payload[length] = '\0';
|
||||
INFOF("--> %s\n", payload);
|
||||
if (OK == deserializeJson(iris_ind_doc, payload)) {
|
||||
if (DeserializationError::Ok == deserializeJson(iris_ind_doc, payload)) {
|
||||
String event_name = iris_ind_doc["eventName"];
|
||||
String product_key = iris_ind_doc["productKey"];
|
||||
String device_name = iris_ind_doc["deviceName"];
|
||||
@@ -273,7 +278,7 @@ static int handleHartBeat(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());
|
||||
emit_code_doc.clear();
|
||||
if (OK == deserializeJson(emit_code_doc, content)) {
|
||||
if (DeserializationError::Ok == deserializeJson(emit_code_doc, content)) {
|
||||
int remote_id = emit_code_doc["remoteId"];
|
||||
String key_name = emit_code_doc["keyName"];
|
||||
String key_value = emit_code_doc["keyValue"];
|
||||
@@ -25,9 +25,11 @@
|
||||
#define IRBABY_IRIS_H
|
||||
|
||||
#define CREDENTIAL_MAX (40)
|
||||
#define USER_NAME_MAX (64)
|
||||
#define PASSWORD_MAX (64)
|
||||
|
||||
// web http call URL list
|
||||
#define FETCH_CREDENTIAL_SUFFIX "/irext-collect/credentials/fetch_credential"
|
||||
#define GET_IRIS_KIT_ACCOUNT_SUFFIX "/irext-collect/credentials/auth_iris_kit_account"
|
||||
#define LOAD_ALIOT_ACCOUNT_SUFFIX "/irext-collect/aliot/load_account"
|
||||
#define DOWNLOAD_BIN_SUFFIX "/irext-collect/download"
|
||||
#define DOWNLOAD_PREFIX "http://irext-debug.oss-cn-hangzhou.aliyuncs.com/irda_"
|
||||
@@ -50,11 +52,12 @@ int getIRISKitVersion(char *buffer, int buffer_size);
|
||||
|
||||
int getDeviceID(char* buffer, int buffer_size);
|
||||
|
||||
int fetchIrisCredential(String credential_token,
|
||||
String& product_key,
|
||||
String& device_name,
|
||||
String& device_secret,
|
||||
int& app_id);
|
||||
int authIrisKitAccount(String credential_token,
|
||||
String password,
|
||||
String& product_key,
|
||||
String& device_name,
|
||||
String& device_secret,
|
||||
int& app_id);
|
||||
|
||||
void sendIrisKitConnect();
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#include <Arduino.h>
|
||||
#include <WString.h>
|
||||
|
||||
#include "IRbabySerial.h"
|
||||
#include "IRbabyAlink.h"
|
||||
#include "IRbabyIRIS.h"
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRISKitSerials.h"
|
||||
#include "IRISKitIoT.h"
|
||||
#include "IRISKitIRbaby.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
|
||||
#include "IRbaby.h"
|
||||
#include "IRISKit.h"
|
||||
|
||||
#define TOPIC_NAME_MAX (64)
|
||||
#define IOT_RETRY_MAX (3)
|
||||
@@ -51,15 +51,14 @@ int g_app_id = 0;
|
||||
|
||||
|
||||
static bool downstream_topic_subscribed = false;
|
||||
static AliyunIoTSDK iot;
|
||||
static ep_state_t endpoint_state = FSM_IDLE;
|
||||
|
||||
static void registerCallback(const char* topic, int qos);
|
||||
static void irisAlinkCallback(const char *topic, uint8_t *data, int length);
|
||||
static void irisIrextIoTCallback(const char *topic, uint8_t *data, int length);
|
||||
|
||||
static int iot_retry = 0;
|
||||
|
||||
void connectToAliyunIoT() {
|
||||
void connectToIrextIoT() {
|
||||
downstream_topic_subscribed = false;
|
||||
|
||||
if (g_product_key.equals(IRIS_KIT_PK_DEV)) {
|
||||
@@ -76,42 +75,33 @@ void connectToAliyunIoT() {
|
||||
INFOF("Try connecting to Aliyun IoT : %s, %s, %s, %s\n",
|
||||
g_product_key.c_str(), g_device_name.c_str(), g_device_secret.c_str(), g_region_id.c_str());
|
||||
|
||||
/*
|
||||
if (0 == iot.begin(wifi_client, g_product_key.c_str(), g_device_name.c_str(), g_device_secret.c_str(),
|
||||
g_region_id.c_str())) {
|
||||
sendIrisKitConnect();
|
||||
}
|
||||
*/
|
||||
INFOLN("Aliyun IoT connect done");
|
||||
|
||||
}
|
||||
|
||||
void aliotKeepAlive() {
|
||||
void irextIoTKeepAlive() {
|
||||
/*
|
||||
iot.loop();
|
||||
*/
|
||||
}
|
||||
|
||||
// not only for IRIS related topic based session
|
||||
void sendRawData(const char* topic, const uint8_t *data, int length) {
|
||||
void sendData(const char* topic, const uint8_t *data, int length) {
|
||||
/*
|
||||
iot.sendCustomData(topic, data, length);
|
||||
*/
|
||||
}
|
||||
|
||||
AliyunIoTSDK getSession() {
|
||||
return iot;
|
||||
void* getSession() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void registerCallback(const char* topic, int qos) {
|
||||
if (iot.subscribe(topic, qos)) {
|
||||
INFOLN("topic subscribed");
|
||||
iot.registerCustomCallback(irisAlinkCallback);
|
||||
}
|
||||
}
|
||||
|
||||
static void irisAlinkCallback(const char *topic, uint8_t *data, int length) {
|
||||
INFOF("downstream message received, topic = %s, length = %d\n", topic, length);
|
||||
if (NULL != g_downstream_topic.c_str() && 0 == strcmp(topic, g_downstream_topic.c_str())) {
|
||||
handleIrisKitMessage((const char*) data, length);
|
||||
}
|
||||
}
|
||||
|
||||
void checkAlinkMQTT() {
|
||||
void checkIrextIoT() {
|
||||
int mqttStatus = 0;
|
||||
|
||||
if (0 == mqttStatus) {
|
||||
@@ -131,4 +121,20 @@ void checkAlinkMQTT() {
|
||||
ERRORLN("Alink could not established, something went wrong, reset...");
|
||||
factoryReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void registerCallback(const char* topic, int qos) {
|
||||
/*
|
||||
if (iot.subscribe(topic, qos)) {
|
||||
INFOLN("topic subscribed");
|
||||
iot.registerCustomCallback(irisIrextIoTCallback);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
static void irisIrextIoTCallback(const char *topic, uint8_t *data, int length) {
|
||||
INFOF("downstream message received, topic = %s, length = %d\n", topic, length);
|
||||
if (NULL != g_downstream_topic.c_str() && 0 == strcmp(topic, g_downstream_topic.c_str())) {
|
||||
handleIrisKitMessage((const char*) data, length);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@
|
||||
#define IRBABY_ALINK_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <AliyunIoTSDK.h>
|
||||
|
||||
typedef enum {
|
||||
FSM_IDLE = 0,
|
||||
@@ -35,15 +34,15 @@ typedef enum {
|
||||
FSM_MAX = 7,
|
||||
} ep_state_t;
|
||||
|
||||
void connectToAliyunIoT();
|
||||
void connectToIrextIoT();
|
||||
|
||||
void aliotKeepAlive();
|
||||
void irextIoTKeepAlive();
|
||||
|
||||
void checkAlinkMQTT();
|
||||
void checkIrextIoT();
|
||||
|
||||
AliyunIoTSDK getSession();
|
||||
void* getSession();
|
||||
|
||||
void sendRawData(const char* topic, const uint8_t *data, int length);
|
||||
void sendData(const char* topic, const uint8_t *data, int length);
|
||||
|
||||
int securityPublish(const char *topic, const uint8_t *message, size_t msg_size, void *channel);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define IRBABY_SERIAL_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
// generic COM debug
|
||||
@@ -25,11 +25,11 @@
|
||||
#include <WiFiManager.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "IRbabyGlobal.h"
|
||||
#include "IRbabySerial.h"
|
||||
#include "IRbabyIR.h"
|
||||
#include "IRISKitGlobal.h"
|
||||
#include "IRISKitSerials.h"
|
||||
#include "IRISKitIR.h"
|
||||
|
||||
#include "IRbabyUserSettings.h"
|
||||
#include "IRISKitUserSettings.h"
|
||||
|
||||
|
||||
#define FILE_GENERIC_CONFIG "config"
|
||||
@@ -168,9 +168,10 @@ t_remote_ac_status getACStatus(String file) {
|
||||
return status;
|
||||
}
|
||||
|
||||
bool saveIrisKitSettings(t_iriskit_settings& iriskit_settings) {
|
||||
bool setIrisKitSettings(t_iriskit_settings& iriskit_settings) {
|
||||
IrisKitSettings["server_address"] = iriskit_settings.server_address;
|
||||
IrisKitSettings["token"] = iriskit_settings.credential_token;
|
||||
IrisKitSettings["password"] = iriskit_settings.password;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -178,5 +179,6 @@ t_iriskit_settings getIrisKitSettings() {
|
||||
t_iriskit_settings iriskit_settings;
|
||||
iriskit_settings.server_address = (String)IrisKitSettings["server_address"];
|
||||
iriskit_settings.credential_token = (String)IrisKitSettings["token"];
|
||||
iriskit_settings.password = (String)IrisKitSettings["password"];
|
||||
return iriskit_settings;
|
||||
}
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include "IRbaby.h"
|
||||
#include "IRISKit.h"
|
||||
|
||||
#include "ir_ac_control.h"
|
||||
|
||||
/* save settings */
|
||||
@@ -38,7 +39,7 @@ bool loadSettings();
|
||||
bool saveACStatus(String file, t_remote_ac_status status);
|
||||
t_remote_ac_status getACStatus(String file);
|
||||
|
||||
bool saveIrisKitSettings(t_iriskit_settings& iriskit_settings);
|
||||
bool setIrisKitSettings(t_iriskit_settings& iriskit_settings);
|
||||
t_iriskit_settings getIrisKitSettings();
|
||||
|
||||
extern StaticJsonDocument<1024> ConfigData;
|
||||
@@ -24,8 +24,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <MD5Builder.h>
|
||||
|
||||
#include "IRbabyUtils.h"
|
||||
#include "IRISKitUtils.h"
|
||||
|
||||
// public variable definitions
|
||||
MD5Builder md5_builder;
|
||||
|
||||
int split_string(const String source, char* parts[], const char* delimiter) {
|
||||
char* pch = NULL;
|
||||
@@ -68,4 +72,11 @@ exit:
|
||||
free(parts[j]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
String md5(String str) {
|
||||
md5_builder.begin();
|
||||
md5_builder.add(String(str));
|
||||
md5_builder.calculate();
|
||||
return md5_builder.toString();
|
||||
}
|
||||
@@ -28,5 +28,7 @@
|
||||
|
||||
int split_string(const String source, char* parts[], const char* delimiter);
|
||||
|
||||
String md5(String str);
|
||||
|
||||
#endif //IRBABY_IRIS_UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user