[fix]:
1.Fix the problem of incorrect setting of global variables in lynq-init-call
2.add lynq log
Change-Id: I57ea6b0c645d65510da114a4a779e4aca1d96d2d
diff --git a/src/lynq/lib/liblynq-call/lynq_call.cpp b/src/lynq/lib/liblynq-call/lynq_call.cpp
index 6091329..2af714d 100755
--- a/src/lynq/lib/liblynq-call/lynq_call.cpp
+++ b/src/lynq/lib/liblynq-call/lynq_call.cpp
@@ -13,7 +13,7 @@
#include <pthread.h>
#include "liblog/lynq_deflog.h"
#include <sys/time.h>
-
+#include <string.h>
#define LYNQ_SERVICE_PORT 8088
#define LYNQ_URC_SERVICE_PORT 8086
#define LYNQ_REC_BUF 8192
@@ -122,7 +122,7 @@
ret = write(sockfd, client_tmp, LYQN_SEDN_BUF);
if(ret==-1)
{
- perror("write error");
+ LYERRLOG("write error:%s",strerror(errno));
return -1;
}
return 0;
@@ -137,10 +137,9 @@
len = read(sockfd, recvline, LYNQ_REC_BUF);
if(len == -1)
{
- perror("read error");
+ LYERRLOG("read error:%s",strerror(errno));
return -1;
}
- printf("===>n=%d\n",len);
if (recvline != NULL) {
p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
p.setDataPosition(0);
@@ -419,7 +418,7 @@
lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if(connect(lynq_call_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
{
- perror("connect error");
+ LYERRLOG("connect error:%s",strerror(errno));
return -1;
}
return 0;
@@ -461,14 +460,14 @@
len = recvfrom(socket_fd,urc_data,LYNQ_REC_BUF,0,(struct sockaddr *)&dest_addr,&addr_len);
if(len <= 0)
{
- perror("thread_urc_recv step2 fail:");
+ LYERRLOG("thread_urc_recv step2 fail:%s",strerror(errno));
break;
}
LYDBGLOG("=====>urc data len<=====:%d\n",len);
p = new Parcel();
if(p==NULL)
{
- RLOGD("new parcel failure!!!");
+ LYERRLOG("new parcel failure!!!");
break;
}
p->setData((uint8_t *)urc_data,len); // p.setData((uint8_t *) buffer, buflen);
@@ -520,10 +519,9 @@
pthread_t tid;
pthread_attr_t attr;
socket_fd = socket(AF_INET,SOCK_DGRAM,0);
- printf("test 001\n");
if(socket_fd < 0)
{
- perror("creaet socket for udp fail");
+ LYERRLOG("creaet socket for udp fail:%s",strerror(errno));
return -1;
}
urc_local_addr.sin_family = AF_INET;
@@ -533,13 +531,15 @@
rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
if(rt<0)
{
- perror("SO_REUSEADDR fail\n");
+ LYERRLOG("SO_REUSEADDR fail:%s",strerror(errno));
+ perror("SO_REUSEADDR fail:");
return -1;
}
rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
if (rt == -1)
{
- perror("bind failed");
+ LYERRLOG("bind failed");
+ perror("bind failed:");
return -1;
}
pthread_attr_init(&attr);
@@ -547,10 +547,10 @@
rt = pthread_create(&tid,&attr,thread_urc_recv,(void *)socket_fd);
if(rt < 0)
{
- printf("urc loop failure!!!\n");
+ LYERRLOG("urc loop failure!!!\n");
return -1;
}
- printf("urc loop success!!!\n");
+ LYDBGLOG("urc loop success!!!\n");
return 0;
}
int getSelfElement(char addr[])
@@ -577,7 +577,7 @@
{
int result = 0;
Global_uToken_call = uToken;
- call_list_loop = 1;
+ urc_call_recive_status = 1;
LYLOGSET(LOG_INFO);
LYLOGEINIT(USER_LOG_TAG);
result = lynq_socket_client_start();