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
7305d32d
Commit
7305d32d
authored
Mar 18, 2022
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
【修改内容】增加设置下发网关延迟处理 See merge request chenweican/k-sdk!210
parents
9e5016f1
a1753362
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
172 additions
and
70 deletions
+172
-70
application/klansdk/kk_ccu_msg.c
application/klansdk/kk_ccu_msg.c
+31
-17
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+10
-3
midware/midware/dm/kk_dm_api.c
midware/midware/dm/kk_dm_api.c
+9
-1
midware/midware/dm/kk_dm_api.h
midware/midware/dm/kk_dm_api.h
+4
-1
midware/midware/dm/kk_dm_queue.c
midware/midware/dm/kk_dm_queue.c
+100
-3
midware/midware/dm/kk_dm_queue.h
midware/midware/dm/kk_dm_queue.h
+4
-0
midware/midware/midware.c
midware/midware/midware.c
+13
-44
tsl/product_3098.json
tsl/product_3098.json
+1
-1
No files found.
application/klansdk/kk_ccu_msg.c
View file @
7305d32d
...
...
@@ -46,7 +46,9 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON
*
args
=
NULL
;
int
bVal
=
0
;
if
(
n_dataType
==
NULL
||
n_id
==
NULL
){
return
NULL
;
}
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
...
...
@@ -92,7 +94,9 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
static
cJSON
*
int_type_convert
(
cJSON
*
n_id
,
cJSON
*
n_dataType
)
{
cJSON
*
args
=
NULL
;
if
(
n_dataType
==
NULL
||
n_id
==
NULL
){
return
NULL
;
}
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
...
...
@@ -149,7 +153,9 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
{
cJSON
*
args
=
NULL
;
int
flag
=
-
1
;
if
(
n_dataType
==
NULL
||
n_id
==
NULL
){
return
NULL
;
}
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
...
...
@@ -204,7 +210,9 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
double
dVal
;
}
val
=
{
0
};
memset
(
sVal
,
0
,
sizeof
(
sVal
));
if
(
n_dataType
==
NULL
||
n_id
==
NULL
){
return
NULL
;
}
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
...
...
@@ -290,7 +298,9 @@ cJSON *string_time_type_convert(cJSON *n_id,cJSON *n_dataType)
cJSON
*
args
=
NULL
;
int
val
;
char
tm
[
10
]
=
{
0
};
if
(
n_dataType
==
NULL
||
n_id
==
NULL
){
return
NULL
;
}
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
...
...
@@ -311,7 +321,9 @@ cJSON *string_time_type_convert(cJSON *n_id,cJSON *n_dataType)
cJSON
*
fit_type_convert
(
cJSON
*
n_id
,
cJSON
*
n_dataType
)
{
cJSON
*
args
=
NULL
;
if
(
n_id
==
NULL
){
return
NULL
;
}
if
(
n_id
->
type
==
cJSON_True
)
{
args
=
cJSON_CreateTrue
();
}
else
if
(
n_id
->
type
==
cJSON_False
){
...
...
@@ -366,7 +378,7 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
{
cJSON
*
args
=
NULL
;
cJSON
*
rlt
;
char
*
sVrg
=
NULL
,
*
dVrg
=
NULL
,
*
pVal
=
NULL
;
//
char *sVrg = NULL,*dVrg = NULL,*pVal = NULL;
int
j
;
int
vra_size
;
...
...
@@ -381,15 +393,15 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
return
NULL
;
}
sVrg
=
cJSON_Print
(
s_valueRange
);
dVrg
=
cJSON_Print
(
d_valueRange
);
pVal
=
cJSON_Print
(
value
);
debug_log
(
LOG_DEBUG_LEVEL
,
"[convert] s_dataType:%s,val=%s
\n
"
,
s_dataType
->
valuestring
,
pVal
);
debug_log
(
LOG_INFO_LEVEL
,
"s_valueRange=%s
\n
"
,
sVrg
);
debug_log
(
LOG_INFO_LEVEL
,
"d_valueRange=%s
\n
"
,
dVrg
);
free
(
sVrg
);
free
(
dVrg
);
free
(
pVal
);
//
sVrg = cJSON_Print(s_valueRange);
//
dVrg = cJSON_Print(d_valueRange);
//
pVal = cJSON_Print(value);
//
debug_log(LOG_DEBUG_LEVEL,"[convert] s_dataType:%s,val=%s\n",s_dataType->valuestring,pVal);
//
debug_log(LOG_INFO_LEVEL,"s_valueRange=%s\n",sVrg);
//
debug_log(LOG_INFO_LEVEL,"d_valueRange=%s\n",dVrg);
//
free(sVrg);
//
free(dVrg);
//
free(pVal);
vra_size
=
cJSON_GetArraySize
(
s_valueRange
);
for
(
j
=
0
;
j
<
vra_size
;
j
++
){
...
...
@@ -449,7 +461,9 @@ cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_r
{
cJSON
*
val
=
NULL
;
if
(
d_dType
==
NULL
){
return
NULL
;
}
if
(
strcmp
(
d_dType
->
valuestring
,
"map"
)
==
0
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
application/klansdk/kk_data_handle.c
View file @
7305d32d
...
...
@@ -378,6 +378,9 @@ static void kk_zb_devs_hw_ack(int sockfd,cJSON *conditions)
cJSON
*
array
=
cJSON_CreateArray
();
for
(
i
=
0
;
i
<
size
;
i
++
){
qMac
=
cJSON_GetArrayItem
(
arg
,
i
);
if
(
qMac
==
NULL
){
continue
;
}
if
(
mac_switchto_deviceCode
(
qMac
->
valuestring
,
devCode
)
==
0
){
if
((
item
=
kk_zb_dev_hw_info_build_by_deviceCode
(
sockfd
,
devCode
,
-
1
))
!=
NULL
){
cJSON_AddItemToArray
(
array
,
item
);
...
...
@@ -522,6 +525,9 @@ static int kk_parse_syncinfo(cJSON *payload)
deviceCode
=
cJSON_GetObjectItem
(
subitem
,
MSG_DEVICE_CODE_STR
)
->
valuestring
;
productCode
=
cJSON_GetObjectItem
(
subitem
,
MSG_PRODUCT_CODE_STR
)
->
valuestring
;
onlineStatus
=
cJSON_GetObjectItem
(
subitem
,
MSG_ONLINE_STATUS_STR
);
if
(
onlineStatus
==
NULL
){
continue
;
}
properties
=
cJSON_GetObjectItem
(
subitem
,
MSG_PROPERTIES_STR
);
kk_map_dev_node_add
(
deviceCode
,
productCode
,
gwdevicecode
,(
onlineStatus
->
valueint
==
1
)
?
"1"
:
"0"
);
kk_lan_property_syn_deal
(
deviceCode
,
properties
);
...
...
@@ -541,6 +547,9 @@ int is_ccu_msg(cJSON *productCode,cJSON *deviceCode)
char
pid
[
33
]
=
{
0
};
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_pid
(
pid
);
if
(
productCode
==
NULL
||
deviceCode
==
NULL
){
return
0
;
}
if
((
strlen
(
productCode
->
valuestring
)
==
strlen
(
pid
)
&&
!
strcmp
(
productCode
->
valuestring
,
pid
))
&&
(
strlen
(
deviceCode
->
valuestring
)
==
strlen
(
ccuid
)
&&
...
...
@@ -938,13 +947,11 @@ static int kk_get_ccu_info_handle(cJSON *param)
cJSON_AddStringToObject
(
root
,
"opcode"
,
"GET_CCU_INFO"
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddItemToObject
(
root
,
"arg"
,
param
);
char
*
data
=
cJSON_Print
(
root
);
kk_send_data_to_sdk
(
data
);
cJSON_Delete
(
root
);
free
(
data
);
return
0
;
}
...
...
midware/midware/dm/kk_dm_api.c
View file @
7305d32d
...
...
@@ -187,7 +187,7 @@ int iotx_dm_subdev_logout(_IN_ int devid)
return
res
;
}
extern
void
kk_sendData2gw
(
void
*
data
,
int
len
,
char
*
chalMark
);
void
iotx_dm_dispatch
(
void
)
{
int
count
=
0
;
...
...
@@ -212,6 +212,14 @@ void iotx_dm_dispatch(void)
kk_ipc_send
(
IPC_MID2APP
,
data
,
strlen
(
data
)
+
1
);
free
(
data
);
data
=
NULL
;
}
else
if
(
dm_queue_msg_next5
(
&
data
)
==
SUCCESS_RETURN
){
msg_to_plat_t
*
getData
=
(
msg_to_plat_t
*
)
data
;
if
(
getData
!=
NULL
){
kk_sendData2gw
(
getData
->
data
,
strlen
(
getData
->
data
),
getData
->
gwDeviceCode
);
free
(
getData
->
data
);
free
(
getData
);
usleep
(
100
*
1000
);
//网关可能处理不过来,需要中控稍微延时
}
}
else
{
break
;
...
...
midware/midware/dm/kk_dm_api.h
View file @
7305d32d
...
...
@@ -17,7 +17,10 @@ typedef struct {
void
*
local_connectivity
;
iotx_dm_event_callback
event_callback
;
}
dm_api_ctx_t
;
typedef
struct
{
char
*
data
;
char
gwDeviceCode
[
32
];
}
msg_to_plat_t
;
#if defined(DEPRECATED_LINKKIT)
typedef
struct
{
void
*
mutex
;
...
...
midware/midware/dm/kk_dm_queue.c
View file @
7305d32d
...
...
@@ -47,6 +47,13 @@ static void _dm_queue_lock4(void)
}
}
static
void
_dm_queue_lock5
(
void
)
{
dm_queue_t
*
ctx
=
_dm_queue_get_ctx
();
if
(
ctx
->
mutex5
)
{
HAL_MutexLock
(
ctx
->
mutex5
);
}
}
static
void
_dm_queue_unlock
(
void
)
{
...
...
@@ -77,7 +84,13 @@ static void _dm_queue_unlock4(void)
HAL_MutexUnlock
(
ctx
->
mutex4
);
}
}
static
void
_dm_queue_unlock5
(
void
)
{
dm_queue_t
*
ctx
=
_dm_queue_get_ctx
();
if
(
ctx
->
mutex5
)
{
HAL_MutexUnlock
(
ctx
->
mutex5
);
}
}
int
dm_queue_init
(
int
max_size
)
...
...
@@ -109,7 +122,11 @@ int dm_queue_init(int max_size)
if
(
ctx
->
mutex4
==
NULL
)
{
return
INVALID_PARAMETER
;
}
/* Create Mutex */
ctx
->
mutex5
=
HAL_MutexCreate
();
if
(
ctx
->
mutex5
==
NULL
)
{
return
INVALID_PARAMETER
;
}
/* Init List */
ctx
->
msg_list
.
max_size
=
max_size
;
INIT_LIST_HEAD
(
&
ctx
->
msg_list
.
message_list
);
...
...
@@ -119,7 +136,8 @@ int dm_queue_init(int max_size)
INIT_LIST_HEAD
(
&
ctx
->
msg_list3
.
message_list
);
ctx
->
msg_list4
.
max_size
=
max_size
;
INIT_LIST_HEAD
(
&
ctx
->
msg_list4
.
message_list
);
ctx
->
msg_list5
.
max_size
=
max_size
;
INIT_LIST_HEAD
(
&
ctx
->
msg_list5
.
message_list
);
return
SUCCESS_RETURN
;
}
...
...
@@ -146,6 +164,9 @@ void dm_queue_deinit(void)
HAL_MutexDestroy
(
ctx
->
mutex4
);
}
if
(
ctx
->
mutex5
)
{
HAL_MutexDestroy
(
ctx
->
mutex5
);
}
list_for_each_entry_safe
(
del_node
,
next_node
,
&
ctx
->
msg_list
.
message_list
,
linked_list
,
dm_queue_msg_node_t
)
{
/* Free Message */
del_msg
=
(
dm_queue_msg_t
*
)
del_node
->
data
;
...
...
@@ -209,6 +230,22 @@ void dm_queue_deinit(void)
list_del
(
&
del_node
->
linked_list
);
free
(
del_node
);
}
del_node
=
NULL
;
next_node
=
NULL
;
del_msg
=
NULL
;
list_for_each_entry_safe
(
del_node
,
next_node
,
&
ctx
->
msg_list5
.
message_list
,
linked_list
,
dm_queue_msg_node_t
)
{
/* Free Message */
del_msg
=
(
dm_queue_msg_t
*
)
del_node
->
data
;
if
(
del_msg
->
data
)
{
free
(
del_msg
->
data
);
}
free
(
del_msg
);
del_msg
=
NULL
;
/* Free Node */
list_del
(
&
del_node
->
linked_list
);
free
(
del_node
);
}
}
int
dm_queue_msg_insert
(
void
*
data
)
...
...
@@ -445,3 +482,63 @@ int dm_queue_msg_next4(void **data)
return
SUCCESS_RETURN
;
}
int
dm_queue_msg_insert5
(
void
*
data
)
{
dm_queue_t
*
ctx
=
_dm_queue_get_ctx
();
dm_queue_msg_node_t
*
node
=
NULL
;
if
(
data
==
NULL
)
{
return
INVALID_PARAMETER
;
}
_dm_queue_lock5
();
printf
(
"dm msg list size: %d, max size: %d"
,
ctx
->
msg_list5
.
size
,
ctx
->
msg_list5
.
max_size
);
if
(
ctx
->
msg_list5
.
size
>=
ctx
->
msg_list5
.
max_size
)
{
printf
(
"dm queue list full"
);
_dm_queue_unlock5
();
return
FAIL_RETURN
;
}
node
=
malloc
(
sizeof
(
dm_queue_msg_node_t
));
if
(
node
==
NULL
)
{
_dm_queue_unlock5
();
return
MEMORY_NOT_ENOUGH
;
}
memset
(
node
,
0
,
sizeof
(
dm_queue_msg_node_t
));
node
->
data
=
data
;
INIT_LIST_HEAD
(
&
node
->
linked_list
);
ctx
->
msg_list5
.
size
++
;
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
msg_list5
.
message_list
);
_dm_queue_unlock5
();
return
SUCCESS_RETURN
;
}
int
dm_queue_msg_next5
(
void
**
data
)
{
dm_queue_t
*
ctx
=
_dm_queue_get_ctx
();
dm_queue_msg_node_t
*
node
=
NULL
;
if
(
data
==
NULL
||
*
data
!=
NULL
)
{
return
INVALID_PARAMETER
;
}
_dm_queue_lock5
();
if
(
list_empty
(
&
ctx
->
msg_list5
.
message_list
))
{
_dm_queue_unlock5
();
return
FAIL_RETURN
;
}
node
=
list_first_entry
(
&
ctx
->
msg_list5
.
message_list
,
dm_queue_msg_node_t
,
linked_list
);
list_del
(
&
node
->
linked_list
);
ctx
->
msg_list5
.
size
--
;
*
data
=
node
->
data
;
free
(
node
);
_dm_queue_unlock5
();
return
SUCCESS_RETURN
;
}
midware/midware/dm/kk_dm_queue.h
View file @
7305d32d
...
...
@@ -32,10 +32,12 @@ typedef struct {
void
*
mutex2
;
void
*
mutex3
;
void
*
mutex4
;
void
*
mutex5
;
dm_queue_msg_list_t
msg_list
;
dm_queue_msg_list_t
msg_list2
;
dm_queue_msg_list_t
msg_list3
;
dm_queue_msg_list_t
msg_list4
;
dm_queue_msg_list_t
msg_list5
;
}
dm_queue_t
;
int
dm_queue_init
(
int
max_size
);
...
...
@@ -48,4 +50,6 @@ int dm_queue_msg_insert3(void *data);
int
dm_queue_msg_next3
(
void
**
data
);
int
dm_queue_msg_insert4
(
void
*
data
);
int
dm_queue_msg_next4
(
void
**
data
);
int
dm_queue_msg_insert5
(
void
*
data
);
int
dm_queue_msg_next5
(
void
**
data
);
#endif
midware/midware/midware.c
View file @
7305d32d
...
...
@@ -878,47 +878,6 @@ static int kk_get_ccu_info_reply(cJSON *param,char *msgType)
return
res
;
}
static
int
_kk_handle_airswitch_property
(
char
*
fatherDeviceCode
,
cJSON
*
info_root
,
cJSON
*
payload
)
{
cJSON
*
params
=
NULL
;
cJSON
*
epNums
=
NULL
;
cJSON
*
pSub
=
NULL
;
char
epStr
[
4
]
=
{
0
};
int
i
=
0
;
if
(
payload
==
NULL
){
return
INVALID_PARAMETER
;
}
params
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
params
==
NULL
){
return
FAIL_RETURN
;
}
epNums
=
cJSON_GetObjectItem
(
params
,
"epNums"
);
if
(
epNums
==
NULL
||
epNums
->
type
!=
cJSON_Array
){
return
FAIL_RETURN
;
}
int
array_size
=
cJSON_GetArraySize
(
epNums
);
for
(
i
=
0
;
i
<
array_size
;
i
++
){
memset
(
epStr
,
0x0
,
sizeof
(
epStr
));
pSub
=
cJSON_GetArrayItem
(
epNums
,
i
);
if
(
pSub
==
NULL
){
continue
;}
sprintf
(
epStr
,
"%d"
,
pSub
->
valueint
);
cJSON
*
rootData
=
cJSON_CreateObject
();
cJSON_DeleteItemFromObject
(
params
,
"epNums"
);
cJSON_DeleteItemFromObject
(
params
,
"epNum"
);
cJSON_AddStringToObject
(
params
,
"epNum"
,
epStr
);
char
*
info_rootS
=
cJSON_Print
(
info_root
);
char
*
payloadS
=
cJSON_Print
(
payload
);
cJSON_AddItemToObject
(
rootData
,
MSG_INFO_STR
,
cJSON_Parse
(
info_rootS
));
cJSON_AddItemToObject
(
rootData
,
MSG_PAYLOAD_STR
,
cJSON_Parse
(
payloadS
));
char
*
pnewout
=
cJSON_Print
(
rootData
);
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
fatherDeviceCode
);
//send to sub device
cJSON_Delete
(
rootData
);
free
(
info_rootS
);
free
(
payloadS
);
free
(
pnewout
);
}
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:nanomsg数据回调,app to mid
...
...
@@ -1020,11 +979,21 @@ void mid_cb(void* data, int len){
cJSON_AddItemToObject
(
rootData
,
MSG_INFO_STR
,
cJSON_Parse
(
info_rootS
));
cJSON_AddItemToObject
(
rootData
,
MSG_PAYLOAD_STR
,
cJSON_Parse
(
payloadS
));
char
*
pnewout
=
cJSON_Print
(
rootData
);
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
node
->
fatherDeviceCode
);
//send to sub device
msg_to_plat_t
*
sendData
=
NULL
;
sendData
=
(
msg_to_plat_t
*
)
malloc
(
sizeof
(
msg_to_plat_t
));
if
(
sendData
!=
NULL
){
sendData
->
data
=
pnewout
;
memset
(
sendData
->
gwDeviceCode
,
0x0
,
sizeof
(
sendData
->
gwDeviceCode
));
memcpy
(
sendData
->
gwDeviceCode
,
node
->
fatherDeviceCode
,
strlen
(
node
->
fatherDeviceCode
));
dm_queue_msg_insert5
((
void
*
)
sendData
);
}
else
{
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
node
->
fatherDeviceCode
);
//send to sub device
free
(
pnewout
);
}
cJSON_Delete
(
rootData
);
free
(
info_rootS
);
free
(
payloadS
);
free
(
pnewout
);
}
}
else
{
...
...
@@ -1068,8 +1037,8 @@ void mid2p_cb(void* data, int len, char* chalMark){
}
res
=
dm_queue_msg_insert2
((
void
*
)
queue_msg
);
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
queue_msg
);
free
(
buf
);
free
(
queue_msg
);
buf
=
NULL
;
return
;
}
...
...
tsl/product_3098.json
View file @
7305d32d
{
"schema"
:
"https://iot-ap.ikonke.com/model/product_3098.json"
,
"productType"
:
"fan
c
oil"
,
"productType"
:
"fan
C
oil"
,
"version"
:
"1.2"
,
"profile"
:
{
"heartbeat"
:
"300"
,
...
...
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