Commit d59b0f9c authored by chen.weican's avatar chen.weican

【修改内容】调整msgType采用字串格式,统一业务API接口

【提交人】陈伟灿
parent c02ee8a2
...@@ -18,24 +18,9 @@ ...@@ -18,24 +18,9 @@
#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_TOPIC "/thing/event/property/post"
#define KK_FILTER_EVENT_POST_REPLY "/thing/event/property/post_reply" #define KK_FILTER_EVENT_POST_REPLY "/thing/event/property/post_reply"
const char DM_MSG_TO_MIDDWARE[] = "{\"msgtype\":\"%d\",\"productType\":\"%s\",\"deviceCode\":\"%s\"}"; const char DM_MSG_TO_MIDDWARE[] = "{\"msgtype\":\"%s\",\"productType\":\"%s\",\"productCode\":\"%s\",\"deviceCode\":\"%s\"}";
#define KK_TOPIC_SERVICE_DELIMITER '/' #define KK_TOPIC_SERVICE_DELIMITER '/'
typedef struct{
char *str;
kk_msg_type_t type;
}kk_topic_type_map_t;
kk_topic_type_map_t g_type_map[] = {
{"register_reply",MSG_REGISTER_REPLY},
{"add_reply",MSG_TOPOADD_REPLY},
{"login_reply",MSG_LOGIN_REPLY},
{"offline_reply",MSG_OFFLINE_REPLY},
{"/ota/device/upgrade",MSG_OTA_UPGRADE},
{"thing/service/property/set",MSG_PROPERTYSET},
};
int _kk_sendto_cloud(cJSON *root) int _kk_sendto_cloud(cJSON *root)
{ {
cJSON *info,*pData; cJSON *info,*pData;
...@@ -51,6 +36,7 @@ int _kk_sendto_cloud(cJSON *root) ...@@ -51,6 +36,7 @@ int _kk_sendto_cloud(cJSON *root)
} }
pData = cJSON_GetObjectItem(root, MSG_PAYLOAD_STR); pData = cJSON_GetObjectItem(root, MSG_PAYLOAD_STR);
if(pData == NULL){ if(pData == NULL){
free(topic);
return -1; return -1;
} }
INFO_PRINT("[%s][%d] payload:%s\n",__FUNCTION__,__LINE__,pData->valuestring); INFO_PRINT("[%s][%d] payload:%s\n",__FUNCTION__,__LINE__,pData->valuestring);
...@@ -108,25 +94,40 @@ static int _check_invalid_topic(const char* topic) ...@@ -108,25 +94,40 @@ static int _check_invalid_topic(const char* topic)
} }
return 0; return 0;
} }
static kk_msg_type_t _kk_parse_type(const char *topic)
static int _kk_topic_parse_msgType(_IN_ char *topic, _IN_ int start_deli,_OU_ char **msgTypeStr)
{ {
int num = 0,idx = 0; int res = 0, start = 0, len = 0, slice = 0;
if(topic == NULL){ char *msgTypeStr_tmp = NULL;
return MSG_INVALID;
if (topic == NULL) {
return -1;
} }
num = sizeof(g_type_map)/sizeof(kk_topic_type_map_t); res = kk_utils_memtok(topic, strlen(topic), KK_TOPIC_SERVICE_DELIMITER, start_deli, &start);
for(idx = 0; idx < num; idx++){ if (res != 0) {
if(strstr(topic,g_type_map[idx].str) != NULL){ return -1;
return g_type_map[idx].type;
} }
len = strlen(topic) - start + 1;
msgTypeStr_tmp = (char*)malloc(len+1);
if(msgTypeStr_tmp == NULL){
ERROR_PRINT("[%s][%d]malloc fail!!!\n",__FUNCTION__,__LINE__);
return -1;
} }
return MSG_INVALID; memcpy(msgTypeStr_tmp, topic + start, len);
*msgTypeStr = msgTypeStr_tmp;
INFO_PRINT("[%s][%d]%s\n",__FUNCTION__,__LINE__,*msgTypeStr);
/* dm_log_debug("URI Product Key: %.*s, Device Name: %.*s", slice - start - 1, uri + start + 1, end - slice - 1,
uri + slice + 1); */
return 0;
} }
static int _kk_topic_parse_pkdn(_IN_ char *topic, _IN_ int start_deli, _IN_ int end_deli, static int _kk_topic_parse_pkdn(_IN_ char *topic, _IN_ int start_deli,
_OU_ char productType[PRODUCT_TYPE_LEN], _OU_ char deviceCode[DEVICE_CODE_LEN]) _OU_ char productType[PRODUCT_TYPE_LEN], _OU_ char productCode[PRODUCT_CODE_LEN],_OU_ char deviceCode[DEVICE_CODE_LEN])
{ {
int res = 0, start = 0, end = 0, slice = 0; int res = 0, start = 0, end = 0, slice = 0,slice1 = 0;
if (topic == NULL || productType == NULL || deviceCode == NULL) { if (topic == NULL || productType == NULL || deviceCode == NULL) {
return -1; return -1;
...@@ -139,16 +140,18 @@ static int _kk_topic_parse_pkdn(_IN_ char *topic, _IN_ int start_deli, _IN_ int ...@@ -139,16 +140,18 @@ static int _kk_topic_parse_pkdn(_IN_ char *topic, _IN_ int start_deli, _IN_ int
if (res != 0) { if (res != 0) {
return -1; return -1;
} }
res = kk_utils_memtok(topic, strlen(topic), KK_TOPIC_SERVICE_DELIMITER, end_deli, &end); res = kk_utils_memtok(topic, strlen(topic), KK_TOPIC_SERVICE_DELIMITER, start_deli + 2, &slice1);
if (res != 0) {
return -1;
}
res = kk_utils_memtok(topic, strlen(topic), KK_TOPIC_SERVICE_DELIMITER, start_deli + 3, &end);
if (res != 0) { if (res != 0) {
return -1; return -1;
} }
/* dm_log_debug("URI Product Key: %.*s, Device Name: %.*s", slice - start - 1, uri + start + 1, end - slice - 1,
uri + slice + 1); */
memcpy(productType, topic + start + 1, slice - start - 1); memcpy(productType, topic + start + 1, slice - start - 1);
memcpy(deviceCode, topic + slice + 1, end - slice - 1); memcpy(productCode, topic + slice + 1, slice1 - slice - 1);
memcpy(deviceCode, topic + slice1 + 1, end - slice1 - 1);
return 0; return 0;
} }
...@@ -160,30 +163,29 @@ static char * _kk_data_create(const char *topic,const char *data) ...@@ -160,30 +163,29 @@ static char * _kk_data_create(const char *topic,const char *data)
char *infoStr = NULL; char *infoStr = NULL;
int infoStr_len = 0; int infoStr_len = 0;
int res = 0; int res = 0;
char product_key[PRODUCT_TYPE_LEN] = {0}; char productType[PRODUCT_TYPE_LEN] = {0};
char device_name[DEVICE_CODE_LEN] = {0}; char productCode[PRODUCT_CODE_LEN] = {0};
kk_msg_type_t type; char deviceCode[DEVICE_CODE_LEN] = {0};
type = _kk_parse_type(topic); char * msgStr = NULL;
if(type == MSG_INVALID){
ERROR_PRINT("[%s][%d]\n",__FUNCTION__,__LINE__); res =_kk_topic_parse_pkdn((char *)topic,2, productType,productCode,deviceCode);
return NULL; res|=_kk_topic_parse_msgType((char *)topic,5,&msgStr);
} infoStr_len = strlen(DM_MSG_TO_MIDDWARE)+strlen(productType)+strlen(productCode)+strlen(deviceCode)+strlen(msgStr)+10;
res =_kk_topic_parse_pkdn((char *)topic,2,4, product_key,device_name);
infoStr_len = strlen(DM_MSG_TO_MIDDWARE)+strlen(product_key)+strlen(device_name)+10;
infoStr = malloc(infoStr_len); infoStr = malloc(infoStr_len);
if(infoStr == NULL){ if(infoStr == NULL){
ERROR_PRINT("[%s][%d]\n",__FUNCTION__,__LINE__); ERROR_PRINT("[%s][%d]\n",__FUNCTION__,__LINE__);
free(msgStr);
return NULL; return NULL;
} }
memset(infoStr,0x0,infoStr_len); memset(infoStr,0x0,infoStr_len);
snprintf(infoStr,infoStr_len,DM_MSG_TO_MIDDWARE,type,product_key,device_name); snprintf(infoStr,infoStr_len,DM_MSG_TO_MIDDWARE,msgStr,productType,productCode,deviceCode);
root=cJSON_CreateObject(); root=cJSON_CreateObject();
cJSON_AddStringToObject(root,MSG_INFO_STR,infoStr); cJSON_AddStringToObject(root,MSG_INFO_STR,infoStr);
cJSON_AddStringToObject(root,MSG_PAYLOAD_STR,data); cJSON_AddStringToObject(root,MSG_PAYLOAD_STR,data);
out=cJSON_Print(root); out=cJSON_Print(root);
cJSON_Delete(root); cJSON_Delete(root);
free(msgStr);
free(infoStr); free(infoStr);
INFO_PRINT("[%s][%d]%s\n",__FUNCTION__,__LINE__,out); INFO_PRINT("[%s][%d]%s\n",__FUNCTION__,__LINE__,out);
return out; return out;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
const char KK_URI_SYS_PREFIX[] = "/sys/kk/%s/%s/#"; const char KK_URI_SYS_PREFIX[] = "/sys/kk/%s/%s/#";
const char KK_URI_SYS_PREFIX_EX[] = "/sys/kk/%s/%s/"; const char KK_URI_SYS_PREFIX_EX[] = "/sys/kk/%s/%s";
const char DM_URI_THING_SUB_REGISTER[] = "thing/sub/register"; const char DM_URI_THING_SUB_REGISTER[] = "thing/sub/register";
const char DM_URI_THING_SUB_UNREGISTER[] = "thing/sub/unregister"; const char DM_URI_THING_SUB_UNREGISTER[] = "thing/sub/unregister";
const char DM_URI_THING_TOPO_ADD[] = "thing/topo/add"; const char DM_URI_THING_TOPO_ADD[] = "thing/topo/add";
...@@ -130,27 +130,21 @@ static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code, ...@@ -130,27 +130,21 @@ static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code,
return 0; return 0;
} }
static int _kk_utils_topic_ota(_IN_ int type ,_IN_ char *product_code, _IN_ char *device_code, _OU_ char **topic) static int _kk_utils_topic_ota(_IN_ char* str, _OU_ char **topic)
{ {
int service_name_len = 0; int service_name_len = 0;
int *pstr_uri = NULL; int *pstr_uri = NULL;
if (product_code == NULL || device_code == NULL || if (str == NULL ||topic == NULL || *topic != NULL) {
topic == NULL || *topic != NULL) {
return -1; return -1;
} }
if(type = 0){
pstr_uri = KK_URI_OTA_PROCESS; service_name_len = strlen(str)+1;
}
else if(type = 1){
pstr_uri = KK_URI_OTA_INFORM;
}
service_name_len = strlen(pstr_uri) + strlen(product_code) + strlen(device_code)+1;
*topic = malloc(service_name_len); *topic = malloc(service_name_len);
if (*topic == NULL) { if (*topic == NULL) {
return -1; return -1;
} }
memset(*topic, 0, service_name_len); memset(*topic, 0, service_name_len);
snprintf(*topic, service_name_len, pstr_uri, product_code, device_code); memcpy(*topic,str,service_name_len);
return 0; return 0;
} }
...@@ -158,7 +152,6 @@ static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code, ...@@ -158,7 +152,6 @@ static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code,
char* KK_Make_Topic(cJSON *info) char* KK_Make_Topic(cJSON *info)
{ {
cJSON *type,*product_code,*device_code,*root; cJSON *type,*product_code,*device_code,*root;
kk_msg_type_t msgtype;
char *topic = NULL; char *topic = NULL;
root=cJSON_Parse((char*)info->valuestring); root=cJSON_Parse((char*)info->valuestring);
...@@ -174,7 +167,14 @@ char* KK_Make_Topic(cJSON *info) ...@@ -174,7 +167,14 @@ char* KK_Make_Topic(cJSON *info)
if(device_code == NULL){ if(device_code == NULL){
goto errorreturn; goto errorreturn;
} }
msgtype = atoi(type->valuestring); if(strstr(type->valuestring,"/ota/device/inform")){
_kk_utils_topic_ota(type->valuestring,&topic);
}
else{
_kk_utils_topic(type->valuestring,product_code->valuestring,device_code->valuestring,&topic);
}
#if 0
switch(msgtype) switch(msgtype)
{ {
case MSG_REGISTER: case MSG_REGISTER:
...@@ -255,6 +255,7 @@ char* KK_Make_Topic(cJSON *info) ...@@ -255,6 +255,7 @@ char* KK_Make_Topic(cJSON *info)
break; break;
} }
#endif
INFO_PRINT("[%s][%d] TOPIC:%s\n",__FUNCTION__,__LINE__,topic); INFO_PRINT("[%s][%d] TOPIC:%s\n",__FUNCTION__,__LINE__,topic);
cJSON_Delete(root); cJSON_Delete(root);
return topic; return topic;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "dm_ota.h" #include "dm_ota.h"
#include "cJSON.h" #include "cJSON.h"
#include "kk_dm_api.h" #include "kk_dm_api.h"
#include "kk_dm_msg.h"
#include "com_api.h" #include "com_api.h"
...@@ -191,7 +193,7 @@ void dm_ota_handle(void *data){ ...@@ -191,7 +193,7 @@ void dm_ota_handle(void *data){
payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR); payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR);
printf(" payload= %s \n",payload->valuestring ); printf(" payload= %s \n",payload->valuestring );
if (atoi(typeJson->valuestring) == MSG_OTA_UPGRADE){ if (strstr(typeJson->valuestring,KK_THING_OTA_DEVICE_UPGRADE)){
char buf[128] = {0}; char buf[128] = {0};
int len = 128; int len = 128;
if (dm_ota_check(payload->valuestring, strlen(payload->valuestring)+1, IOTX_OTA_TOPIC_TYPE_DEVICE_UPGRATE) == 0){ if (dm_ota_check(payload->valuestring, strlen(payload->valuestring)+1, IOTX_OTA_TOPIC_TYPE_DEVICE_UPGRATE) == 0){
......
...@@ -398,11 +398,11 @@ int dm_mgr_deinit(void) ...@@ -398,11 +398,11 @@ int dm_mgr_deinit(void)
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
const char DM_URI_THING_EVENT_POST[] = "/thing/event/%.*s/post";
const char DM_MSG_THING_UPSTREAM_REQUEST_PARAMS[] DM_READ_ONLY = const char DM_MSG_THING_UPSTREAM_REQUEST_PARAMS[] DM_READ_ONLY =
"{\"value\":%s,\"timestamp\":\"%s\"}"; "{\"value\":%s,\"timestamp\":\"%s\"}";
static int _dm_mgr_upstream_request_assemble(_IN_ int msgid, _IN_ int devid, static int _dm_mgr_upstream_request_assemble(_IN_ int msgid, _IN_ int devid,
_IN_ int msgtype, _IN_ char *identify, _IN_ char *identify,
_IN_ char *params, _IN_ int params_len, _IN_ char *method, _OU_ dm_msg_request_t *request) _IN_ char *params, _IN_ int params_len, _IN_ char *method, _OU_ dm_msg_request_t *request)
{ {
int res = 0; int res = 0;
...@@ -430,12 +430,11 @@ static int _dm_mgr_upstream_request_assemble(_IN_ int msgid, _IN_ int devid, ...@@ -430,12 +430,11 @@ static int _dm_mgr_upstream_request_assemble(_IN_ int msgid, _IN_ int devid,
request->msgid = msgid; request->msgid = msgid;
request->devid = devid; request->devid = devid;
request->msgtype = msgtype; request->msgTypeStr = malloc(strlen(DM_URI_THING_EVENT_POST) + strlen(identify) + 1);
memset(request->identity,0x0,sizeof(request->identity)); if(request->msgTypeStr == NULL){
if(strlen(identify) < IDENTIFY_MAXLEN) return MEMORY_NOT_ENOUGH;
{
memcpy(request->identity,identify,strlen(identify));
} }
sprintf(request->msgTypeStr,DM_URI_THING_EVENT_POST,identify);
memcpy(request->productType, node->productType, strlen(node->productType)); memcpy(request->productType, node->productType, strlen(node->productType));
memcpy(request->productCode, node->productCode, strlen(node->productCode)); memcpy(request->productCode, node->productCode, strlen(node->productCode));
memcpy(request->deviceCode, node->deviceCode, strlen(node->deviceCode)); memcpy(request->deviceCode, node->deviceCode, strlen(node->deviceCode));
...@@ -462,7 +461,7 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_ ...@@ -462,7 +461,7 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
res = _dm_mgr_upstream_request_assemble(iotx_report_id(), devid, MSG_PROPERTYPOST, "", res = _dm_mgr_upstream_request_assemble(iotx_report_id(), devid, "property",
payload, payload_len, DM_URI_THING_EVENT_PROPERTY_POST_METHOD, &request); payload, payload_len, DM_URI_THING_EVENT_PROPERTY_POST_METHOD, &request);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
return FAIL_RETURN; return FAIL_RETURN;
...@@ -473,6 +472,7 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_ ...@@ -473,6 +472,7 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_
/* Send Message To Cloud */ /* Send Message To Cloud */
res = dm_msg_request(&request); res = dm_msg_request(&request);
free(request.msgTypeStr);
free(request.params); free(request.params);
return res; return res;
} }
...@@ -488,7 +488,7 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_ ...@@ -488,7 +488,7 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
res = _dm_mgr_upstream_request_assemble(iotx_report_id(), devid,MSG_EVENTPOST,identifier, res = _dm_mgr_upstream_request_assemble(iotx_report_id(), devid,identifier,
payload, payload_len, method, &request); payload, payload_len, method, &request);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
return FAIL_RETURN; return FAIL_RETURN;
...@@ -499,12 +499,13 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_ ...@@ -499,12 +499,13 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_
/* Send Message To Cloud */ /* Send Message To Cloud */
res = dm_msg_request(&request); res = dm_msg_request(&request);
free(request.msgTypeStr);
free(request.params);
return res; return res;
} }
const char DM_URI_THING_SERVICE_RESPONSE[] = "/thing/service/%.*s_reply";
static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid, _IN_ int msgid_len, static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid, _IN_ int msgid_len,
_IN_ int msgtype,
_IN_ const char *identfy, _IN_ int code, _OU_ kk_msg_request_payload_t *request, _OU_ kk_msg_response_t *response) _IN_ const char *identfy, _IN_ int code, _OU_ kk_msg_request_payload_t *request, _OU_ kk_msg_response_t *response)
{ {
int res = 0; int res = 0;
...@@ -518,11 +519,11 @@ static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid, ...@@ -518,11 +519,11 @@ static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid,
request->id.value = msgid; request->id.value = msgid;
request->id.value_length = msgid_len; request->id.value_length = msgid_len;
response->msgtype = msgtype; response->msgTypeStr = malloc(strlen(DM_URI_THING_SERVICE_RESPONSE) + strlen(identfy) + 1);
if(strlen(identfy) < IDENTIFY_MAXLEN) if(response->msgTypeStr == NULL){
{ return MEMORY_NOT_ENOUGH;
memcpy(response->identity,identfy,strlen(identfy));
} }
sprintf(response->msgTypeStr,DM_URI_THING_SERVICE_RESPONSE,identfy);
memcpy(response->productType, node->productType, strlen(node->productType)); memcpy(response->productType, node->productType, strlen(node->productType));
memcpy(response->productCode, node->productCode, strlen(node->productCode)); memcpy(response->productCode, node->productCode, strlen(node->productCode));
memcpy(response->deviceCode, node->deviceCode, strlen(node->deviceCode)); memcpy(response->deviceCode, node->deviceCode, strlen(node->deviceCode));
...@@ -557,7 +558,7 @@ int dm_mgr_deprecated_upstream_thing_service_response(_IN_ int devid, _IN_ int m ...@@ -557,7 +558,7 @@ int dm_mgr_deprecated_upstream_thing_service_response(_IN_ int devid, _IN_ int m
/* Service Name */ /* Service Name */
res = _kk_mgr_upstream_response_assemble(devid, msgid_str, strlen(msgid_str), MSG_SERVICERESPONSE, identifier, code, res = _kk_mgr_upstream_response_assemble(devid, msgid_str, strlen(msgid_str), identifier, code,
&request, &request,
&response); &response);
if (res != SUCCESS_RETURN) { if (res != SUCCESS_RETURN) {
...@@ -566,11 +567,12 @@ int dm_mgr_deprecated_upstream_thing_service_response(_IN_ int devid, _IN_ int m ...@@ -566,11 +567,12 @@ int dm_mgr_deprecated_upstream_thing_service_response(_IN_ int devid, _IN_ int m
dm_msg_response(&request, &response, payload, payload_len, NULL); dm_msg_response(&request, &response, payload, payload_len, NULL);
free(response.msgTypeStr);
free(msgid_str); free(msgid_str);
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
const char DM_URI_THING_SUB_REGISTER[] = "/thing/sub/register";
int dm_mgr_upstream_thing_sub_register(_IN_ int devid) int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
{ {
int res = 0; int res = 0;
...@@ -594,8 +596,7 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid) ...@@ -594,8 +596,7 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
return FAIL_RETURN; return FAIL_RETURN;
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_REGISTER; request.msgTypeStr = DM_URI_THING_SUB_REGISTER;
memcpy(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode)); memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
...@@ -624,6 +625,7 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid) ...@@ -624,6 +625,7 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
return res; return res;
} }
const char DM_URI_THING_SUB_UNREGISTER[] = "/thing/sub/unregister";
int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid) int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
{ {
int res = 0; int res = 0;
...@@ -646,8 +648,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid) ...@@ -646,8 +648,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_UNREGISTER; request.msgTypeStr = DM_URI_THING_SUB_UNREGISTER;
memset(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode)); memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
...@@ -680,6 +681,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid) ...@@ -680,6 +681,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
return res; return res;
} }
const char DM_URI_THING_TOPO_ADD[] = "/thing/topo/add";
int dm_mgr_upstream_thing_topo_add(_IN_ int devid) int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
{ {
int res = 0; int res = 0;
...@@ -702,8 +704,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid) ...@@ -702,8 +704,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_TOPOADD; request.msgTypeStr = DM_URI_THING_TOPO_ADD;
memcpy(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode)); memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
...@@ -736,6 +737,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid) ...@@ -736,6 +737,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
return res; return res;
} }
const char DM_URI_THING_TOPO_DELETE[] = "/thing/topo/delete";
int dm_mgr_upstream_thing_topo_delete(_IN_ int devid) int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
{ {
int res = 0; int res = 0;
...@@ -759,7 +761,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid) ...@@ -759,7 +761,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_TOPODELETE; request.msgTypeStr = DM_URI_THING_TOPO_DELETE;
memcpy(request.identity,"",strlen("")); memcpy(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
...@@ -794,6 +796,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid) ...@@ -794,6 +796,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
return res; return res;
} }
const char DM_URI_THING_TOPO_GET[] = "/thing/topo/get";
int dm_mgr_upstream_thing_topo_get(void) int dm_mgr_upstream_thing_topo_get(void)
{ {
int res = 0; int res = 0;
...@@ -802,8 +805,7 @@ int dm_mgr_upstream_thing_topo_get(void) ...@@ -802,8 +805,7 @@ int dm_mgr_upstream_thing_topo_get(void)
dm_msg_request_t request; dm_msg_request_t request;
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_TOPOGET; request.msgTypeStr = DM_URI_THING_TOPO_GET;
memcpy(request.identity,"",strlen(""));
HAL_GetProduct_Type(request.productType); HAL_GetProduct_Type(request.productType);
HAL_GetProduct_Code(request.deviceCode); HAL_GetProduct_Code(request.deviceCode);
...@@ -837,6 +839,7 @@ int dm_mgr_upstream_thing_topo_get(void) ...@@ -837,6 +839,7 @@ int dm_mgr_upstream_thing_topo_get(void)
return res; return res;
} }
const char DM_URI_THING_LIST_FOUND[] = "/thing/list/found";
int dm_mgr_upstream_thing_list_found(_IN_ int devid) int dm_mgr_upstream_thing_list_found(_IN_ int devid)
{ {
...@@ -860,8 +863,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid) ...@@ -860,8 +863,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_LISTFOUND; request.msgTypeStr = DM_URI_THING_LIST_FOUND;
memcpy(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode)); memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
...@@ -892,7 +894,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid) ...@@ -892,7 +894,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
return res; return res;
} }
const char DM_URI_COMBINE_LOGIN[] = "/thing/combine/login";
int dm_mgr_upstream_combine_login(_IN_ int devid) int dm_mgr_upstream_combine_login(_IN_ int devid)
{ {
int res = 0; int res = 0;
...@@ -915,8 +917,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid) ...@@ -915,8 +917,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_LOGIN; request.msgTypeStr = DM_URI_COMBINE_LOGIN;
memcpy(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode)); memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
...@@ -948,7 +949,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid) ...@@ -948,7 +949,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
return res; return res;
} }
const char DM_URI_COMBINE_LOGOUT[] = "/thing/combine/logout";
int dm_mgr_upstream_combine_logout(_IN_ int devid) int dm_mgr_upstream_combine_logout(_IN_ int devid)
{ {
int res = 0; int res = 0;
...@@ -971,8 +972,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid) ...@@ -971,8 +972,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_LOGOUT; request.msgTypeStr = DM_URI_COMBINE_LOGOUT;
memcpy(request.identity,"",strlen(""));
memcpy(request.productType,gw_node->productType,strlen(gw_node->productType)); memcpy(request.productType,gw_node->productType,strlen(gw_node->productType));
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode)); memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode)); memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
...@@ -1006,6 +1006,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid) ...@@ -1006,6 +1006,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
return res; return res;
} }
const char KK_URI_OTA_INFORM[] = "/ota/device/inform/%s/%s";
int dm_mgr_ota_report_version(_IN_ int devid, char *version) int dm_mgr_ota_report_version(_IN_ int devid, char *version)
{ {
int res = 0; int res = 0;
...@@ -1022,8 +1023,11 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version) ...@@ -1022,8 +1023,11 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
} }
memset(&request, 0, sizeof(dm_msg_request_t)); memset(&request, 0, sizeof(dm_msg_request_t));
request.msgtype = MSG_OTA_INFORM; request.msgTypeStr = malloc(strlen(KK_URI_OTA_INFORM)+strlen(node->productCode)+strlen(node->deviceCode)+1);
memcpy(request.identity,"",strlen("")); if(request.msgTypeStr == NULL){
return MEMORY_NOT_ENOUGH;
}
sprintf(request.msgTypeStr,KK_URI_OTA_INFORM,node->productCode,node->deviceCode);
memcpy(request.productType, node->productType, PRODUCT_TYPE_MAXLEN); memcpy(request.productType, node->productType, PRODUCT_TYPE_MAXLEN);
memcpy(request.productCode, node->productCode, PRODUCT_CODE_MAXLEN); memcpy(request.productCode, node->productCode, PRODUCT_CODE_MAXLEN);
memcpy(request.deviceCode, node->deviceCode, DEVICE_CODE_MAXLEN); memcpy(request.deviceCode, node->deviceCode, DEVICE_CODE_MAXLEN);
...@@ -1052,6 +1056,7 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version) ...@@ -1052,6 +1056,7 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
res = request.msgid; res = request.msgid;
} }
free(request.params); free(request.params);
free(request.msgTypeStr);
return res; return res;
} }
......
...@@ -38,7 +38,7 @@ typedef struct { ...@@ -38,7 +38,7 @@ typedef struct {
int devid; int devid;
//const char *service_prefix; //const char *service_prefix;
//const char *service_name; //const char *service_name;
kk_msg_type_t msgtype; char *msgTypeStr;
char identity[IDENTIFY_MAXLEN]; char identity[IDENTIFY_MAXLEN];
char productType[PRODUCT_TYPE_MAXLEN]; char productType[PRODUCT_TYPE_MAXLEN];
char productCode[PRODUCT_CODE_MAXLEN]; char productCode[PRODUCT_CODE_MAXLEN];
...@@ -49,8 +49,7 @@ typedef struct { ...@@ -49,8 +49,7 @@ typedef struct {
//iotx_cm_data_handle_cb callback; //iotx_cm_data_handle_cb callback;
} dm_msg_request_t; } dm_msg_request_t;
typedef struct { typedef struct {
kk_msg_type_t msgtype; char *msgTypeStr;
char identity[IDENTIFY_MAXLEN];
char productType[PRODUCT_TYPE_MAXLEN]; char productType[PRODUCT_TYPE_MAXLEN];
char productCode[PRODUCT_CODE_MAXLEN]; char productCode[PRODUCT_CODE_MAXLEN];
char deviceCode[DEVICE_CODE_MAXLEN]; char deviceCode[DEVICE_CODE_MAXLEN];
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%d\",\"version\":\"%s\",\"params\":%.*s,\"method\":\"%s\"}"; const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%d\",\"version\":\"%s\",\"params\":%.*s,\"method\":\"%s\"}";
const char DM_MSG_INFO[] DM_READ_ONLY = "{\"msgtype\":\"%d\",\"productType\":\"%s\",\"productCode\":\"%s\",\"deviceCode\":\"%s\",\"identifier\":\"%s\"}"; const char DM_MSG_INFO[] DM_READ_ONLY = "{\"msgtype\":\"%s\",\"productType\":\"%s\",\"productCode\":\"%s\",\"deviceCode\":\"%s\"}";
void kk_sendData2app(void *info, void *payload){ void kk_sendData2app(void *info, void *payload){
cJSON *root=cJSON_CreateObject(); cJSON *root=cJSON_CreateObject();
...@@ -438,15 +438,15 @@ int dm_msg_request (_IN_ dm_msg_request_t *request) ...@@ -438,15 +438,15 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
snprintf(payload, payload_len, DM_MSG_REQUEST, request->msgid, snprintf(payload, payload_len, DM_MSG_REQUEST, request->msgid,
DM_MSG_VERSION, request->params_len, request->params, request->method); DM_MSG_VERSION, request->params_len, request->params, request->method);
req_info_len = strlen(DM_MSG_INFO)+10+strlen(request->productType)+strlen(request->productCode)+strlen(request->deviceCode)+strlen(request->identity)+1; req_info_len = strlen(DM_MSG_INFO)+10+strlen(request->productType)+strlen(request->productCode)+strlen(request->deviceCode)+strlen(request->msgTypeStr)+1;
req_info = malloc(req_info_len); req_info = malloc(req_info_len);
if (req_info == NULL) { if (req_info == NULL) {
free(payload); free(payload);
return MEMORY_NOT_ENOUGH; return MEMORY_NOT_ENOUGH;
} }
memset(req_info, 0, req_info_len); memset(req_info, 0, req_info_len);
snprintf(req_info, req_info_len, DM_MSG_INFO, request->msgtype, snprintf(req_info, req_info_len, DM_MSG_INFO, request->msgTypeStr,
request->productType, request->productCode, request->deviceCode,request->identity); request->productType, request->productCode, request->deviceCode);
memset(&lite, 0, sizeof(lite_cjson_t)); memset(&lite, 0, sizeof(lite_cjson_t));
res = lite_cjson_parse(payload, payload_len, &lite); res = lite_cjson_parse(payload, payload_len, &lite);
...@@ -500,7 +500,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response ...@@ -500,7 +500,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
snprintf(payload, payload_len, DM_MSG_RESPONSE_WITH_DATA, snprintf(payload, payload_len, DM_MSG_RESPONSE_WITH_DATA,
request->id.value_length, request->id.value, response->code, data_len, data); request->id.value_length, request->id.value, response->code, data_len, data);
res_info_len = strlen(DM_MSG_INFO)+10+strlen(response->productType)+strlen(response->deviceCode)+strlen(response->identity)+1; res_info_len = strlen(DM_MSG_INFO)+10+strlen(response->productType)+strlen(response->productCode)+strlen(response->deviceCode)+strlen(response->msgTypeStr)+1;
res_info = malloc(res_info_len); res_info = malloc(res_info_len);
if (res_info == NULL) { if (res_info == NULL) {
free(payload); free(payload);
...@@ -508,8 +508,8 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response ...@@ -508,8 +508,8 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
} }
memset(res_info, 0, res_info_len); memset(res_info, 0, res_info_len);
snprintf(res_info, res_info_len, DM_MSG_INFO, response->msgtype, snprintf(res_info, res_info_len, DM_MSG_INFO, response->msgTypeStr,
response->productType, response->deviceCode,response->identity); response->productType,response->productCode, response->deviceCode);
memset(&lite, 0, sizeof(lite_cjson_t)); memset(&lite, 0, sizeof(lite_cjson_t));
...@@ -597,19 +597,21 @@ static int dm_msg_request_parse(_IN_ char *payload, _IN_ int payload_len, _OU_ k ...@@ -597,19 +597,21 @@ static int dm_msg_request_parse(_IN_ char *payload, _IN_ int payload_len, _OU_ k
return SUCCESS_RETURN; return SUCCESS_RETURN;
} }
const char DM_URI_THING_SERVICE_PROPERTY_SET_REPLY[] = "/thing/service/property/set_reply";
int dm_msg_thing_property_set_reply(char productType[PRODUCT_TYPE_MAXLEN], char deviceCode[DEVICE_CODE_MAXLEN],char *payload, unsigned int payload_len, int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *payload, unsigned int payload_len,
void *context){ void *context){
kk_msg_request_payload_t request; kk_msg_request_payload_t request;
kk_msg_response_t response; kk_msg_response_t response;
dm_mgr_dev_node_t *node = NULL;
int res = 0, devid = 0; int res = 0, devid = 0;
memset(&request, 0, sizeof(kk_msg_request_payload_t)); memset(&request, 0, sizeof(kk_msg_request_payload_t));
memset(&response, 0, sizeof(kk_msg_response_t)); memset(&response, 0, sizeof(kk_msg_response_t));
res = dm_mgr_search_device_by_pkdn(productType, deviceCode, &devid); res = dm_mgr_get_device_by_mac(deviceCode, &node);
if (res < SUCCESS_RETURN) { if (res < SUCCESS_RETURN) {
ERROR_PRINT("dm_mgr_search_device_by_pkdn failed"); ERROR_PRINT("dm_mgr_search_device_by_pkdn failed");
return res; return res;
...@@ -620,13 +622,13 @@ int dm_msg_thing_property_set_reply(char productType[PRODUCT_TYPE_MAXLEN], char ...@@ -620,13 +622,13 @@ int dm_msg_thing_property_set_reply(char productType[PRODUCT_TYPE_MAXLEN], char
return res ; return res ;
} }
/* Response */ response.msgTypeStr = DM_URI_THING_SERVICE_PROPERTY_SET_REPLY;
response.msgtype = MSG_SETREPLY; memcpy(response.productType, node->productType, strlen( node->productType));
memset(response.identity,"",strlen("")); memcpy(response.productCode, node->productCode, strlen( node->productCode));
memcpy(response.productType, productType, strlen(productType)); memcpy(response.deviceCode, node->deviceCode, strlen(node->deviceCode));
memcpy(response.deviceCode, deviceCode, strlen(deviceCode));
response.code = (res == SUCCESS_RETURN) ? (IOTX_DM_ERR_CODE_SUCCESS) : (IOTX_DM_ERR_CODE_REQUEST_ERROR); response.code = (res == SUCCESS_RETURN) ? (IOTX_DM_ERR_CODE_SUCCESS) : (IOTX_DM_ERR_CODE_REQUEST_ERROR);
dm_msg_response(&request, &response, "{}", strlen("{}"), NULL); dm_msg_response(&request, &response, "{}", strlen("{}"), NULL);
return SUCCESS_RETURN;
} }
...@@ -41,6 +41,13 @@ typedef struct { ...@@ -41,6 +41,13 @@ typedef struct {
#define DM_MSG_VERSION "1.0" #define DM_MSG_VERSION "1.0"
const char DM_MSG_INFO[] DM_READ_ONLY; const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_REGISTER_TOPIC_REPLY "/thing/sub/register_reply"
#define KK_ADD_TOPIC_REPLY "/thing/topo/add_reply"
#define KK_LOGIN_TOPIC_REPLY "/thing/combine/login_reply"
#define KK_THING_SERVICE_PROPERTY_SET "/thing/service/property/set"
#define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade"
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/"; //const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
......
...@@ -231,7 +231,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -231,7 +231,6 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
cJSON *json; cJSON *json;
cJSON *info_root,*info; cJSON *info_root,*info;
cJSON *payload,*typeJson; cJSON *payload,*typeJson;
kk_msg_type_t msgType;
json=cJSON_Parse(data); json=cJSON_Parse(data);
if (json == NULL) { if (json == NULL) {
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse"); WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
...@@ -241,9 +240,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -241,9 +240,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
info = cJSON_Parse(info_root->valuestring); info = cJSON_Parse(info_root->valuestring);
typeJson = cJSON_GetObjectItem(info, MSG_TYPE_STR); typeJson = cJSON_GetObjectItem(info, MSG_TYPE_STR);
payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR); payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR);
msgType = atoi(typeJson->valuestring);
if (msgType == MSG_REGISTER_REPLY){ if (strstr(typeJson->valuestring,KK_REGISTER_TOPIC_REPLY)){
//====todo====== //====todo======
//get devicececret and save it //get devicececret and save it
INFO_PRINT(" topic:register_reply \n"); INFO_PRINT(" topic:register_reply \n");
...@@ -257,7 +255,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -257,7 +255,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int); _iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int);
_iotx_linkkit_upstream_mutex_unlock(); _iotx_linkkit_upstream_mutex_unlock();
}else if (msgType == MSG_TOPOADD_REPLY){ }else if (strstr(typeJson->valuestring,KK_ADD_TOPIC_REPLY)){
//====todo====== //====todo======
// //
INFO_PRINT(" topic:add_reply \n"); INFO_PRINT(" topic:add_reply \n");
...@@ -271,7 +269,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -271,7 +269,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int); _iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int);
_iotx_linkkit_upstream_mutex_unlock(); _iotx_linkkit_upstream_mutex_unlock();
}else if (msgType == MSG_LOGIN_REPLY){ }else if (strstr(typeJson->valuestring,KK_LOGIN_TOPIC_REPLY)){
//====todo====== //====todo======
// //
INFO_PRINT(" topic:login_reply \n"); INFO_PRINT(" topic:login_reply \n");
...@@ -284,13 +282,12 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data) ...@@ -284,13 +282,12 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_mutex_lock(); _iotx_linkkit_upstream_mutex_lock();
_iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int); _iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int);
_iotx_linkkit_upstream_mutex_unlock(); _iotx_linkkit_upstream_mutex_unlock();
}else if (msgType == MSG_PROPERTYSET){ }else if (strstr(typeJson->valuestring,KK_THING_SERVICE_PROPERTY_SET)){
INFO_PRINT("property set reply \n"); INFO_PRINT("property set \n");
cJSON *product_type = cJSON_GetObjectItem(info, MSG_PRODUCT_TYPE_STR); cJSON *deviceCode = cJSON_GetObjectItem(info, MSG_DEVICE_CODE_STR);
cJSON *device_name = cJSON_GetObjectItem(info, MSG_DEVICE_CODE_STR); dm_msg_thing_property_set_reply(deviceCode->valuestring,payload->valuestring, strlen(payload->valuestring), NULL);
dm_msg_thing_property_set_reply(product_type->valuestring, device_name->valuestring,payload->valuestring, strlen(payload->valuestring), NULL);
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL); //kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}else if (msgType == MSG_OTA_UPGRADE){ }else if (strstr(typeJson->valuestring,KK_THING_OTA_DEVICE_UPGRADE)){
INFO_PRINT("ota upgrade... \n"); INFO_PRINT("ota upgrade... \n");
kk_dm_ota_send(data, strlen(data)+1); kk_dm_ota_send(data, strlen(data)+1);
......
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