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
a8ec59b6
Commit
a8ec59b6
authored
Sep 13, 2021
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除编译警告,离线语音面板接入空调,新风,线控器,窗帘
parent
23221610
Changes
33
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
1325 additions
and
417 deletions
+1325
-417
application/klansdk/kk_ccu_msg.c
application/klansdk/kk_ccu_msg.c
+3
-2
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+4
-2
application/klansdk/kk_data_handle.h
application/klansdk/kk_data_handle.h
+6
-0
application/klansdk/kk_data_mng.c
application/klansdk/kk_data_mng.c
+7
-7
application/klansdk/kk_data_mng.h
application/klansdk/kk_data_mng.h
+9
-2
application/klansdk/kk_findccu_handle.c
application/klansdk/kk_findccu_handle.c
+1
-0
application/klansdk/kk_findccu_handle.h
application/klansdk/kk_findccu_handle.h
+1
-0
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+8
-3
application/klansdk/kk_lan_debug.h
application/klansdk/kk_lan_debug.h
+7
-0
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+9
-7
application/klansdk/kk_lan_new_dev_notify.c
application/klansdk/kk_lan_new_dev_notify.c
+5
-5
application/klansdk/kk_lan_new_dev_notify.h
application/klansdk/kk_lan_new_dev_notify.h
+10
-3
application/klansdk/kk_lan_node_db.c
application/klansdk/kk_lan_node_db.c
+18
-16
application/klansdk/kk_lan_node_db.h
application/klansdk/kk_lan_node_db.h
+2
-2
application/klansdk/kk_lan_queue.c
application/klansdk/kk_lan_queue.c
+1
-2
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+164
-66
application/klansdk/kk_lan_sync.h
application/klansdk/kk_lan_sync.h
+12
-1
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+19
-9
application/klansdk/kk_lan_vp_ctrl.c
application/klansdk/kk_lan_vp_ctrl.c
+387
-83
application/klansdk/kk_lan_vp_ctrl.h
application/klansdk/kk_lan_vp_ctrl.h
+54
-1
application/klansdk/kk_login_handle.c
application/klansdk/kk_login_handle.c
+4
-0
application/klansdk/kk_newccu_msg.c
application/klansdk/kk_newccu_msg.c
+4
-1
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+19
-13
application/klansdk/kk_oldccu_msg.h
application/klansdk/kk_oldccu_msg.h
+4
-0
application/klansdk/kk_voice_panel_cfg.c
application/klansdk/kk_voice_panel_cfg.c
+344
-50
application/klansdk/kk_voice_panel_cfg.h
application/klansdk/kk_voice_panel_cfg.h
+9
-7
application/klansdk/kk_voice_panel_handle.c
application/klansdk/kk_voice_panel_handle.c
+142
-99
application/klansdk/kk_voice_panel_handle.h
application/klansdk/kk_voice_panel_handle.h
+10
-15
application/klansdk/uart_proto.c
application/klansdk/uart_proto.c
+9
-10
midware/midware/dm/kk_sync_data.c
midware/midware/dm/kk_sync_data.c
+12
-5
midware/midware/scene/kk_scene_db.c
midware/midware/scene/kk_scene_db.c
+3
-0
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+37
-5
midware/tsl/tsl_handle/kk_tsl_common.h
midware/tsl/tsl_handle/kk_tsl_common.h
+1
-1
No files found.
application/klansdk/kk_ccu_msg.c
View file @
a8ec59b6
...
...
@@ -464,6 +464,7 @@ int kk_lan_get_msg_id_str(char *msgId,int size)
{
memset
(
msgId
,
0
,
size
);
snprintf
(
msgId
,
size
,
"%d"
,
kk_lan_get_msg_id
());
return
0
;
}
...
...
@@ -495,7 +496,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_LEVEL
,
"[err] nonsupport type(%
s
).
\n
"
,
val
->
type
);
debug_log
(
LOG_DEBUG_LEVEL
,
"[err] nonsupport type(%
d
).
\n
"
,
val
->
type
);
return
-
1
;
}
return
0
;
...
...
@@ -525,7 +526,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_LEVEL
,
"[err] nonsupport type(%
s
).
\n
"
,
val
->
type
);
debug_log
(
LOG_DEBUG_LEVEL
,
"[err] nonsupport type(%
d
).
\n
"
,
val
->
type
);
return
-
1
;
}
return
0
;
...
...
application/klansdk/kk_data_handle.c
View file @
a8ec59b6
...
...
@@ -18,8 +18,10 @@
#include "kk_lan_ctrl.h"
#include "kk_lan_sync.h"
#include "kk_lan_debug.h"
#include "kk_findccu_handle.h"
#include "kk_voice_panel_handle.h"
#include "kk_lan_node_db.h"
#include "kk_oldccu_msg.h"
const
char
DM_MSG_TO_MIDDWARE
[]
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
...
...
@@ -219,7 +221,7 @@ static int kk_loginccu_ack(cJSON *arg,int sockfd)
}
//构建hw信息
static
cJSON
*
kk_zb_dev_hw_info_build
(
const
char
*
deviceCode
,
c
JSON
*
productCode
,
int
online
,
const
char
*
hw_ver
,
const
char
*
sw_ver
)
static
cJSON
*
kk_zb_dev_hw_info_build
(
const
char
*
deviceCode
,
c
onst
char
*
productCode
,
int
online
,
const
char
*
hw_ver
,
const
char
*
sw_ver
)
{
cJSON
*
item
;
char
mac
[
32
]
=
{
0
};
...
...
application/klansdk/kk_data_handle.h
View file @
a8ec59b6
...
...
@@ -7,4 +7,10 @@
int
kk_data_handle
(
cJSON
*
json
,
int
sockfd
);
void
kk_handle_sync_info
(
void
);
void
KK_Data_FromMid
(
void
*
str
,
int
len
);
int
kk_lan_property_syn_deal
(
const
char
*
deviceCode
,
cJSON
*
properties
);
int
send_msg_to_module
(
cJSON
*
root
);
void
device_add_sync
(
cJSON
*
payload
);
void
kk_handle_sync_push_info
(
void
);
#endif
\ No newline at end of file
application/klansdk/kk_data_mng.c
View file @
a8ec59b6
...
...
@@ -5,7 +5,7 @@
#include "kk_data_mng.h"
#include "kk_lan_node_db.h"
#include "kk_oldccu_msg.h"
#include "kk_utils.h"
static
kk_map_dev_ctx
g_map_dev_mgr
=
{
0
};
...
...
@@ -192,7 +192,7 @@ static kk_map_dev_node_t *kk_map_dev_node_create_ex(const char *deviceCode,const
}
static
char
*
kk_open_lan_cfg_file
(
char
*
deviceCode
)
static
char
*
kk_open_lan_cfg_file
(
c
onst
c
har
*
deviceCode
)
{
char
path
[
128
]
=
{
0
};
unsigned
int
filesize
;
...
...
@@ -226,7 +226,7 @@ static char *kk_open_lan_cfg_file(char *deviceCode)
return
buf
;
}
//todo:
int
kk_creater_nodeid
(
char
*
deviceCode
,
int
channel
,
char
*
nodeId
,
int
operate_type
)
int
kk_creater_nodeid
(
char
*
deviceCode
,
int
channel
,
char
*
nodeId
)
{
static
int
next
=
1
;
int
node
=-
1
;
...
...
@@ -245,7 +245,7 @@ int kk_creater_nodeid(char *deviceCode,int channel,char *nodeId,int operate_type
while
(
kk_check_lan_node
(
next
)){
++
next
;
}
if
(
0
==
kk_lan_db_node_insert
(
deviceCode
,
channel
,
next
,
operate_type
)){
if
(
0
==
kk_lan_db_node_insert
(
deviceCode
,
channel
,
next
)){
node
=
next
;
}
}
...
...
@@ -264,7 +264,7 @@ int kk_creater_nodeid(char *deviceCode,int channel,char *nodeId,int operate_type
static
char
*
kk_value_int_map_string
(
char
*
opcodemap
,
kk_map_dev_node_t
*
node
,
int
idx
)
{
if
(
opcodemap
==
NULL
||
node
==
NULL
){
return
-
1
;
return
""
;
}
cJSON
*
oldccuItem
=
node
->
oldccu
->
child
;
while
(
oldccuItem
!=
NULL
){
...
...
@@ -321,7 +321,7 @@ int mac_switchto_deviceCode(char *mac,char * deviceCode)
deviceCode
[
j
]
=
'\0'
;
/*在串s结尾加结束标志*/
return
0
;
}
int
_deviceCode_switchto_mac
(
char
*
deviceCode
,
char
*
mac
)
int
_deviceCode_switchto_mac
(
c
onst
c
har
*
deviceCode
,
char
*
mac
)
{
char
deviceCode_bak
[
33
]
=
{
0
};
int
i
,
j
;
...
...
@@ -435,7 +435,7 @@ int kk_map_dev_update_int_value_by_devicecode(char *deviceCode,char *identifier,
}
int
kk_map_dev_search_by_deviceCode
(
char
*
deviceCode
,
kk_map_dev_node_t
**
node
)
int
kk_map_dev_search_by_deviceCode
(
c
onst
c
har
*
deviceCode
,
kk_map_dev_node_t
**
node
)
{
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
kk_map_dev_node_t
*
search_node
=
NULL
;
...
...
application/klansdk/kk_data_mng.h
View file @
a8ec59b6
...
...
@@ -31,11 +31,18 @@ typedef struct {
kk_map_dev_node_t
*
kk_map_dev_node_add
(
const
char
*
deviceCode
,
const
char
*
productCode
,
const
char
*
gwdeviceCode
,
const
char
*
onlineStatus
);
int
kk_create_devicestatus_to_sdk
(
cJSON
*
root
);
int
kk_create_devices_to_sdk
(
cJSON
*
root
);
int
_deviceCode_switchto_mac
(
char
*
deviceCode
,
char
*
mac
);
int
_deviceCode_switchto_mac
(
c
onst
c
har
*
deviceCode
,
char
*
mac
);
int
mac_switchto_deviceCode
(
char
*
mac
,
char
*
deviceCode
);
int
kk_map_dev_search_by_deviceCode
(
char
*
deviceCode
,
kk_map_dev_node_t
**
node
);
int
kk_map_dev_search_by_deviceCode
(
c
onst
c
har
*
deviceCode
,
kk_map_dev_node_t
**
node
);
kk_map_dev_ctx
*
_kk_map_dev_ctx
(
void
);
int
kk_map_dev_init
(
void
);
int
kk_map_dev_search_by_productCode
(
char
*
productCode
,
kk_map_dev_node_t
**
node
);
void
_kk_map_dev_mutex_lock
(
void
);
void
_kk_map_dev_mutex_unlock
(
void
);
void
kk_map_dev_deinit
(
void
);
int
kk_creater_nodeid
(
char
*
deviceCode
,
int
channel
,
char
*
nodeId
);
#endif
application/klansdk/kk_findccu_handle.c
View file @
a8ec59b6
...
...
@@ -17,6 +17,7 @@
#include "kk_hal.h"
#include "cJSON.h"
static
int
kk_findccu_ack
(
int
sockfd
,
struct
sockaddr_in
*
addr
){
cJSON
*
json
=
NULL
,
*
args
=
NULL
;
cJSON
*
ccu
=
NULL
;
...
...
application/klansdk/kk_findccu_handle.h
View file @
a8ec59b6
...
...
@@ -15,6 +15,7 @@
#define FINDCCU_LOCAL_PORT 8989
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
int
kk_findccu_handle_init
(
void
);
#endif
\ No newline at end of file
application/klansdk/kk_lan_ctrl.c
View file @
a8ec59b6
...
...
@@ -10,8 +10,9 @@
#include "kk_ccu_msg.h"
#include "kk_oldccu_msg.h"
#include "kk_newccu_msg.h"
#include "kk_lan_node_db.h"
extern
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
int
match_opcode_pos
(
cJSON
*
array
,
const
char
*
opcode
,
int
ch
)
...
...
@@ -320,8 +321,12 @@ int kk_ccu_opcode_handle(cJSON *root)
WARNING_PRINT
(
"[requester]%s
\n
"
,
requester
->
valuestring
);
if
(
strcmp
(
requester
->
valuestring
,
"HJ_CentralAC"
)
==
0
&&
strcmp
(
opcode
->
valuestring
,
"CENTRAL_AC_INDOOR_UNIT_SETTING"
)
==
0
){
int
channel
=
-
1
;
char
epNum
[
8
]
=
{
0
};
kk_indoorAir_ctrl_handle
(
nodeId
->
valuestring
,
arg
);
kk_lan_db_channel_get
(
atoi
(
nodeId
->
valuestring
),
&
channel
);
snprintf
(
epNum
,
sizeof
(
epNum
),
"%d"
,
channel
);
kk_indoorAir_ctrl_handle
(
epNum
,
arg
);
return
0
;
}
else
if
(
strcmp
(
requester
->
valuestring
,
"HJ_Server"
)
==
0
){
if
(
strcmp
(
opcode
->
valuestring
,
"ARMING_IN_HOME"
)
==
0
){
...
...
application/klansdk/kk_lan_debug.h
View file @
a8ec59b6
...
...
@@ -49,8 +49,15 @@
printf("%s%s [%s:%d(%s)] "format"\033[m", LOG_LEVEL_(level),buff,__FILE__,__LINE__,__func__,##__VA_ARGS__); \
} \
}while(0)
#define _debug_log(level,format,...) do { \
if( level >= LOG_LEVEL && level <= LOG_CRITICAL_LEVEL) { \
printf("%s"format"\033[m", LOG_LEVEL_(level),##__VA_ARGS__); \
} \
}while(0)
#else
#define debug_log(level,format,...)
#define _debug_log(level,format,...)
#endif
...
...
application/klansdk/kk_lan_main.c
View file @
a8ec59b6
...
...
@@ -59,8 +59,8 @@ static void kk_lan_ccuid_init(void)
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
sprintf
(
ccuidTmp
,
"CCU_%s"
,
ccuid
);
_setDevice_Code
(
ccuidTmp
,
strlen
(
ccuidTmp
)
-
1
);
sprintf
(
(
char
*
)
ccuidTmp
,
"CCU_%s"
,
ccuid
);
_setDevice_Code
(
(
char
*
)
ccuidTmp
,
strlen
((
char
*
)
ccuidTmp
)
-
1
);
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
...
...
@@ -132,10 +132,10 @@ int main(int argc, char* argv[])
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;
//
}
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
();
...
...
@@ -144,7 +144,9 @@ 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
();
...
...
application/klansdk/kk_lan_new_dev_notify.c
View file @
a8ec59b6
...
...
@@ -33,8 +33,8 @@ static cJSON * _new_central_ac_gw_indoor_build(void* arg);
static
cJSON
*
_new_youzhuan_music_controllers_build
(
void
*
arg
);
typedef
cJSON
*
(
*
build_func
)(
void
*
*
items
);
typedef
struct
{
typedef
cJSON
*
(
*
build_func
)(
void
*
arg
);
typedef
struct
BUILD_FUNC
{
#define NEW_DEVICES_BUILD_TYPE 0
#define NEW_HUE_LIGHTS_BUILD_TYPE 1
...
...
@@ -74,13 +74,13 @@ static BUILD_FUNC new_dev_build_table[]={
{
NEW_YOUZHUAN_MUSIC_CONTROLLERS_BUILD_TYPE
,
_new_youzhuan_music_controllers_build
},
};
build_func
*
find_build_func
(
int
type
)
build_func
find_build_func
(
int
type
)
{
int
i
,
size
;
BUILD_FUNC
*
func
=
NULL
;
size
=
sizeof
(
new_dev_build_table
)
/
sizeof
(
BUILD_FUNC
);
func
=
&
new_dev_build_table
;
func
=
(
BUILD_FUNC
*
)
&
new_dev_build_table
;
for
(
i
=
0
;
i
<
size
;
i
++
,
func
++
){
if
(
func
->
type
==
type
){
...
...
@@ -353,7 +353,7 @@ static cJSON *new_devices_build_gw(int count)
}
return
ary
;
}
static
cJSON
*
new_devices_build_indoor
(
int
count
)
cJSON
*
new_devices_build_indoor
(
int
count
)
{
int
i
=
0
;
cJSON
*
ary
=
cJSON_CreateArray
();
...
...
application/klansdk/kk_lan_new_dev_notify.h
View file @
a8ec59b6
#ifndef __KK_LAN_NEW_DEV_NOTIFY_H
#define __KK_LAN_NEW_DEV_NOTIFY_H
#include "kk_ccu_msg.h"
#include "kk_lan_sync.h"
#include <stdbool.h>
typedef
struct
{
cJSON
*
new_device_count
;
...
...
@@ -135,9 +136,11 @@ typedef struct{
}
CENTRAL_AC_INDOOR_STATUS
;
typedef
struct
{
char
id
[
4
];
char
indooruint_addr
[
4
];
char
nodeid
[
8
];
char
id
[
AIR_AC_INDOOR_ID_SIZE
];
char
indooruint_addr
[
AIR_AC_INDOOR_ADDR_SIZE
];
char
nodeid
[
AIR_AC_INDOOR_ID_SIZE
];
char
dev_name
[
AIR_AC_INDOOR_NAME_SIZE
];
char
room_id
[
AIR_AC_INDOOR_ROOM_ID_SIZE
];
CENTRAL_AC_INDOOR_STATUS
ac_gw_status
;
}
CENTRAL_AC_INDOOR_ITEM
;
...
...
@@ -150,6 +153,10 @@ typedef struct{
char
*
music_controller_status
;
}
YOUZHUAN_MC_CTRL_ITEM
;
void
kk_clear_indoor_data
();
void
kk_new_device_send
();
#endif
...
...
application/klansdk/kk_lan_node_db.c
View file @
a8ec59b6
...
...
@@ -7,6 +7,9 @@
extern
void
HAL_MutexLock
(
_IN_
void
*
mutex
);
extern
void
HAL_MutexUnlock
(
_IN_
void
*
mutex
);
extern
void
*
HAL_MutexCreate
(
void
);
static
sqlite3
*
g_lan_pDb
;
...
...
@@ -46,8 +49,7 @@ static int _kk_lan_node_db_Init(void)
idx INTEGER PRIMARY KEY, \
deviceCode varchar(33), \
channel INTEGER, \
nodeId INTEGER, \
operate_type INTEGER)"
;
nodeId INTEGER)"
;
char
*
pcErr
;
...
...
@@ -105,7 +107,7 @@ int kk_check_lan_node(int nodeId)
{
int
isExist
=
0
;
sqlite3_stmt
*
stmt
;
char
*
pDeviceCode
=
NULL
;
unsigned
char
*
pDeviceCode
=
NULL
;
int
node
=
0
;
kk_lan_node_db_ctx_t
*
ctx
=
_kk_lan_node_db_get_ctx
();
const
char
*
searchCmd
=
"select * from Map2Node;"
;
...
...
@@ -140,7 +142,7 @@ int kk_check_lan_node_exist(const char* deviceCode,int channel)
{
int
isExist
=
0
;
sqlite3_stmt
*
stmt
;
char
*
pDeviceCode
=
NULL
;
c
onst
unsigned
c
har
*
pDeviceCode
=
NULL
;
int
ch
=
0
;
int
node
=
0
;
kk_lan_node_db_ctx_t
*
ctx
=
_kk_lan_node_db_get_ctx
();
...
...
@@ -151,7 +153,7 @@ int kk_check_lan_node_exist(const char* deviceCode,int channel)
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pDeviceCode
=
sqlite3_column_text
(
stmt
,
LAN_DB_DEVICECODE
);
ch
=
sqlite3_column_int
(
stmt
,
LAN_DB_CHANNEL
);
if
(
!
strcmp
(
deviceCode
,
pDeviceCode
)
&&
ch
==
channel
)
if
(
!
strcmp
(
deviceCode
,
(
const
char
*
)
pDeviceCode
)
&&
ch
==
channel
)
{
isExist
=
1
;
break
;
...
...
@@ -166,7 +168,7 @@ static int _kk_check_lan_node_same(const char* deviceCode,int channel,int nodeId
{
int
same
=
0
;
sqlite3_stmt
*
stmt
;
char
*
pDeviceCode
=
NULL
;
c
onst
unsigned
c
har
*
pDeviceCode
=
NULL
;
int
ch
=
0
;
int
node
=
0
;
kk_lan_node_db_ctx_t
*
ctx
=
_kk_lan_node_db_get_ctx
();
...
...
@@ -178,7 +180,7 @@ static int _kk_check_lan_node_same(const char* deviceCode,int channel,int nodeId
pDeviceCode
=
sqlite3_column_text
(
stmt
,
LAN_DB_DEVICECODE
);
ch
=
sqlite3_column_int
(
stmt
,
LAN_DB_CHANNEL
);
node
=
sqlite3_column_int
(
stmt
,
LAN_DB_NODE
);
if
(
!
strcmp
(
deviceCode
,
pDeviceCode
)
&&
ch
==
channel
&&
node
==
nodeId
)
if
(
!
strcmp
(
deviceCode
,
(
const
char
*
)
pDeviceCode
)
&&
ch
==
channel
&&
node
==
nodeId
)
{
same
=
1
;
break
;
...
...
@@ -234,10 +236,10 @@ static int kk_lan_db_node_update(const char *deviceCode,int channel,int node)
*返 回 值: 0:成功;其他:失败
*其他说明:属性的值插入的时候先置空,后续再update
*************************************************************/
int
kk_lan_db_node_insert
(
const
char
*
deviceCode
,
int
channel
,
int
node
,
int
operate_type
)
int
kk_lan_db_node_insert
(
const
char
*
deviceCode
,
int
channel
,
int
node
)
{
const
char
*
insertCmd
=
"insert into Map2Node (deviceCode,channel,nodeId
,operate_type
) \
values ('%s','%d','%d'
,'%d'
);"
;
const
char
*
insertCmd
=
"insert into Map2Node (deviceCode,channel,nodeId) \
values ('%s','%d','%d');"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
...
...
@@ -251,7 +253,7 @@ int kk_lan_db_node_insert(const char *deviceCode,int channel,int node,int operat
}
_kk_lan_node_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
channel
,
node
,
operate_type
);
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
channel
,
node
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
...
...
@@ -355,7 +357,7 @@ int kk_lan_db_get_item_by_node(int node,char *deviceCode,int *channel)
char
*
zErrMsg
=
0
;
sqlite3_stmt
*
stmt
;
kk_lan_node_db_ctx_t
*
ctx
=
_kk_lan_node_db_get_ctx
();
char
*
dCode
=
0
;
c
onst
unsigned
c
har
*
dCode
=
0
;
_kk_lan_node_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
"select * from Map2Node WHERE nodeId= '%d' "
,
node
);
...
...
@@ -363,7 +365,7 @@ int kk_lan_db_get_item_by_node(int node,char *deviceCode,int *channel)
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
if
(
deviceCode
!=
NULL
){
dCode
=
sqlite3_column_text
(
stmt
,
LAN_DB_DEVICECODE
);
memcpy
(
deviceCode
,
dCode
,
strlen
(
dCode
));
memcpy
(
deviceCode
,
(
char
*
)
dCode
,
strlen
((
char
*
)
dCode
));
}
if
(
channel
!=
NULL
){
...
...
@@ -379,12 +381,12 @@ int kk_lan_db_get_item_by_node(int node,char *deviceCode,int *channel)
}
int
kk_lan_db_channel_get
(
int
node
,
int
*
channel
)
{
kk_lan_db_get_item_by_node
(
node
,
NULL
,
channel
);
return
kk_lan_db_get_item_by_node
(
node
,
NULL
,
channel
);
}
int
kk_lan_db_deviceCode_get
(
int
node
,
char
*
deviceCode
)
{
kk_lan_db_get_item_by_node
(
node
,
deviceCode
,
NULL
);
return
kk_lan_db_get_item_by_node
(
node
,
deviceCode
,
NULL
);
}
...
...
@@ -396,7 +398,7 @@ int kk_lan_db_deviceCode_get(int node,char *deviceCode)
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_lan_db_node_delete
(
char
*
deviceCode
)
int
kk_lan_db_node_delete
(
c
onst
c
har
*
deviceCode
)
{
const
char
*
deleteCmd
=
"delete from Map2Node where deviceCode = '%s';"
;
char
*
sqlCmd
=
NULL
;
...
...
application/klansdk/kk_lan_node_db.h
View file @
a8ec59b6
...
...
@@ -18,7 +18,7 @@ enum{
};
int
kk_lan_db_node_init
(
void
);
int
kk_lan_db_node_insert
(
const
char
*
deviceCode
,
int
channel
,
int
node
,
int
operate_type
);
int
kk_lan_db_node_insert
(
const
char
*
deviceCode
,
int
channel
,
int
node
);
int
kk_lan_db_node_get
(
const
char
*
deviceCode
,
int
channel
);
int
kk_lan_db_node_get_all
(
const
char
*
deviceCode
,
int
*
nodes
);
...
...
@@ -26,7 +26,7 @@ int kk_lan_db_deviceCode_get(int node,char *deviceCode);
int
kk_lan_db_channel_get
(
int
node
,
int
*
channel
);
int
kk_lan_db_get_item_by_node
(
int
node
,
char
*
deviceCode
,
int
*
channel
);
int
kk_lan_db_node_delete
(
char
*
deviceCode
);
int
kk_lan_db_node_delete
(
c
onst
c
har
*
deviceCode
);
int
kk_check_lan_node_exist
(
const
char
*
deviceCode
,
int
channel
);
int
kk_check_lan_node
(
int
nodeId
);
...
...
application/klansdk/kk_lan_queue.c
View file @
a8ec59b6
...
...
@@ -38,7 +38,6 @@ static int _lan_queue_init(LAN_QUEUE_ENUM ix,int max_size)
ctx
->
mutex
=
(
pthread_mutex_t
*
)
malloc
(
sizeof
(
pthread_mutex_t
));
if
(
ctx
->
mutex
==
NULL
)
{
WARNING_PRINT
(
"
\n
malloc queue mutex[%d] failed: - '%s' (%d)
\n
"
,
ix
,
strerror
(
err_num
),
err_num
);
return
-
1
;
}
...
...
@@ -59,7 +58,7 @@ static int _lan_queue_init(LAN_QUEUE_ENUM ix,int max_size)
int
lan_queue_init
(
void
)
{
_lan_queue_init
(
NODE_MAP
,
LAN_QUEUE_SIZE
(
1
));
return
_lan_queue_init
(
NODE_MAP
,
LAN_QUEUE_SIZE
(
1
));
}
void
lan_queue_deinit
(
void
)
{
...
...
application/klansdk/kk_lan_sync.c
View file @
a8ec59b6
This diff is collapsed.
Click to expand it.
application/klansdk/kk_lan_sync.h
View file @
a8ec59b6
...
...
@@ -4,6 +4,16 @@
#include "cJSON.h"
#define AIR_AC_INDOOR_ID_SIZE 8
#define AIR_AC_INDOOR_ROOM_ID_SIZE 24
#define AIR_AC_INDOOR_NAME_SIZE 32
#define AIR_AC_INDOOR_ADDR_SIZE 8
typedef
struct
{
char
*
floor_id
;
char
*
room_id
;
...
...
@@ -48,7 +58,8 @@ int kk_sync_devices_status_to_sdk(cJSON *root);
int
kk_create_syncinfo_to_sdk
(
cJSON
*
payload
,
int
push
);
int
kk_send_indoorAir_status
(
cJSON
*
info
);
int
kk_send_indoorAir_status
(
cJSON
*
info
,
const
char
*
deviceCode
);
cJSON
*
val_conver_new2old
(
cJSON
*
newccuItem
,
cJSON
*
oldccuItem
,
int
syn_type
);
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
a8ec59b6
...
...
@@ -83,6 +83,7 @@ static void *kk_vp_uart_thread(void *arg)
}
ERROR_PRINT
(
"[%s]thread end...
\n
"
,
__FUNCTION__
);
return
0
;
}
...
...
@@ -118,7 +119,7 @@ char *vp_file_load(const char *path)
fp
=
fopen
(
path
,
"r"
);
if
(
fp
==
NULL
){
printf
(
"open err.
\n
"
);
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
path
);
return
NULL
;
}
...
...
@@ -175,6 +176,7 @@ static int _vp_config_file_version_load(void)
cJSON_Delete
(
json
);
free
(
pFile
);
return
1
;
}
void
kk_vp_set_updateFlag
(
int
flag
)
...
...
@@ -208,7 +210,7 @@ void kk_vp_set_state_machine(int state)
}
}
void
kk_vp_get_config_file_version
(
int
ver
)
int
kk_vp_get_config_file_version
(
void
)
{
return
vp_mag
.
cfg_info
.
next_ver
;
}
...
...
@@ -341,6 +343,7 @@ void *kk_vp_manage_thread(void *arg)
usleep
(
50
*
1000
);
}
ERROR_PRINT
(
"[%s]thread end...
\n
"
,
__FUNCTION__
);
return
0
;
}
...
...
@@ -375,6 +378,15 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
debug_log
(
LOG_FOCUS_LEVEL
,
"serialDev=%s
\n
"
,
serialDev
);
}
static
int
kk_vp_cfg_file_dir_create
(
void
){
char
cmd
[
128
]
=
{
0
};
snprintf
(
cmd
,
sizeof
(
cmd
),
"mkdir -p %s"
,
VP_VP_CONFIG_FILE_DIR
);
return
system
(
cmd
);
}
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[])
{
size_t
s
=
1500
;
...
...
@@ -387,9 +399,13 @@ int kk_voice_panel_init(int argc, char* argv[])
kk_voice_panel_uart_dev_chose
(
argc
,
argv
);
kk_vp_cfg_file_dir_create
();
pthread_attr_setstacksize
(
&
attr
,
s
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
kk_vp_ac_mutex_init
();
if
(
pthread_mutex_init
(
&
v_mux
,
NULL
)
!=
0
)
{
pthread_attr_destroy
(
&
attr
);
ERROR_PRINT
(
"pthread_mutex_init v_mux fail.
\n
"
);
...
...
@@ -407,12 +423,6 @@ int kk_voice_panel_init(int argc, char* argv[])
return
-
3
;
}
/*if((pthread_create(&tid3, NULL, kk_voice_panel_333, NULL))!= 0 ) {
ERROR_PRINT("pthread_create kk_voice_panel fail\n");
return -4;
}*/
return
0
;
}
...
...
application/klansdk/kk_lan_vp_ctrl.c
View file @
a8ec59b6
This diff is collapsed.
Click to expand it.
application/klansdk/kk_lan_vp_ctrl.h
View file @
a8ec59b6
...
...
@@ -44,7 +44,60 @@
void
kk_lan_vp_control
(
uint8_t
num
,
uint32_t
nodeIdAry
[],
uint8_t
*
arg
);
//SKILL TYPE(0x12)----------------------------------------->WINDSPEED
#define VP_SKILLTYPE_12_WINDSPEED_LOW 0x01
#define VP_SKILLTYPE_12_WINDSPEED_MID 0x02
#define VP_SKILLTYPE_12_WINDSPEED_HIGH 0x03
#define VP_SKILLTYPE_12_WINDSPEED_AUTO 0x04
//SKILL TYPE(0X1C)----------------------------------------->WORKMODE
#define VP_SKILLTYPE_1C_WORKMODE_AUTO 0x01
#define VP_SKILLTYPE_1C_WORKMODE_MANUAL 0x02
#define VP_SKILLTYPE_1C_WORKMODE_COLD 0x03
#define VP_SKILLTYPE_1C_WORKMODE_HEATING 0x04
#define VP_SKILLTYPE_1C_WORKMODE_ENERGY 0x05
#define VP_SKILLTYPE_1C_WORKMODE_COMFORT 0x06
#define VP_SKILLTYPE_1C_WORKMODE_FAN 0x07
#define VP_SKILLTYPE_1C_WORKMODE_DEHUM 0x08
#define AIR_CONDITIONER_DEV_PID {\
3062\
}
//DEVICE PID DEFINE
//3001,3002,3003,3022,3023,3024
#define LIGHT_DEV_PID {\
3024\
}
//3005,3006,3007,3008,3009,3010,3011,3026,3027,3067
#define CURTAIN_DEV_PID {\
3027\
}
//3019,3020,3037,3038
#define OUTLET_DEV_PID {\
3019,3020,3037,3038\
}
#define FRESHAIR_DEV_PID {\
3032\
}
#define FANCOILSWITCH_DEV_PID {\
3034\
}
int
kk_lan_vp_control
(
uint8_t
num
,
uint32_t
nodeIdAry
[],
uint8_t
*
arg
,
uint8_t
arg_len
);
...
...
application/klansdk/kk_login_handle.c
View file @
a8ec59b6
...
...
@@ -52,15 +52,18 @@ int kk_send_data_to_sdk(char *buf)
INFO_PRINT
(
"tmpBuf:%s
\n
"
,
tmpBuf
);
for
(
i
=
0
;
i
<
LISTEN_MAX
;
i
++
){
tcp_data_mutex_lock
();
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
if
(
s_ConnInfo
[
i
].
socketfd
!=
-
1
){
send
(
s_ConnInfo
[
i
].
socketfd
,
tmpBuf
,
strlen
(
tmpBuf
),
0
);
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
tcp_data_mutex_unlock
();
}
free
(
tmpBuf
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
0
;
}
static
int
_kk_handle_data
(
char
*
buf
,
int
sockfd
){
...
...
@@ -83,6 +86,7 @@ static int _kk_handle_data(char *buf,int sockfd){
kk_data_handle
(
json
,
sockfd
);
cJSON_Delete
(
json
);
}
return
0
;
}
static
void
PrintMesg
(
int
i
,
char
buf
[])
...
...
application/klansdk/kk_newccu_msg.c
View file @
a8ec59b6
...
...
@@ -11,6 +11,7 @@
#include "kk_newccu_msg.h"
#include "kk_product.h"
#include "kk_lan_node_db.h"
static
pthread_mutex_t
*
mutex
=
NULL
;
...
...
@@ -83,6 +84,8 @@ cJSON * property_report(const char *productCode,const char *deviceCode,const cha
}
extern
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
cJSON
*
scene_payload_build
(
const
char
*
method
,
const
char
*
msgId
,
cJSON
*
params
)
{
char
ccuid
[
33
]
=
{
0
};
...
...
@@ -141,7 +144,7 @@ int kk_ipc_send_json(cJSON *root)
}
msg
=
cJSON_Print
(
root
);
printf
(
"[lan->midware]json:
\n
%s
\n
"
,
msg
);
debug_log
(
LOG_NORMAL_LEVEL
,
"[lan->midware]json:
\n
%s
\n
"
,
msg
);
cJSON_Minify
(
msg
);
pthread_mutex_lock
(
mutex
);
...
...
application/klansdk/kk_oldccu_msg.c
View file @
a8ec59b6
...
...
@@ -13,10 +13,9 @@
#include "kk_lan_ctrl.h"
#include "kk_data_mng.h"
#include "kk_oldccu_msg.h"
#include "kk_lan_sync.h"
#include "kk_data_mng.h"
#include "kk_data_handle.h"
cJSON
*
old_ccu_msg_build_json
(
const
char
*
nodeid
,
const
char
*
opcode
,
const
char
*
status
,
cJSON
*
arg
)
{
...
...
@@ -382,7 +381,7 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
static
int
attr_indoorAir_report
(
cJSON
*
params
)
static
int
attr_indoorAir_report
(
cJSON
*
params
,
const
char
*
deviceCode
)
{
int
k
=
0
;
if
(
params
==
NULL
){
...
...
@@ -390,14 +389,18 @@ static int attr_indoorAir_report(cJSON *params)
}
cJSON
*
epsAry
=
cJSON_GetObjectItem
(
params
,
"eps"
);
if
(
epsAry
==
NULL
){
kk_send_indoorAir_status
(
params
,
deviceCode
);
return
-
1
;
}
}
else
{
int
epsize
=
cJSON_GetArraySize
(
epsAry
);
for
(
k
=
0
;
k
<
epsize
;
k
++
){
char
tmpIdx
[
4
]
=
{
0
};
cJSON
*
infoItem
=
cJSON_GetArrayItem
(
epsAry
,
k
);
if
(
infoItem
==
NULL
)
continue
;
kk_send_indoorAir_status
(
infoItem
);
kk_send_indoorAir_status
(
infoItem
,
deviceCode
);
}
}
return
0
;
}
...
...
@@ -413,8 +416,11 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
if
(
strcmp
(
dev
->
productCode
,
"3062"
)
==
0
){
attr_indoorAir_report
(
params
);
debug_log
(
LOG_CRITICAL_LEVEL
,
"mark
\n
"
);
attr_indoorAir_report
(
params
,
deviceCode
);
debug_log
(
LOG_CRITICAL_LEVEL
,
"mark
\n
"
);
}
else
{
debug_log
(
LOG_CRITICAL_LEVEL
,
"mark
\n
"
);
return
kk_lan_property_convert
(
deviceCode
,
dev
,
params
);
}
}
else
{
...
...
application/klansdk/kk_oldccu_msg.h
View file @
a8ec59b6
...
...
@@ -25,6 +25,10 @@ int kk_lan_device_delete_notify(cJSON *payload);
cJSON
*
_kk_sync_devicestatus_arg_build
(
kk_map_dev_node_t
*
node
);
int
kk_send_indoorAir_status
(
cJSON
*
info
,
const
char
*
deviceCode
);
#endif
...
...
application/klansdk/kk_voice_panel_cfg.c
View file @
a8ec59b6
This diff is collapsed.
Click to expand it.
application/klansdk/kk_voice_panel_cfg.h
View file @
a8ec59b6
...
...
@@ -34,12 +34,12 @@ typedef struct{
typedef
struct
{
char
*
ac_gw_nodeId
;
char
*
addr
;
char
*
nodeId
;
char
*
name
;
char
*
operateType
;
char
*
room
;
char
ac_gw_nodeId
[
8
]
;
char
addr
[
8
]
;
char
nodeId
[
8
]
;
char
name
[
32
]
;
char
operateType
[
8
]
;
char
room
[
32
]
;
int
online
;
}
VP_AC_INDOOR_ITEM
;
...
...
@@ -64,7 +64,9 @@ typedef struct{
int
kk_vp_cfg_init
(
void
);
void
kk_vp_ac_mutex_init
(
void
);
int
is_ac_gw_pid
(
int
pid
);
_OUT
int
kk_vp_syncinfo
(
_IN
cJSON
*
payload
,
_IN
int
ver
,
_OUT
cJSON
**
root
);
...
...
application/klansdk/kk_voice_panel_handle.c
View file @
a8ec59b6
This diff is collapsed.
Click to expand it.
application/klansdk/kk_voice_panel_handle.h
View file @
a8ec59b6
...
...
@@ -5,12 +5,11 @@
#include "kk_lan_voice_panel.h"
#include "kk_voice_panel_cfg.h"
#define VP_VP_CONFIG_FILE_DIR "/etc/smarthome"
#define VP_CONFIG_FILE "/etc/smarthome/voice_data.json"
#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
#define OPCODE_SNAPSHOOT 0x1001
#define OPCODE_SCENE_ID_NOTIFY 0x1003
...
...
@@ -22,16 +21,7 @@
#define OPCODE_CONFIG_FILE_UPDATE_STOP 0x100E
#define OPCODE_CONFIG_FILE_INFO_GET 0x100F
#define OPCODE_CONFIG_FILE_UPDATE_STATUS 0x1010
#define EXECUTE_CMD(cmd) do {\
printf("\n[%s][%d]------------------execte cmd------------------\n",__FUNCTION__,__LINE__);\
printf("%s\n",cmd);\
}while(0)
#define VP_SEND_PRINT(format,...) printf("\n\033[33;32m"format"\033[0m\n",##__VA_ARGS__)
#define VP_RECV_PRINT(format,...) printf("\n\033[33;34m"format"\033[0m\n",##__VA_ARGS__)
#define OPCODE_VOICE_CONTROL_NOTIFY 0x1022
typedef
void
(
*
vp_handle_func
)(
pro_data_t
*
pro_data
);
typedef
struct
...
...
@@ -68,8 +58,13 @@ void kk_vp_get_8009_snapshoot(void);
void
kk_vp_syncinfo_handle
(
_IN
cJSON
*
payload
);
int
kk_vp_opcode_handle
(
_IN
pro_data_t
*
pro_data
);
int
kk_vp_get_config_file_version
(
void
);
void
vp_scene_id_map_deinit
(
void
);
int
vp_scene_id_item_add
(
int
scene_id
);
int
vp_scene_id_item_load
(
int
scene_id
,
uint16_t
map_id
);
int
vp_scene_id_map_save
(
void
);
...
...
application/klansdk/uart_proto.c
View file @
a8ec59b6
...
...
@@ -8,7 +8,7 @@
#include <unistd.h>
#include "Serial.h"
#include "main.h"
//#include "common.h"
...
...
@@ -18,7 +18,7 @@
//#include "net_handle.h"
#include "uart_proto.h"
#include "kk_lan_debug.h"
uart_data_t
g_uart_data
;
...
...
@@ -464,23 +464,23 @@ void dev_send_uart(uint8_t *data, uint16_t data_len)
static
void
uart_protocol_print
(
pro_data_t
*
pro_data
)
{
printf
(
"seq
%02X
\n
"
,
pro_data
->
seq
);
printf
(
"channel
%02X
\n
"
,
pro_data
->
ch
);
printf
(
"opcode
%04X
\n
"
,
pro_data
->
opcode
);
printf
(
"args_len:
%d
\n
"
,
pro_data
->
args_len
);
_debug_log
(
LOG_DEBUG_LEVEL
,
"
\n
[VP->LAN]
\n
"
);
_debug_log
(
LOG_DEBUG_LEVEL
,
"seq:
\t\t
%02X
\n
"
,
pro_data
->
seq
);
_debug_log
(
LOG_DEBUG_LEVEL
,
"channel:
\t
%02X
\n
"
,
pro_data
->
ch
);
_debug_log
(
LOG_DEBUG_LEVEL
,
"opcode:
\t\t
%04X
\n
"
,
pro_data
->
opcode
);
_debug_log
(
LOG_DEBUG_LEVEL
,
"args_len:
\t
%d
\n
"
,
pro_data
->
args_len
);
char
print_buf
[
512
]
=
{
0
};
int
i
=
0
;
snprintf
(
print_buf
,
sizeof
(
print_buf
),
"args:
"
);
snprintf
(
print_buf
,
sizeof
(
print_buf
),
"args:
\t\t
"
);
for
(
i
=
0
;
i
<
pro_data
->
args_len
;
i
++
)
{
snprintf
(
print_buf
+
strlen
(
print_buf
),
sizeof
(
print_buf
),
"%02X "
,
pro_data
->
arg
[
i
]);
}
printf
(
"%s
\n
"
,
print_buf
);
_debug_log
(
LOG_DEBUG_LEVEL
,
"%s
\n
\n
"
,
print_buf
);
}
...
...
@@ -875,7 +875,6 @@ extern void kk_vp_opcode_handle(pro_data_t *pro_data);
void
uart_frame_handle
()
{
GW_LOG_DBG
(
"uart_frame_handle
\n
"
);
uint8_t
*
data
=
g_uart_data
.
data
;
uint8_t
data_len
=
g_uart_data
.
data_len
;
pro_data_t
pro_data
;
...
...
midware/midware/dm/kk_sync_data.c
View file @
a8ec59b6
...
...
@@ -105,11 +105,11 @@ static cJSON * kk_get_room_devices(const char *roomId)
if
(
kk_check_multi_ep_num
(
deviceCode
)){
cJSON_AddStringToObject
(
dev
,
KK_SYNC_SCENE_EPNUM_STR
,
epNum
);
}
else
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_GATEWAY_TYPE
)
==
0
){
if
(
atoi
(
epNum
)
==
1
){
//epNum为1的是空调网关
continue
;
}
else
{
//
if(atoi(epNum) == 1){//epNum为1的是空调网关
//
continue;
//
}else{
cJSON_AddStringToObject
(
dev
,
KK_SYNC_SCENE_EPNUM_STR
,
epNum
);
}
//
}
}
cJSON_AddStringToObject
(
dev
,
KK_SYNC_DEVICECODE_STR
,
deviceCode
);
//cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
...
...
@@ -761,6 +761,7 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,int id)
char
*
propertyName
=
NULL
;
char
*
propertyValue
=
NULL
;
char
room_name
[
64
]
=
{
0
};
cJSON
*
prtyObj
=
NULL
;
char
*
type
=
NULL
;
int
delay
=
0
,
epNum
=
0
,
scene_id
=
0
;
...
...
@@ -807,7 +808,13 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,int id)
//cJSON_AddNumberToObject(actionItem, KK_SYNC_SCENE_EPNUM_STR, epNum);
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_SCENE_TYPE_STR
,
type
);
if
((
prtyObj
=
cJSON_Parse
(
propertyValue
))
==
NULL
){
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_SCENE_PROPERTYVALUE_STR
,
propertyValue
);
}
else
{
cJSON_AddItemToObject
(
actionItem
,
KK_SYNC_SCENE_PROPERTYVALUE_STR
,
prtyObj
);
}
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_ROOMID_STR
,
room_name
);
cJSON_AddItemToArray
(
actionArray
,
actionItem
);
}
...
...
midware/midware/scene/kk_scene_db.c
View file @
a8ec59b6
...
...
@@ -640,6 +640,9 @@ int kk_scene_insert_scene_action(const char* type,const char* deviceCode,int epN
char
*
sqlCmd
=
NULL
;
char
*
zErrMsg
=
0
;
printf
(
"----->kk_scene_insert_scene_action
\n
"
);
printf
(
"propertyValue----->%s
\n
"
,
propertyValue
);
const
char
*
insertCmd
=
"insert into SceneActionInfo (type, deviceCode,epNum,propertyName,propertyValue,delay,sceneId,gwdeviceCode) \
values ('%s','%s','%d','%s','%s','%d','%s','%s');"
;
...
...
midware/midware/scene/kk_scene_handle.c
View file @
a8ec59b6
...
...
@@ -510,6 +510,7 @@ int kk_scene_action_add(const char *gwdeviceCode,const char *sceneId,kk_scene_ac
cJSON
*
array
;
cJSON
*
info
;
char
*
out
;
cJSON
*
prtyObj
=
NULL
;
kk_scene_action_t
*
ptr
=
p_kk_scene_action
;
kk_scene_action_info_ex_t
*
ptmp
=
NULL
;
if
(
ptr
==
NULL
){
...
...
@@ -524,7 +525,13 @@ int kk_scene_action_add(const char *gwdeviceCode,const char *sceneId,kk_scene_ac
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
ptr
->
actionInfo
->
info
.
deviceCode
);
cJSON_AddStringToObject
(
info
,
MSG_SCENE_PROPERTYNAME
,
ptr
->
actionInfo
->
info
.
propertyName
);
if
((
prtyObj
=
cJSON_Parse
(
ptr
->
actionInfo
->
info
.
propertyValue
))
==
NULL
){
cJSON_AddStringToObject
(
info
,
MSG_SCENE_PROPERTYVALUE
,
ptr
->
actionInfo
->
info
.
propertyValue
);
}
else
{
cJSON_AddItemToObject
(
info
,
MSG_SCENE_PROPERTYVALUE
,
prtyObj
);
}
cJSON_AddNumberToObject
(
info
,
MSG_SCENE_DELAY
,
ptr
->
actionInfo
->
info
.
delay
);
cJSON_AddNumberToObject
(
info
,
MSG_SCENE_EPNUM
,
ptr
->
actionInfo
->
info
.
epNum
);
cJSON_AddItemToArray
(
array
,
info
);
...
...
@@ -949,8 +956,20 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
delay
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_DELAY
);
if
(
delay
==
NULL
)
return
FAIL_RETURN
;
int
idelay
=
delay
->
valueint
;
if
(
propertyValue
->
type
==
cJSON_String
){
kk_subDev_set_action_by_productType
(
productType
->
valuestring
,
sceneId
,
propertyName
->
valuestring
,
propertyValue
->
valuestring
,
type
->
valuestring
,
idelay
);
}
else
{
printf
(
"1111
\r\n
"
);
char
*
str
=
cJSON_PrintUnformatted
(
propertyValue
);
printf
(
"222
\r\n
"
);
kk_subDev_set_action_by_productType
(
productType
->
valuestring
,
sceneId
,
propertyName
->
valuestring
,
str
,
type
->
valuestring
,
idelay
);
printf
(
"333
\r\n
"
);
free
(
str
);
printf
(
"4444
\r\n
"
);
}
}
else
{
memset
(
propertyValueStr
,
0x0
,
sizeof
(
propertyValueStr
));
...
...
@@ -989,8 +1008,20 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
kk_scene_action_detail_t
info
=
{
0
};
memcpy
(
info
.
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
memcpy
(
info
.
propertyValue
,
propertyValueStr
,
strlen
(
propertyValueStr
));
memcpy
(
info
.
propertyName
,
propertyName
->
valuestring
,
strlen
(
propertyName
->
valuestring
));
if
(
propertyValue
->
type
==
cJSON_Number
){
memset
(
propertyValueStr
,
0
,
sizeof
(
propertyValueStr
));
snprintf
(
propertyValueStr
,
sizeof
(
propertyValueStr
),
"%d"
,
propertyValue
->
valueint
);
}
else
if
(
propertyValue
->
type
==
cJSON_String
){
snprintf
(
propertyValueStr
,
sizeof
(
propertyValueStr
),
"%s"
,
propertyValue
->
valuestring
);
}
else
{
char
*
str
=
cJSON_PrintUnformatted
(
propertyValue
);
snprintf
(
propertyValueStr
,
sizeof
(
propertyValueStr
),
"%s"
,
str
);
free
(
str
);
}
memcpy
(
info
.
propertyValue
,
propertyValueStr
,
strlen
(
propertyValueStr
));
info
.
epNum
=
iepnum
;
info
.
delay
=
idelay
;
...
...
@@ -2135,3 +2166,4 @@ int kk_scene_execute_quickpanel(const char *buttonId,char *deviceCode)
INFO_PRINT
(
"[%d]kk_scene_execute_quickpanel called!!!
\n
"
,
__LINE__
);
return
res
;
}
midware/tsl/tsl_handle/kk_tsl_common.h
View file @
a8ec59b6
...
...
@@ -26,7 +26,7 @@
#define DM_UTILS_UINT32_STRLEN (10)
#define DM_UTILS_UINT64_STRLEN (20)
#define DEVICE_PROPERTY_NAME_MAX (64+1)
#define DEVICE_PROPERTY_VALUE_MAX (
64
+1)
#define DEVICE_PROPERTY_VALUE_MAX (
255
+1)
#define DEVICE_PROPERTY_NUM_MAX (16)
#define KK_TSL_KEY_SCHEMA "schema"
...
...
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