Commit 89415e10 authored by chen.weican's avatar chen.weican

【修改内容】增加主机reboot service调用

【提交人】陈伟灿
parent be4b4048
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "kk_product.h" #include "kk_product.h"
//#include "kcloud_log.h" //#include "kcloud_log.h"
#define KK_FILTER_ADD_TOPIC "/thing/topo/add" #define KK_FILTER_TOPO_TOPIC "/thing/topo/"
#define KK_FILTER_ADD_TOPIC_REPLY "/thing/topo/add_reply" #define KK_FILTER_TOPO_REPLY "_reply"
#define KK_FILTER_DELETE_TOPIC "/thing/topo/delete" #define KK_FILTER_DELETE_TOPIC "/thing/topo/delete"
#define KK_FILTER_DELETE_TOPIC_REPLY "/thing/topo/delete_reply" #define KK_FILTER_DELETE_TOPIC_REPLY "/thing/topo/delete_reply"
#define KK_FILTER_REGISTER_TOPIC "/thing/sub/register" #define KK_FILTER_REGISTER_TOPIC "/thing/sub/register"
...@@ -17,17 +17,14 @@ ...@@ -17,17 +17,14 @@
#define KK_FILTER_LOGIN_TOPIC_REPLY "/thing/combine/login_reply" #define KK_FILTER_LOGIN_TOPIC_REPLY "/thing/combine/login_reply"
#define KK_FILTER_SET_TOPIC "/thing/service/property/set" #define KK_FILTER_SET_TOPIC "/thing/service/property/set"
#define KK_FILTER_SET_TOPIC_REPLY "/thing/service/property/set_reply" #define KK_FILTER_SET_TOPIC_REPLY "/thing/service/property/set_reply"
#define KK_FILTER_EVENT_POST_TOPIC "/thing/event/property/post" #define KK_FILTER_EVENT_POST_TOPIC1 "/thing/event/"
#define KK_FILTER_EVENT_POST_REPLY "/thing/event/property/post_reply" #define KK_FILTER_EVENT_POST_TOPIC2 "/post"
#define KK_FILTER_EVENT_POST_REPLY "/post_reply"
#define KK_FILTER_STATUS_ONLINE "/thing/status/online" #define KK_FILTER_STATUS_ONLINE "/thing/status/online"
#define KK_FILTER_STATUS_ONLINE_REPLY "/thing/status/online_reply" #define KK_FILTER_STATUS_ONLINE_REPLY "/thing/status/online_reply"
#define KK_FILTER_STATUS_OFFLINE "/thing/status/offline" #define KK_FILTER_STATUS_OFFLINE "/thing/status/offline"
#define KK_FILTER_STATUS_OFFLINE_REPLY "/thing/status/offline_reply" #define KK_FILTER_STATUS_OFFLINE_REPLY "/thing/status/offline_reply"
#define KK_FILTER_TOPO_BATCH_ADD "/thing/topo/batch_add"
#define KK_FILTER_TOPO_BATCH_ADD_REPLY "/thing/topo/batch_add_reply"
#define KK_FILTER_TOPO_BATCH_DELETE "/thing/topo/batch_delete" #define KK_FILTER_TOPO_BATCH_DELETE "/thing/topo/batch_delete"
#define KK_FILTER_TOPO_BATCH_DELETE_REPLY "/thing/topo/batch_delete_reply"
#define KK_FILTER_TOPO_CHANEG_REPLY "/thing/topo/change_reply" #define KK_FILTER_TOPO_CHANEG_REPLY "/thing/topo/change_reply"
#define KK_CLOUDSTATE_MSG "/thing/ccu/cloudstate" #define KK_CLOUDSTATE_MSG "/thing/ccu/cloudstate"
...@@ -212,12 +209,8 @@ void KK_Data_FromDev(void* str,int len) ...@@ -212,12 +209,8 @@ void KK_Data_FromDev(void* str,int len)
} }
static int _check_invalid_topic(const char* topic) static int _check_invalid_topic(const char* topic)
{ {
if(strstr(topic, KK_FILTER_ADD_TOPIC) != NULL && \ if(strstr(topic, KK_FILTER_TOPO_TOPIC) != NULL && \
strstr(topic,KK_FILTER_ADD_TOPIC_REPLY) == NULL){ strstr(topic,KK_FILTER_TOPO_REPLY) == NULL){
return 1;
}
else if(strstr(topic, KK_FILTER_DELETE_TOPIC) != NULL && \
strstr(topic,KK_FILTER_DELETE_TOPIC_REPLY) == NULL){
return 1; return 1;
} }
else if(strstr(topic, KK_FILTER_REGISTER_TOPIC) != NULL && \ else if(strstr(topic, KK_FILTER_REGISTER_TOPIC) != NULL && \
...@@ -234,8 +227,9 @@ static int _check_invalid_topic(const char* topic) ...@@ -234,8 +227,9 @@ static int _check_invalid_topic(const char* topic)
else if(strstr(topic,KK_FILTER_TOPO_CHANEG_REPLY) != NULL){ else if(strstr(topic,KK_FILTER_TOPO_CHANEG_REPLY) != NULL){
return 1; return 1;
} }
else if(strstr(topic, KK_FILTER_EVENT_POST_TOPIC) != NULL && \ else if(strstr(topic, KK_FILTER_EVENT_POST_TOPIC1) != NULL && \
strstr(topic,KK_FILTER_LOGIN_TOPIC_REPLY) == NULL){ strstr(topic,KK_FILTER_EVENT_POST_TOPIC2) != NULL && \
strstr(topic,KK_FILTER_EVENT_POST_REPLY) == NULL){
return 1; return 1;
} }
else if(strstr(topic, KK_FILTER_STATUS_ONLINE) != NULL && \ else if(strstr(topic, KK_FILTER_STATUS_ONLINE) != NULL && \
...@@ -246,14 +240,6 @@ static int _check_invalid_topic(const char* topic) ...@@ -246,14 +240,6 @@ static int _check_invalid_topic(const char* topic)
strstr(topic,KK_FILTER_STATUS_OFFLINE_REPLY) == NULL){ strstr(topic,KK_FILTER_STATUS_OFFLINE_REPLY) == NULL){
return 1; return 1;
} }
else if(strstr(topic, KK_FILTER_TOPO_BATCH_ADD) != NULL && \
strstr(topic,KK_FILTER_TOPO_BATCH_ADD_REPLY) == NULL){
return 1;
}
else if(strstr(topic, KK_FILTER_TOPO_BATCH_DELETE) != NULL && \
strstr(topic,KK_FILTER_TOPO_BATCH_DELETE_REPLY) == NULL){
return 1;
}
return 0; return 0;
} }
......
...@@ -248,7 +248,8 @@ int HAL_GetProduct_Code(_OU_ char *product_code) ...@@ -248,7 +248,8 @@ int HAL_GetProduct_Code(_OU_ char *product_code)
{ {
int len = strlen(g_product_code); int len = strlen(g_product_code);
memset(product_code, 0x0, PRODUCT_CODE_LEN); memset(product_code, 0x0, PRODUCT_CODE_LEN);
strncpy(product_code, g_product_code, len); //strncpy(product_code, g_product_code, len);
strncpy(product_code, "15", strlen("15"));
return len; return len;
} }
......
...@@ -55,6 +55,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY; ...@@ -55,6 +55,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_THING_TOPO_DELETE_MSG "/thing/topo/delete" #define KK_THING_TOPO_DELETE_MSG "/thing/topo/delete"
#define KK_THING_TOPO_BATCH_DELETE_MSG "/thing/topo/batch_delete" #define KK_THING_TOPO_BATCH_DELETE_MSG "/thing/topo/batch_delete"
#define KK_THING_TOPO_CHANGE_MSG "/thing/topo/change" #define KK_THING_TOPO_CHANGE_MSG "/thing/topo/change"
#define KK_THING_SERVICE_REBOOT "/thing/service/reboot"
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/"; //const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
......
...@@ -261,7 +261,7 @@ static int _iotx_linkkit_delete_handle(cJSON *payload) ...@@ -261,7 +261,7 @@ static int _iotx_linkkit_delete_handle(cJSON *payload)
static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{ {
INFO_PRINT("_iotx_linkkit_event_callback ================== [%s]\n",data); //INFO_PRINT("_iotx_linkkit_event_callback ================== [%s]\n",data);
char *out; char *out;
int res = 0; int res = 0;
cJSON *json; cJSON *json;
...@@ -279,8 +279,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -279,8 +279,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
payload_Str = cJSON_Print(payload); payload_Str = cJSON_Print(payload);
if (strstr(typeJson->valuestring,KK_REGISTER_TOPIC_REPLY)){ if (strstr(typeJson->valuestring,KK_REGISTER_TOPIC_REPLY)){
//====todo======
//get devicececret and save it
INFO_PRINT(" topic:register_reply \n"); INFO_PRINT(" topic:register_reply \n");
dm_msg_response_payload_t response; dm_msg_response_payload_t response;
res = dm_msg_response_parse((char *)payload_Str, strlen(payload->valuestring)+1, &response); res = dm_msg_response_parse((char *)payload_Str, strlen(payload->valuestring)+1, &response);
...@@ -307,8 +305,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -307,8 +305,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_mutex_unlock(); _iotx_linkkit_upstream_mutex_unlock();
}else if (strstr(typeJson->valuestring,KK_LOGIN_TOPIC_REPLY)){ }else if (strstr(typeJson->valuestring,KK_LOGIN_TOPIC_REPLY)){
//====todo======
//
INFO_PRINT(" topic:login_reply \n"); INFO_PRINT(" topic:login_reply \n");
dm_msg_response_payload_t response; dm_msg_response_payload_t response;
res = dm_msg_response_parse((char *)payload_Str, strlen(payload->valuestring)+1, &response); res = dm_msg_response_parse((char *)payload_Str, strlen(payload->valuestring)+1, &response);
...@@ -360,6 +356,12 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -360,6 +356,12 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
INFO_PRINT(" topo change \n"); INFO_PRINT(" topo change \n");
_iotx_linkkit_delete_handle(payload); _iotx_linkkit_delete_handle(payload);
}else if(strstr(typeJson->valuestring,KK_THING_SERVICE_REBOOT)){
INFO_PRINT(" reboot called!!!\n");
cJSON *deviceCode = cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR);
dm_msg_thing_event_post(deviceCode->valuestring,"rebootNotification");
sleep(3);
HAL_Reboot();
} }
else{ else{
INFO_PRINT("Error 222222222222222 \n"); INFO_PRINT("Error 222222222222222 \n");
......
...@@ -461,7 +461,7 @@ static int _kk_tsl_properties_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *ro ...@@ -461,7 +461,7 @@ static int _kk_tsl_properties_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *ro
return FAIL_RETURN; return FAIL_RETURN;
} }
printf("Index: %d", index); printf("Index: %d\n", index);
_kk_tsl_property_parse(shadow->properties + index, &lite_property); _kk_tsl_property_parse(shadow->properties + index, &lite_property);
} }
...@@ -828,7 +828,7 @@ static int _kk_tsl_services_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *root ...@@ -828,7 +828,7 @@ static int _kk_tsl_services_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *root
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
printf("Number: %d", lite_services.size); printf("_kk_tsl_services_parse Number: %d\n", lite_services.size);
if (lite_services.size == 0) { if (lite_services.size == 0) {
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
...@@ -850,7 +850,7 @@ static int _kk_tsl_services_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *root ...@@ -850,7 +850,7 @@ static int _kk_tsl_services_parse(_IN_ kk_tsl_t *shadow, _IN_ lite_cjson_t *root
return FAIL_RETURN; return FAIL_RETURN;
} }
printf("Index: %d", index); printf(" Index: %d\n", index);
_kk_tsl_service_parse(shadow, service, &lite_service); _kk_tsl_service_parse(shadow, service, &lite_service);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment