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
8fcfbe3a
Commit
8fcfbe3a
authored
Jul 13, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
20210713:问题 See merge request chenweican/k-sdk!88
parents
3533b5b2
8fd421e1
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1352 additions
and
901 deletions
+1352
-901
application/klansdk/iot.mk
application/klansdk/iot.mk
+3
-0
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+514
-325
application/klansdk/kk_data_mng.c
application/klansdk/kk_data_mng.c
+437
-238
application/klansdk/kk_data_mng.h
application/klansdk/kk_data_mng.h
+21
-11
application/klansdk/kk_findccu_handle.c
application/klansdk/kk_findccu_handle.c
+90
-90
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+23
-1
application/klansdk/kk_login_handle.c
application/klansdk/kk_login_handle.c
+219
-214
application/klansdk/kk_opcode.h
application/klansdk/kk_opcode.h
+12
-1
common/api/com_api.c
common/api/com_api.c
+3
-0
common/api/com_api.h
common/api/com_api.h
+7
-0
common/hal/kk_product.h
common/hal/kk_product.h
+1
-1
makefile
makefile
+1
-1
midware/midware/dm/kk_sync_data.c
midware/midware/dm/kk_sync_data.c
+2
-0
midware/tsl/tsl_handle/kk_utils.c
midware/tsl/tsl_handle/kk_utils.c
+15
-15
midware/tsl/tsl_handle/klist.h
midware/tsl/tsl_handle/klist.h
+2
-2
opcodeMapCfg/device_3023.json
opcodeMapCfg/device_3023.json
+2
-2
No files found.
application/klansdk/iot.mk
View file @
8fcfbe3a
...
...
@@ -8,8 +8,11 @@ CFLAGS += -I$(TOP_DIR)/common/api
CFLAGS
+=
-I
$(TOP_DIR)
/common/json
CFLAGS
+=
-I
$(TOP_DIR)
/common/nanomsg/include
CFLAGS
+=
-I
$(TOP_DIR)
/common/ev/include
CFLAGS
+=
-I
$(TOP_DIR)
/common/sqlite
LDFLAGS
+=
-lkk_tsl
LDFLAGS
+=
-lapi_com
LDFLAGS
+=
-lsqlite
-ldl
ifeq
($(CONFIG_MODEL),x86)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_ubuntu
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_ubuntu
...
...
application/klansdk/kk_data_handle.c
View file @
8fcfbe3a
...
...
@@ -15,6 +15,8 @@
#include "kk_opcode.h"
#include "com_api.h"
#include "kk_data_mng.h"
#include "kk_lan_ctrl.h"
const
char
DM_MSG_TO_MIDDWARE
[]
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
char
*
strrpl
(
char
*
in
,
char
*
out
,
int
outlen
,
char
*
src
,
char
*
dst
)
{
...
...
@@ -99,13 +101,14 @@ static char * _kk_data_create(char *msgtype,const char *productCode,const char *
return
out
;
//free(out); /* Print to text, Delete the cJSON, print it, release the string. */
}
static
void
kk_handle_sync_info
(
void
)
void
kk_handle_sync_info
(
void
)
{
char
*
send_data
=
NULL
;
send_data
=
_kk_data_create
(
SYNC_MSG_TYPE
,
"*"
,
"*"
,
"*"
);
if
(
send_data
==
NULL
){
return
;
}
printf
(
"kk_ipc_send........%s
\n
"
,
send_data
);
kk_ipc_send
(
IPC_APP2MID
,
send_data
,
strlen
(
send_data
)
+
1
);
free
(
send_data
);
}
...
...
@@ -117,7 +120,6 @@ static int kk_send_ack(cJSON *root,int sockfd)
cJSON_Minify
((
char
*
)
out
);
tmpBuf
=
calloc
(
strlen
(
out
)
+
4
,
1
);
if
(
tmpBuf
==
NULL
){
cJSON_Delete
(
root
);
free
(
out
);
return
-
1
;
}
...
...
@@ -126,12 +128,11 @@ static int kk_send_ack(cJSON *root,int sockfd)
strcat
(
tmpBuf
,
"$"
);
printf
(
"tmpBuf:%s
\n
"
,
tmpBuf
);
send
(
sockfd
,
tmpBuf
,
strlen
(
tmpBuf
),
0
);
cJSON_Delete
(
root
);
free
(
out
);
free
(
tmpBuf
);
return
0
;
}
static
int
_kk_send_data_to_sdk
(
char
*
nodeid
,
char
*
opcode
,
c
har
*
arg
)
static
int
_kk_send_data_to_sdk
(
char
*
nodeid
,
char
*
opcode
,
c
JSON
*
arg
)
{
cJSON
*
root
;
char
*
out
=
NULL
;
...
...
@@ -140,14 +141,14 @@ static int _kk_send_data_to_sdk(char *nodeid,char *opcode,char *arg)
cJSON_AddStringToObject
(
root
,
"nodeid"
,
nodeid
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
opcode
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddStringToObject
(
root
,
"arg"
,
arg
);
cJSON_AddItemToObject
(
root
,
"arg"
,
arg
);
out
=
cJSON_Print
(
root
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"out:%s
\n
"
,
out
);
cJSON_Minify
((
char
*
)
out
);
kk_send_data_to_sdk
(
out
);
}
free
(
arg
);
cJSON_Delete
(
root
);
return
0
;
}
...
...
@@ -200,6 +201,148 @@ static int kk_loginccu_ack(cJSON *arg,int sockfd)
}
return
0
;
}
//构建hw信息
static
cJSON
*
kk_zb_dev_hw_info_build
(
const
char
*
deviceCode
,
cJSON
*
productCode
,
cJSON
*
online
,
const
char
*
hw_ver
,
const
char
*
sw_ver
)
{
cJSON
*
item
;
char
mac
[
32
]
=
{
0
};
int
online_status
=
0
;
int
pid
;
if
(
mac
==
NULL
){
return
NULL
;
}
item
=
cJSON_CreateObject
();
if
(
item
){
if
(
hw_ver
!=
NULL
){
cJSON_AddStringToObject
(
item
,
"hardware_version"
,
hw_ver
);
}
else
{
cJSON_AddStringToObject
(
item
,
"hardware_version"
,
""
);
}
_deviceCode_switchto_mac
(
deviceCode
,
mac
);
if
(
online
==
0
){
online_status
=
1
;
//在线
}
else
if
(
online
==
1
){
online_status
=
2
;
//离线
}
else
{
online_status
=
0
;
//未知
}
pid
=
atoi
(
productCode
);
cJSON_AddStringToObject
(
item
,
"mac"
,
mac
);
cJSON_AddNumberToObject
(
item
,
"online_status"
,
online_status
);
cJSON_AddNumberToObject
(
item
,
"product_id"
,
pid
);
if
(
hw_ver
!=
NULL
){
cJSON_AddStringToObject
(
item
,
"version"
,
sw_ver
);
}
else
{
cJSON_AddStringToObject
(
item
,
"version"
,
""
);
}
}
return
item
;
}
static
void
_kk_zb_devs_hw_ack
(
int
sockfd
,
cJSON
*
arg
)
{
cJSON
*
root
;
root
=
cJSON_CreateObject
();
if
(
root
){
cJSON_AddStringToObject
(
root
,
"nodeid"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
GET_ZB_DEVS_HW_INFO_OPCODE
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddItemToObject
(
root
,
"arg"
,
arg
);
kk_send_ack
(
root
,
sockfd
);
}
cJSON_Delete
(
root
);
}
int
kk_zb_devs_hw_ack_all
(
int
sockfd
)
{
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
kk_map_dev_node_t
*
search_node
=
NULL
;
cJSON
*
array
=
cJSON_CreateArray
();
cJSON
*
item
;
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
if
((
item
=
kk_zb_dev_hw_info_build
(
search_node
->
deviceCode
,
search_node
->
productCode
,
search_node
->
online_status
,
NULL
,
NULL
))
!=
NULL
){
cJSON_AddItemToArray
(
array
,
item
);
}
}
_kk_zb_devs_hw_ack
(
sockfd
,
array
);
return
-
1
;
}
int
kk_zb_dev_hw_info_build_by_deviceCode
(
int
sockfd
,
const
char
*
deviceCode
)
{
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
kk_map_dev_node_t
*
search_node
=
NULL
;
cJSON
*
item
;
unsigned
char
online_status
=
0
;
int
pid
=-
1
;
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
if
(
(
strlen
(
search_node
->
deviceCode
)
==
strlen
(
deviceCode
))
&&
(
memcmp
(
search_node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
))
==
0
))
{
item
=
kk_zb_dev_hw_info_build
(
search_node
->
deviceCode
,
search_node
->
productCode
,
search_node
->
online_status
,
NULL
,
NULL
);
return
item
;
}
}
return
NULL
;
}
static
void
kk_zb_devs_hw_ack
(
int
sockfd
,
cJSON
*
conditions
)
{
int
i
,
size
;
cJSON
*
type
;
cJSON
*
arg
;
char
devCode
[
33
]
=
{
0
};
type
=
cJSON_GetObjectItem
(
conditions
,
"condition_type"
);
if
(
type
==
NULL
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_zb_devs_hw_ack_all
(
sockfd
);
}
else
{
if
(
strcmp
(
type
->
valuestring
,
"dev_list"
)){
WARNING_PRINT
(
"[type err]%s,%s
\n
"
,
type
->
valuestring
,
"dev_list"
);
return
;
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
arg
=
cJSON_GetObjectItem
(
conditions
,
"condition_arg"
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
size
=
cJSON_GetArraySize
(
arg
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON
*
qMac
;
cJSON
*
item
;
cJSON
*
array
=
cJSON_CreateArray
();
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
for
(
i
=
0
;
i
<
size
;
i
++
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
qMac
=
cJSON_GetArrayItem
(
arg
,
1
);
if
(
mac_switchto_deviceCode
(
qMac
->
valuestring
,
devCode
)
==
0
){
if
((
item
=
kk_zb_dev_hw_info_build_by_deviceCode
(
sockfd
,
devCode
))
!=
NULL
){
cJSON_AddItemToArray
(
array
,
item
);
}
}
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
_kk_zb_devs_hw_ack
(
sockfd
,
array
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
return
0
;
}
int
kk_data_handle
(
cJSON
*
json
,
int
sockfd
)
{
cJSON
*
opcode
;
...
...
@@ -213,16 +356,23 @@ int kk_data_handle(cJSON *json,int sockfd)
kk_heartbeat_ack
(
sockfd
);
}
else
if
(
strcmp
(
opcode
->
valuestring
,
SYNC_OPCODE
)
==
0
){
kk_handle_sync_info
();
}
else
if
(
strcmp
(
opcode
->
valuestring
,
GET_ZB_DEVS_HW_INFO_OPCODE
)
==
0
){
cJSON
*
conditions
=
cJSON_GetObjectItem
(
json
,
OPCODE_STRING
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_zb_devs_hw_ack
(
sockfd
,
conditions
);
}
else
{
kk_ccu_opcode_handle
(
json
);
}
}
return
0
;
}
static
int
kk_parse_syncinfo
(
cJSON
*
payload
)
{
cJSON
*
paramStr
,
*
dataStr
;
cJSON
*
gwdevices
,
*
subdevices
;
cJSON
*
gwitem
,
*
properties
;
cJSON
*
onlineStatus
;
char
*
gwdevicecode
;
char
*
deviceCode
,
*
productCode
;
char
*
identifier
,
*
valuetype
;
...
...
@@ -230,6 +380,9 @@ static int kk_parse_syncinfo(cJSON *payload)
cJSON
*
newccuItem
;
cJSON
*
valuejson
;
int
value
;
printf
(
"
\n\n\n
00000000000000000000000000000000000000
\n\n\n
"
);
kk_map_dev_deinit
();
printf
(
"
\n\n\n
11111111111111111111111111111111111
\n\n\n
"
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_map_dev_node_t
*
node
=
NULL
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
@@ -245,43 +398,53 @@ static int kk_parse_syncinfo(cJSON *payload)
if
(
gwdevices
==
NULL
)
return
-
1
;
gwitem
=
gwdevices
->
child
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"
\n\n
222222222222222222222222222222222
\n\n\n
"
);
while
(
gwitem
!=
NULL
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
subdevices
=
cJSON_GetObjectItem
(
gwitem
,
DEVICES_STRING
);
gwdevicecode
=
cJSON_GetObjectItem
(
gwitem
,
MSG_DEVICE_CODE_STR
)
->
valuestring
;
if
(
subdevices
!=
NULL
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
subitem
=
subdevices
->
child
;
while
(
subitem
!=
NULL
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
deviceCode
=
cJSON_GetObjectItem
(
subitem
,
MSG_DEVICE_CODE_STR
)
->
valuestring
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
productCode
=
cJSON_GetObjectItem
(
subitem
,
MSG_PRODUCT_CODE_STR
)
->
valuestring
;
properties
=
cJSON_GetObjectItem
(
subitem
,
MSG_PROPERTIES_STR
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
node
=
kk_map_dev_add
(
deviceCode
,
productCode
,
gwdevicecode
);
if
(
node
!=
NULL
&&
node
->
newccu
!=
NULL
){
newccuItem
=
node
->
newccu
->
child
;
while
(
newccuItem
!=
NULL
){
identifier
=
cJSON_GetObjectItem
(
newccuItem
,
MSG_INDENTIFIER_STR
)
->
valuestring
;
valuetype
=
cJSON_GetObjectItem
(
newccuItem
,
MSG_INDENTIFIER_STR
)
->
valuestring
;
valuejson
=
cJSON_GetObjectItem
(
properties
,
identifier
);
if
(
valuejson
!=
NULL
){
if
(
strcmp
(
valuetype
,
"bool"
)
==
0
||
strcmp
(
valuetype
,
"int"
)
==
0
){
value
=
valuejson
->
valueint
;
onlineStatus
=
cJSON_GetObjectItem
(
subitem
,
MSG_ONLINE_STATUS_STR
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_map_dev_update_int_value
(
node
,
identifier
,
value
);
}
}
newccuItem
=
newccuItem
->
next
;
}
}
properties
=
cJSON_GetObjectItem
(
subitem
,
MSG_PROPERTIES_STR
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
node
=
kk_map_dev_add
(
deviceCode
,
productCode
,
gwdevicecode
,
onlineStatus
->
valuestring
);
property_syn_deal
(
deviceCode
,
properties
);
subitem
=
subitem
->
next
;
}
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
gwitem
=
gwitem
->
next
;
}
printf
(
"
\n\n
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
\n\n\n
"
);
return
0
;
}
static
int
kk_create_floors_to_sdk
(
cJSON
*
root
)
{
cJSON
*
floors
=
cJSON_CreateArray
();
...
...
@@ -332,6 +495,7 @@ int kk_create_syncinfo_to_sdk(void)
cJSON
*
guard
;
cJSON
*
gw_version
;
char
*
out
=
NULL
;
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
aiks_controllers
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
root
,
"aiks_controllers"
,
aiks_controllers
);
...
...
@@ -360,11 +524,14 @@ int kk_create_syncinfo_to_sdk(void)
controllers
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
root
,
"controllers"
,
controllers
);
kk_create_devicestatus_to_sdk
(
root
);
kk_create_devices_to_sdk
(
root
);
#if 1
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
expand_rules
=
cJSON_CreateArray
();
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON_AddItemToObject
(
root
,
"expand_rules"
,
expand_rules
);
...
...
@@ -388,30 +555,52 @@ int kk_create_syncinfo_to_sdk(void)
out
=
cJSON_Print
(
root
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"out:%s
\n
"
,
out
);
cJSON_Minify
((
char
*
)
out
);
_kk_send_data_to_sdk
(
"*"
,
"*"
,
out
);
_kk_send_data_to_sdk
(
"*"
,
"SYNC_INFO"
,
root
);
return
0
;
}
void
KK_Data_FromMid
(
void
*
str
,
int
len
)
{
cJSON
*
json
;
cJSON
*
info_root
;
cJSON
*
payload
,
*
typeJson
;
cJSON
*
deviceCode
;
printf
(
"
str
:%s
\n
"
,
str
);
printf
(
"
[midware->lan]
:%s
\n
"
,
str
);
json
=
cJSON_Parse
(
str
);
if
(
json
==
NULL
){
return
;
}
info_root
=
cJSON_GetObjectItem
(
json
,
MSG_INFO_STR
);
if
(
info_root
==
NULL
)
return
;
payload
=
cJSON_GetObjectItem
(
json
,
MSG_PAYLOAD_STR
);
if
(
payload
==
NULL
)
return
;
deviceCode
=
cJSON_GetObjectItem
(
info_root
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
)
return
;
typeJson
=
cJSON_GetObjectItem
(
info_root
,
MSG_TYPE_STR
);
if
(
typeJson
==
NULL
)
return
;
if
(
strstr
(
typeJson
->
valuestring
,
SYNC_MSG_TYPE_REPLY
)
!=
NULL
){
kk_parse_syncinfo
(
payload
);
kk_create_syncinfo_to_sdk
();
printf
(
"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
\n
"
);
}
else
if
((
typeJson
->
valuestring
,
"/thing/event/property/post"
)
!=
NULL
){
property_post_deal
(
deviceCode
->
valuestring
,
payload
);
}
}
application/klansdk/kk_data_mng.c
View file @
8fcfbe3a
...
...
@@ -3,9 +3,14 @@
#include <stdlib.h>
#include <string.h>
#include "kk_data_mng.h"
#include "kk_lan_node_db.h"
static
kk_map_dev_ctx
g_map_dev_mgr
=
{
0
};
static
kk_map_dev_ctx
*
_kk_map_dev_ctx
(
void
)
kk_map_dev_ctx
*
_kk_map_dev_ctx
(
void
)
{
return
&
g_map_dev_mgr
;
}
...
...
@@ -35,6 +40,40 @@ int kk_map_dev_init(void)
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
return
0
;
}
void
kk_map_dev_deinit
(
void
)
{
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
kk_map_dev_node_t
*
node
=
NULL
;
kk_map_dev_node_t
*
n
=
NULL
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
list_for_each_entry_safe
(
node
,
n
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
printf
(
"[remove list] node->linked_list000000000
\n
"
);
if
(
node
!=
NULL
)
{
_kk_map_dev_mutex_lock
();
if
(
node
->
json
){
printf
(
"[delete cjson] node->json.
\n
"
);
cJSON_Delete
(
node
->
json
);
}
if
(
node
->
syn_opcode
)
{
printf
(
"[free] node->syn_opcode.
\n
"
);
free
(
node
->
syn_opcode
);
}
printf
(
"[remove list] node->linked_list
\n
"
);
dlist_del
(
&
node
->
linked_list
);
memset
(
node
,
0
,
sizeof
(
kk_map_dev_node_t
));
_kk_map_dev_mutex_unlock
();
}
}
}
static
int
kk_open_cfg_file
(
char
*
deviceCode
,
kk_map_dev_node_t
*
node
)
{
char
path
[
128
]
=
{
0
};
...
...
@@ -43,6 +82,8 @@ static int kk_open_cfg_file(char *deviceCode,kk_map_dev_node_t *node)
char
*
buf
=
NULL
;
cJSON
*
json
=
NULL
;
cJSON
*
optype
=
NULL
;
cJSON
*
syn_type
=
NULL
;
sprintf
(
path
,
KK_DEVICE_MAP_FILE_PATH
,
deviceCode
);
printf
(
"kk_open_cfg_file path:%s
\n
"
,
path
);
if
(
!
(
fp
=
fopen
(
path
,
"r"
)))
...
...
@@ -72,11 +113,23 @@ static int kk_open_cfg_file(char *deviceCode,kk_map_dev_node_t *node)
fclose
(
fp
);
return
-
1
;
}
node
->
json
=
json
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
optype
=
cJSON_GetObjectItem
(
json
,
OPEARTETYPE_STRING
);
if
(
optype
!=
NULL
){
memcpy
(
node
->
opearteType
,
optype
->
valuestring
,
strlen
(
optype
->
valuestring
));
}
syn_type
=
cJSON_GetObjectItem
(
json
,
"syn_type"
);
if
(
syn_type
){
cJSON
*
syn_opcode
=
cJSON_GetObjectItem
(
json
,
"syn_opcode"
);
node
->
syn_type
=
syn_type
->
valueint
;
node
->
syn_opcode
=
(
char
*
)
malloc
(
strlen
(
syn_opcode
->
valuestring
)
+
1
);
memset
(
node
->
syn_opcode
,
0
,
strlen
(
node
->
syn_opcode
)
+
1
);
memcpy
(
node
->
syn_opcode
,
syn_opcode
->
valuestring
,
strlen
(
syn_opcode
->
valuestring
));
}
printf
(
"[%s][%d]node->syn_type=%d****************
\n
"
,
__FUNCTION__
,
__LINE__
,
node
->
syn_type
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
node
->
channelNum
=
cJSON_GetObjectItem
(
json
,
CHANNEL_STRING
)
->
valueint
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
@@ -96,17 +149,53 @@ static int kk_open_cfg_file(char *deviceCode,kk_map_dev_node_t *node)
return
0
;
}
static
int
kk_creater_nodeid
(
char
*
deviceCode
,
char
*
channel
,
char
*
nodeId
)
int
kk_creater_nodeid
(
char
*
deviceCode
,
int
channel
,
char
*
nodeId
)
{
static
int
next
=
1
;
int
node
=-
1
;
if
(
deviceCode
==
NULL
||
channel
==
NULL
||
nodeId
==
NULL
){
printf
(
"bbb
\n
"
);
return
-
1
;
}
strcat
(
nodeId
,
deviceCode
);
strcat
(
nodeId
,
"_"
);
strcat
(
nodeId
,
channel
);
printf
(
"nodeId:%s
\n
"
,
nodeId
);
printf
(
"aaa
\n
"
);
printf
(
"channel=%d
\n
"
,
channel
);
printf
(
"deviceCode=%s
\n
"
,
deviceCode
);
printf
(
",,,,
\n
"
);
//INFO_PRINT("-------------->deviceCode=%s,channel=%d\n",deviceCode,channel);
printf
(
"aaa-1
\n
"
);
if
(
kk_check_lan_node_exist
(
deviceCode
,
channel
)){
printf
(
"aaa-2
\n
"
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
node
=
kk_lan_db_node_get
(
deviceCode
,
channel
);
}
else
{
printf
(
"aaa-3
\n
"
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
while
(
kk_check_lan_node
(
next
)){
++
next
;
}
INFO_PRINT
(
"#################next=%d
\n
"
,
next
);
if
(
0
==
kk_lan_db_node_insert
(
deviceCode
,
channel
,
next
)){
node
=
next
;
}
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"aaa-44,node=%d
\n
"
,
node
);
sprintf
(
nodeId
,
"%d"
,
node
);
printf
(
"aaa-4
\n
"
);
//INFO_PRINT("[node]deviceCode=%s,channel=%d,node=%d,nodeId=%s\n",deviceCode,channel,node,nodeId);
return
0
;
}
/******************************************
*从映射表中获取组件所需的值
*******************************************/
static
char
*
kk_value_int_map_string
(
char
*
opcodemap
,
kk_map_dev_node_t
*
node
,
int
idx
)
{
if
(
opcodemap
==
NULL
||
node
==
NULL
){
...
...
@@ -126,26 +215,48 @@ static char* kk_value_int_map_string(char *opcodemap,kk_map_dev_node_t *node,int
}
}
}
}
}
return
""
;
}
static
int
kk_get_int_value_idx
(
cJSON
*
range
,
int
val
)
int
kk_get_int_value_idx
(
cJSON
*
range
,
int
val
)
{
int
i
=
0
;
int
array_size
=
cJSON_GetArraySize
(
range
);
for
(
i
=
0
;
i
<
array_size
;
i
++
){
cJSON
*
pSub
=
cJSON_GetArrayItem
(
range
,
i
);
if
(
pSub
!=
NULL
&&
pSub
->
valueint
==
val
){
if
(
pSub
!=
NULL
&&
(
pSub
->
valueint
==
val
)){
return
i
;
}
}
return
-
1
;
}
static
int
_deviceCode_switchto_mac
(
char
*
deviceCode
,
char
*
mac
)
int
mac_switchto_deviceCode
(
char
*
mac
,
char
*
deviceCode
)
{
char
mac_bak
[
33
]
=
{
0
};
int
i
,
j
;
int
len
=
strlen
(
mac
);
if
(
len
!=
23
)
return
-
1
;
for
(
i
=
0
;
i
<
len
;
i
++
)
/*将串s拷贝至串t*/
mac_bak
[
i
]
=
mac
[
i
];
mac_bak
[
i
]
=
'\0'
;
for
(
i
=
0
,
j
=
0
;
i
<
len
;
i
++
){
if
((
i
+
1
)
%
3
==
0
&&
i
!=
0
){
continue
;
}
deviceCode
[
j
++
]
=
mac_bak
[
i
];
}
deviceCode
[
j
]
=
'\0'
;
/*在串s结尾加结束标志*/
return
0
;
}
int
_deviceCode_switchto_mac
(
char
*
deviceCode
,
char
*
mac
)
{
char
deviceCode_bak
[
33
]
=
{
0
};
int
i
,
j
;
...
...
@@ -167,18 +278,25 @@ static int _deviceCode_switchto_mac(char * deviceCode,char *mac)
mac
[
j
]
=
'\0'
;
/*在串s结尾加结束标志*/
return
0
;
}
int
kk_create_devices_to_sdk
(
cJSON
*
root
)
{
kk_map_dev_node_t
*
node
=
NULL
;
char
nodeid
[
32
]
=
{
0
};
char
channel
[
4
]
=
{
0
};
char
gwmac
[
32
]
=
{
0
};
char
submac
[
32
]
=
{
0
};
char
channel
[
4
];
int
idx
=
1
;
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
cJSON
*
devices
=
cJSON_CreateArray
();
list_for_each_entry
(
node
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
if
(
node
!=
NULL
)
{
for
(
idx
=
1
;
idx
<=
node
->
channelNum
;
idx
++
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON
*
subdevicesItem
=
cJSON_CreateObject
();
...
...
@@ -193,64 +311,76 @@ int kk_create_devices_to_sdk(cJSON *root)
cJSON_AddStringToObject
(
subdevicesItem
,
GW_MAC_STRING
,
gwmac
);
_deviceCode_switchto_mac
(
node
->
deviceCode
,
submac
);
cJSON_AddStringToObject
(
subdevicesItem
,
MAC_STRING
,
submac
);
//todo name字段
cJSON_AddStringToObject
(
subdevicesItem
,
NAME_STRING
,
"默认灯"
);
memset
(
nodeid
,
0x0
,
sizeof
(
nodeid
));
kk_creater_nodeid
(
node
->
deviceCode
,
channel
,
nodeid
);
kk_creater_nodeid
(
node
->
deviceCode
,
idx
,
nodeid
);
cJSON_AddStringToObject
(
subdevicesItem
,
NODEID_STRING
,
nodeid
);
cJSON_AddStringToObject
(
subdevicesItem
,
OPERATE_TYPE_STRING
,
node
->
opearteType
);
cJSON_AddStringToObject
(
subdevicesItem
,
ROOM_ID_STRING
,
"1"
);
cJSON_AddItemToArray
(
devices
,
subdevicesItem
);
}
}
}
cJSON_AddItemToObject
(
root
,
DEVICES_STRING
,
devices
);
return
0
;
}
char
*
double_value_string
(
double
val
)
{
char
*
value
=
(
char
*
)
malloc
(
33
);
memset
(
value
,
0
,
33
);
snprintf
(
value
,
32
,
"%6f"
,
val
);
return
value
;
}
int
kk_create_devicestatus_to_sdk
(
cJSON
*
root
)
{
kk_map_dev_node_t
*
node
=
NULL
;
char
nodeid
[
32
]
=
{
0
};
char
indxId
[
4
]
=
{
0
};
int
idx
=
1
;
int
syn_type
=
0
;
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
cJSON
*
device_status
=
cJSON_CreateArray
();
#if 1
list_for_each_entry
(
node
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
if
(
node
!=
NULL
)
{
cJSON
*
newccuItem
=
node
->
newccu
->
child
;
while
(
newccuItem
!=
NULL
){
cJSON
*
subdevicesItem
=
cJSON_CreateObject
();
memset
(
nodeid
,
0x0
,
sizeof
(
nodeid
));
cJSON
*
args
;
cJSON
*
sub_device
;
list_for_each_entry
(
node
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
){
char
*
opcodemap
=
cJSON_GetObjectItem
(
newccuItem
,
OPCODEMAP_STRING
)
->
valuestring
;
char
*
channel
=
cJSON_GetObjectItem
(
newccuItem
,
CHANNEL_STRING
)
->
valuestring
;
char
*
dataType
=
cJSON_GetObjectItem
(
newccuItem
,
DATATYPE_STRING
)
->
valuestring
;
cJSON
*
range
=
cJSON_GetObjectItem
(
newccuItem
,
VALUERANGE_STRING
);
kk_creater_nodeid
(
node
->
deviceCode
,
channel
,
nodeid
);
cJSON_AddStringToObject
(
subdevicesItem
,
OPCODE_STRING
,
opcodemap
);
cJSON_AddStringToObject
(
subdevicesItem
,
NODEID_STRING
,
nodeid
);
sprintf
(
indxId
,
"%d"
,
idx
++
);
cJSON_AddStringToObject
(
subdevicesItem
,
"index"
,
indxId
);
if
(
node
->
syn_type
==
1
){
kk_creater_nodeid
(
node
->
deviceCode
,
1
,
nodeid
);
if
(
strcmp
(
dataType
,
"int"
)
==
0
){
int
value
=
cJSON_GetObjectItem
(
newccuItem
,
VALUE_STRING
)
->
valueint
;
if
(
range
!=
NULL
){
int
index
=
kk_get_int_value_idx
(
range
,
value
);
cJSON_AddStringToObject
(
subdevicesItem
,
"arg"
,
kk_value_int_map_string
(
opcodemap
,
node
,
index
));
if
((
args
=
kk_devicestatus_build
(
node
))
!=
NULL
){
sub_device
=
old_ccu_msg_build_json_node_int
(
atoi
(
nodeid
),
node
->
syn_opcode
,
NULL
,
args
);
if
(
sub_device
){
cJSON_AddItemToArray
(
device_status
,
sub_device
);
}
}
cJSON_AddItemToArray
(
device_status
,
subdevicesItem
);
newccuItem
=
newccuItem
->
next
;
}
else
{
kk_devicestatus_build_aaa
(
device_status
,
node
)
;
}
}
}
#endif
cJSON_AddItemToObject
(
root
,
DEVICE_STATUS_STRING
,
device_status
);
return
0
;
}
int
kk_map_dev_update_int_value
(
kk_map_dev_node_t
*
node
,
char
*
identifier
,
int
val
)
{
int
ret
=
0
;
...
...
@@ -291,6 +421,7 @@ int kk_map_dev_update_int_value_by_devicecode(char *deviceCode,char *identifier,
return
0
;
}
int
kk_map_dev_search_by_deviceCode
(
char
*
deviceCode
,
kk_map_dev_node_t
**
node
)
{
kk_map_dev_ctx
*
ctx
=
_kk_map_dev_ctx
();
...
...
@@ -307,10 +438,13 @@ int kk_map_dev_search_by_deviceCode(char *deviceCode, kk_map_dev_node_t **node)
}
}
ERROR_PRINT
(
"Device Not Found, deviceCode: %s
"
,
deviceCode
);
ERROR_PRINT
(
"Device Not Found, deviceCode: %s
\n
"
,
deviceCode
);
return
-
1
;
}
kk_map_dev_node_t
*
kk_map_dev_add
(
char
*
deviceCode
,
char
*
productCode
,
char
*
gwdeviceCode
)
kk_map_dev_node_t
*
kk_map_dev_add
(
char
*
deviceCode
,
char
*
productCode
,
char
*
gwdeviceCode
,
char
*
onlineStatus
)
{
#if 1
kk_map_dev_node_t
*
node
=
NULL
;
...
...
@@ -320,16 +454,36 @@ kk_map_dev_node_t *kk_map_dev_add(char *deviceCode,char *productCode,char *gwdev
if
(
node
==
NULL
)
{
return
NULL
;
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"----------------------------------------->%s
\n
"
,
onlineStatus
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
_kk_map_dev_mutex_lock
();
printf
(
"[%s][%d]%d
\n
"
,
__FUNCTION__
,
__LINE__
,
onlineStatus
);
memset
(
node
,
0x0
,
sizeof
(
kk_map_dev_node_t
));
printf
(
"[%s][%d]%d
\n
"
,
__FUNCTION__
,
__LINE__
,
onlineStatus
);
memcpy
(
node
->
gwDeviceCode
,
gwdeviceCode
,
strlen
(
gwdeviceCode
));
printf
(
"[%s][%d]%d
\n
"
,
__FUNCTION__
,
__LINE__
,
onlineStatus
);
memcpy
(
node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
printf
(
"[%s][%d]%d
\n
"
,
__FUNCTION__
,
__LINE__
,
onlineStatus
);
memcpy
(
node
->
productCode
,
productCode
,
strlen
(
productCode
));
printf
(
"[%s][%d]%d
\n
"
,
__FUNCTION__
,
__LINE__
,
onlineStatus
);
if
(
onlineStatus
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]%d
\n
"
,
__FUNCTION__
,
__LINE__
,
onlineStatus
);
}
else
{
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
if
(
strcmp
(
onlineStatus
,
"1"
)
==
0
){
node
->
online_status
=
1
;
}
else
{
node
->
online_status
=
0
;
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_open_cfg_file
(
productCode
,
node
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
INIT_LIST_HEAD
(
&
node
->
linked_list
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"#55,%d
\n
"
,
node
);
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
dev_list
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
_kk_map_dev_mutex_unlock
();
...
...
@@ -337,3 +491,48 @@ printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return
node
;
#endif
}
/*
int get_productCode_by_deviceCode(const char *deviceCode)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
kk_map_dev_node_t *search_node = NULL;
list_for_each_entry(search_node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if ( (strlen(search_node->deviceCode) == strlen(deviceCode)) &&
(memcmp(search_node->deviceCode, deviceCode, strlen(deviceCode)) == 0)) {
item = kk_zb_dev_hw_info_build(search_node->deviceCode,search_node->productCode,search_node->online_status,NULL,NULL);
return item;
}
}
return NULL;
}
*/
application/klansdk/kk_data_mng.h
View file @
8fcfbe3a
...
...
@@ -8,13 +8,18 @@
#include "com_api.h"
#include "kk_opcode.h"
typedef
struct
{
cJSON
*
json
;
cJSON
*
newccu
;
cJSON
*
oldccu
;
unsigned
char
online_status
;
int
channelNum
;
int
syn_type
;
char
*
syn_opcode
;
char
gwDeviceCode
[
DEVICE_CODE_LEN
];
char
productCode
[
PRODUCT_CODE_LEN
];
char
deviceCode
[
DEVICE_CODE_LEN
];
char
opearteType
[
8
];
struct
list_head
linked_list
;
}
kk_map_dev_node_t
;
...
...
@@ -23,7 +28,12 @@ typedef struct {
struct
list_head
dev_list
;
}
kk_map_dev_ctx
;
kk_map_dev_node_t
*
kk_map_dev_add
(
char
*
deviceCode
,
char
*
productCode
,
char
*
gwdeviceCode
);
kk_map_dev_node_t
*
kk_map_dev_add
(
char
*
deviceCode
,
char
*
productCode
,
char
*
gwdeviceCode
,
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
mac_switchto_deviceCode
(
char
*
mac
,
char
*
deviceCode
);
kk_map_dev_ctx
*
_kk_map_dev_ctx
(
void
);
#endif
\ No newline at end of file
application/klansdk/kk_findccu_handle.c
View file @
8fcfbe3a
application/klansdk/kk_lan_main.c
View file @
8fcfbe3a
...
...
@@ -24,18 +24,40 @@
#include "kk_findccu_handle.h"
#include "kk_login_handle.h"
#include "kk_data_handle.h"
//#include "kcloud_log.h"
//#include "kk_lan_queue.h"
#include "kk_lan_node_db.h"
static
void
sig_handler
(
int
sig
)
{
printf
(
"Received signal: %d
\n
"
,
sig
);
abort
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
rc
=
0
;
char
*
ppp
;
open
(
"kk_lan"
,
LOG_PID
,
LOG_USER
);
/*set the callback to get the device date to cloud*/
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromMid
,
NULL
,
NULL
);
kk_findccu_handle_init
();
kk_map_dev_init
();
kk_login_init
();
struct
sigaction
sig
=
{
0
};
sig
.
sa_handler
=
sig_handler
;
sig
.
sa_flags
=
0
;
for
(
int
i
=
0
;
i
<
31
;
i
++
){
//sigaction(i, &sig, NULL);
}
//lan_queue_init();
kk_lan_db_node_init
();
kk_handle_sync_info
();
while
(
1
){
//count++;
//if(count == 10){
...
...
application/klansdk/kk_login_handle.c
View file @
8fcfbe3a
...
...
@@ -42,7 +42,7 @@ int kk_send_data_to_sdk(char *buf)
send
(
s_ConnInfo
[
i
].
socketfd
,
tmpBuf
,
strlen
(
tmpBuf
),
0
);
}
}
free
(
buf
);
free
(
tmpBuf
);
return
0
;
}
...
...
@@ -66,7 +66,10 @@ static int _kk_handle_data(char *buf,int sockfd){
}
else
{
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_data_handle
(
json
,
sockfd
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON_Delete
(
json
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
}
...
...
@@ -109,12 +112,14 @@ void *TCP_Analyzer(void *pPara)
s_ConnInfo
[
index
].
socketfd
=
-
1
;
memset
(
s_ConnInfo
[
index
].
ip
,
0x0
,
sizeof
(
s_ConnInfo
[
index
].
ip
));
pthread_mutex_unlock
(
&
data_mutex
);
return
NULL
;
}
else
{
printf
(
"TCP_Analyzer:%s,%d
\n
"
,
Buf
,(
int
)
Size
);
_kk_handle_data
(
Buf
,
s_ConnInfo
[
index
].
socketfd
);
printf
(
"[%s][%d] TCP_Analyzer end.
\n
"
,
__FUNCTION__
,
__LINE__
);
}
}
return
NULL
;
...
...
@@ -214,7 +219,7 @@ void *TCPServer()
}
for
(
i
=
0
;
i
<
LISTEN_MAX
;
i
++
){
if
(
s_ConnInfo
[
i
].
socketfd
!=
-
1
){
if
(
i
==
4
){
if
(
i
==
LISTEN_MAX
-
1
){
DEBUG_PRINT
(
"more then max client!!!
\n
"
);
}
continue
;
...
...
application/klansdk/kk_opcode.h
View file @
8fcfbe3a
...
...
@@ -16,10 +16,21 @@
#define OPEARTETYPE_STRING "operateType"
#define NEWCCU_STRING "newccu"
#define OLDCCU_STRING "oldccu"
#define FINDCCU_OPCODE "FIND_CCU"
#define LOGIN_OPCODE "LOGIN"
#define HEARTBEAT_OPCODE "CCU_HB"
#define SYNC_OPCODE "SYNC_INFO"
#define GET_ZB_DEVS_HW_INFO_OPCODE "GET_ZIGBEE_DEVS_HW_INFO"
#define SWITCH_OPCODE "SWITCH"
#define VALUERANGE_STRING "valueRange"
#define DEVICE_FIELD_STRING "device_field"
#define DEVICE_FIELD_IDNDEX_STRING "device_field_index"
...
...
common/api/com_api.c
View file @
8fcfbe3a
...
...
@@ -6,8 +6,11 @@
#define APP2MID "ipc:///tmp/app2mid.ipc"
#define APP2MID_PUBSUB "ipc:///tmp/app2mid_pubsub.ipc"
#define PLAT2MID "ipc:///tmp/plat2mid.ipc"
//#define GW2CCU_PIPE "tcp://%s:5555"
//#define GW2CCU_PUBSUB "tcp://%s:5557"
#define GW2CCU_PIPE "tcp://%s:35567"
#define GW2CCU_PUBSUB "tcp://%s:35568"
#define MAGIC "magic12"
#define MAGIC_ACK "magic12ack"
#define FILTERSTR "|"
...
...
common/api/com_api.h
View file @
8fcfbe3a
...
...
@@ -38,6 +38,11 @@ typedef enum {
#define MSG_PAYLOAD_STR "payload"
#define MSG_INFO_STR "info"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_DATA_TYPE_STR "dataType"
#define MSG_PARAMS_STR "params"
#define MSG_IOTClOUDSTATE_STR "IOTCloudState"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
...
...
@@ -64,6 +69,8 @@ typedef enum {
#define MSG_TIMER_SETCOUNTDOWN_GETCOUNTDOWN "getCountDown"
#define MSG_PROPERTY_STR "property"
#define MSG_PROPERTIES_STR "properties"
#define MSG_ONLINE_STATUS_STR "onlineStatus"
/************************LOCK KEY*************************/
#define MSG_KEYDELETE_NOTIFICATION_KEYID "KeyDeletedNotification.KeyID"
#define MSG_KEYDELETE_NOTIFICATION_KEYTYPE "KeyDeletedNotification.KeyType"
...
...
common/hal/kk_product.h
View file @
8fcfbe3a
...
...
@@ -31,7 +31,7 @@
#define PRODUCT_TPYE "kk"
#define CCU_LAN "eth1"
#define KK_CCU_ID "CCU_7777
7
"
#define KK_CCU_ID "CCU_7777
1
"
#define KK_CCU_PRODUCTID "ccu_n12"
#define KK_GW_PRODUCTID "gateway_2"
#define KK_CCU_RANDOM "0000000000"
...
...
makefile
View file @
8fcfbe3a
...
...
@@ -13,7 +13,7 @@ COMP_LIB_COMPONENTS := \
#SUBDIRS += application/kcloud
$(call
Append_Conditional,
SUBDIRS,
application/kcloud,
KCLOUD_PLATFORM_SUPPORT)
$(call
Append_Conditional,
SUBDIRS,
application/kk_luoma,
LUOMA_PLATFORM_SUPPORT)
SUBDIRS
+=
application/oled
#
SUBDIRS += application/oled
SUBDIRS
+=
application/klansdk
SUBDIRS
+=
midware/midware
SUBDIRS
+=
common/mqtt
...
...
midware/midware/dm/kk_sync_data.c
View file @
8fcfbe3a
...
...
@@ -154,6 +154,8 @@ static int kk_get_properties_info(char *deviceCode,cJSON *obj)
valueType
==
KK_TSL_DATA_TYPE_ENUM
||
valueType
==
KK_TSL_DATA_TYPE_BOOL
){
cJSON_AddNumberToObject
(
propertyItem
,
propertyStr
,
atoi
(
valueStr
));
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_DOUBLE
){
cJSON_AddNumberToObject
(
propertyItem
,
propertyStr
,
atof
(
valueStr
));
}
}
cJSON_AddItemToObject
(
obj
,
KK_SYNC_PROPERTY_STR
,
propertyItem
);
...
...
midware/tsl/tsl_handle/kk_utils.c
View file @
8fcfbe3a
midware/tsl/tsl_handle/klist.h
View file @
8fcfbe3a
opcodeMapCfg/device_3023.json
View file @
8fcfbe3a
...
...
@@ -24,14 +24,14 @@
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch_1"
,
"dataType"
:
"
string
"
,
"dataType"
:
"
map
"
,
"channel"
:
"1"
,
"valueRange"
:[
"OFF"
,
"ON"
]
},
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch_2"
,
"dataType"
:
"
string
"
,
"dataType"
:
"
map
"
,
"channel"
:
"2"
,
"valueRange"
:[
"OFF"
,
"ON"
]
}
...
...
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