Commit 741f9a18 authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

【修改内容】修改kk_lan recv处理

See merge request chenweican/k-sdk!212
parents 04d9a5be 9f5d183e
......@@ -355,7 +355,7 @@ cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value)
pVal = cJSON_Print(value);
debug_log(LOG_DEBUG_LEVEL,"[convert]type:%s->%s,val=%s.\n",s_type->valuestring,d_type->valuestring,pVal);
//debug_log(LOG_DEBUG_LEVEL,"[convert]type:%s->%s,val=%s.\n",s_type->valuestring,d_type->valuestring,pVal);
free(pVal);
......@@ -465,12 +465,8 @@ cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_r
return NULL;
}
if(strcmp(d_dType->valuestring,"map")==0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
val = map_type_convert(s_dType,s_range,value,d_range);
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
val = msg_convert_value(d_dType,s_dType,value);
}
......@@ -507,7 +503,7 @@ int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id)
return -1;
}
debug_log(LOG_DEBUG_LEVEL,"[add] id(%s),type(%d).\n",id,val->type);
//debug_log(LOG_DEBUG_LEVEL,"[add] id(%s),type(%d).\n",id,val->type);
if(val->type==cJSON_False){
cJSON_AddFalseToObject(obj,id);
......@@ -536,7 +532,7 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}
pVal = cJSON_Print(val);
debug_log(LOG_DEBUG_LEVEL,"[replace] id=%s,type=%d,val=%s.\n",id,val->type,pVal);
//debug_log(LOG_DEBUG_LEVEL,"[replace] id=%s,type=%d,val=%s.\n",id,val->type,pVal);
free(pVal);
if(val->type==cJSON_False){
......
......@@ -229,14 +229,26 @@ void *TCPServer()
INFO_PRINT("recv->buf:%s\n",Buf);
_kk_handle_data(Buf,s_ConnInfo[i].socketfd);
}
else
else if(ret < 0)
{
INFO_PRINT("client disconnected\r\n");
pthread_mutex_lock(&data_mutex);
close(s_ConnInfo[i].socketfd);
s_ConnInfo[i].socketfd = -1;
memset(s_ConnInfo[i].ip,0x0,sizeof(s_ConnInfo[i].ip));
pthread_mutex_unlock(&data_mutex);
if (errno == EWOULDBLOCK || errno == EINTR) {
usleep(200*1000);
continue;
}else{
INFO_PRINT("client disconnected ret:%d, errno:%d\r\n",ret,errno);
pthread_mutex_lock(&data_mutex);
close(s_ConnInfo[i].socketfd);
s_ConnInfo[i].socketfd = -1;
memset(s_ConnInfo[i].ip,0x0,sizeof(s_ConnInfo[i].ip));
pthread_mutex_unlock(&data_mutex);
}
}else{
INFO_PRINT("client disconnected ret:%d, errno:%d\r\n",ret,errno);
pthread_mutex_lock(&data_mutex);
close(s_ConnInfo[i].socketfd);
s_ConnInfo[i].socketfd = -1;
memset(s_ConnInfo[i].ip,0x0,sizeof(s_ConnInfo[i].ip));
pthread_mutex_unlock(&data_mutex);
}
}
}
......
......@@ -380,10 +380,10 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
}
}
debug_log(LOG_EMERG_LEVEL,"devNode->channelNum=%d\n",devNode->channelNum);
//debug_log(LOG_EMERG_LEVEL,"devNode->channelNum=%d\n",devNode->channelNum);
for(k=0;k<devNode->channelNum;k++){
debug_log(LOG_EMERG_LEVEL,"k=%d\n",k);
//debug_log(LOG_EMERG_LEVEL,"k=%d\n",k);
_kk_lan_sync_device_status(deviceCode,devNode,k+1);
}
return 0;
......
......@@ -218,7 +218,7 @@ void iotx_dm_dispatch(void)
kk_sendData2gw(getData->data, strlen(getData->data), getData->gwDeviceCode);
free(getData->data);
free(getData);
usleep(100*1000);//网关可能处理不过来,需要中控稍微延时
usleep(50*1000);//网关可能处理不过来,需要中控稍微延时
}
}
else {
......
......@@ -8,7 +8,7 @@
#define _KK_DM_API_H_
#include "iotx_dm.h"
#include "kk_dm_mng.h"
#define CONFIG_DISPATCH_QUEUE_MAXLEN (50)
#define CONFIG_DISPATCH_QUEUE_MAXLEN (200)
typedef struct {
......
......@@ -1253,6 +1253,8 @@ static int kk_service_addScreen_handle(cJSON *info,cJSON *msgId,cJSON *params)
kk_service_addScreen_handle_reply(info,msgId,serialid->valuestring);
if(strcmp(mac_head,"01:01") == 0){//moore4c mac
kk_screenDev_insert_db(devtype->valueint,serialid->valuestring,ip->valuestring,&str_mac[6],version->valuestring,"","MOORE4C");
}else if(strstr(serialid->valuestring,"MOORE4CDEVICE") != NULL){//moore4c mac
kk_screenDev_insert_db(devtype->valueint,serialid->valuestring,ip->valuestring,str_mac,version->valuestring,"","MOORE4C");
}else{
kk_screenDev_insert_db(devtype->valueint,serialid->valuestring,ip->valuestring,str_mac,version->valuestring,"","MOORE4S");
}
......
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