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
4d9d15b7
Commit
4d9d15b7
authored
Aug 31, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
【20210831】修复局越网地暖控制上报问题。优化配置表解析。 See merge request chenweican/k-sdk!117
parents
9da143b4
b804d326
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
721 additions
and
584 deletions
+721
-584
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+18
-18
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+123
-123
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+191
-192
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+4
-4
application/klansdk/kk_ccu_msg.c
application/klansdk/kk_ccu_msg.c
+163
-100
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+5
-6
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+11
-11
application/klansdk/kk_lan_debug.h
application/klansdk/kk_lan_debug.h
+11
-9
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+44
-4
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+6
-3
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+3
-3
application/klansdk/kk_lan_vp_ctrl.c
application/klansdk/kk_lan_vp_ctrl.c
+5
-3
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+77
-41
application/klansdk/kk_voice_panel_handle.h
application/klansdk/kk_voice_panel_handle.h
+2
-2
opcodeMapCfg/device_3024.json
opcodeMapCfg/device_3024.json
+56
-56
opcodeMapCfg/device_3029.json
opcodeMapCfg/device_3029.json
+2
-9
No files found.
application/kcloud/kcloud_main.c
View file @
4d9d15b7
application/kcloud/kk_info_report.c
View file @
4d9d15b7
...
...
@@ -44,7 +44,7 @@ static int kk_info_get(char *str)
if
(
str
==
NULL
){
return
-
1
;
}
HAL_GetVersion
(
version
);
//
HAL_GetVersion(version);
KK_Get_ccuid
(
ccuid
);
cJSON
*
root
=
cJSON_CreateObject
();
...
...
application/kcloud/kk_register.c
View file @
4d9d15b7
...
...
@@ -32,7 +32,6 @@ int kk_execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len)
memset
(
buf
,
0
,
buf_len
);
FILE
*
fp
=
NULL
;
fp
=
popen
(
cmd
,
"r"
);
while
(
fgets
(
buf
,
buf_len
,
fp
)
!=
NULL
){
INFO_PRINT
(
"%s return %s"
,
cmd
,
buf
);
...
...
application/kcloud/mqtt_api.c
View file @
4d9d15b7
application/klansdk/kk_ccu_msg.c
View file @
4d9d15b7
...
...
@@ -38,12 +38,26 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
return
NULL
;
}
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)){
args
=
cJSON_CreateBool
(
n_id
->
valueint
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
bVal
=
(
n_id
->
valuedouble
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
args
=
cJSON_CreateBool
(
atoi
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
bVal
=
(
atof
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
...
...
@@ -52,15 +66,13 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateBool
(
0
);
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
int
iVal
=
atoi
(
n_id
->
valuestring
);
bVal
=
(
iVal
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
double
dVal
=
atof
(
n_id
->
valuestring
);
bVal
=
(
dVal
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
}
else
if
(
n_id
->
type
==
cJSON_False
){
args
=
cJSON_CreateNumber
(
0
);
}
else
if
(
n_id
->
type
==
cJSON_True
){
args
=
cJSON_CreateNumber
(
1
);
}
return
args
;
}
...
...
@@ -72,10 +84,13 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
return
NULL
;
}
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
args
=
cJSON_CreateNumber
(
n_id
->
valueint
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
))
{
args
=
cJSON_CreateNumber
(
n_id
->
valuedouble
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
...
...
@@ -85,11 +100,30 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
0
);
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
}
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
args
=
cJSON_CreateNumber
(
atoi
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
args
=
cJSON_CreateNumber
((
int
)
atof
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
args
=
cJSON_CreateNumber
(
atof
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
1
);
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
0
);
}
}
}
else
if
(
n_id
->
type
==
cJSON_False
){
args
=
cJSON_CreateNumber
(
0
);
}
else
if
(
n_id
->
type
==
cJSON_True
){
args
=
cJSON_CreateNumber
(
1
);
}
return
args
;
}
...
...
@@ -106,12 +140,28 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
if
(
n_id
->
type
==
cJSON_True
)
{
flag
==
1
;
}
else
if
(
n_id
->
type
==
cJSON_False
){
flag
==
0
;
}
else
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)){
flag
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
flag
=
(
n_id
->
valuedouble
>
0
)
?
1
:
0
;
}
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
flag
=
(
atoi
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
flag
=
(
atof
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
...
...
@@ -120,10 +170,7 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
){
flag
=
0
;
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
flag
=
(
atoi
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
flag
=
(
atof
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
}
if
(
flag
==
1
)
{
...
...
@@ -149,6 +196,11 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
return
NULL
;
}
if
(
n_id
->
type
==
cJSON_True
)
{
args
=
cJSON_CreateTrue
();
}
else
if
(
n_id
->
type
==
cJSON_False
){
args
=
cJSON_CreateFalse
();
}
else
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
if
(
type
==
1
){
...
...
@@ -162,7 +214,24 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
}
else
{
val
.
iVal
=
n_id
->
valueint
;
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
}
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
atoi
(
n_id
->
valuestring
);
}
else
{
val
.
iVal
=
atoi
(
n_id
->
valuestring
);
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
atof
(
n_id
->
valuestring
);
}
else
{
val
.
iVal
=
atof
(
n_id
->
valuestring
);
}
}
}
else
if
(
n_id
->
type
==
cJSON_False
||
n_id
->
type
==
cJSON_True
){
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
){
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
if
(
type
==
1
){
...
...
@@ -171,26 +240,17 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
val
.
iVal
=
1
;
}
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"false"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
)
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
0
;
}
else
{
val
.
iVal
=
0
;
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
if
(
type
==
1
){
val
.
dVal
=
atoi
(
n_id
->
valuestring
);
}
else
{
val
.
iVal
=
atoi
(
n_id
->
valuestring
);
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
if
(
type
==
1
){
val
.
dVal
=
atof
(
n_id
->
valuestring
);
}
else
{
val
.
iVal
=
atof
(
n_id
->
valuestring
);
}
}
if
(
type
==
1
){
snprintf
(
sVal
,
sizeof
(
sVal
),
"%f"
,
val
.
dVal
);
}
else
{
...
...
@@ -263,13 +323,13 @@ cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value)
if
(
d_type
==
NULL
||
s_type
==
NULL
||
value
==
NULL
||
d_type
->
type
!=
cJSON_String
||
s_type
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[ERR] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[ERR] para.
\n
"
);
return
NULL
;
}
pVal
=
cJSON_Print
(
value
);
debug_log
(
LOG_NORMAL
,
"[convert]type:%s->%s,val=%s.
\n
"
,
s_type
->
valuestring
,
d_type
->
valuestring
,
pVal
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[convert]type:%s->%s,val=%s.
\n
"
,
s_type
->
valuestring
,
d_type
->
valuestring
,
pVal
);
free
(
pVal
);
...
...
@@ -299,11 +359,11 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
if
(
s_valueRange
==
NULL
||
s_valueRange
->
type
!=
cJSON_Array
||
d_valueRange
==
NULL
||
d_valueRange
->
type
!=
cJSON_Array
){
debug_log
(
LOG_DEBUG
,
"[ERR] range.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[ERR] range.
\n
"
);
return
NULL
;
}
if
(
s_dataType
==
NULL
||
s_dataType
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[ERR] dataType.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[ERR] dataType.
\n
"
);
return
NULL
;
}
...
...
@@ -314,9 +374,9 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
sVrg
=
cJSON_Print
(
s_valueRange
);
dVrg
=
cJSON_Print
(
d_valueRange
);
pVal
=
cJSON_Print
(
value
);
debug_log
(
LOG_NORMAL
,
"[convert] s_dataType:%s,val=%s
\n
"
,
s_dataType
->
valuestring
,
pVal
);
debug_log
(
LOG_INFO
,
"s_valueRange=%s
\n
"
,
sVrg
);
debug_log
(
LOG_INFO
,
"d_valueRange=%s
\n
"
,
dVrg
);
debug_log
(
LOG_NORMAL
_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
);
...
...
@@ -379,8 +439,11 @@ cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_r
{
cJSON
*
val
=
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__
);
...
...
@@ -415,11 +478,11 @@ int kk_lan_get_msg_id_str(char *msgId,int size)
int
kk_lan_add_val_to_obj
(
cJSON
*
obj
,
cJSON
*
val
,
const
char
*
id
)
{
if
(
id
==
NULL
||
obj
==
NULL
||
obj
->
type
!=
cJSON_Object
||
val
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_NORMAL
,
"[add] id(%s),type(%d).
\n
"
,
id
,
val
->
type
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[add] id(%s),type(%d).
\n
"
,
id
,
val
->
type
);
if
(
val
->
type
==
cJSON_False
){
cJSON_AddFalseToObject
(
obj
,
id
);
...
...
@@ -432,7 +495,7 @@ int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}
else
if
(
val
->
type
==
cJSON_String
){
cJSON_AddStringToObject
(
obj
,
id
,
val
->
valuestring
);
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
return
-
1
;
}
return
0
;
...
...
@@ -443,12 +506,12 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
{
char
*
pVal
=
NULL
;
if
(
id
==
NULL
||
obj
==
NULL
||
obj
->
type
!=
cJSON_Object
||
val
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
pVal
=
cJSON_Print
(
val
);
debug_log
(
LOG_NORMAL
,
"[replace] id=%s,type=%d,val=%s.
\n
"
,
id
,
val
->
type
,
pVal
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[replace] id=%s,type=%d,val=%s.
\n
"
,
id
,
val
->
type
,
pVal
);
free
(
pVal
);
if
(
val
->
type
==
cJSON_False
){
...
...
@@ -462,7 +525,7 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}
else
if
(
val
->
type
==
cJSON_String
){
cJSON_ReplaceItemInObject
(
obj
,
id
,
cJSON_CreateString
(
val
->
valuestring
));
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
return
-
1
;
}
return
0
;
...
...
application/klansdk/kk_data_handle.c
View file @
4d9d15b7
...
...
@@ -114,7 +114,7 @@ void kk_handle_sync_info(void)
return
;
}
debug_log
(
LOG_INFO
,
"[sync] send.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[sync] send.
\n
"
);
kk_ipc_send
(
IPC_APP2MID
,
send_data
,
strlen
(
send_data
)
+
1
);
free
(
send_data
);
...
...
@@ -354,7 +354,6 @@ int kk_data_handle(cJSON *json,int sockfd)
cJSON
*
opcode
=
NULL
;
cJSON
*
arg
=
NULL
;
opcode
=
cJSON_GetObjectItem
(
json
,
OPCODE_STRING
);
if
(
opcode
!=
NULL
){
if
(
strcmp
(
opcode
->
valuestring
,
LOGIN_OPCODE
)
==
0
){
...
...
@@ -712,18 +711,18 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
cJSON
*
sceneId
=
NULL
;
if
(
payload
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] payload.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] payload.
\n
"
);
return
-
1
;
}
if
((
params
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
))
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] params err.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params err.
\n
"
);
return
-
1
;
}
if
((
sceneId
=
cJSON_GetObjectItem
(
params
,
MSG_SCENE_SCENEID
))
==
NULL
||
sceneId
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] sceneId err.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] sceneId err.
\n
"
);
return
-
1
;
}
...
...
@@ -745,7 +744,7 @@ void KK_Data_FromMid(void* str,int len)
cJSON
*
info
=
NULL
,
*
payload
=
NULL
;
cJSON
*
msgtype
=
NULL
,
*
deviceCode
=
NULL
,
*
productCode
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[midware->lan] len=%d,data=%s
\n
"
,
len
,
str
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[midware->lan] len=%d,data=%s
\n
"
,
len
,
str
);
if
((
json
=
cJSON_Parse
(
str
))
==
NULL
)
{
return
;
...
...
application/klansdk/kk_lan_ctrl.c
View file @
4d9d15b7
...
...
@@ -69,34 +69,34 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
pos
=
match_opcode_pos
(
devNode
->
oldccu
,
opcode
->
valuestring
,
channel
);
if
(
pos
==-
1
){
debug_log
(
LOG_FOCUS
,
"not find
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"not find
\n
"
);
return
NULL
;
}
debug_log
(
LOG_FOCUS
,
"1
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"1
\n
"
);
newccuItem
=
cJSON_GetArrayItem
(
devNode
->
newccu
,
pos
);
oldccuItem
=
cJSON_GetArrayItem
(
devNode
->
oldccu
,
pos
);
debug_log
(
LOG_FOCUS
,
"2
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"2
\n
"
);
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
"dataType"
);
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
debug_log
(
LOG_FOCUS
,
"3
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"3
\n
"
);
n_dataType
=
cJSON_GetObjectItem
(
newccuItem
,
"dataType"
);
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_identifier
=
cJSON_GetObjectItem
(
newccuItem
,
"identifier"
);
epNum
=
cJSON_GetObjectItem
(
newccuItem
,
"channel"
);
debug_log
(
LOG_FOCUS
,
"4
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"4
\n
"
);
if
(
strcmp
(
o_dataType
->
valuestring
,
"map"
)
==
0
){
debug_log
(
LOG_FOCUS
,
"5
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"5
\n
"
);
val
=
map_type_convert
(
o_dataType
,
o_valueRange
,
arg
,
n_valueRange
);
}
else
{
debug_log
(
LOG_FOCUS
,
"6
\n
"
);
val
=
msg_convert_value
(
o_dataType
,
n
_dataType
,
arg
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"6
\n
"
);
val
=
msg_convert_value
(
n_dataType
,
o
_dataType
,
arg
);
}
debug_log
(
LOG_FOCUS
,
"7
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"7
\n
"
);
cJSON_AddStringToObject
(
params
,
"epNum"
,
epNum
->
valuestring
);
debug_log
(
LOG_FOCUS
,
"8
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"8
\n
"
);
if
(
val
->
type
==
cJSON_False
){
cJSON_AddFalseToObject
(
params
,
n_identifier
->
valuestring
);
...
...
@@ -111,7 +111,7 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
}
else
if
(
val
->
type
==
cJSON_Array
){
printf
(
"......................
\n
"
);
}
debug_log
(
LOG_FOCUS
,
"9
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"9
\n
"
);
return
params
;
}
...
...
application/klansdk/kk_lan_debug.h
View file @
4d9d15b7
...
...
@@ -4,13 +4,15 @@
#include <stdio.h>
#include <time.h>
#define LOG_NORMAL 1 //亮白色
#define LOG_DEBUG 2 //绿色
#define LOG_INFO 3 //蓝色
#define LOG_FOCUS 4 //黄色
#define LOG_WARNING 5 //蓝绿色
#define LOG_ERROR 6 //紫色
#define LOG_CRITICAL 7 //红色
#define LOG_NORMAL_LEVEL 1 //亮白色
#define LOG_DEBUG_LEVEL 2 //绿色
#define LOG_INFO_LEVEL 3 //蓝色
#define LOG_FOCUS_LEVEL 4 //黄色
#define LOG_WARNING_LEVEL 5 //蓝绿色
#define LOG_ERROR_LEVEL 6 //紫色
#define LOG_CRITICAL_LEVEL 7 //红色
#define LOG_NORMAL_ACT "\033[0;1;37m"
#define LOG_DEBUG_ACT "\033[0;1;32m"
...
...
@@ -23,7 +25,7 @@
#define syslog_en 1
#define LOG_LEVEL LOG_NORMAL
#define LOG_LEVEL LOG_NORMAL
_LEVEL
#define LOG_LEVEL_1 LOG_NORMAL_ACT
...
...
@@ -48,7 +50,7 @@
#if (syslog_en)
#define debug_log(level,format,...) do { \
if( level >= LOG_LEVEL && level <= LOG_CRITICAL) { \
if( level >= LOG_LEVEL && level <= LOG_CRITICAL
_LEVEL
) { \
char buff[64] = {0};\
time_t curTime = time(NULL); \
struct tm *c = gmtime(&curTime);\
...
...
application/klansdk/kk_lan_main.c
View file @
4d9d15b7
...
...
@@ -66,15 +66,55 @@ static void kk_lan_ccuid_init(void)
}
}
int
prg_run_singleton
(
const
char
*
prg
)
{
int
fd
;
int
ret
;
char
pid_file
[
256
]
=
{
0
};
char
pid_data
[
32
]
=
{
0
};
struct
flock
fl
;
if
(
prg
==
NULL
){
return
-
1
;
}
memset
(
pid_file
,
0
,
sizeof
(
pid_file
));
snprintf
(
pid_file
,
sizeof
(
pid_file
),
"/var/run/%s.pid"
,
prg
);
fd
=
open
(
pid_file
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
,
0644
);
if
(
fd
<
0
){
return
-
1
;
}
fl
.
l_type
=
F_WRLCK
;
fl
.
l_start
=
0
;
fl
.
l_whence
=
SEEK_SET
;
fl
.
l_len
=
0
;
ret
=
fcntl
(
fd
,
F_SETLK
,
&
fl
);
if
(
ret
<
0
){
return
-
1
;
}
memset
(
pid_data
,
0
,
sizeof
(
pid_data
));
snprintf
(
pid_data
,
sizeof
(
pid_data
),
"%d"
,
getpid
());
return
write
(
fd
,
pid_data
,
strlen
(
pid_data
));
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
r
c
=
0
;
char
*
ppp
;
int
r
et
=
0
;
open
(
"kk_lan"
,
LOG_PID
,
LOG_USER
);
if
(
prg_run_singleton
(
argv
[
0
])
<
0
){
debug_log
(
LOG_CRITICAL_LEVEL
,
"[%s]run singleton fail!
\n
"
,
argv
[
0
]);
return
-
1
;
}
kk_lan_ccuid_init
();
/*set the callback to get the device date to cloud*/
...
...
@@ -82,7 +122,7 @@ int main(int argc, char* argv[])
kk_findccu_handle_init
();
kk_map_dev_init
();
kk_login_init
();
kk_voice_panel_init
(
argc
,
argv
);
//
kk_voice_panel_init(argc,argv);
//lan_queue_init();
kk_lan_db_node_init
();
...
...
@@ -91,6 +131,6 @@ int main(int argc, char* argv[])
while
(
1
){
sleep
(
1
);
}
return
rc
;
return
0
;
}
application/klansdk/kk_lan_sync.c
View file @
4d9d15b7
...
...
@@ -428,7 +428,7 @@ int kk_sync_devices_to_sdk(cJSON *root,cJSON *data)
//
cJSON
*
_kk_sync_devicestatus_arg_build
(
kk_map_dev_node_t
*
node
)
{
int
i
,
num
=
0
;
int
i
,
num
=
0
,
n_num
=
0
,
o_num
=
0
;
cJSON
*
newccu
,
*
oldccu
;
cJSON
*
arg
=
cJSON_CreateObject
();
...
...
@@ -445,8 +445,11 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node)
return
arg
;
}
n_num
=
cJSON_GetArraySize
(
newccu
);
o_num
=
cJSON_GetArraySize
(
oldccu
);
num
=
(
n_num
>
o_num
)
?
n_num
:
o_num
;
num
=
cJSON_GetArraySize
(
newccu
);
for
(
i
=
0
;
i
<
num
;
i
++
){
cJSON
*
newccuItem
=
cJSON_GetArrayItem
(
newccu
,
i
);
cJSON
*
oldccuItem
=
cJSON_GetArrayItem
(
oldccu
,
i
);
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
4d9d15b7
...
...
@@ -315,7 +315,7 @@ void *kk_vp_manage_thread(void *arg)
break
;
case
UPDATING_8009_CONFIG_FILE_INFO
:
debug_log
(
LOG_INFO
,
"updating...
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"updating...
\n
"
);
sleep
(
1
);
//todo :超时取消
break
;
...
...
@@ -357,7 +357,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
{
NULL
,
0
,
NULL
,
0
},
};
debug_log
(
LOG_FOCUS
,
"kk_voice_panel_uart_dev_chose
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"kk_voice_panel_uart_dev_chose
\n
"
);
while
((
opt
=
getopt_long_only
(
argc
,
argv
,
string
,
long_options
,
&
option_index
))
!=
-
1
)
{
if
(
opt
==
0xAA5555AA
){
...
...
@@ -372,7 +372,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
snprintf
(
serialDev
,
sizeof
(
serialDev
),
"%s"
,
SERIAL_NAME
);
}
debug_log
(
LOG_FOCUS
,
"serialDev=%s
\n
"
,
serialDev
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"serialDev=%s
\n
"
,
serialDev
);
}
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[])
...
...
application/klansdk/kk_lan_vp_ctrl.c
View file @
4d9d15b7
...
...
@@ -46,16 +46,18 @@ static KK_VP_CTRL vp_ctrl_table[]={
{
is_outlet_dev
,
outlet_dev_handle
}
};
static
int
light_dev_pid
[]
=
{
3023
,
3024
30
01
,
3002
,
3003
,
3022
,
30
23
,
3024
};
static
int
curtain_dev_pid
[]
=
{
3067
30
05
,
3006
,
3007
,
3008
,
3009
,
3010
,
3011
,
3026
,
3027
,
30
67
};
static
int
outlet_dev_pid
[]
=
{
30
20
30
19
,
3020
,
3037
,
3038
};
...
...
application/klansdk/kk_oldccu_msg.c
View file @
4d9d15b7
...
...
@@ -67,7 +67,7 @@ int send_msg_to_module(cJSON *root)
}
if
((
msg
=
cJSON_Print
(
root
))
!=
NULL
){
debug_log
(
LOG_INFO
,
"[lan->module]
\n
%s
\n
"
,
msg
);
debug_log
(
LOG_INFO
_LEVEL
,
"[lan->module]
\n
%s
\n
"
,
msg
);
cJSON_Minify
(
msg
);
kk_send_data_to_sdk
(
msg
);
free
(
msg
);
...
...
@@ -90,13 +90,14 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
if
(
newccuItem
==
NULL
||
newccuItem
->
type
!=
cJSON_Object
||
oldccuItem
==
NULL
||
oldccuItem
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
NULL
;
}
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_dataType
=
cJSON_GetObjectItem
(
newccuItem
,
DATATYPE_STRING
);
n_value
=
cJSON_GetObjectItem
(
newccuItem
,
"value"
);
...
...
@@ -105,6 +106,7 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
}
else
{
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
DATATYPE_STRING
);
}
return
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
n_value
);
}
...
...
@@ -113,18 +115,38 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg)
{
cJSON
*
msg
=
NULL
;
char
nodeBuff
[
33
]
=
{
0
};
char
valBuff
[
33
]
=
{
0
};
if
(
opcode
==
NULL
||
opcode
->
type
!=
cJSON_String
||
arg
==
NULL
||
arg
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
arg
==
NULL
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"nodeId=%d,opcode=%s,arg=%s
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuestring
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
32
,
"%d"
,
nodeId
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
memset
(
valBuff
,
0
,
sizeof
(
valBuff
));
if
(
arg
->
type
==
cJSON_String
){
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%s
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuestring
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
arg
->
valuestring
);
}
else
if
(
arg
->
type
==
cJSON_Number
){
if
(((
int
)(
arg
->
valuedouble
*
10
))
%
10
==
0
){
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%d
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valueint
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%d"
,
arg
->
valueint
);
}
else
{
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%f
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuedouble
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%f"
,
arg
->
valuedouble
);
}
}
else
if
(
arg
->
type
==
cJSON_True
){
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
"true"
);
}
else
if
(
arg
->
type
==
cJSON_True
){
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
"false"
);
}
msg
=
old_ccu_msg_build
(
nodeBuff
,
opcode
->
valuestring
,
"success"
,
arg
->
valuestring
);
send_msg_to_module
(
msg
);
cJSON_Delete
(
msg
);
...
...
@@ -139,7 +161,7 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
if
(
channelObj
!=
NULL
&&
epNumObj
!=
NULL
){
if
(
epNumObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
,
"[err] epNumObj.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] epNumObj.
\n
"
);
return
-
1
;
}
if
(
strlen
(
channelObj
->
valuestring
)
!=
strlen
(
epNumObj
->
valuestring
)
||
...
...
@@ -151,13 +173,13 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
}
else
{
if
(
channelObj
==
NULL
){
if
(
epNumObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
,
"[err] epNumObj.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] epNumObj.
\n
"
);
return
-
1
;
}
channel
=
atoi
(
epNumObj
->
valuestring
);
}
else
if
(
epNumObj
==
NULL
){
if
(
channelObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
,
"[err] channelObj.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] channelObj.
\n
"
);
return
-
1
;
}
channel
=
atoi
(
channelObj
->
valuestring
);
...
...
@@ -183,15 +205,15 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t *
}
if
((
arg
=
_kk_sync_devicestatus_arg_build
(
devNode
))
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] arg.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] arg.
\n
"
);
return
-
1
;
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
1
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[err] nodeId.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nodeId.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"[sync] device status.
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[sync] device status.
\n
"
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
sizeof
(
nodeBuff
),
"%d"
,
nodeId
);
...
...
@@ -221,7 +243,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
cJSON
*
n_id
=
NULL
;
cJSON
*
item_size
=
NULL
;
int
o_item_size
=
0
,
n_item_size
=
0
;
int
item_size
=
0
;
cJSON
*
epsAry
=
NULL
,
*
epAryItem
=
NULL
,
*
epAryEpNumObj
=
NULL
;
...
...
@@ -231,27 +254,33 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
if
(
deviceCode
==
NULL
||
devNode
==
NULL
||
params
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
oldccu
=
devNode
->
oldccu
;
newccu
=
devNode
->
newccu
;
item_size
=
cJSON_GetArraySize
(
newccu
);
o_item_size
=
cJSON_GetArraySize
(
oldccu
);
n_item_size
=
cJSON_GetArraySize
(
newccu
);
item_size
=
(
n_item_size
>
o_item_size
)
?
n_item_size
:
o_item_size
;
for
(
i
=
0
;
i
<
item_size
;
i
++
){
n_item
=
cJSON_GetArrayItem
(
newccu
,
i
);
if
((
o_item
=
cJSON_GetArrayItem
(
oldccu
,
i
))
==
NULL
||
o_item
->
type
!=
cJSON_Object
){
debug_log
(
LOG_INFO
,
"[err] para.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] para.i=%d
\n
"
,
i
);
continue
;
}
if
((
n_id
=
cJSON_GetObjectItem
(
n_item
,
"identifier"
))
==
NULL
||
n_id
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] cfg file.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] cfg file.
\n
"
);
continue
;
}
...
...
@@ -263,16 +292,18 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
o_dataType
=
cJSON_GetObjectItem
(
o_item
,
"dataType"
);
o_valueRange
=
cJSON_GetObjectItem
(
o_item
,
"valueRange"
);
if
(
n_dataType
==
NULL
||
n_dataType
->
type
!=
cJSON_String
||
o_dataType
==
NULL
||
o_dataType
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] dataType.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] dataType.
\n
"
);
continue
;
}
channelObj
=
cJSON_GetObjectItem
(
o_item
,
"channel"
);
epNumObj
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
if
((
channel
=
_kk_lan_check_channel
(
channelObj
,
epNumObj
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[channel] %d.
\n
"
,
channel
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[channel] %d.
\n
"
,
channel
);
continue
;
}
...
...
@@ -283,12 +314,12 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
epAryEpNumObj
=
cJSON_GetObjectItem
(
epAryItem
,
"epNum"
);
if
(
epAryEpNumObj
==
NULL
||
epAryEpNumObj
->
type
!=
cJSON_String
||
channel
!=
atoi
(
epAryEpNumObj
->
valuestring
)){
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[epsAry match] next.
\n
"
);
continue
;
}
if
((
valObj
=
cJSON_GetObjectItem
(
epAryItem
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[epsAry match] next.
\n
"
);
continue
;
}
else
{
mFlag
=
1
;
...
...
@@ -300,35 +331,40 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
}
}
else
{
if
((
valObj
=
cJSON_GetObjectItem
(
params
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[match] next.
\n
"
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[match] next.
\n
"
);
continue
;
}
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
channel
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[err] not find node.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find node.
\n
"
);
continue
;
}
if
((
opcode
=
cJSON_GetObjectItem
(
n_item
,
"opcodemap"
))
==
NULL
||
opcode
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] cfg file.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] cfg file.
\n
"
);
continue
;
}
kk_lan_replace_val_to_obj
(
n_item
,
valObj
,
"value"
);
if
((
args
=
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
valObj
))
!=
NULL
){
_kk_lan_update_device_status
(
nodeId
,
opcode
,
args
);
//todo :
//cJSON_Delete(args);
}
}
_kk_lan_sync_device_status
(
deviceCode
,
devNode
);
...
...
@@ -363,7 +399,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
cJSON
*
params
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[property post] deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[property post] deviceCode(%s).
\n
"
,
deviceCode
);
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
dev
)
==
0
){
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
...
...
@@ -374,7 +410,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
return
kk_lan_property_convert
(
deviceCode
,
dev
,
params
);
}
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
return
-
1
;
}
return
0
;
...
...
@@ -386,12 +422,12 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
cJSON
*
params
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[property syn] deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[property syn] deviceCode(%s).
\n
"
,
deviceCode
);
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
dev
)
==
0
){
return
kk_lan_property_convert
(
deviceCode
,
dev
,
properties
);
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
return
-
1
;
}
return
0
;
...
...
@@ -400,7 +436,7 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
//添加场景通知
void
kk_lan_add_scene_notify
(
const
char
*
scene_id
)
{
debug_log
(
LOG_FOCUS
,
"[notify] add scene(%s).
\n
"
,
scene_id
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] add scene(%s).
\n
"
,
scene_id
);
kk_handle_sync_info
();
}
...
...
@@ -408,7 +444,7 @@ void kk_lan_add_scene_notify(const char* scene_id)
//删除场景通知
void
kk_lan_delete_scene_notify
(
const
char
*
scene_id
)
{
debug_log
(
LOG_FOCUS
,
"[notify] delete scene(%s).
\n
"
,
scene_id
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] delete scene(%s).
\n
"
,
scene_id
);
cJSON
*
msg
=
old_ccu_msg_build
(
scene_id
,
"DELETE_SCENE"
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
send_msg_to_module
(
msg
);
...
...
@@ -422,7 +458,7 @@ int kk_lan_arming_status_notify(int type)
{
cJSON
*
msg
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[notify] arming status(%d).
\n
"
,
type
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] arming status(%d).
\n
"
,
type
);
if
(
type
==
0
){
msg
=
old_ccu_msg_build
(
WILDCARD_CHARACTER_STR
,
GUARD_STATUS_ARMING_LEAVE_HOME
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
...
...
@@ -433,7 +469,7 @@ int kk_lan_arming_status_notify(int type)
}
else
if
(
type
==
3
){
msg
=
old_ccu_msg_build
(
WILDCARD_CHARACTER_STR
,
ARMING_STATUS_GUARD_ZONE
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] unknow type(%d).
\n
"
,
type
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] unknow type(%d).
\n
"
,
type
);
return
-
1
;
}
...
...
@@ -451,11 +487,11 @@ static int _kk_lan_delete_node(const char *deviceCode,const char *nodeid)
kk_map_dev_node_t
*
dev
;
if
(
deviceCode
==
NULL
||
nodeid
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] params.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"[del dev node] id(%s).
\n
"
,
nodeid
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[del dev node] id(%s).
\n
"
,
nodeid
);
arg
=
cJSON_CreateObject
();
_deviceCode_switchto_mac
(
deviceCode
,
mac
);
...
...
@@ -476,7 +512,7 @@ static int _kk_lan_delete_device(const char *deviceCode)
num
=
kk_lan_db_node_get_all
(
deviceCode
,
list
);
debug_log
(
LOG_FOCUS
,
"[del dev] deviceCode(%s)/node num(%d).
\n
"
,
deviceCode
,
num
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[del dev] deviceCode(%s)/node num(%d).
\n
"
,
deviceCode
,
num
);
for
(
i
=
0
;
i
<
num
;
i
++
){
memset
(
nodeId
,
0
,
sizeof
(
nodeId
));
...
...
@@ -500,13 +536,13 @@ int kk_lan_device_delete_notify(cJSON *payload)
if
((
params
=
cJSON_GetObjectItem
(
payload
,
"params"
))
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] params.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params.
\n
"
);
return
-
1
;
}
if
((
deviceCode
=
cJSON_GetObjectItem
(
params
,
"deviceCode"
))
==
NULL
||
params
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] deviceCode.
\n
"
);
deviceCode
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] deviceCode.
\n
"
);
return
-
1
;
}
...
...
application/klansdk/kk_voice_panel_handle.h
View file @
4d9d15b7
...
...
@@ -6,9 +6,9 @@
#include "kk_voice_panel_cfg.h"
#define VP_CONFIG_FILE_MD5 "voice_data.MD5"
#define VP_CONFIG_FILE "/etc/smarthome/voice_data.json"
#define VP_CONFIG_FILE_TAR_GZ "voice_data.tar.gz"
#define VP_CONFIG_FILE_MD5 "/data/kk/voice_data.MD5"
#define VP_CONFIG_FILE_TAR_GZ "/data/kk/voice_data.tar.gz"
#define OPCODE_8009_SNAPSHOOT 0x1000
...
...
opcodeMapCfg/device_3024.json
View file @
4d9d15b7
opcodeMapCfg/device_3029.json
View file @
4d9d15b7
...
...
@@ -47,13 +47,6 @@
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
22
},{
"identifier"
:
"time_off"
,
"opcodemap"
:
"FLOOR_HEATING_DEV_STATUS"
,
"dataType"
:
"dummy"
,
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
0
}
],
"oldccu"
:[
...
...
@@ -76,7 +69,7 @@
},{
"opcode"
:
"SET_WORK_TEMPERATURE"
,
"identifiermap"
:
"Temperature"
,
"dataType"
:
"double"
,
"dataType"
:
"
string_
double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"work_temperature"
,
...
...
@@ -84,7 +77,7 @@
},{
"opcode"
:
"FLOOR_HEATING_SET_TIME_OFF"
,
"identifiermap"
:
"TimingOffTime"
,
"dataType"
:
"
double
"
,
"dataType"
:
"
fit
"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"time_off"
,
...
...
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