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
7d63f2f6
Commit
7d63f2f6
authored
Aug 13, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】调整zigbee端物模型处理
【提交人】陈伟灿
parent
784fe296
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
121 additions
and
375 deletions
+121
-375
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/a1h88DsZIaY.json
platform/zigbee/app/builder/Z3GatewayHost/a1h88DsZIaY.json
+0
-222
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.c
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.c
+68
-68
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.h
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.h
+0
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+34
-74
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
+13
-7
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
+4
-1
platform/zigbee/app/builder/Z3GatewayHost/libkk_tsl.a
platform/zigbee/app/builder/Z3GatewayHost/libkk_tsl.a
+0
-0
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
7d63f2f6
...
@@ -377,7 +377,7 @@ $(TARGET_FILE): $(APPLICATION_OBJECTS) $(LIBRARIES)
...
@@ -377,7 +377,7 @@ $(TARGET_FILE): $(APPLICATION_OBJECTS) $(LIBRARIES)
@
echo
-e
'\n$@ build success'
@
echo
-e
'\n$@ build success'
else
else
$(TARGET_FILE)
:
$(APPLICATION_OBJECTS) $(LIBRARIES)
$(TARGET_FILE)
:
$(APPLICATION_OBJECTS) $(LIBRARIES)
$(LD)
$^
$(LINKER_FLAGS)
-lm
-L
.
-static
-lapi_com
-static
-lnanomsg
-l
kk_tsl
-l
anl
-pthread
-static
-lev
-ltinfo
-o
$(TARGET_FILE)
$(LD)
$^
$(LINKER_FLAGS)
-lm
-L
.
-static
-lapi_com
-static
-lnanomsg
-lanl
-pthread
-static
-lev
-ltinfo
-o
$(TARGET_FILE)
@
echo
-e
'\n$@ build success'
@
echo
-e
'\n$@ build success'
endif
endif
...
...
platform/zigbee/app/builder/Z3GatewayHost/a1h88DsZIaY.json
deleted
100644 → 0
View file @
784fe296
{
"schema"
:
"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json"
,
"profile"
:{
"productKey"
:
"a1h88DsZIaY"
},
"services"
:[
{
"outputData"
:[
],
"identifier"
:
"set"
,
"inputData"
:[
{
"identifier"
:
"LightStatus"
,
"dataType"
:{
"specs"
:{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"工作状态"
},
{
"identifier"
:
"LightAdjustLevel"
,
"dataType"
:{
"specs"
:{
"unit"
:
"%"
,
"min"
:
"0"
,
"max"
:
"100"
,
"step"
:
"1"
},
"type"
:
"int"
},
"name"
:
"调光等级"
},
{
"identifier"
:
"LightAlias"
,
"dataType"
:{
"specs"
:{
"length"
:
"32"
},
"type"
:
"text"
},
"name"
:
"别名"
}
],
"method"
:
"thing.service.property.set"
,
"name"
:
"set"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性设置"
},
{
"outputData"
:[
{
"identifier"
:
"LightStatus"
,
"dataType"
:{
"specs"
:{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"工作状态"
},
{
"identifier"
:
"LightAdjustLevel"
,
"dataType"
:{
"specs"
:{
"unit"
:
"%"
,
"min"
:
"0"
,
"max"
:
"100"
,
"step"
:
"1"
},
"type"
:
"int"
},
"name"
:
"调光等级"
},
{
"identifier"
:
"LightAlias"
,
"dataType"
:{
"specs"
:{
"length"
:
"32"
},
"type"
:
"text"
},
"name"
:
"别名"
}
],
"identifier"
:
"get"
,
"inputData"
:[
"LightStatus"
,
"LightAdjustLevel"
,
"LightAlias"
],
"method"
:
"thing.service.property.get"
,
"name"
:
"get"
,
"required"
:
true
,
"callType"
:
"async"
,
"desc"
:
"属性获取"
}
],
"properties"
:[
{
"identifier"
:
"LightStatus"
,
"dataType"
:{
"specs"
:{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"工作状态"
,
"accessMode"
:
"rw"
,
"required"
:
false
},
{
"identifier"
:
"LightAdjustLevel"
,
"dataType"
:{
"specs"
:{
"unit"
:
"%"
,
"min"
:
"0"
,
"max"
:
"100"
,
"step"
:
"1"
},
"type"
:
"int"
},
"name"
:
"调光等级"
,
"accessMode"
:
"rw"
,
"required"
:
false
,
"desc"
:
"调光等级采用百分比表示"
},
{
"identifier"
:
"LightAlias"
,
"dataType"
:{
"specs"
:{
"length"
:
"32"
},
"type"
:
"text"
},
"name"
:
"别名"
,
"accessMode"
:
"rw"
,
"required"
:
false
}
],
"events"
:[
{
"outputData"
:[
{
"identifier"
:
"LightStatus"
,
"dataType"
:{
"specs"
:{
"0"
:
"关闭"
,
"1"
:
"打开"
},
"type"
:
"bool"
},
"name"
:
"工作状态"
},
{
"identifier"
:
"LightAdjustLevel"
,
"dataType"
:{
"specs"
:{
"unit"
:
"%"
,
"min"
:
"0"
,
"max"
:
"100"
,
"step"
:
"1"
},
"type"
:
"int"
},
"name"
:
"调光等级"
},
{
"identifier"
:
"LightAlias"
,
"dataType"
:{
"specs"
:{
"length"
:
"32"
},
"type"
:
"text"
},
"name"
:
"别名"
}
],
"identifier"
:
"post"
,
"method"
:
"thing.event.property.post"
,
"name"
:
"post"
,
"type"
:
"info"
,
"required"
:
true
,
"desc"
:
"属性上报"
},
{
"outputData"
:[
{
"identifier"
:
"ErrorCode"
,
"dataType"
:{
"specs"
:{
"0"
:
"恢复正常"
},
"type"
:
"enum"
},
"name"
:
"故障代码"
}
],
"identifier"
:
"Error"
,
"method"
:
"thing.event.Error.post"
,
"name"
:
"故障上报"
,
"type"
:
"alert"
,
"required"
:
false
},
{
"outputData"
:[
],
"identifier"
:
"TamperAlarm"
,
"method"
:
"thing.event.TamperAlarm.post"
,
"name"
:
"防撬报警"
,
"type"
:
"alert"
,
"required"
:
false
}
]
}
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.c
View file @
7d63f2f6
...
@@ -12,6 +12,59 @@ static kk_sub_dev_ctx_t * _sub_dev_get_ctx(void)
...
@@ -12,6 +12,59 @@ static kk_sub_dev_ctx_t * _sub_dev_get_ctx(void)
{
{
return
&
g_sub_dev_mgr
;
return
&
g_sub_dev_mgr
;
}
}
static
void
*
_sub_MutexCreate
(
void
)
{
int
err_num
;
pthread_mutex_t
*
mutex
=
(
pthread_mutex_t
*
)
malloc
(
sizeof
(
pthread_mutex_t
));
if
(
NULL
==
mutex
)
{
return
NULL
;
}
if
(
0
!=
(
err_num
=
pthread_mutex_init
(
mutex
,
NULL
)))
{
printf
(
"create mutex failed
\n
"
);
free
(
mutex
);
return
NULL
;
}
return
mutex
;
}
static
void
_sub_MutexLock
(
void
*
mutex
)
{
int
err_num
;
if
(
0
!=
(
err_num
=
pthread_mutex_lock
((
pthread_mutex_t
*
)
mutex
)))
{
printf
(
"lock mutex failed: - '%s' (%d)
\n
"
,
strerror
(
err_num
),
err_num
);
}
}
static
void
_sub_MutexUnLock
(
void
*
mutex
)
{
int
err_num
;
if
(
0
!=
(
err_num
=
pthread_mutex_unlock
((
pthread_mutex_t
*
)
mutex
)))
{
printf
(
"unlock mutex failed - '%s' (%d)
\n
"
,
strerror
(
err_num
),
err_num
);
}
}
static
void
_sub_MutexDestroy
(
void
*
mutex
)
{
int
err_num
;
if
(
!
mutex
)
{
printf
(
"mutex want to destroy is NULL!
\n
"
);
return
;
}
if
(
0
!=
(
err_num
=
pthread_mutex_destroy
((
pthread_mutex_t
*
)
mutex
)))
{
printf
(
"destroy mutex failed
\n
"
);
}
free
(
mutex
);
}
static
int
_sub_tsl_next_devid
(
void
)
static
int
_sub_tsl_next_devid
(
void
)
{
{
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
...
@@ -23,7 +76,7 @@ static void _sub_dev_mutex_lock(void)
...
@@ -23,7 +76,7 @@ static void _sub_dev_mutex_lock(void)
{
{
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
if
(
ctx
->
mutex
)
{
if
(
ctx
->
mutex
)
{
kk
_MutexLock
(
ctx
->
mutex
);
_sub
_MutexLock
(
ctx
->
mutex
);
}
}
}
}
...
@@ -31,28 +84,23 @@ static void _sub_dev_mutex_unlock(void)
...
@@ -31,28 +84,23 @@ static void _sub_dev_mutex_unlock(void)
{
{
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
if
(
ctx
->
mutex
)
{
if
(
ctx
->
mutex
)
{
kk
_MutexUnLock
(
ctx
->
mutex
);
_sub
_MutexUnLock
(
ctx
->
mutex
);
}
}
}
}
int
kk_tsl_init
(
void
)
int
kk_tsl_init
(
void
)
{
{
char
*
tsl_str
=
NULL
;
int
res
=
0
;
int
res
=
0
;
kk_tsl_t
*
dev_shadow
;
sub_dev_node_t
*
node
=
NULL
;
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
ctx
->
mutex
=
kk
_MutexCreate
();
ctx
->
mutex
=
_sub
_MutexCreate
();
if
(
ctx
->
mutex
==
NULL
)
{
if
(
ctx
->
mutex
==
NULL
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
ctx
->
sub_devid
=
1
;
ctx
->
sub_devid
=
1
;
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
//kk_sub_tsl_add("112233445566","a1h88DsZIaY");
kk_sub_tsl_add
(
"112233445566"
,
"a1h88DsZIaY"
);
//usleep(1000000);
usleep
(
1000000
);
//kk_test();
kk_test
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_sub_tsl_add
(
const
char
*
device_mac
,
const
char
*
product_type
)
int
kk_sub_tsl_add
(
const
char
*
device_mac
,
const
char
*
product_type
)
...
@@ -71,32 +119,23 @@ int kk_sub_tsl_add(const char *device_mac,const char *product_type)
...
@@ -71,32 +119,23 @@ int kk_sub_tsl_add(const char *device_mac,const char *product_type)
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
_sub_dev_mutex_lock
();
memset
(
node
->
product_type
,
0x0
,
sizeof
(
node
->
product_type
));
memset
(
node
->
product_type
,
0x0
,
sizeof
(
node
->
product_type
));
memcpy
(
node
->
device_mac
,
device_mac
,
strlen
(
device_mac
));
memcpy
(
node
->
device_mac
,
device_mac
,
strlen
(
device_mac
));
memcpy
(
node
->
product_type
,
product_type
,
strlen
(
product_type
));
memcpy
(
node
->
product_type
,
product_type
,
strlen
(
product_type
));
node
->
devid
=
_sub_tsl_next_devid
();
node
->
devid
=
_sub_tsl_next_devid
();
node
->
dev_shadow
=
NULL
;
memset
(
name
,
0x0
,
sizeof
(
name
));
sprintf
(
name
,
"%s.json"
,
product_type
);
tsl_str
=
kk_load_json
(
name
);
if
(
tsl_str
!=
NULL
)
{
res
=
kk_tsl_create
(
tsl_str
,
strlen
(
tsl_str
),
&
node
->
dev_shadow
);
free
(
tsl_str
);
if
(
res
!=
0
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
FAIL_RETURN
;
}
}
INIT_LIST_HEAD
(
&
node
->
linked_list
);
INIT_LIST_HEAD
(
&
node
->
linked_list
);
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
dev_list
);
list_add_tail
(
&
node
->
linked_list
,
&
ctx
->
dev_list
);
_sub_dev_mutex_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_sub_tsl_get_device_by_mac
(
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
sub_dev_node_t
**
node
)
int
kk_sub_tsl_get_device_by_mac
(
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
sub_dev_node_t
**
node
)
{
{
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
kk_sub_dev_ctx_t
*
ctx
=
_sub_dev_get_ctx
();
sub_dev_node_t
*
search_node
=
NULL
;
sub_dev_node_t
*
search_node
=
NULL
;
_sub_dev_mutex_lock
();
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
sub_dev_node_t
)
{
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
sub_dev_node_t
)
{
if
((
strlen
(
search_node
->
device_mac
)
==
strlen
(
device_mac
))
&&
if
((
strlen
(
search_node
->
device_mac
)
==
strlen
(
device_mac
))
&&
...
@@ -105,61 +144,22 @@ int kk_sub_tsl_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ s
...
@@ -105,61 +144,22 @@ int kk_sub_tsl_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ s
if
(
node
)
{
if
(
node
)
{
*
node
=
search_node
;
*
node
=
search_node
;
}
}
_sub_dev_mutex_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
}
}
_sub_dev_mutex_unlock
();
printf
(
"Device Not Found, device_mac: %s
\n
"
,
device_mac
);
printf
(
"Device Not Found, device_mac: %s
\n
"
,
device_mac
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
int
kk_sub_tsl_get_Identifier_by_index
(
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
int
idx
,
_OU_
char
**
identifiers
)
const
char
DM_MSG_REQUEST
[]
=
"{
\"
LightStatus
\"
:
\"
1
\"
}"
;
{
int
res
=
0
;
sub_dev_node_t
*
node
=
NULL
;
int
index
=
0
;
kk_tsl_t
*
dev_shadow
=
NULL
;
int
propertiesNum
=
0
;
kk_tsl_data_t
*
pProperty
=
NULL
;
char
*
identifier
=
NULL
;
res
=
kk_sub_tsl_get_device_by_mac
(
device_mac
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
dev_shadow
=
node
->
dev_shadow
;
propertiesNum
=
dev_shadow
->
property_number
;
if
(
idx
>=
propertiesNum
){
return
FAIL_RETURN
;
}
pProperty
=
(
kk_tsl_data_t
*
)(
dev_shadow
->
properties
+
idx
);
identifier
=
(
char
*
)
malloc
(
strlen
(
pProperty
->
identifier
)
+
1
);
memset
(
identifier
,
0x0
,
strlen
(
pProperty
->
identifier
)
+
1
);
memcpy
(
identifier
,
pProperty
->
identifier
,
strlen
(
pProperty
->
identifier
));
*
identifiers
=
identifier
;
return
SUCCESS_RETURN
;
}
int
kk_sub_tsl_get_Identifiers_Num
(
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
num
)
{
int
res
=
0
;
sub_dev_node_t
*
node
=
NULL
;
kk_tsl_t
*
dev_shadow
=
NULL
;
res
=
kk_sub_tsl_get_device_by_mac
(
device_mac
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
dev_shadow
=
node
->
dev_shadow
;
*
num
=
dev_shadow
->
property_number
;
return
SUCCESS_RETURN
;
}
const
char
DM_MSG_REQUEST
[]
=
"{
\"
LightStatus123
\"
:
\"
1
\"
}"
;
int
kk_test
(
void
)
int
kk_test
(
void
)
{
{
int
num
;
int
i
=
0
;
char
*
identifier
=
NULL
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_test_fuc
(
"112233445566"
,
DM_MSG_REQUEST
);
kk_test_fuc
(
"112233445566"
,
DM_MSG_REQUEST
);
//kk_get_Identity_Num(0);
return
0
;
return
0
;
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_sub_tsl.h
View file @
7d63f2f6
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
typedef
struct
{
typedef
struct
{
int
devid
;
int
devid
;
kk_tsl_t
*
dev_shadow
;
char
product_type
[
PRODUCT_KEY_MAXLEN
];
char
product_type
[
PRODUCT_KEY_MAXLEN
];
char
device_mac
[
DEVICE_MAC_MAXLEN
];
char
device_mac
[
DEVICE_MAC_MAXLEN
];
struct
list_head
linked_list
;
struct
list_head
linked_list
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
7d63f2f6
...
@@ -71,7 +71,7 @@ bool kk_rpc_report_LightStatus(EmberEUI64 mac,bool LightStatus)
...
@@ -71,7 +71,7 @@ bool kk_rpc_report_LightStatus(EmberEUI64 mac,bool LightStatus)
kk_rpc_report_status
(
root
,
mac
);
kk_rpc_report_status
(
root
,
mac
);
}
}
int
lightStatus
Ctrl
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
)
int
lightStatus
Set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
)
{
{
uint8_t
eui64
[
EUI64_SIZE
];
uint8_t
eui64
[
EUI64_SIZE
];
uint8_t
LightStatus
=
0
;
uint8_t
LightStatus
=
0
;
...
@@ -124,8 +124,7 @@ int kk_test_fuc(char *mac,const char *params)
...
@@ -124,8 +124,7 @@ int kk_test_fuc(char *mac,const char *params)
int
res
=
0
;
int
res
=
0
;
int
pCtrlIdx
=
0
;
int
pCtrlIdx
=
0
;
int
num
=
0
;
int
num
=
0
;
int
index
=
0
,
idx
=
0
;
int
index
=
0
;
char
*
identifier
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
root
;
cJSON
*
root
;
root
=
cJSON_Parse
((
char
*
)
params
);
root
=
cJSON_Parse
((
char
*
)
params
);
...
@@ -140,42 +139,28 @@ int kk_test_fuc(char *mac,const char *params)
...
@@ -140,42 +139,28 @@ int kk_test_fuc(char *mac,const char *params)
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
}
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_sub_tsl_get_Identifiers_Num
(
mac
,
&
num
);
num
=
kk_get_Identity_Num
(
pCtrlIdx
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
for
(
index
=
0
;
index
<
num
;
index
++
){
for
(
index
=
0
;
index
<
num
;
index
++
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_sub_tsl_get_Identifier_by_index
(
mac
,
index
,
&
identifier
);
printf
(
"[%s][%d]------->%s
\n
"
,
__FUNCTION__
,
__LINE__
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
Identity
);
printf
(
"[%s][%d]identifier:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
identifier
);
//kk_sub_tsl_get_Identifier_by_index(mac,index,&
identifier);
propertyItem
=
rpc_cJSON_GetObjectItem
(
root
,
identifier
);
propertyItem
=
rpc_cJSON_GetObjectItem
(
root
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
Identity
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
if
(
propertyItem
!=
NULL
)
if
(
propertyItem
!=
NULL
)
{
{
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
printf
(
"[%s][%d]value:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
value
);
printf
(
"[%s][%d]value:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
value
);
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_cb
(
NULL
,
mac
,
&
value
);
for
(
idx
=
0
;
idx
<
num
;
idx
++
)
if
(
res
<
0
)
{
{
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
if
(
!
strcmp
(
identifier
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
idx
].
Identity
))
return
-
1
;
{
}
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
idx
].
zigbee_cb
(
NULL
,
mac
,
&
value
);
else
{
if
(
res
<
0
)
{
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
free
(
identifier
);
return
0
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
else
{
free
(
identifier
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
0
;
}
}
}
}
}
}
free
(
identifier
);
identifier
=
NULL
;
}
}
return
0
;
return
0
;
...
@@ -184,8 +169,7 @@ cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac
...
@@ -184,8 +169,7 @@ cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac
{
{
rpc_nwk_info_s
info
;
rpc_nwk_info_s
info
;
EmberStatus
status
;
EmberStatus
status
;
int
num
=
0
,
index
=
0
,
idx
=
0
;
int
num
=
0
,
index
=
0
;
char
*
identifier
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
sub_dev_node_t
*
node
=
NULL
;
sub_dev_node_t
*
node
=
NULL
;
int
pCtrlIdx
=
0
;
int
pCtrlIdx
=
0
;
...
@@ -204,34 +188,22 @@ cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac
...
@@ -204,34 +188,22 @@ cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac
if
(
pCtrlIdx
<
SUCCESS_RETURN
){
if
(
pCtrlIdx
<
SUCCESS_RETURN
){
goto
error_return
;
goto
error_return
;
}
}
kk_sub_tsl_get_Identifiers_Num
(
mac
->
valuestring
,
&
num
);
num
=
kk_get_Identity_Num
(
pCtrlIdx
);
for
(
index
=
0
;
index
<
num
;
index
++
){
for
(
index
=
0
;
index
<
num
;
index
++
){
kk_sub_tsl_get_Identifier_by_index
(
mac
->
valuestring
,
index
,
&
identifier
);
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
Identity
);
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
identifier
);
if
(
propertyItem
!=
NULL
)
if
(
propertyItem
!=
NULL
)
{
{
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_cb
(
ctx
,
mac
,
&
value
);
for
(
idx
=
0
;
idx
<
num
;
idx
++
)
if
(
ret
<
0
)
{
{
goto
error_return
;
if
(
!
strcmp
(
identifier
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
idx
].
Identity
))
{
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
idx
].
zigbee_cb
(
ctx
,
mac
,
&
value
);
if
(
ret
<
0
)
{
free
(
identifier
);
goto
error_return
;
}
else
{
free
(
identifier
);
return
rpc_cJSON_CreateNumber
(
ret
);
}
}
}
}
else
{
return
rpc_cJSON_CreateNumber
(
ret
);
}
}
}
free
(
identifier
);
identifier
=
NULL
;
}
}
}
}
error_return:
error_return:
...
@@ -248,8 +220,7 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
...
@@ -248,8 +220,7 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
int
pCtrlIdx
=
0
;
int
pCtrlIdx
=
0
;
rpc_nwk_info_s
info
;
rpc_nwk_info_s
info
;
EmberStatus
status
;
EmberStatus
status
;
int
index
=
0
,
idx
=
0
;
int
index
=
0
;
char
*
identifier
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
if
(
params
==
NULL
){
if
(
params
==
NULL
){
...
@@ -269,32 +240,21 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
...
@@ -269,32 +240,21 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
goto
error_return
;
}
}
kk_sub_tsl_get_Identifiers_Num
(
mac
->
string
,
&
num
);
num
=
kk_get_Identity_Num
(
pCtrlIdx
);
for
(
index
=
0
;
index
<
num
;
index
++
){
for
(
index
=
0
;
index
<
num
;
index
++
){
kk_sub_tsl_get_Identifier_by_index
(
mac
->
string
,
index
,
&
identifier
);
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
Identity
);
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
identifier
);
if
(
propertyItem
!=
NULL
)
if
(
propertyItem
!=
NULL
)
{
{
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
int
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
for
(
idx
=
0
;
idx
<
num
;
idx
++
)
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
index
].
zigbee_cb
(
ctx
,
mac
,
&
value
);
{
if
(
res
<
0
)
{
if
(
!
strcmp
(
identifier
,
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
idx
].
Identity
))
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
{
goto
error_return
;
res
=
g_tsl_zigbee_map
[
pCtrlIdx
].
zigbee_ctrl
[
idx
].
zigbee_cb
(
ctx
,
mac
,
&
value
);
}
if
(
res
<
0
)
{
else
{
free
(
identifier
);
return
rpc_cJSON_CreateNumber
(
res
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
}
goto
error_return
;
}
else
{
free
(
identifier
);
return
rpc_cJSON_CreateNumber
(
res
);
}
}
}
}
}
free
(
identifier
);
identifier
=
NULL
;
}
}
}
}
error_return:
error_return:
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
7d63f2f6
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
cJSON
*
rpc_read_attribue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
cJSON
*
rpc_read_attribue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
int
lightStatus
Ctrl
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
int
lightStatus
Set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
View file @
7d63f2f6
...
@@ -4,19 +4,21 @@
...
@@ -4,19 +4,21 @@
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[]
=
{
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[]
=
{
{
{
"a1h88DsZIaY"
,
"a1h88DsZIaY"
,
3
,
{
{
{
KK_TSL_DATA_TYPE_TEXT
,
"LightStatus"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"LightStatus"
,
lightStatus
Set
},
{
KK_TSL_DATA_TYPE_TEXT
,
"LightAdjustLevel"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"LightAdjustLevel"
,
lightStatus
Set
},
{
KK_TSL_DATA_TYPE_TEXT
,
"LightAlias"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"LightAlias"
,
lightStatus
Set
},
}
}
},
},
{
{
"testtype"
,
"testtype"
,
4
,
{
{
{
KK_TSL_DATA_TYPE_TEXT
,
"test1"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test1"
,
lightStatus
Set
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test12"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test12"
,
lightStatus
Set
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test123"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test123"
,
lightStatus
Set
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test1234"
,
lightStatus
Ctrl
},
{
KK_TSL_DATA_TYPE_TEXT
,
"test1234"
,
lightStatus
Set
},
}
}
},
},
...
@@ -36,6 +38,10 @@ int kk_find_ctrl_obj(const char *product_type)
...
@@ -36,6 +38,10 @@ int kk_find_ctrl_obj(const char *product_type)
return
-
1
;
return
-
1
;
}
}
int
kk_get_Identity_Num
(
int
index
)
{
return
g_tsl_zigbee_map
[
index
].
num
;
}
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
View file @
7d63f2f6
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
#include "RPC_API.h"
#include "RPC_API.h"
#include "kk_tsl_common.h"
#include "kk_tsl_common.h"
#define PROPERTIES_MAX_NUM 20
typedef
int
(
*
zigbee_ctrl_cb
)(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
typedef
int
(
*
zigbee_ctrl_cb
)(
jrpc_context
*
ctx
,
const
char
*
mac
,
void
*
data
);
typedef
struct
{
typedef
struct
{
...
@@ -13,7 +15,8 @@ typedef struct{
...
@@ -13,7 +15,8 @@ typedef struct{
typedef
struct
{
typedef
struct
{
char
*
product_type
;
char
*
product_type
;
kk_zigbee_ctrl_map_t
zigbee_ctrl
[
20
];
int
num
;
kk_zigbee_ctrl_map_t
zigbee_ctrl
[
PROPERTIES_MAX_NUM
];
}
kk_tsl_zigbee_map_t
;
}
kk_tsl_zigbee_map_t
;
#endif
#endif
platform/zigbee/app/builder/Z3GatewayHost/libkk_tsl.a
deleted
100644 → 0
View file @
784fe296
File deleted
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