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
880044d8
Commit
880044d8
authored
Aug 27, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
Yjq See merge request chenweican/k-sdk!114
parents
8325f75c
e11e7cee
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
344 additions
and
137 deletions
+344
-137
application/klansdk/Serial.c
application/klansdk/Serial.c
+10
-2
application/klansdk/Serial.h
application/klansdk/Serial.h
+3
-0
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+16
-10
application/klansdk/kk_data_mng.c
application/klansdk/kk_data_mng.c
+4
-4
application/klansdk/kk_findccu_handle.c
application/klansdk/kk_findccu_handle.c
+3
-3
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+2
-2
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+40
-1
application/klansdk/kk_lan_voice_panel.h
application/klansdk/kk_lan_voice_panel.h
+1
-1
application/klansdk/kk_lan_vp_ctrl.c
application/klansdk/kk_lan_vp_ctrl.c
+1
-0
application/klansdk/kk_login_handle.c
application/klansdk/kk_login_handle.c
+7
-8
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+48
-106
opcodeMapCfg/device_3022.json
opcodeMapCfg/device_3022.json
+27
-0
opcodeMapCfg/device_3026.json
opcodeMapCfg/device_3026.json
+27
-0
opcodeMapCfg/device_3029.json
opcodeMapCfg/device_3029.json
+116
-0
opcodeMapCfg/device_3062.json
opcodeMapCfg/device_3062.json
+12
-0
opcodeMapCfg/device_3067.json
opcodeMapCfg/device_3067.json
+27
-0
No files found.
application/klansdk/Serial.c
View file @
880044d8
...
@@ -22,6 +22,8 @@ int serial_fd = 0;
...
@@ -22,6 +22,8 @@ int serial_fd = 0;
//static struct termios options; //place for settings for serial port
//static struct termios options; //place for settings for serial port
char
buf
[
255
];
//buffer for where data is put
char
buf
[
255
];
//buffer for where data is put
char
serialDev
[
64
];
/**************serial open *******************/
/**************serial open *******************/
/***********************************************************
/***********************************************************
...
@@ -242,7 +244,7 @@ void eSerial_start()
...
@@ -242,7 +244,7 @@ void eSerial_start()
}
}
#endif
#endif
serial_fd
=
devOpen
(
SERIAL_NAME
);
serial_fd
=
devOpen
(
serialDev
);
}
}
/***********************************************************
/***********************************************************
...
@@ -407,7 +409,13 @@ teSerial_Status eSerial_WriteBuffer(unsigned char *data, uint32_t count)
...
@@ -407,7 +409,13 @@ teSerial_Status eSerial_WriteBuffer(unsigned char *data, uint32_t count)
int
attempts
=
0
;
int
attempts
=
0
;
//printf("send char %d\n", data);
//printf("send char %d\n", data);
int
total_sent_bytes
=
0
,
sent_bytes
=
0
;
int
total_sent_bytes
=
0
,
sent_bytes
=
0
;
if
(
serial_fd
<=
0
)
{
return
E_SERIAL_FD_ERROR
;
}
while
(
total_sent_bytes
<
count
)
while
(
total_sent_bytes
<
count
)
{
{
sent_bytes
=
write
(
serial_fd
,
&
data
[
total_sent_bytes
],
count
-
total_sent_bytes
);
sent_bytes
=
write
(
serial_fd
,
&
data
[
total_sent_bytes
],
count
-
total_sent_bytes
);
...
...
application/klansdk/Serial.h
View file @
880044d8
...
@@ -31,6 +31,9 @@ extern "C" {
...
@@ -31,6 +31,9 @@ extern "C" {
#define SERIAL_NAME "/dev/ttyUSB0"//"/dev/ttyS0"
#define SERIAL_NAME "/dev/ttyUSB0"//"/dev/ttyS0"
#define SERIAL_BAUD 115200
#define SERIAL_BAUD 115200
extern
char
serialDev
[
64
];
/****************************************************************************/
/****************************************************************************/
/*** Type Definitions ***/
/*** Type Definitions ***/
/****************************************************************************/
/****************************************************************************/
...
...
application/klansdk/kk_data_handle.c
View file @
880044d8
...
@@ -236,7 +236,7 @@ static cJSON *kk_zb_dev_hw_info_build(const char *deviceCode,cJSON * productCode
...
@@ -236,7 +236,7 @@ static cJSON *kk_zb_dev_hw_info_build(const char *deviceCode,cJSON * productCode
cJSON_AddNumberToObject
(
item
,
"online_status"
,
online_status
);
cJSON_AddNumberToObject
(
item
,
"online_status"
,
online_status
);
cJSON_AddNumberToObject
(
item
,
"product_id"
,
pid
);
cJSON_AddNumberToObject
(
item
,
"product_id"
,
pid
);
if
(
h
w_ver
!=
NULL
){
if
(
s
w_ver
!=
NULL
){
cJSON_AddStringToObject
(
item
,
"version"
,
sw_ver
);
cJSON_AddStringToObject
(
item
,
"version"
,
sw_ver
);
}
else
{
}
else
{
cJSON_AddStringToObject
(
item
,
"version"
,
""
);
cJSON_AddStringToObject
(
item
,
"version"
,
""
);
...
@@ -326,7 +326,7 @@ static void kk_zb_devs_hw_ack(int sockfd,cJSON *conditions)
...
@@ -326,7 +326,7 @@ static void kk_zb_devs_hw_ack(int sockfd,cJSON *conditions)
cJSON
*
item
;
cJSON
*
item
;
cJSON
*
array
=
cJSON_CreateArray
();
cJSON
*
array
=
cJSON_CreateArray
();
for
(
i
=
0
;
i
<
size
;
i
++
){
for
(
i
=
0
;
i
<
size
;
i
++
){
qMac
=
cJSON_GetArrayItem
(
arg
,
1
);
qMac
=
cJSON_GetArrayItem
(
arg
,
i
);
if
(
mac_switchto_deviceCode
(
qMac
->
valuestring
,
devCode
)
==
0
){
if
(
mac_switchto_deviceCode
(
qMac
->
valuestring
,
devCode
)
==
0
){
if
((
item
=
kk_zb_dev_hw_info_build_by_deviceCode
(
sockfd
,
devCode
,
-
1
))
!=
NULL
){
if
((
item
=
kk_zb_dev_hw_info_build_by_deviceCode
(
sockfd
,
devCode
,
-
1
))
!=
NULL
){
cJSON_AddItemToArray
(
array
,
item
);
cJSON_AddItemToArray
(
array
,
item
);
...
@@ -351,8 +351,8 @@ static void kk_handle_del_history_info(char *key)
...
@@ -351,8 +351,8 @@ static void kk_handle_del_history_info(char *key)
int
kk_data_handle
(
cJSON
*
json
,
int
sockfd
)
int
kk_data_handle
(
cJSON
*
json
,
int
sockfd
)
{
{
cJSON
*
opcode
;
cJSON
*
opcode
=
NULL
;
cJSON
*
arg
;
cJSON
*
arg
=
NULL
;
opcode
=
cJSON_GetObjectItem
(
json
,
OPCODE_STRING
);
opcode
=
cJSON_GetObjectItem
(
json
,
OPCODE_STRING
);
...
@@ -395,7 +395,9 @@ static int kk_parse_syncinfo(cJSON *payload)
...
@@ -395,7 +395,9 @@ static int kk_parse_syncinfo(cJSON *payload)
cJSON
*
newccuItem
;
cJSON
*
newccuItem
;
cJSON
*
valuejson
;
cJSON
*
valuejson
;
int
value
;
int
value
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_map_dev_deinit
();
kk_map_dev_deinit
();
...
@@ -426,9 +428,13 @@ static int kk_parse_syncinfo(cJSON *payload)
...
@@ -426,9 +428,13 @@ static int kk_parse_syncinfo(cJSON *payload)
properties
=
cJSON_GetObjectItem
(
subitem
,
MSG_PROPERTIES_STR
);
properties
=
cJSON_GetObjectItem
(
subitem
,
MSG_PROPERTIES_STR
);
kk_map_dev_node_add
(
deviceCode
,
productCode
,
gwdevicecode
,(
onlineStatus
->
valueint
==
1
)
?
"1"
:
"0"
);
kk_map_dev_node_add
(
deviceCode
,
productCode
,
gwdevicecode
,(
onlineStatus
->
valueint
==
1
)
?
"1"
:
"0"
);
kk_lan_property_post_deal
(
deviceCode
,
properties
);
kk_lan_property_syn_deal
(
deviceCode
,
properties
);
//property_syn_deal(deviceCode,properties);
subitem
=
subitem
->
next
;
subitem
=
subitem
->
next
;
}
}
}
}
...
@@ -735,11 +741,11 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
...
@@ -735,11 +741,11 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
void
KK_Data_FromMid
(
void
*
str
,
int
len
)
void
KK_Data_FromMid
(
void
*
str
,
int
len
)
{
{
cJSON
*
json
;
cJSON
*
json
=
NULL
;
cJSON
*
info
,
*
payload
;
cJSON
*
info
=
NULL
,
*
payload
=
NULL
;
cJSON
*
msgtype
,
*
deviceCode
,
*
productCode
;
cJSON
*
msgtype
=
NULL
,
*
deviceCode
=
NULL
,
*
productCode
=
NULL
;
printf
(
"[midware->lan] len=%d,data=%s
\n
"
,
len
,
str
);
debug_log
(
LOG_FOCUS
,
"[midware->lan] len=%d,data=%s
\n
"
,
len
,
str
);
if
((
json
=
cJSON_Parse
(
str
))
==
NULL
)
{
if
((
json
=
cJSON_Parse
(
str
))
==
NULL
)
{
return
;
return
;
...
...
application/klansdk/kk_data_mng.c
View file @
880044d8
...
@@ -51,7 +51,7 @@ void kk_map_dev_deinit(void)
...
@@ -51,7 +51,7 @@ void kk_map_dev_deinit(void)
kk_map_dev_node_t
*
node
=
NULL
;
kk_map_dev_node_t
*
node
=
NULL
;
kk_map_dev_node_t
*
n
=
NULL
;
kk_map_dev_node_t
*
n
=
NULL
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
//
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_map_dev_mutex_lock
();
_kk_map_dev_mutex_lock
();
list_for_each_entry_safe
(
node
,
n
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
list_for_each_entry_safe
(
node
,
n
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
...
@@ -59,15 +59,15 @@ void kk_map_dev_deinit(void)
...
@@ -59,15 +59,15 @@ void kk_map_dev_deinit(void)
if
(
node
!=
NULL
)
{
if
(
node
!=
NULL
)
{
if
(
node
->
json
){
if
(
node
->
json
){
printf
(
"[delete cjson] node->json.
\n
"
);
//
printf("[delete cjson] node->json.\n");
cJSON_Delete
(
node
->
json
);
cJSON_Delete
(
node
->
json
);
}
}
if
(
node
->
syn_opcode
)
{
if
(
node
->
syn_opcode
)
{
printf
(
"[free] node->syn_opcode.
\n
"
);
//
printf("[free] node->syn_opcode.\n");
free
(
node
->
syn_opcode
);
free
(
node
->
syn_opcode
);
}
}
printf
(
"[remove list] node->linked_list
\n
"
);
//
printf("[remove list] node->linked_list\n");
dlist_del
(
&
node
->
linked_list
);
dlist_del
(
&
node
->
linked_list
);
memset
(
node
,
0
,
sizeof
(
kk_map_dev_node_t
));
memset
(
node
,
0
,
sizeof
(
kk_map_dev_node_t
));
...
...
application/klansdk/kk_findccu_handle.c
View file @
880044d8
...
@@ -27,7 +27,7 @@ static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
...
@@ -27,7 +27,7 @@ static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
return
-
1
;
return
-
1
;
}
}
char
ccuid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_ccuid
(
ccuid
);
json
=
cJSON_CreateObject
();
json
=
cJSON_CreateObject
();
if
(
json
){
if
(
json
){
args
=
cJSON_CreateObject
();
args
=
cJSON_CreateObject
();
...
@@ -81,9 +81,9 @@ void *kk_findccu_handle(void *data)
...
@@ -81,9 +81,9 @@ void *kk_findccu_handle(void *data)
saddr
.
sin_port
=
htons
(
FINDCCU_LOCAL_PORT
);
saddr
.
sin_port
=
htons
(
FINDCCU_LOCAL_PORT
);
if
(
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
saddr
,
sizeof
(
saddr
))
==
-
1
)
if
(
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
saddr
,
sizeof
(
saddr
))
==
-
1
)
{
{
ERROR_PRINT
(
"bind error...
\n
"
);
ERROR_PRINT
(
"bind error...
\n
"
);
}
}
while
(
1
)
while
(
1
)
{
{
r
=
recvfrom
(
sockfd
,
recvline
,
sizeof
(
recvline
),
0
,
(
struct
sockaddr
*
)
&
presaddr
,
&
len
);
r
=
recvfrom
(
sockfd
,
recvline
,
sizeof
(
recvline
),
0
,
(
struct
sockaddr
*
)
&
presaddr
,
&
len
);
...
...
application/klansdk/kk_lan_main.c
View file @
880044d8
...
@@ -60,7 +60,7 @@ static void kk_lan_ccuid_init(void)
...
@@ -60,7 +60,7 @@ static void kk_lan_ccuid_init(void)
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
_setDevice_Code
((
char
*
)
ccuid
,
ccuid_len
-
1
);
_setDevice_Code
((
char
*
)
ccuid
,
ccuid_len
-
1
);
}
else
{
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
}
}
}
...
@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
...
@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
kk_findccu_handle_init
();
kk_findccu_handle_init
();
kk_map_dev_init
();
kk_map_dev_init
();
kk_login_init
();
kk_login_init
();
//kk_voice_panel_init(
);
kk_voice_panel_init
(
argc
,
argv
);
//lan_queue_init();
//lan_queue_init();
kk_lan_db_node_init
();
kk_lan_db_node_init
();
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
880044d8
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <pthread.h>
#include <pthread.h>
#include<getopt.h>
#include "kk_log.h"
#include "kk_log.h"
#include "kk_lan_voice_panel.h"
#include "kk_lan_voice_panel.h"
...
@@ -39,6 +40,11 @@ static void *kk_vp_uart_thread(void *arg)
...
@@ -39,6 +40,11 @@ static void *kk_vp_uart_thread(void *arg)
while
(
1
)
while
(
1
)
{
{
while
(
serial_fd
<
0
){
eSerial_start
();
sleep
(
1
);
}
FD_ZERO
(
&
rd
);
FD_ZERO
(
&
rd
);
FD_SET
(
serial_fd
,
&
rd
);
FD_SET
(
serial_fd
,
&
rd
);
...
@@ -337,7 +343,39 @@ void *kk_vp_manage_thread(void *arg)
...
@@ -337,7 +343,39 @@ void *kk_vp_manage_thread(void *arg)
ERROR_PRINT
(
"[%s]thread end...
\n
"
,
__FUNCTION__
);
ERROR_PRINT
(
"[%s]thread end...
\n
"
,
__FUNCTION__
);
}
}
int
kk_voice_panel_init
(
void
)
void
kk_voice_panel_uart_dev_chose
(
int
argc
,
char
*
argv
[])
{
int
flag
=
0
;
int
opt
;
int
option_index
=
0
;
char
*
string
=
""
;
static
struct
option
long_options
[]
=
{
{
"uart"
,
optional_argument
,
NULL
,
0xAA5555AA
},
{
NULL
,
0
,
NULL
,
0
},
};
debug_log
(
LOG_FOCUS
,
"kk_voice_panel_uart_dev_chose
\n
"
);
while
((
opt
=
getopt_long_only
(
argc
,
argv
,
string
,
long_options
,
&
option_index
))
!=
-
1
)
{
if
(
opt
==
0xAA5555AA
){
memset
(
serialDev
,
0
,
sizeof
(
serialDev
));
snprintf
(
serialDev
,
sizeof
(
serialDev
),
"%s"
,
optarg
);
flag
=
1
;
break
;
}
}
if
(
flag
==
0
){
memset
(
serialDev
,
0
,
sizeof
(
serialDev
));
snprintf
(
serialDev
,
sizeof
(
serialDev
),
"%s"
,
SERIAL_NAME
);
}
debug_log
(
LOG_FOCUS
,
"serialDev=%s
\n
"
,
serialDev
);
}
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[])
{
{
size_t
s
=
1500
;
size_t
s
=
1500
;
...
@@ -347,6 +385,7 @@ int kk_voice_panel_init(void)
...
@@ -347,6 +385,7 @@ int kk_voice_panel_init(void)
pthread_attr_t
attr
;
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
pthread_attr_init
(
&
attr
);
kk_voice_panel_uart_dev_chose
(
argc
,
argv
);
pthread_attr_setstacksize
(
&
attr
,
s
);
pthread_attr_setstacksize
(
&
attr
,
s
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
...
...
application/klansdk/kk_lan_voice_panel.h
View file @
880044d8
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
int
kk_voice_panel_init
(
void
);
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[]
);
#define GET_8009_SNAPSHOOT_STATE 0
#define GET_8009_SNAPSHOOT_STATE 0
#define SET_8009_SYSTEM 1
#define SET_8009_SYSTEM 1
...
...
application/klansdk/kk_lan_vp_ctrl.c
View file @
880044d8
#include "kk_data_mng.h"
#include "kk_data_mng.h"
#include "kk_lan_vp_ctrl.h"
#include "kk_lan_vp_ctrl.h"
#include "kk_lan_debug.h"
#include "cJSON.h"
#include "cJSON.h"
cJSON
*
PowerSwitch_msg_build
(
int
ep
,
int
onoff
)
cJSON
*
PowerSwitch_msg_build
(
int
ep
,
int
onoff
)
...
...
application/klansdk/kk_login_handle.c
View file @
880044d8
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
typedef
struct
{
typedef
struct
{
int
socketfd
;
int
socketfd
;
char
ip
[
18
];
char
ip
[
18
];
}
kk_clientInfo_t
;
}
kk_clientInfo_t
;
static
kk_clientInfo_t
s_ConnInfo
[
LISTEN_MAX
]
=
{
0
};
static
kk_clientInfo_t
s_ConnInfo
[
LISTEN_MAX
]
=
{
0
};
static
pthread_mutex_t
data_mutex
;
static
pthread_mutex_t
data_mutex
;
...
@@ -48,8 +48,8 @@ int kk_send_data_to_sdk(char *buf)
...
@@ -48,8 +48,8 @@ int kk_send_data_to_sdk(char *buf)
return
0
;
return
0
;
}
}
static
int
_kk_handle_data
(
char
*
buf
,
int
sockfd
){
static
int
_kk_handle_data
(
char
*
buf
,
int
sockfd
){
char
*
pStart
=
NULL
,
*
pEnd
=
NULL
;
char
*
pStart
=
NULL
,
*
pEnd
=
NULL
;
char
tmpBuf
[
BUF_SIZE
]
=
{
0
};
char
tmpBuf
[
BUF_SIZE
]
=
{
0
};
cJSON
*
json
;
cJSON
*
json
;
if
(
buf
==
NULL
){
if
(
buf
==
NULL
){
return
-
1
;
return
-
1
;
...
@@ -66,13 +66,12 @@ static int _kk_handle_data(char *buf,int sockfd){
...
@@ -66,13 +66,12 @@ static int _kk_handle_data(char *buf,int sockfd){
}
else
{
}
else
{
kk_data_handle
(
json
,
sockfd
);
kk_data_handle
(
json
,
sockfd
);
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
}
}
}
}
static
void
PrintMesg
(
int
i
,
char
buf
[])
static
void
PrintMesg
(
int
i
,
char
buf
[])
{
{
printf
(
"fd : %d, msg: %s
\n
"
,
i
,
buf
);
printf
(
"fd : %d, msg: %s
\n
"
,
i
,
buf
);
}
}
static
int
kk_check_is_connect
(
char
*
ip
){
static
int
kk_check_is_connect
(
char
*
ip
){
...
@@ -140,10 +139,10 @@ void *TCPServer()
...
@@ -140,10 +139,10 @@ void *TCPServer()
{
{
//index = -1;
//index = -1;
max_fd
=
client_fd
>
Listenfd
?
client_fd
:
Listenfd
;
max_fd
=
client_fd
>
Listenfd
?
client_fd
:
Listenfd
;
time_out
.
tv_sec
=
1
;
//select会更改timeout的值,所以需要重新初始化超时时间
time_out
.
tv_sec
=
1
;
//select会更改timeout的值,所以需要重新初始化超时时间
time_out
.
tv_usec
=
0
;
time_out
.
tv_usec
=
0
;
FD_ZERO
(
&
server_fd_set
);
FD_ZERO
(
&
server_fd_set
);
FD_SET
(
Listenfd
,
&
server_fd_set
);
FD_SET
(
Listenfd
,
&
server_fd_set
);
for
(
i
=
0
;
i
<
LISTEN_MAX
;
i
++
)
for
(
i
=
0
;
i
<
LISTEN_MAX
;
i
++
)
{
{
if
(
s_ConnInfo
[
i
].
socketfd
>
0
)
if
(
s_ConnInfo
[
i
].
socketfd
>
0
)
...
...
application/klansdk/kk_oldccu_msg.c
View file @
880044d8
...
@@ -85,13 +85,20 @@ int send_msg_to_module(cJSON *root)
...
@@ -85,13 +85,20 @@ int send_msg_to_module(cJSON *root)
cJSON
*
val_conver_new2old
(
cJSON
*
newccuItem
,
cJSON
*
oldccuItem
,
int
syn_type
)
cJSON
*
val_conver_new2old
(
cJSON
*
newccuItem
,
cJSON
*
oldccuItem
,
int
syn_type
)
{
{
cJSON
*
n_
dataType
=
cJSON_GetObjectItem
(
newccuItem
,
DATATYPE_STRING
)
;
cJSON
*
n_
value
=
NULL
,
*
n_dataType
=
NULL
,
*
o_dataType
=
NULL
;
cJSON
*
n_value
=
cJSON_GetObjectItem
(
newccuItem
,
"value"
)
;
cJSON
*
o_valueRange
=
NULL
,
*
n_valueRange
=
NULL
;
cJSON
*
o_dataType
;
if
(
newccuItem
==
NULL
||
newccuItem
->
type
!=
cJSON_Object
||
oldccuItem
==
NULL
||
oldccuItem
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
return
NULL
;
}
cJSON
*
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
cJSON
*
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_dataType
=
cJSON_GetObjectItem
(
newccuItem
,
DATATYPE_STRING
);
n_value
=
cJSON_GetObjectItem
(
newccuItem
,
"value"
);
if
(
syn_type
==
1
){
if
(
syn_type
==
1
){
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
"synType"
);
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
"synType"
);
...
@@ -101,101 +108,6 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
...
@@ -101,101 +108,6 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
return
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
n_value
);
return
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
n_value
);
}
}
cJSON
*
kk_devicestatus_build
(
kk_map_dev_node_t
*
node
)
{
int
i
,
num
=
0
;
char
nodeid
[
32
]
=
{
0
};
cJSON
*
newccu
,
*
oldccu
;
cJSON
*
dev_status
;
if
(
node
==
NULL
||
node
->
syn_opcode
==
NULL
){
return
NULL
;
}
newccu
=
node
->
newccu
;
oldccu
=
node
->
oldccu
;
if
(
newccu
==
NULL
||
newccu
->
type
!=
cJSON_Object
||
oldccu
==
NULL
||
oldccu
->
type
!=
cJSON_Object
){
return
NULL
;
}
dev_status
=
cJSON_CreateObject
();
num
=
cJSON_GetArraySize
(
newccu
);
for
(
i
=
0
;
i
<
num
;
i
++
){
cJSON
*
newccuItem
=
cJSON_GetArrayItem
(
newccu
,
i
);
cJSON
*
oldccuItem
=
cJSON_GetArrayItem
(
oldccu
,
i
);
cJSON
*
synType
=
cJSON_GetObjectItem
(
oldccuItem
,
"synType"
);
cJSON
*
synKey
=
cJSON_GetObjectItem
(
oldccuItem
,
"syn"
);
cJSON
*
val
=
NULL
;
cJSON
*
status
=
NULL
;
char
indexId
[
4
]
=
{
0
};
if
(
synType
){
if
(
synType
->
type
!=
cJSON_String
||
synKey
==
NULL
||
synKey
->
type
!=
cJSON_String
)
{
continue
;
}
status
=
cJSON_CreateObject
();
kk_creater_nodeid
(
node
->
deviceCode
,
1
,
nodeid
,
atoi
(
node
->
opearteType
));
cJSON_AddStringToObject
(
status
,
OPCODE_STRING
,
node
->
syn_opcode
);
cJSON_AddNumberToObject
(
status
,
NODEID_STRING
,
atoi
(
nodeid
));
memset
(
indexId
,
0
,
sizeof
(
indexId
));
snprintf
(
indexId
,
sizeof
(
indexId
),
"%d"
,
i
+
1
);
cJSON_AddStringToObject
(
status
,
"index"
,
indexId
);
//todo:
if
(
strcmp
(
synType
->
valuestring
,
"timing_shutdown"
)
==
0
)
{
cJSON
*
syn_obj
=
cJSON_CreateObject
();
double
t
=
cJSON_GetObjectItem
(
newccuItem
,
"value"
)
->
valuedouble
;
char
buff
[
32
]
=
{
0
};
snprintf
(
buff
,
32
,
"%f"
,
t
);
if
(
t
>
0
){
cJSON_AddBoolToObject
(
syn_obj
,
"enable"
,
1
);
cJSON_AddStringToObject
(
syn_obj
,
"time"
,
buff
);
}
else
{
cJSON_AddBoolToObject
(
syn_obj
,
"enable"
,
0
);
cJSON_AddNullToObject
(
syn_obj
,
"time"
);
}
cJSON_AddItemToObject
(
dev_status
,
synKey
->
valuestring
,
syn_obj
);
}
else
{
if
((
val
=
val_conver_new2old
(
newccuItem
,
oldccuItem
,
1
))
!=
NULL
){
kk_lan_add_val_to_obj
(
dev_status
,
val
,
synKey
->
valuestring
);
}
}
}
}
return
dev_status
;
}
//更新设备状态
//更新设备状态
static
int
_kk_lan_update_device_status
(
int
nodeId
,
cJSON
*
opcode
,
cJSON
*
arg
)
static
int
_kk_lan_update_device_status
(
int
nodeId
,
cJSON
*
opcode
,
cJSON
*
arg
)
{
{
...
@@ -312,8 +224,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
...
@@ -312,8 +224,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
cJSON
*
item_size
=
NULL
;
cJSON
*
item_size
=
NULL
;
cJSON
*
epsAry
=
NULL
,
*
epAryItem
=
NULL
,
*
epAryEpNumObj
=
NULL
;
int
j
,
mFlag
=
0
,
epsArySize
=
0
;
...
@@ -343,11 +255,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
...
@@ -343,11 +255,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
continue
;
continue
;
}
}
if
((
valObj
=
cJSON_GetObjectItem
(
params
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[match] next.
\n
"
);
continue
;
}
n_dataType
=
cJSON_GetObjectItem
(
n_item
,
"dataType"
);
n_dataType
=
cJSON_GetObjectItem
(
n_item
,
"dataType"
);
n_valueRange
=
cJSON_GetObjectItem
(
n_item
,
"valueRange"
);
n_valueRange
=
cJSON_GetObjectItem
(
n_item
,
"valueRange"
);
...
@@ -363,9 +272,40 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
...
@@ -363,9 +272,40 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
channelObj
=
cJSON_GetObjectItem
(
o_item
,
"channel"
);
channelObj
=
cJSON_GetObjectItem
(
o_item
,
"channel"
);
epNumObj
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
epNumObj
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
if
((
channel
=
_kk_lan_check_channel
(
channelObj
,
epNumObj
))
==-
1
){
if
((
channel
=
_kk_lan_check_channel
(
channelObj
,
epNumObj
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[channel] %d.
\n
"
,
channel
);
continue
;
continue
;
}
}
if
((
epsAry
=
cJSON_GetObjectItem
(
params
,
"eps"
))
!=
NULL
&&
epsAry
->
type
==
cJSON_Array
){
epsArySize
=
cJSON_GetArraySize
(
epsAry
);
for
(
j
=
0
;
j
<
epsArySize
;
j
++
){
epAryItem
=
cJSON_GetArrayItem
(
epsAry
,
j
);
epAryEpNumObj
=
cJSON_GetObjectItem
(
epAryItem
,
"epNum"
);
if
(
epAryEpNumObj
==
NULL
||
epAryEpNumObj
->
type
!=
cJSON_String
||
channel
!=
atoi
(
epAryEpNumObj
->
valuestring
)){
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
continue
;
}
if
((
valObj
=
cJSON_GetObjectItem
(
epAryItem
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
continue
;
}
else
{
mFlag
=
1
;
break
;
}
}
if
(
mFlag
!=
1
){
continue
;
}
}
else
{
if
((
valObj
=
cJSON_GetObjectItem
(
params
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[match] next.
\n
"
);
continue
;
}
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
channel
))
==-
1
){
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
channel
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[err] not find node.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] not find node.
\n
"
);
continue
;
continue
;
...
@@ -396,6 +336,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
...
@@ -396,6 +336,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
return
0
;
return
0
;
}
}
static
int
attr_indoorAir_report
(
cJSON
*
params
)
static
int
attr_indoorAir_report
(
cJSON
*
params
)
{
{
int
k
=
0
;
int
k
=
0
;
...
...
opcodeMapCfg/device_3022.json
0 → 100644
View file @
880044d8
{
"productCode"
:
"3022"
,
"operateType"
:
"3"
,
"channel"
:
1
,
"newccu"
:[
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
}
],
"oldccu"
:[
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"OFF"
,
"ON"
]
}
]
}
\ No newline at end of file
opcodeMapCfg/device_3026.json
0 → 100644
View file @
880044d8
{
"productCode"
:
"3026"
,
"operateType"
:
"1003"
,
"channel"
:
1
,
"newccu"
:[
{
"identifier"
:
"OperationMode"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
,
2
],
"value"
:
2
}
],
"oldccu"
:[
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"OperationMode"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"CLOSE"
,
"OPEN"
,
"STOP"
]
}
]
}
\ No newline at end of file
opcodeMapCfg/device_3029.json
0 → 100644
View file @
880044d8
{
"productCode"
:
"3029"
,
"operateType"
:
"12501"
,
"channel"
:
1
,
"syn_type"
:
1
,
"syn_opcode"
:
"FLOOR_HEATING_DEV_STATUS"
,
"newccu"
:[
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
},{
"identifier"
:
"WorkMode"
,
"opcodemap"
:
"SET_WORK_MODEL"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
],
"value"
:
1
},{
"identifier"
:
"Temperature"
,
"opcodemap"
:
"SET_WORK_TEMPERATURE"
,
"dataType"
:
"double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
16
},{
"identifier"
:
"TimingOffTime"
,
"opcodemap"
:
"FLOOR_HEATING_SET_TIME_OFF"
,
"dataType"
:
"string_time"
,
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
0
},{
"identifier"
:
"ChildLockState"
,
"opcodemap"
:
"FLOOR_HEATING_SET_LOCK_STATUS"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
},{
"identifier"
:
"CurrentTemperature"
,
"opcodemap"
:
"current_real_temperature"
,
"dataType"
:
"double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
22
},{
"identifier"
:
"time_off"
,
"opcodemap"
:
"FLOOR_HEATING_DEV_STATUS"
,
"dataType"
:
"dummy"
,
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
0
}
],
"oldccu"
:[
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"OFF"
,
"ON"
],
"syn"
:
"on"
,
"synType"
:
"bool"
},{
"opcode"
:
"SET_WORK_MODEL"
,
"identifiermap"
:
"WorkMode"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"AUTO"
,
"MANUAL"
],
"syn"
:
"run_model"
,
"synType"
:
"map"
},{
"opcode"
:
"SET_WORK_TEMPERATURE"
,
"identifiermap"
:
"Temperature"
,
"dataType"
:
"double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"work_temperature"
,
"synType"
:
"double"
},{
"opcode"
:
"FLOOR_HEATING_SET_TIME_OFF"
,
"identifiermap"
:
"TimingOffTime"
,
"dataType"
:
"double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"time_off"
,
"synType"
:
"fit"
},{
"opcode"
:
"FLOOR_HEATING_SET_LOCK_STATUS"
,
"identifiermap"
:
"ChildLockState"
,
"dataType"
:
"double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
""
,
"synType"
:
"dummy"
},{
"opcode"
:
"current_real_temperature"
,
"identifiermap"
:
"CurrentTemperature"
,
"dataType"
:
"double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"current_real_temperature"
,
"synType"
:
"double"
}
]
}
opcodeMapCfg/device_3062.json
0 → 100644
View file @
880044d8
{
"productCode"
:
"3062"
,
"operateType"
:
"12001"
,
"channel"
:
1
,
"newccu"
:[
],
"oldccu"
:[
]
}
opcodeMapCfg/device_3067.json
0 → 100644
View file @
880044d8
{
"productCode"
:
"3067"
,
"operateType"
:
"1003"
,
"channel"
:
1
,
"newccu"
:[
{
"identifier"
:
"OperationMode"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
,
2
],
"value"
:
2
}
],
"oldccu"
:[
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"OperationMode"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"CLOSE"
,
"OPEN"
,
"STOP"
]
}
]
}
\ No newline at end of file
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