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
3bf85b9e
Commit
3bf85b9e
authored
Aug 27, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改topo change的处理
【提交人】陈伟灿
parent
880044d8
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
756 additions
and
20 deletions
+756
-20
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+4
-2
application/klansdk/kk_findccu_handle.c
application/klansdk/kk_findccu_handle.c
+1
-1
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+1
-1
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+11
-9
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+34
-4
midware/midware/dm/kk_linkkit.h
midware/midware/dm/kk_linkkit.h
+1
-1
midware/midware/midware.c
midware/midware/midware.c
+4
-2
tsl/product_3062.json
tsl/product_3062.json
+353
-0
tsl/product_3102.json
tsl/product_3102.json
+347
-0
No files found.
application/kcloud/kcloud_main.c
View file @
3bf85b9e
...
...
@@ -44,11 +44,13 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
static
void
KK_Ccuid_init
(
void
)
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
_setDevice_Code
(
ccuid
,
ccuid_len
-
1
);
sprintf
(
ccuidTmp
,
"CCU_%s"
,
ccuid
);
_setDevice_Code
(
ccuidTmp
,
strlen
(
ccuidTmp
)
-
1
);
//减一是因为最后有一个换行
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
...
...
@@ -99,7 +101,7 @@ int main(int argc, char* argv[])
/*set the callback to get the device date to cloud*/
KK_Ccuid_init
();
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
//
kk_info_report_start();
kk_info_report_start
();
again:
rc
=
kk_start_ccu_register
();
if
(
rc
==
0
){
...
...
application/klansdk/kk_findccu_handle.c
View file @
3bf85b9e
...
...
@@ -33,7 +33,7 @@ static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
args
=
cJSON_CreateObject
();
if
(
args
){
cJSON_AddItemToObject
(
json
,
"arg"
,
args
);
cJSON_AddStringToObject
(
args
,
"zkid"
,
ccuid
);
cJSON_AddStringToObject
(
args
,
"zkid"
,
&
ccuid
[
4
]
);
cJSON_AddStringToObject
(
args
,
"zk"
,
KK_CCU_NAME
);
HAL_Get_IP
(
s_IP
,
NULL
);
cJSON_AddStringToObject
(
args
,
"ip"
,
s_IP
);
...
...
application/klansdk/kk_lan_ctrl.c
View file @
3bf85b9e
...
...
@@ -231,7 +231,7 @@ int kk_ccu_opcode_handle(cJSON *root)
}
else
{
WARNING_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
return
0
;
}
...
...
application/klansdk/kk_lan_main.c
View file @
3bf85b9e
...
...
@@ -54,11 +54,13 @@ extern int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
static
void
kk_lan_ccuid_init
(
void
)
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
_setDevice_Code
((
char
*
)
ccuid
,
ccuid_len
-
1
);
sprintf
(
ccuidTmp
,
"CCU_%s"
,
ccuid
);
_setDevice_Code
(
ccuidTmp
,
strlen
(
ccuidTmp
)
-
1
);
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
...
...
midware/midware/dm/kk_linkkit.c
View file @
3bf85b9e
...
...
@@ -312,11 +312,15 @@ int kk_get_cloud_recv_status(void){
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_topo_delete_handle
(
cJSON
*
payload
)
int
kk_topo_delete_handle
(
cJSON
*
payload
,
cJSON
*
buf
)
{
if
(
payload
==
NULL
){
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
gwnode
=
NULL
;
if
(
payload
==
NULL
||
buf
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
MSG_TOPO_CHANGE_TYPE_STR
);
if
(
state
!=
NULL
&&
state
->
valueint
==
1
){
...
...
@@ -327,13 +331,33 @@ int kk_topo_delete_handle(cJSON *payload)
cJSON
*
item
=
deviceArray
->
child
;
while
(
item
!=
NULL
){
char
*
deviceCode
=
cJSON_GetObjectItem
(
item
,
MSG_DEVICE_CODE_STR
)
->
valuestring
;
dm_mgr_subdev_delete
(
deviceCode
);
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
if
(
res
<
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"dm_mgr_search_device_by_pkdn failed"
);
return
res
;
}
res
=
dm_mgr_get_device_by_devicecode
(
node
->
fatherDeviceCode
,
&
gwnode
);
if
(
res
<
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"dm_mgr_search_device_by_pkdn failed"
);
return
res
;
}
cJSON
*
rootData
=
cJSON_CreateObject
();
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
"/thing/topo/change"
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
gwnode
->
deviceCode
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
gwnode
->
productCode
);
cJSON_AddItemToObject
(
rootData
,
"info"
,
info
);
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
;
}
}
return
SUCCESS_RETURN
;
}
...
...
@@ -460,6 +484,7 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
if
(
roomId
==
NULL
){
return
FAIL_RETURN
;
}
kk_room_add
(
room_name
->
valuestring
,
roomId
->
valuestring
);
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
...
...
@@ -1333,6 +1358,11 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
}
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_TOPO_CHANGE_MSG
)
==
0
){
INFO_PRINT
(
"TOPO CHANGE
\n
"
);
kk_topo_delete_handle
(
payload
,
info_root
);
//kk_sendData2gw(data, strlen(data), deviceCode->valuestring);//send to gw itself
}
else
{
INFO_PRINT
(
"Error msgtype!!!
\n
"
);
}
...
...
midware/midware/dm/kk_linkkit.h
View file @
3bf85b9e
...
...
@@ -2,7 +2,7 @@
#define _KK_LINKKIT_H_
#include "kk_tsl_common.h"
int
kk_mid_subdev_batch_add
(
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_topo_delete_handle
(
cJSON
*
payload
);
int
kk_topo_delete_handle
(
cJSON
*
payload
,
cJSON
*
buf
);
int
kk_get_cloudstatus
(
void
);
int
kk_get_cloud_recv_status
(
void
);
int
kk_init_dmproc
(
void
);
...
...
midware/midware/midware.c
View file @
3bf85b9e
...
...
@@ -102,11 +102,13 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
static
void
HAL_Ccuid_init
(
void
)
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
_setDevice_Code
(
ccuid
,
ccuid_len
-
1
);
sprintf
(
ccuidTmp
,
"CCU_%s"
,
ccuid
);
_setDevice_Code
(
ccuidTmp
,
strlen
(
ccuidTmp
)
-
1
);
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
...
...
@@ -441,7 +443,7 @@ void mid_cb(void* data, int len){
}
else
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
/*手机端主动删除设备,需要删除数据库相关内容,再下发给网关*/
if
(
strcmp
(
type
->
valuestring
,
KK_THING_TOPO_CHANGE_MSG
)
==
0
){
kk_topo_delete_handle
(
payload
);
//kk_topo_delete_handle(payload,data
);
}
kk_sendData2gw
(
data
,
strlen
(
data
),
deviceCode
->
valuestring
);
//send to gw itself
}
else
if
(
devType
==
KK_DM_DEVICE_SUBDEV
){
...
...
tsl/product_3062.json
0 → 100644
View file @
3bf85b9e
This diff is collapsed.
Click to expand it.
tsl/product_3102.json
0 → 100644
View file @
3bf85b9e
{
"schema"
:
"https://iot-ap.ikonke.com/model/product_3102.json"
,
"productType"
:
"lightPanel"
,
"version"
:
"1.0"
,
"profile"
:
{
"heartbeat"
:
"300"
,
"productCode"
:
"3102"
,
"productName"
:
"海顿系列.零火线调光面板(KONKE)"
},
"services"
:
[
{
"outputData"
:
[],
"identifier"
:
"set"
,
"inputData"
:
[
{
"identifier"
:
"PowerSwitch"
,
"dataType"
:
{
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"电源开关"
},
{
"identifier"
:
"Brightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"1"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"亮度"
},
{
"identifier"
:
"FadeTime"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"254"
,
"unit"
:
"s"
,
"unitName"
:
"秒"
,
"step"
:
"1"
}
},
"name"
:
"渐变时间"
},
{
"identifier"
:
"LowBrightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"10"
,
"max"
:
"90"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最低亮度"
},
{
"identifier"
:
"HighBrightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"20"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最高亮度"
}
],
"method"
:
"thing.service.property.set"
,
"name"
:
"set"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性设置"
},
{
"outputData"
:
[
{
"identifier"
:
"PowerSwitch"
,
"dataType"
:
{
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"电源开关"
},
{
"identifier"
:
"Brightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"1"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"亮度"
},
{
"identifier"
:
"FadeTime"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"254"
,
"unit"
:
"s"
,
"unitName"
:
"秒"
,
"step"
:
"1"
}
},
"name"
:
"渐变时间"
},
{
"identifier"
:
"LowBrightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"10"
,
"max"
:
"90"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最低亮度"
},
{
"identifier"
:
"HighBrightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"20"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最高亮度"
}
],
"identifier"
:
"get"
,
"inputData"
:
[
"PowerSwitch"
,
"Brightness"
,
"FadeTime"
,
"LowBrightness"
,
"HighBrightness"
],
"method"
:
"thing.service.property.get"
,
"name"
:
"get"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性获取"
},
{
"outputData"
:[
],
"identifier"
:
"negativeProperty"
,
"inputData"
:[
"PowerSwitch"
],
"method"
:
"thing.service.negativeProperty"
,
"name"
:
"negativeProperty"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性值取反"
}
],
"properties"
:
[
{
"identifier"
:
"PowerSwitch"
,
"dataType"
:
{
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"电源开关"
,
"accessMode"
:
"rw"
,
"required"
:
true
},
{
"identifier"
:
"Brightness"
,
"name"
:
"亮度"
,
"accessMode"
:
"rw"
,
"required"
:
false
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"1"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
}
},
{
"identifier"
:
"FadeTime"
,
"accessMode"
:
"rw"
,
"required"
:
false
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"254"
,
"unit"
:
"s"
,
"unitName"
:
"秒"
,
"step"
:
"1"
}
},
"name"
:
"渐变时间"
},
{
"identifier"
:
"LowBrightness"
,
"accessMode"
:
"rw"
,
"required"
:
false
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"10"
,
"max"
:
"90"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最低亮度"
},
{
"identifier"
:
"HighBrightness"
,
"accessMode"
:
"rw"
,
"required"
:
false
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"20"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最高亮度"
}
],
"events"
:
[
{
"outputData"
:
[
{
"identifier"
:
"PowerSwitch"
,
"dataType"
:
{
"specs"
:
{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"电源开关"
},
{
"identifier"
:
"Brightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"1"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"亮度"
},
{
"identifier"
:
"FadeTime"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"0"
,
"max"
:
"254"
,
"unit"
:
"s"
,
"unitName"
:
"秒"
,
"step"
:
"1"
}
},
"name"
:
"渐变时间"
},
{
"identifier"
:
"LowBrightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"10"
,
"max"
:
"90"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最低亮度"
},
{
"identifier"
:
"HighBrightness"
,
"dataType"
:
{
"type"
:
"int"
,
"specs"
:
{
"min"
:
"20"
,
"max"
:
"100"
,
"unit"
:
"%"
,
"unitName"
:
"百分比"
,
"step"
:
"1"
}
},
"name"
:
"最高亮度"
}
],
"identifier"
:
"property"
,
"method"
:
"thing.event.property.post"
,
"name"
:
"property"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"属性上报"
}
]
}
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