Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
b9b502dd
Commit
b9b502dd
authored
Jul 02, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】去掉部分warning
parent
3d890a75
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
22 deletions
+27
-22
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+11
-9
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+4
-0
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+3
-1
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+1
-5
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+5
-3
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+2
-3
application/kcloud/mqtt_api.h
application/kcloud/mqtt_api.h
+1
-1
No files found.
application/kcloud/kcloud_data_handle.c
View file @
b9b502dd
...
...
@@ -52,7 +52,11 @@ const char DM_MSG_TO_MIDDWARE[] = "{\"msgtype\":\"%s\",\"productCode\":\"%s\",\"
#define KK_POWER_SWITCH_2 "PowerSwitch_2"
#define KK_POWER_SWITCH_3 "PowerSwitch_3"
extern
char
*
KK_Make_Topic
(
cJSON
*
info
);
extern
int
KK_Subdev_UnSubscribe
(
cJSON
*
payload
);
extern
int
KK_Subdev_UnSubscribe_By_DeviceCode
(
const
char
*
deviceCode
,
const
char
*
productCode
);
extern
int
KK_Subdev_Subscribe
(
const
cJSON
*
root
);
int
KK_Send_CloudState
(
int
state
);
static
char
*
s_split_product
[]
=
{
"3002"
,
//星辰系列双路面板
...
...
@@ -145,7 +149,7 @@ static int kk_split_send_data(cJSON *pData,const char* topic)
cJSON_AddNumberToObject
(
pParam_new
,
KK_POWER_SWITCH_1
,
powerswitch1
->
valueint
);
cJSON_AddItemToObject
(
pData
,
MSG_PARAMS_STR
,
pParam_new
);
char
*
out
=
cJSON_Print
(
pData
);
KK_MQTT_SendMsg
(
topic
,(
const
char
*
)
out
);
KK_MQTT_SendMsg
(
(
char
*
)
topic
,(
const
char
*
)
out
);
free
(
out
);
}
...
...
@@ -157,7 +161,7 @@ static int kk_split_send_data(cJSON *pData,const char* topic)
cJSON_AddNumberToObject
(
pParam_new
,
KK_POWER_SWITCH_2
,
powerswitch2
->
valueint
);
cJSON_AddItemToObject
(
pData
,
MSG_PARAMS_STR
,
pParam_new
);
char
*
out
=
cJSON_Print
(
pData
);
KK_MQTT_SendMsg
(
topic
,(
const
char
*
)
out
);
KK_MQTT_SendMsg
(
(
char
*
)
topic
,(
const
char
*
)
out
);
free
(
out
);
}
powerswitch3
=
cJSON_GetObjectItem
(
pParam
,
KK_POWER_SWITCH_3
);
...
...
@@ -167,7 +171,7 @@ static int kk_split_send_data(cJSON *pData,const char* topic)
cJSON_AddNumberToObject
(
pParam_new
,
KK_POWER_SWITCH_3
,
powerswitch3
->
valueint
);
cJSON_AddItemToObject
(
pData
,
MSG_PARAMS_STR
,
pParam_new
);
char
*
out
=
cJSON_Print
(
pData
);
KK_MQTT_SendMsg
(
topic
,(
const
char
*
)
out
);
KK_MQTT_SendMsg
(
(
char
*
)
topic
,(
const
char
*
)
out
);
free
(
out
);
}
free
(
param_tmp
);
...
...
@@ -181,6 +185,7 @@ static int kk_split_send_data(cJSON *pData,const char* topic)
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
_kk_sendto_cloud
(
cJSON
*
root
)
{
cJSON
*
info
,
*
pData
;
...
...
@@ -271,18 +276,15 @@ void KK_Data_FromDev(void* str,int len)
ERROR_PRINT
(
"[%s][%d] root is null
\n
"
,
__FUNCTION__
,
__LINE__
);
return
;
}
ERROR_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cmd
=
cJSON_GetObjectItem
(
root
,
"cmd"
);
if
(
cmd
==
NULL
){
_kk_sendto_cloud
(
root
);
ERROR_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
else
{
KK_Subdev_Subscribe
(
root
);
}
ERROR_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON_Delete
(
root
);
ERROR_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
/************************************************************
*功能描述:无效主题过滤
...
...
@@ -339,7 +341,7 @@ static int _check_invalid_topic(const char* topic)
*************************************************************/
static
int
_kk_topic_parse_msgType
(
_IN_
char
*
topic
,
_IN_
int
start_deli
,
_OU_
char
**
msgTypeStr
)
{
int
res
=
0
,
start
=
0
,
len
=
0
,
slice
=
0
;
int
res
=
0
,
start
=
0
,
len
=
0
;
char
*
msgTypeStr_tmp
=
NULL
;
if
(
topic
==
NULL
)
{
...
...
application/kcloud/kcloud_main.c
View file @
b9b502dd
...
...
@@ -18,6 +18,10 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "MQTTAsync.h"
#include "mqtt_api.h"
#include "com_api.h"
...
...
application/kcloud/kk_info_report.c
View file @
b9b502dd
...
...
@@ -16,7 +16,10 @@
#include "com_api.h"
#include "kk_product.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "mqtt_api.h"
static
pthread_mutex_t
s_data_mutex
;
extern
int
kk_get_gw_status
(
void
);
#define TO_OLED_NANOMSG_SOCKET_ADDR "ipc:///tmp/oled_pair.ipc"
static
int
kk_info_nanomsg_init
(
void
)
{
...
...
@@ -135,7 +138,6 @@ void *kk_info_nanomsg_send(void *data)
}
int
kk_info_report_start
(
void
)
{
void
*
status
;
int
rc
;
pthread_t
info_report_thread
;
pthread_attr_t
info_report_attr
;
...
...
application/kcloud/kk_register.c
View file @
b9b502dd
...
...
@@ -13,6 +13,7 @@
#include <arpa/inet.h>
#include "cJSON.h"
#include "com_api.h"
#include "kk_hal.h"
#include "kk_product.h"
#include "kcloud_config.h"
...
...
@@ -196,12 +197,9 @@ int arrayToStr(unsigned char *buf, unsigned int buflen, char *out)
static
char
*
kk_create_register_info
()
{
cJSON
*
root
;
char
testout
[
64
]
=
{
0
};
char
outlen
=
0
;
char
*
out
=
NULL
;
char
*
productCode
=
KK_CCU_PRODUCTID
;
char
*
signSource
,
*
base64Out
=
NULL
;
int
len
=
0
,
tleng
=
0
;
char
mac
[
16
]
=
{
0
};
char
ramdonId
[
16
]
=
{
0
};
unsigned
char
sign_hex
[
32
]
=
{
0
};
...
...
@@ -302,8 +300,6 @@ int kk_start_ccu_register(void)
int
sockfd
,
ret
,
i
,
h
;
struct
sockaddr_in
servaddr
;
char
buf
[
1024
]
=
{
0
},
buf2
[
1024
]
=
{
0
};
char
*
sendBuf
=
NULL
;
socklen_t
len
;
fd_set
t_set1
;
struct
timeval
tv
;
int
registerType
=
0
;
...
...
application/kcloud/kk_topic_mng.c
View file @
b9b502dd
...
...
@@ -6,7 +6,8 @@
#include "cJSON.h"
#include "com_api.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "mqtt_api.h"
const
char
KK_URI_SYS_PREFIX
[]
=
"biz/kk/%s/%s/thing/service/property/set"
;
const
char
KK_URI_SYS_PREFIX_SERVICE
[]
=
"biz/kk/%s/%s/thing/service/+"
;
...
...
@@ -20,6 +21,7 @@ static int s_gw_status = DEVICE_OFFLINE;
int
kk_set_gw_status
(
int
status
)
{
s_gw_status
=
status
;
return
0
;
}
int
kk_get_gw_status
(
void
)
{
...
...
@@ -31,7 +33,7 @@ int KK_Subdev_Subscribe(const cJSON *root)
cJSON
*
deviceCode
=
NULL
;
cJSON
*
productCode
=
NULL
;
cJSON
*
data
=
NULL
;
cJSON
*
cmd
=
NULL
;
//
cJSON *cmd = NULL;
int
url_len
=
0
;
data
=
cJSON_GetObjectItem
(
root
,
"data"
);
...
...
@@ -76,7 +78,7 @@ int KK_Subdev_Subscribe(const cJSON *root)
static
int
_kk_ccu_topic_subscribe
(
char
productCode
[
PRODUCT_CODE_LEN
],
char
deviceCode
[
DEVICE_CODE_LEN
])
{
int
res
=
0
,
index
=
0
,
fail_count
=
0
;
int
res
=
0
;
int
url_len
=
0
;
url_len
=
strlen
(
KK_URI_SYS_PREFIX_SERVICE
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
1
;
...
...
application/kcloud/mqtt_api.c
View file @
b9b502dd
...
...
@@ -4,14 +4,14 @@
#include "mqtt_api.h"
#include "com_api.h"
#include "kk_product.h"
#include "kk_hal.h"
static
const
char
*
OPT_SEND
=
"MQTTAsync_sendMessage"
;
static
const
char
*
OPT_SUB
=
"MQTTAsync_subscribe"
;
static
const
char
*
OPT_UNSUB
=
"MQTTAsync_unsubscribe"
;
static
MQTTAsync
s_Client
;
static
int
s_mqttStop
=
0
;
static
int
s_cloudStatus
=
DEVICE_OFFLINE
;
int
KK_Send_CloudState
(
int
state
);
int
kk_get_cloud_status
(
void
){
return
s_cloudStatus
;
}
...
...
@@ -129,7 +129,6 @@ static void onDeliveryComplete(void* context, MQTTAsync_token token)
}
static
void
onConnectBuild
(
void
*
context
,
char
*
cause
)
{
int
rc
=
0
;
INFO_PRINT
(
"onConnectBuild:%s
\n
"
,
cause
);
//rc = KK_Client_Gateway_Subscribe();
//if(rc != 0)
...
...
application/kcloud/mqtt_api.h
View file @
b9b502dd
...
...
@@ -15,6 +15,6 @@ extern int KK_MQTT_RecvMsg(const char *topicName,const char *payload);
extern
int
KK_MQTT_UnsubTopic
(
const
char
*
topicName
);
extern
MQTTAsync
KK_MQTT_Connect
(
void
);
int
kk_get_cloud_status
(
void
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment