fixed json payload parse issue
This commit is contained in:
@@ -18,8 +18,8 @@ platform = espressif8266
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
upload_port = COM6
|
upload_port = COM5
|
||||||
monitor_port = COM6
|
monitor_port = COM5
|
||||||
board_build.flash_mode = dout
|
board_build.flash_mode = dout
|
||||||
build_flags =
|
build_flags =
|
||||||
-Wno-unused-function
|
-Wno-unused-function
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ int fetchIrisCredential(String credential_token,
|
|||||||
int resultCode = http_response_doc["status"]["code"];
|
int resultCode = http_response_doc["status"]["code"];
|
||||||
if (0 == resultCode) {
|
if (0 == resultCode) {
|
||||||
INFOLN("response valid, try getting entity");
|
INFOLN("response valid, try getting entity");
|
||||||
device_secret = (String) http_response_doc["entity"]["deviceSecret"];
|
device_secret = (const char*) http_response_doc["entity"]["deviceSecret"];
|
||||||
app_id = (int) http_response_doc["entity"]["appId"];
|
app_id = (int) http_response_doc["entity"]["appId"];
|
||||||
INFOF("HTTP response deserialized, PK = %s, DN = %s, DS = %s\n",
|
INFOF("HTTP response deserialized, PK = %s, DN = %s, DS = %s\n",
|
||||||
product_key.c_str(), device_name.c_str(), device_secret.c_str());
|
product_key.c_str(), device_name.c_str(), device_secret.c_str());
|
||||||
@@ -169,12 +169,11 @@ void sendIrisKitHeartBeat() {
|
|||||||
void handleIrisKitMessage(const char* data, int length) {
|
void handleIrisKitMessage(const char* data, int length) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char* payload = (char*) malloc(length + 1);
|
char* payload = (char*) malloc(length + 1);
|
||||||
char* payload_json = payload;
|
|
||||||
if (NULL != payload) {
|
if (NULL != payload) {
|
||||||
strncpy(payload, data, length);
|
strncpy(payload, data, length);
|
||||||
payload[length] = '\0';
|
payload[length] = '\0';
|
||||||
INFOF("--> %s\n", payload);
|
INFOF("--> %s\n", payload);
|
||||||
if (OK == deserializeJson(iris_ind_doc, payload_json)) {
|
if (OK == deserializeJson(iris_ind_doc, payload)) {
|
||||||
String event_name = iris_ind_doc["eventName"];
|
String event_name = iris_ind_doc["eventName"];
|
||||||
String product_key = iris_ind_doc["productKey"];
|
String product_key = iris_ind_doc["productKey"];
|
||||||
String device_name = iris_ind_doc["deviceName"];
|
String device_name = iris_ind_doc["deviceName"];
|
||||||
@@ -237,8 +236,8 @@ 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());
|
||||||
emit_code_doc.clear();
|
emit_code_doc.clear();
|
||||||
if (OK == deserializeJson(emit_code_doc, content)) {
|
if (OK == deserializeJson(emit_code_doc, content)) {
|
||||||
int remote_id = emit_code_doc["content"]["remoteId"];
|
int remote_id = emit_code_doc["remoteId"];
|
||||||
int key_number = emit_code_doc["content"]["keyNumber"];
|
int key_number = emit_code_doc["keyNumber"];
|
||||||
INFOF("will emit key : %d for remote %d\n", key_number, remote_id);
|
INFOF("will emit key : %d for remote %d\n", key_number, remote_id);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
// web http call URL list
|
// web http call URL list
|
||||||
#define FETCH_CREDENTIAL_SUFFIX "/irext-collect/credentials/fetch_credential"
|
#define FETCH_CREDENTIAL_SUFFIX "/irext-collect/credentials/fetch_credential"
|
||||||
#define LOAD_ALIOT_ACCOUNT_SUFFIX "/irext-collect/aliot/load_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_"
|
#define DOWNLOAD_PREFIX "http://irext-debug.oss-cn-hangzhou.aliyuncs.com/irda_"
|
||||||
#define DOWNLOAD_SUFFIX ".bin"
|
#define DOWNLOAD_SUFFIX ".bin"
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ typedef unsigned short uint16_t;
|
|||||||
typedef short int16_t;
|
typedef short int16_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
|
|
||||||
#define FIRMWARE_VERSION "0.2.7" // version name
|
#define FIRMWARE_VERSION "1.2.7" // version name
|
||||||
#define VERSION_CODE 1 // version code
|
#define VERSION_CODE 1 // version code
|
||||||
|
|
||||||
/* log settings */
|
/* log settings */
|
||||||
|
|||||||
Reference in New Issue
Block a user