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
93d95f0b
Commit
93d95f0b
authored
Aug 31, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
Cwc See merge request chenweican/k-sdk!118
parents
4d9d15b7
298ae08d
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
212 additions
and
134 deletions
+212
-134
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+18
-18
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+2
-3
application/klansdk/Serial.c
application/klansdk/Serial.c
+2
-2
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+32
-1
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+1
-1
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+40
-76
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+45
-0
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+1
-1
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+18
-7
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+0
-6
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+30
-1
midware/midware/dm/kk_sub_db.h
midware/midware/dm/kk_sub_db.h
+1
-1
midware/midware/midware.c
midware/midware/midware.c
+1
-0
onboot.sh
onboot.sh
+19
-17
tools/build-rules/_rules-top.mk
tools/build-rules/_rules-top.mk
+2
-0
No files found.
application/kcloud/kk_info_report.c
View file @
93d95f0b
...
...
@@ -60,24 +60,24 @@ static int kk_info_get(char *str)
{
char
status
[
4
]
=
{
0
};
cJSON_AddItemToObject
(
args
,
"ccu"
,
ccu
);
cJSON_AddStringToObject
(
ccu
,
"id"
,
&
ccuid
[
4
]);
cJSON_AddStringToObject
(
ccu
,
"version"
,
version
);
cJSON_AddStringToObject
(
ccu
,
"name"
,
"kk_new_ccu"
);
//INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status());
//if(kk_get_gw_status() == DEVICE_OFFLINE){
//memcpy(status,"2",strlen("2"));
//}
if
(
kk_get_cloud_status
()
==
DEVICE_OFFLINE
)
{
//cJSON_AddStringToObject(ccu, "status", "1");
//INFO_PRINT("_-----------------------------------------------------------11\n");
memcpy
(
status
,
"1"
,
strlen
(
"1"
));
}
else
{
//INFO_PRINT("_-----------------------------------------------------------22\n");
memcpy
(
status
,
"0"
,
strlen
(
"0"
));
}
//INFO_PRINT("------------------------------------->status :%s\n",status);
cJSON_AddItemToObject
(
args
,
"ccu"
,
ccu
);
cJSON_AddStringToObject
(
ccu
,
"id"
,
&
ccuid
[
4
]);
cJSON_AddStringToObject
(
ccu
,
"version"
,
"1.1.1"
);
cJSON_AddStringToObject
(
ccu
,
"name"
,
"kk_new_ccu"
);
//INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status());
//if(kk_get_gw_status() == DEVICE_OFFLINE){
//memcpy(status,"2",strlen("2"));
//}
if
(
kk_get_cloud_status
()
==
DEVICE_OFFLINE
)
{
//cJSON_AddStringToObject(ccu, "status", "1");
//INFO_PRINT("_-----------------------------------------------------------11\n");
memcpy
(
status
,
"1"
,
strlen
(
"1"
));
}
else
{
//INFO_PRINT("_-----------------------------------------------------------22\n");
memcpy
(
status
,
"0"
,
strlen
(
"0"
));
}
//INFO_PRINT("------------------------------------->status :%s\n",status);
cJSON_AddStringToObject
(
ccu
,
"status"
,
status
);
}
...
...
application/kcloud/kk_topic_mng.c
View file @
93d95f0b
...
...
@@ -115,16 +115,15 @@ void KK_reset_sub_flag(void)
int
KK_CCU_TOPIC_Subscribe
(
void
)
{
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
deviceCode
[
MAC_ADDR_LEN
]
=
{
0
};
if
(
s_ccu_topic_sub
==
1
){
INFO_PRINT
(
"[%s][%d] already Subscribe
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
//
return -1;
}
char
ccuid
[
32
]
=
{
0
};
KK_Get_ccuid
(
ccuid
);
s_ccu_topic_sub
=
1
;
HAL_GetProduct_Code
(
productCode
);
HAL_Get_mac
(
deviceCode
);
return
_kk_ccu_topic_subscribe
(
productCode
,
ccuid
);
}
...
...
application/klansdk/Serial.c
View file @
93d95f0b
...
...
@@ -198,8 +198,8 @@ int devOpen(char *dev)
if
(
fd
==
-
1
)
{
SERIAL_LOG_ERR
(
"devOpen %s
\n
"
,
dev
);
perror
(
"devOpen"
);
//
SERIAL_LOG_ERR("devOpen %s\n ",dev);
//
perror("devOpen");
return
-
1
;
}
...
...
application/klansdk/kk_lan_ctrl.c
View file @
93d95f0b
...
...
@@ -115,7 +115,27 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
return
params
;
}
static
int
kk_guard_ctrl_handle
(
int
status
)
{
char
ccuid
[
33
]
=
{
0
};
kk_lan_get_ccuid
(
ccuid
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
params
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
params
,
"epNum"
,
"1"
);
if
(
status
==
0
){
//
cJSON_AddStringToObject
(
params
,
"ArmingState"
,
"0"
);
}
else
if
(
status
==
2
){
//ڼ
cJSON_AddStringToObject
(
params
,
"ArmingState"
,
"2"
);
}
else
{
//
cJSON_AddStringToObject
(
params
,
"ArmingState"
,
"1"
);
}
cJSON
*
info
=
property_info_build
(
"/thing/service/property/set"
,
KK_CCU_PRODUCTID
,
ccuid
);
cJSON
*
payload
=
property_payload_build
(
"thing.service.property.set"
,
"1"
,
"v1.0"
,
params
);
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
PAYLOAD_STRING
,
payload
);
kk_ipc_send_json
(
root
);
return
0
;
}
static
int
kk_indoorAir_ctrl_handle
(
char
*
epNum
,
cJSON
*
arg
)
{
kk_map_dev_node_t
*
dev
=
NULL
;
...
...
@@ -202,6 +222,17 @@ int kk_ccu_opcode_handle(cJSON *root)
kk_indoorAir_ctrl_handle
(
nodeId
->
valuestring
,
arg
);
return
0
;
}
else
if
(
strcmp
(
requester
->
valuestring
,
"HJ_Server"
)
==
0
){
if
(
strcmp
(
opcode
->
valuestring
,
"ARMING_IN_HOME"
)
==
0
){
kk_guard_ctrl_handle
(
2
);
return
0
;
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"ARMING_LEAVE_HOME"
)
==
0
){
kk_guard_ctrl_handle
(
0
);
return
0
;
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"DISARMING"
)
==
0
){
kk_guard_ctrl_handle
(
1
);
return
0
;
}
}
}
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
93d95f0b
...
...
@@ -315,7 +315,7 @@ void *kk_vp_manage_thread(void *arg)
break
;
case
UPDATING_8009_CONFIG_FILE_INFO
:
debug_log
(
LOG_INFO_LEVEL
,
"updating...
\n
"
);
//debug_log(LOG_INFO
,"updating...\n");
sleep
(
1
);
//todo :超时取消
break
;
...
...
application/klansdk/kk_oldccu_msg.c
View file @
93d95f0b
...
...
@@ -67,7 +67,7 @@ int send_msg_to_module(cJSON *root)
}
if
((
msg
=
cJSON_Print
(
root
))
!=
NULL
){
debug_log
(
LOG_INFO
_LEVEL
,
"[lan->module]
\n
%s
\n
"
,
msg
);
debug_log
(
LOG_INFO
,
"[lan->module]
\n
%s
\n
"
,
msg
);
cJSON_Minify
(
msg
);
kk_send_data_to_sdk
(
msg
);
free
(
msg
);
...
...
@@ -90,14 +90,13 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
if
(
newccuItem
==
NULL
||
newccuItem
->
type
!=
cJSON_Object
||
oldccuItem
==
NULL
||
oldccuItem
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
return
NULL
;
}
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_dataType
=
cJSON_GetObjectItem
(
newccuItem
,
DATATYPE_STRING
);
n_value
=
cJSON_GetObjectItem
(
newccuItem
,
"value"
);
...
...
@@ -106,7 +105,6 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
}
else
{
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
DATATYPE_STRING
);
}
return
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
n_value
);
}
...
...
@@ -115,38 +113,18 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg)
{
cJSON
*
msg
=
NULL
;
char
nodeBuff
[
33
]
=
{
0
};
char
valBuff
[
33
]
=
{
0
};
if
(
opcode
==
NULL
||
opcode
->
type
!=
cJSON_String
||
arg
==
NULL
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
arg
==
NULL
||
arg
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"nodeId=%d,opcode=%s,arg=%s
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuestring
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
32
,
"%d"
,
nodeId
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
memset
(
valBuff
,
0
,
sizeof
(
valBuff
));
if
(
arg
->
type
==
cJSON_String
){
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%s
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuestring
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
arg
->
valuestring
);
}
else
if
(
arg
->
type
==
cJSON_Number
){
if
(((
int
)(
arg
->
valuedouble
*
10
))
%
10
==
0
){
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%d
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valueint
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%d"
,
arg
->
valueint
);
}
else
{
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%f
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuedouble
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%f"
,
arg
->
valuedouble
);
}
}
else
if
(
arg
->
type
==
cJSON_True
){
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
"true"
);
}
else
if
(
arg
->
type
==
cJSON_True
){
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
"false"
);
}
msg
=
old_ccu_msg_build
(
nodeBuff
,
opcode
->
valuestring
,
"success"
,
arg
->
valuestring
);
send_msg_to_module
(
msg
);
cJSON_Delete
(
msg
);
...
...
@@ -161,7 +139,7 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
if
(
channelObj
!=
NULL
&&
epNumObj
!=
NULL
){
if
(
epNumObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
_LEVEL
,
"[err] epNumObj.
\n
"
);
debug_log
(
LOG_INFO
,
"[err] epNumObj.
\n
"
);
return
-
1
;
}
if
(
strlen
(
channelObj
->
valuestring
)
!=
strlen
(
epNumObj
->
valuestring
)
||
...
...
@@ -173,13 +151,13 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
}
else
{
if
(
channelObj
==
NULL
){
if
(
epNumObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
_LEVEL
,
"[err] epNumObj.
\n
"
);
debug_log
(
LOG_INFO
,
"[err] epNumObj.
\n
"
);
return
-
1
;
}
channel
=
atoi
(
epNumObj
->
valuestring
);
}
else
if
(
epNumObj
==
NULL
){
if
(
channelObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
_LEVEL
,
"[err] channelObj.
\n
"
);
debug_log
(
LOG_INFO
,
"[err] channelObj.
\n
"
);
return
-
1
;
}
channel
=
atoi
(
channelObj
->
valuestring
);
...
...
@@ -205,15 +183,15 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t *
}
if
((
arg
=
_kk_sync_devicestatus_arg_build
(
devNode
))
==
NULL
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] arg.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] arg.
\n
"
);
return
-
1
;
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
1
))
==-
1
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nodeId.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] nodeId.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
_LEVEL
,
"[sync] device status.
\n
"
);
debug_log
(
LOG_FOCUS
,
"[sync] device status.
\n
"
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
sizeof
(
nodeBuff
),
"%d"
,
nodeId
);
...
...
@@ -243,8 +221,7 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
cJSON
*
n_id
=
NULL
;
int
o_item_size
=
0
,
n_item_size
=
0
;
int
item_size
=
0
;
cJSON
*
item_size
=
NULL
;
cJSON
*
epsAry
=
NULL
,
*
epAryItem
=
NULL
,
*
epAryEpNumObj
=
NULL
;
...
...
@@ -254,33 +231,27 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
if
(
deviceCode
==
NULL
||
devNode
==
NULL
||
params
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
return
-
1
;
}
oldccu
=
devNode
->
oldccu
;
newccu
=
devNode
->
newccu
;
o_item_size
=
cJSON_GetArraySize
(
oldccu
);
n_item_size
=
cJSON_GetArraySize
(
newccu
);
item_size
=
(
n_item_size
>
o_item_size
)
?
n_item_size
:
o_item_size
;
item_size
=
cJSON_GetArraySize
(
newccu
);
for
(
i
=
0
;
i
<
item_size
;
i
++
){
n_item
=
cJSON_GetArrayItem
(
newccu
,
i
);
if
((
o_item
=
cJSON_GetArrayItem
(
oldccu
,
i
))
==
NULL
||
o_item
->
type
!=
cJSON_Object
){
debug_log
(
LOG_INFO
_LEVEL
,
"[err] para.i=%d
\n
"
,
i
);
debug_log
(
LOG_INFO
,
"[err] para.
\n
"
);
continue
;
}
if
((
n_id
=
cJSON_GetObjectItem
(
n_item
,
"identifier"
))
==
NULL
||
n_id
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] cfg file.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] cfg file.
\n
"
);
continue
;
}
...
...
@@ -292,18 +263,16 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
o_dataType
=
cJSON_GetObjectItem
(
o_item
,
"dataType"
);
o_valueRange
=
cJSON_GetObjectItem
(
o_item
,
"valueRange"
);
if
(
n_dataType
==
NULL
||
n_dataType
->
type
!=
cJSON_String
||
o_dataType
==
NULL
||
o_dataType
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] dataType.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] dataType.
\n
"
);
continue
;
}
channelObj
=
cJSON_GetObjectItem
(
o_item
,
"channel"
);
epNumObj
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
if
((
channel
=
_kk_lan_check_channel
(
channelObj
,
epNumObj
))
==-
1
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[channel] %d.
\n
"
,
channel
);
debug_log
(
LOG_DEBUG
,
"[channel] %d.
\n
"
,
channel
);
continue
;
}
...
...
@@ -314,12 +283,12 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
epAryEpNumObj
=
cJSON_GetObjectItem
(
epAryItem
,
"epNum"
);
if
(
epAryEpNumObj
==
NULL
||
epAryEpNumObj
->
type
!=
cJSON_String
||
channel
!=
atoi
(
epAryEpNumObj
->
valuestring
)){
debug_log
(
LOG_NORMAL
_LEVEL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
continue
;
}
if
((
valObj
=
cJSON_GetObjectItem
(
epAryItem
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
_LEVEL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
continue
;
}
else
{
mFlag
=
1
;
...
...
@@ -331,40 +300,35 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
}
}
else
{
if
((
valObj
=
cJSON_GetObjectItem
(
params
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
_LEVEL
,
"[match] next.
\n
"
);
debug_log
(
LOG_NORMAL
,
"[match] next.
\n
"
);
continue
;
}
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
channel
))
==-
1
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find node.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] not find node.
\n
"
);
continue
;
}
if
((
opcode
=
cJSON_GetObjectItem
(
n_item
,
"opcodemap"
))
==
NULL
||
opcode
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] cfg file.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] cfg file.
\n
"
);
continue
;
}
kk_lan_replace_val_to_obj
(
n_item
,
valObj
,
"value"
);
if
((
args
=
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
valObj
))
!=
NULL
){
_kk_lan_update_device_status
(
nodeId
,
opcode
,
args
);
//todo :
//cJSON_Delete(args);
}
}
_kk_lan_sync_device_status
(
deviceCode
,
devNode
);
...
...
@@ -399,7 +363,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
cJSON
*
params
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
debug_log
(
LOG_FOCUS
_LEVEL
,
"[property post] deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_FOCUS
,
"[property post] deviceCode(%s).
\n
"
,
deviceCode
);
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
dev
)
==
0
){
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
...
...
@@ -410,7 +374,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
return
kk_lan_property_convert
(
deviceCode
,
dev
,
params
);
}
}
else
{
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_DEBUG
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
return
-
1
;
}
return
0
;
...
...
@@ -422,12 +386,12 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
cJSON
*
params
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
debug_log
(
LOG_FOCUS
_LEVEL
,
"[property syn] deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_FOCUS
,
"[property syn] deviceCode(%s).
\n
"
,
deviceCode
);
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
dev
)
==
0
){
return
kk_lan_property_convert
(
deviceCode
,
dev
,
properties
);
}
else
{
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_DEBUG
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
return
-
1
;
}
return
0
;
...
...
@@ -436,7 +400,7 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
//添加场景通知
void
kk_lan_add_scene_notify
(
const
char
*
scene_id
)
{
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] add scene(%s).
\n
"
,
scene_id
);
debug_log
(
LOG_FOCUS
,
"[notify] add scene(%s).
\n
"
,
scene_id
);
kk_handle_sync_info
();
}
...
...
@@ -444,7 +408,7 @@ void kk_lan_add_scene_notify(const char* scene_id)
//删除场景通知
void
kk_lan_delete_scene_notify
(
const
char
*
scene_id
)
{
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] delete scene(%s).
\n
"
,
scene_id
);
debug_log
(
LOG_FOCUS
,
"[notify] delete scene(%s).
\n
"
,
scene_id
);
cJSON
*
msg
=
old_ccu_msg_build
(
scene_id
,
"DELETE_SCENE"
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
send_msg_to_module
(
msg
);
...
...
@@ -458,7 +422,7 @@ int kk_lan_arming_status_notify(int type)
{
cJSON
*
msg
=
NULL
;
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] arming status(%d).
\n
"
,
type
);
debug_log
(
LOG_FOCUS
,
"[notify] arming status(%d).
\n
"
,
type
);
if
(
type
==
0
){
msg
=
old_ccu_msg_build
(
WILDCARD_CHARACTER_STR
,
GUARD_STATUS_ARMING_LEAVE_HOME
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
...
...
@@ -469,7 +433,7 @@ int kk_lan_arming_status_notify(int type)
}
else
if
(
type
==
3
){
msg
=
old_ccu_msg_build
(
WILDCARD_CHARACTER_STR
,
ARMING_STATUS_GUARD_ZONE
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
}
else
{
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] unknow type(%d).
\n
"
,
type
);
debug_log
(
LOG_DEBUG
,
"[err] unknow type(%d).
\n
"
,
type
);
return
-
1
;
}
...
...
@@ -487,11 +451,11 @@ static int _kk_lan_delete_node(const char *deviceCode,const char *nodeid)
kk_map_dev_node_t
*
dev
;
if
(
deviceCode
==
NULL
||
nodeid
==
NULL
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] params.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
_LEVEL
,
"[del dev node] id(%s).
\n
"
,
nodeid
);
debug_log
(
LOG_FOCUS
,
"[del dev node] id(%s).
\n
"
,
nodeid
);
arg
=
cJSON_CreateObject
();
_deviceCode_switchto_mac
(
deviceCode
,
mac
);
...
...
@@ -512,7 +476,7 @@ static int _kk_lan_delete_device(const char *deviceCode)
num
=
kk_lan_db_node_get_all
(
deviceCode
,
list
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[del dev] deviceCode(%s)/node num(%d).
\n
"
,
deviceCode
,
num
);
debug_log
(
LOG_FOCUS
,
"[del dev] deviceCode(%s)/node num(%d).
\n
"
,
deviceCode
,
num
);
for
(
i
=
0
;
i
<
num
;
i
++
){
memset
(
nodeId
,
0
,
sizeof
(
nodeId
));
...
...
@@ -536,13 +500,13 @@ int kk_lan_device_delete_notify(cJSON *payload)
if
((
params
=
cJSON_GetObjectItem
(
payload
,
"params"
))
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] params.
\n
"
);
return
-
1
;
}
if
((
deviceCode
=
cJSON_GetObjectItem
(
params
,
"deviceCode"
))
==
NULL
||
deviceCode
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] deviceCode.
\n
"
);
debug_log
(
LOG_DEBUG
,
"[err] deviceCode.
\n
"
);
return
-
1
;
}
...
...
midware/midware/dm/kk_dm_msg.c
View file @
93d95f0b
...
...
@@ -1239,7 +1239,52 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
return
SUCCESS_RETURN
;
}
int
kk_msg_cloud_status_notify
(
const
char
*
deviceCode
,
const
char
*
productCode
)
{
char
*
method
=
"thing.service.cloudStatus"
;
char
*
req_info
=
NULL
,
*
payload
=
NULL
;
int
req_info_len
=
0
,
payload_len
=
0
;
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
req_info_len
=
strlen
(
DM_MSG_INFO
)
+
10
+
strlen
(
deviceCode
)
+
strlen
(
productCode
)
+
strlen
(
KK_THING_SERVICE_CLOUDSTATUS
)
+
1
;
req_info
=
malloc
(
req_info_len
);
if
(
req_info
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
}
memset
(
req_info
,
0
,
req_info_len
);
snprintf
(
req_info
,
req_info_len
,
DM_MSG_INFO
,
KK_THING_SERVICE_CLOUDSTATUS
,
productCode
,
deviceCode
);
cJSON
*
params
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
params
,
"status"
,
1
);
char
*
paramStr
=
cJSON_Print
(
params
);
payload_len
=
strlen
(
DM_MSG_REQUEST
)
+
10
+
strlen
(
DM_MSG_VERSION
)
+
strlen
(
paramStr
)
+
strlen
(
method
)
+
1
+
20
+
sizeof
(
msgId
);
payload
=
malloc
(
payload_len
);
if
(
payload
==
NULL
)
{
free
(
req_info
);
return
MEMORY_NOT_ENOUGH
;
}
memset
(
payload
,
0
,
payload_len
);
iotx_report_id
(
msgId
);
//sprintf(msgId,"%d",iotx_report_id());
snprintf
(
payload
,
payload_len
,
DM_MSG_REQUEST
,
msgId
,
DM_MSG_VERSION
,
paramStr
,
HAL_GetTime
(),
method
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
infoObj
=
cJSON_Parse
(
req_info
);
cJSON
*
payloadObj
=
cJSON_Parse
(
payload
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
printf
(
"------------------------------------------------------->333
\n
"
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
deviceCode
);
free
(
paramStr
);
free
(
buf
);
free
(
req_info
);
free
(
payload
);
cJSON_Delete
(
params
);
cJSON_Delete
(
root
);
return
SUCCESS_RETURN
;
}
int
kk_msg_execute_property_set
(
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
params
,
const
char
*
fatherDeviceCode
)
{
char
*
method
=
"thing.service.property.set"
;
...
...
midware/midware/dm/kk_dm_msg.h
View file @
93d95f0b
...
...
@@ -85,7 +85,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_THING_SERVICE_SYNCINFO "/thing/service/syncinfo"
#define KK_THING_SERVICE_SYNCDEVICEINFO "/thing/service/syncDeviceInfo"
#define KK_THING_SERVICE_SYNCDEVICEINFO_REPLY "/thing/service/syncDeviceInfo_reply"
#define KK_THING_SERVICE_CLOUDSTATUS "/thing/service/cloudStatus"
...
...
midware/midware/dm/kk_linkkit.c
View file @
93d95f0b
...
...
@@ -56,7 +56,7 @@
static
int
s_gateway_add_flag
=
0
;
typedef
struct
{
int
msgid
;
...
...
@@ -351,10 +351,10 @@ int kk_topo_delete_handle(cJSON *payload,cJSON *buf)
cJSON_AddItemToObject
(
rootData
,
"payload"
,
payload
);
char
*
pnewout
=
cJSON_Print
(
rootData
);
kk_sendData2gw
(
pnewout
,
strlen
(
pnewout
),
node
->
fatherDeviceCode
);
//send to gw itself
free
(
pnewout
);
cJSON_Delete
(
rootData
);
dm_mgr_subdev_delete
(
deviceCode
);
item
=
item
->
next
;
free
(
pnewout
);
//cJSON_Delete(rootData);
return
SUCCESS_RETURN
;
}
}
...
...
@@ -1094,9 +1094,10 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
char
*
payload_Str
=
NULL
;
cJSON
*
deviceCode
=
NULL
;
json
=
cJSON_Parse
(
data
);
_iotx_linkkit_mutex_lock
();
if
(
json
==
NULL
)
{
WARNING_PRINT
(
"Error before: [%s]
\n
"
,
"cJSON_Parse"
);
_iotx_linkkit_mutex_unlock
();
return
;
}
info_root
=
cJSON_GetObjectItem
(
json
,
MSG_INFO_STR
);
...
...
@@ -1195,7 +1196,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
node
->
isOffline
=
KK_DEV_ONLINE
;
dm_mgr_upstream_thing_sub_register
(
KK_DM_DEVICE_CCU_DEVICEID
);
iotx_dm_dev_online
(
KK_DM_DEVICE_CCU_DEVICEID
);
//first online,report the online status
usleep
(
200000
);
if
(
s_gateway_add_flag
==
0
)
kk_subDev_check_auth
(
KK_DM_DEVICE_GATEWAY
);
dm_msg_ccu_property_post
(
node
);
dm_mgr_resubscribe
();
}
...
...
@@ -1370,6 +1372,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
directReturn:
free
(
payload_Str
);
cJSON_Delete
(
json
);
_iotx_linkkit_mutex_unlock
();
}
/************************************************************
...
...
@@ -1765,7 +1768,15 @@ int kk_mid_subdev_add(int devType, char productCode[PRODUCT_CODE_MAXLEN], char d
}
kk_subDev_update_productType
(
node
->
productType
,
deviceCode
);
}
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
//如果还没有连上云,网关topo add不处理
if
(
s_CloudStatus
){
//kk_subDev_update_auth(1,deviceCode);
s_gateway_add_flag
=
1
;
}
else
{
ERROR_PRINT
(
"Cloud is not connected!!!!!!!!
\n
"
);
return
FAIL_RETURN
;
}
}
_iotx_linkkit_mutex_lock
();
res
=
_iotx_linkkit_slave_connect
(
devid
);
if
(
res
!=
SUCCESS_RETURN
)
{
...
...
midware/midware/dm/kk_property_db.c
View file @
93d95f0b
...
...
@@ -228,8 +228,6 @@ static int _kk_check_door_induction_device(char *productCode){
int
kk_property_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
devtype
)
{
printf
(
"---------------------------------------->identifier:%s
\n
"
,
identifier
);
dm_mgr_dev_node_t
*
node
=
NULL
;
int
res
=
0
;
const
char
*
insertCmd
=
"insert into PropertiesInfo (deviceCode,identifier,value,valueType,devType) \
...
...
@@ -238,12 +236,10 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
printf
(
"---------------------------------------->1
\n
"
);
if
(
_kk_check_property_exist
(
deviceCode
,
identifier
)
==
1
)
{
return
SUCCESS_RETURN
;
}
printf
(
"---------------------------------------->2
\n
"
);
_kk_property_db_lock
();
//传感器类默认安防等级为离家安防
if
(
strcmp
(
identifier
,
"SensorType"
)
==
0
&&
devtype
==
KK_DM_DEVICE_SUBDEV
){
...
...
@@ -251,12 +247,10 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
printf
(
"---------------------------------------->3
\n
"
);
if
(
_kk_check_human_induction_device
(
node
->
productCode
)
==
1
||
//门磁和人体默认室外安防
_kk_check_door_induction_device
(
node
->
productCode
)
==
1
){
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
"1"
,
valuetype
,
devtype
);
}
else
{
printf
(
"---------------------------------------->
\n
"
);
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
"2"
,
valuetype
,
devtype
);
//其他24小时警戒
}
}
else
{
...
...
midware/midware/dm/kk_sub_db.c
View file @
93d95f0b
...
...
@@ -385,7 +385,36 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode)
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:更新设备注册标记
*输入参数:deviceCode:设备deviceCode
isAuth:1,已注册;0,未注册
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_subDev_check_auth
(
int
devType
)
{
char
*
sqlCmd
=
NULL
;
sqlite3_stmt
*
stmt
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
const
char
*
searchCmd
=
"select * from SubDeviceInfo WHERE devType = '%d';"
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
printf
(
"------------------------------------------------------->111
\n
"
);
sqlCmd
=
sqlite3_mprintf
(
searchCmd
,
devType
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
printf
(
"------------------------------------------------------->222
\n
"
);
char
*
pDeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SUB_DEVICECODE
);
char
*
pProductCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SUB_PRODUCTCODE
);
kk_msg_cloud_status_notify
(
pProductCode
,
pDeviceCode
);
//kk_subDev_update_auth(1,pDeviceCode);
}
sqlite3_finalize
(
stmt
);
sqlite3_free
(
sqlCmd
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:更新内场景支持,此接口只针对网关设备有效
*输入参数:deviceCode:设备deviceCode
...
...
midware/midware/dm/kk_sub_db.h
View file @
93d95f0b
...
...
@@ -15,7 +15,6 @@ int kk_subDev_update_auth(int isAuth,const char *deviceCode);
int
kk_subDev_update_sceneSupport
(
int
sceneSupport
,
const
char
*
deviceCode
);
int
kk_subDev_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_subDev_update_productType
(
char
*
productType
,
const
char
*
deviceCode
);
int
kk_subDev_update_auth
(
int
isAuth
,
const
char
*
deviceCode
);
int
kk_subDev_send_property_get_from_db
(
void
);
int
kk_subDev_send_property_get
(
const
char
*
fatherDeviceCode
);
...
...
@@ -24,6 +23,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
int
kk_subDev_update_offline
(
int
isOffline
,
const
char
*
deviceCode
);
int
kk_subDev_getSensors_reply
(
SensorType_t
*
list
);
int
kk_load_subDevice
(
void
);
int
kk_subDev_check_auth
(
int
devType
);
enum
{
DB_SUB_IDX
=
0
,
DB_SUB_ONLINE
,
...
...
midware/midware/midware.c
View file @
93d95f0b
...
...
@@ -783,6 +783,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
if
(
sceneSupportStr
!=
NULL
&&!
strcmp
(
sceneSupportStr
->
valuestring
,
"1"
)){
kk_subDev_update_sceneSupport
(
1
,
devCode
->
valuestring
);
}
kk_dm_gw_status_update_online
(
info_dcode
->
valuestring
);
}
else
{
kk_mid_subdev_add
(
KK_DM_DEVICE_SUBDEV
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
,
info_dcode
->
valuestring
);
}
...
...
onboot.sh
View file @
93d95f0b
#!/bin/sh
#filepath="/home/kk"
filepath
=
"/app/ccuApps"
if
[
!
-f
"/sbin/jq"
]
then
cp
/app/ccuApps
/jq /sbin
cp
$filepath
/jq /sbin
fi
if
[
-f
"/app/nx5Apps/syscfg.json"
]
then
...
...
@@ -19,9 +21,9 @@ then
fi
fi
nanomsg_File
=
"
/app/ccuApps
/lib/libnanomsg.so.5"
ev_File
=
"
/app/ccuApps
/lib/libev.so.4"
sqlite_File
=
"
/app/ccuApps
/lib/libsqlite3.so.0"
nanomsg_File
=
"
$filepath
/lib/libnanomsg.so.5"
ev_File
=
"
$filepath
/lib/libev.so.4"
sqlite_File
=
"
$filepath
/lib/libsqlite3.so.0"
run_Dir
=
"/data/kk"
tsl_Dir
=
"
${
run_Dir
}
/tsl"
...
...
@@ -38,36 +40,36 @@ if [ ! -d "$run_Dir" ]; then
fi
if
[
!
-d
"
$tsl_Dir
"
]
;
then
cp
-rf
/app/ccuApps
/tsl
${
run_Dir
}
/
cp
-rf
$filepath
/tsl
${
run_Dir
}
/
fi
if
[
!
-d
"
$map_Dir
"
]
;
then
cp
-rf
/app/ccuApps
/map
${
run_Dir
}
/
cp
-rf
$filepath
/map
${
run_Dir
}
/
fi
cd
/app/ccuApps
/lib
cd
$filepath
/lib
if
[
!
-f
"
$nanomsg_File
"
]
;
then
ln
-sf
/app/ccuApps
/lib/libnanomsg.so /lib/libnanomsg.so.5
ln
-sf
$filepath
/lib/libnanomsg.so /lib/libnanomsg.so.5
fi
if
[
!
-f
"
$ev_File
"
]
;
then
ln
-sf
/app/ccuApps
/lib/libev.so /lib/libev.so.4
ln
-sf
$filepath
/lib/libev.so /lib/libev.so.4
fi
if
[
!
-f
"
$sqlite_File
"
]
;
then
ln
-sf
/app/ccuApps
/lib/libsqlite3.so /lib/libsqlite3.so.0
ln
-sf
$filepath
/lib/libsqlite3.so /lib/libsqlite3.so.0
fi
export
LD_LIBRARY_PATH
=
/app/ccuApps
/lib
export
LD_LIBRARY_PATH
=
$filepath
/lib
/app/ccuApps
/bin/kk_midware &
$filepath
/bin/kk_midware &
sleep
3
/app/ccuApps
/bin/kk_cloud &
sleep
1
$filepath
/bin/kk_cloud &
sleep
5
#/home/kk/process_check.sh >/dev/null 2>&1 &
/app/ccuApps/bin/smarthome_z3gw_nx5
-r0
-l3
--device-def
=
/app/ccuApps
/kk_device_def.json
--db
=
/data/kk/kk_z3gw.db
--uart
=
/dev/ttyS1&
$filepath
/bin/smarthome_z3gw_nx5
-r0
-l3
--device-def
=
$filepath
/kk_device_def.json
--db
=
/data/kk/kk_z3gw.db
--uart
=
/dev/ttyS1&
sleep
2
/app/ccuApps/bin/kk_lan
&
$filepath
/bin/kk_lan
--uart
=
/dev/ttyS3
&
sleep
1
echo
"*/1 * * * * /app/ccuApps/process_check.sh"
>
/etc/cron.d/ccu
||
{
echo
"ERROR:add ccu crontab rule failed."
;
exit
1
;
}
#
echo "*/1 * * * * /app/ccuApps/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;}
ntpd
-n
-q
-d
-p
stdtime.gov.hk &
exit
0
\ No newline at end of file
tools/build-rules/_rules-top.mk
View file @
93d95f0b
...
...
@@ -210,6 +210,7 @@ package:
cp
-rf
$(TOP_DIR)/process_check.sh
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/onboot.sh
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/killall.sh
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/VERSION
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/opcodeMapCfg/*
$(TOP_DIR)/$(releaseDir)/map
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table $(TOP_DIR)/$(releaseDir)/
...
...
@@ -218,6 +219,7 @@ ifeq ($(CONFIG_MODEL),ubuntu)
cp
-rf
$(TOP_DIR)/common/nanomsg/libnanomsg_ubuntu.so
$(TOP_DIR)/$(releaseDir)/lib/libnanomsg.so.5
cp
-rf
$(TOP_DIR)/common/ev/libev_ubuntu.so
$(TOP_DIR)/$(releaseDir)/lib
else
ifeq
($(CONFIG_MODEL),nx5)
cp
-rf
$(TOP_DIR)/jq
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/common/nanomsg/libnanomsg_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libnanomsg.so
cp
-rf
$(TOP_DIR)/common/ev/libev_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libev.so
cp
-rf
$(TOP_DIR)/common/sqlite/libsqlite3_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libsqlite3.so
...
...
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