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
0de6644f
Commit
0de6644f
authored
Sep 16, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://172.17.3.10:17001/chenweican/k-sdk
parents
1e3c7b60
bab0bf4f
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
2245 additions
and
1081 deletions
+2245
-1081
common/api/tcp_channel.c
common/api/tcp_channel.c
+4
-2
common/mqtt/MQTTAsync.c
common/mqtt/MQTTAsync.c
+1
-2
common/mqtt/MQTTProtocolClient.c
common/mqtt/MQTTProtocolClient.c
+0
-4
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+25
-7
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+38
-0
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+23
-0
midware/tsl/tsl_handle/kk_tsl_load.c
midware/tsl/tsl_handle/kk_tsl_load.c
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+58
-9
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
+43
-42
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+265
-65
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
+8
-3
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
+1398
-738
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+381
-209
No files found.
common/api/tcp_channel.c
View file @
0de6644f
...
@@ -320,7 +320,7 @@ static void read_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
...
@@ -320,7 +320,7 @@ static void read_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
}
}
int
res
=
0
;
int
res
=
0
;
kk_tcp_ctrl_t
*
tcp_ctrl
=
(
kk_tcp_ctrl_t
*
)
watcher
->
data
;
kk_tcp_ctrl_t
*
tcp_ctrl
=
(
kk_tcp_ctrl_t
*
)
watcher
->
data
;
int32_t
bytes
=
re
ad
(
watcher
->
fd
,
buffer
,
sizeof
(
buffer
)
);
int32_t
bytes
=
re
cv
(
watcher
->
fd
,
buffer
,
sizeof
(
buffer
),
0
);
if
(
-
1
==
bytes
)
{
if
(
-
1
==
bytes
)
{
//tcp Error
//tcp Error
if
(
EINTR
!=
errno
&&
EAGAIN
!=
errno
)
{
if
(
EINTR
!=
errno
&&
EAGAIN
!=
errno
)
{
...
@@ -659,6 +659,7 @@ static void loop_tcp_client_thread(void *arg){
...
@@ -659,6 +659,7 @@ static void loop_tcp_client_thread(void *arg){
{
{
//接受网络数据
//接受网络数据
_MutexLock
(
g_client_ctrl
.
mutex
);
_MutexLock
(
g_client_ctrl
.
mutex
);
memset
(
buf
,
0x0
,
sizeof
(
buf
));
ret
=
read
(
g_client_ctrl
.
sd
,
buf
,
sizeof
(
buf
));
ret
=
read
(
g_client_ctrl
.
sd
,
buf
,
sizeof
(
buf
));
_MutexUnlock
(
g_client_ctrl
.
mutex
);
_MutexUnlock
(
g_client_ctrl
.
mutex
);
...
@@ -670,7 +671,7 @@ static void loop_tcp_client_thread(void *arg){
...
@@ -670,7 +671,7 @@ static void loop_tcp_client_thread(void *arg){
break
;
break
;
}
}
}
else
if
(
ret
>
0
){
}
else
if
(
ret
>
0
){
printf
(
"
buf = %s
\n
"
,
buf
);
//printf("11
buf = %s\n",buf);
if
(
g_client_ctrl
.
cb
!=
NULL
){
if
(
g_client_ctrl
.
cb
!=
NULL
){
g_client_ctrl
.
cb
(
buf
,
ret
,
""
);
g_client_ctrl
.
cb
(
buf
,
ret
,
""
);
}
}
...
@@ -701,6 +702,7 @@ int kk_reset_retry_num(){
...
@@ -701,6 +702,7 @@ int kk_reset_retry_num(){
int
kk_tcp_client_send
(
char
*
data
,
int
len
){
int
kk_tcp_client_send
(
char
*
data
,
int
len
){
int
ret
=
0
;
int
ret
=
0
;
int
cnt
=
0
;
int
cnt
=
0
;
if
(
data
!=
NULL
){
if
(
data
!=
NULL
){
while
(
g_client_ctrl
.
sd
==
-
1
&&
cnt
<
5
){
while
(
g_client_ctrl
.
sd
==
-
1
&&
cnt
<
5
){
printf
(
"[%s] tcp don't connect, sleep 1s !!!!
\n
"
,
__FUNCTION__
);
printf
(
"[%s] tcp don't connect, sleep 1s !!!!
\n
"
,
__FUNCTION__
);
...
...
common/mqtt/MQTTAsync.c
View file @
0de6644f
...
@@ -2885,7 +2885,7 @@ static int MQTTAsync_cleanSession(Clients* client)
...
@@ -2885,7 +2885,7 @@ static int MQTTAsync_cleanSession(Clients* client)
static
int
MQTTAsync_deliverMessage
(
MQTTAsyncs
*
m
,
char
*
topicName
,
size_t
topicLen
,
MQTTAsync_message
*
mm
)
static
int
MQTTAsync_deliverMessage
(
MQTTAsyncs
*
m
,
char
*
topicName
,
size_t
topicLen
,
MQTTAsync_message
*
mm
)
{
{
int
rc
;
int
rc
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
Log
(
TRACE_MIN
,
-
1
,
"Calling messageArrived for client %s, queue depth %d"
,
Log
(
TRACE_MIN
,
-
1
,
"Calling messageArrived for client %s, queue depth %d"
,
m
->
c
->
clientID
,
m
->
c
->
messageQueue
->
count
);
m
->
c
->
clientID
,
m
->
c
->
messageQueue
->
count
);
rc
=
(
*
(
m
->
ma
))(
m
->
maContext
,
topicName
,
(
int
)
topicLen
,
mm
);
rc
=
(
*
(
m
->
ma
))(
m
->
maContext
,
topicName
,
(
int
)
topicLen
,
mm
);
...
@@ -2902,7 +2902,6 @@ void Protocol_processPublication(Publish* publish, Clients* client, int allocate
...
@@ -2902,7 +2902,6 @@ void Protocol_processPublication(Publish* publish, Clients* client, int allocate
MQTTAsync_message
*
mm
=
NULL
;
MQTTAsync_message
*
mm
=
NULL
;
MQTTAsync_message
initialized
=
MQTTAsync_message_initializer
;
MQTTAsync_message
initialized
=
MQTTAsync_message_initializer
;
int
rc
=
0
;
int
rc
=
0
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
FUNC_ENTRY
;
FUNC_ENTRY
;
if
((
mm
=
malloc
(
sizeof
(
MQTTAsync_message
)))
==
NULL
)
if
((
mm
=
malloc
(
sizeof
(
MQTTAsync_message
)))
==
NULL
)
...
...
common/mqtt/MQTTProtocolClient.c
View file @
0de6644f
...
@@ -304,7 +304,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
...
@@ -304,7 +304,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
Clients
*
client
=
NULL
;
Clients
*
client
=
NULL
;
char
*
clientid
=
NULL
;
char
*
clientid
=
NULL
;
int
rc
=
TCPSOCKET_COMPLETE
;
int
rc
=
TCPSOCKET_COMPLETE
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
FUNC_ENTRY
;
FUNC_ENTRY
;
client
=
(
Clients
*
)(
ListFindItem
(
bstate
->
clients
,
&
sock
,
clientSocketCompare
)
->
content
);
client
=
(
Clients
*
)(
ListFindItem
(
bstate
->
clients
,
&
sock
,
clientSocketCompare
)
->
content
);
...
@@ -313,7 +312,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
...
@@ -313,7 +312,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
publish
->
header
.
bits
.
retain
,
publish
->
payloadlen
,
min
(
20
,
publish
->
payloadlen
),
publish
->
payload
);
publish
->
header
.
bits
.
retain
,
publish
->
payloadlen
,
min
(
20
,
publish
->
payloadlen
),
publish
->
payload
);
if
(
publish
->
header
.
bits
.
qos
==
0
){
if
(
publish
->
header
.
bits
.
qos
==
0
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
Protocol_processPublication
(
publish
,
client
,
1
);
Protocol_processPublication
(
publish
,
client
,
1
);
}
}
else
if
(
!
Socket_noPendingWrites
(
sock
))
else
if
(
!
Socket_noPendingWrites
(
sock
))
...
@@ -324,7 +322,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
...
@@ -324,7 +322,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
rc
=
MQTTPacket_send_puback
(
publish
->
MQTTVersion
,
publish
->
msgId
,
&
client
->
net
,
client
->
clientID
);
rc
=
MQTTPacket_send_puback
(
publish
->
MQTTVersion
,
publish
->
msgId
,
&
client
->
net
,
client
->
clientID
);
/* if we get a socket error from sending the puback, should we ignore the publication? */
/* if we get a socket error from sending the puback, should we ignore the publication? */
Protocol_processPublication
(
publish
,
client
,
1
);
Protocol_processPublication
(
publish
,
client
,
1
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
}
else
if
(
publish
->
header
.
bits
.
qos
==
2
)
else
if
(
publish
->
header
.
bits
.
qos
==
2
)
{
{
...
@@ -374,7 +371,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
...
@@ -374,7 +371,6 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
publish1
.
payloadlen
=
m
->
publish
->
payloadlen
;
publish1
.
payloadlen
=
m
->
publish
->
payloadlen
;
publish1
.
MQTTVersion
=
m
->
MQTTVersion
;
publish1
.
MQTTVersion
=
m
->
MQTTVersion
;
publish1
.
properties
=
m
->
properties
;
publish1
.
properties
=
m
->
properties
;
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
Protocol_processPublication
(
&
publish1
,
client
,
1
);
Protocol_processPublication
(
&
publish1
,
client
,
1
);
ListRemove
(
&
(
state
.
publications
),
m
->
publish
);
ListRemove
(
&
(
state
.
publications
),
m
->
publish
);
...
...
midware/midware/dm/kk_dm_mng.c
View file @
0de6644f
...
@@ -148,9 +148,10 @@ static int _dm_init_tsl_params(kk_tsl_t * dev_shadow)
...
@@ -148,9 +148,10 @@ static int _dm_init_tsl_params(kk_tsl_t * dev_shadow)
}
}
return
res
;
return
res
;
}
}
/*目前支持到三级结构体的属性解析保存到数据库*/
int
dm_mgr_properities_db_create
(
kk_tsl_t
*
dev_shadow
,
char
*
deviceCode
,
int
devType
)
int
dm_mgr_properities_db_create
(
kk_tsl_t
*
dev_shadow
,
char
*
deviceCode
,
int
devType
)
{
{
int
num
=
0
,
idx
=
0
,
index
=
0
;
int
num
=
0
,
idx
=
0
,
index
=
0
,
index1
=
0
;
kk_tsl_data_t
*
pProperty
=
NULL
;
kk_tsl_data_t
*
pProperty
=
NULL
;
kk_tsl_data_t
*
current_data
=
NULL
;
kk_tsl_data_t
*
current_data
=
NULL
;
char
tmp_identifiers
[
256
]
=
{
0
};
char
tmp_identifiers
[
256
]
=
{
0
};
...
@@ -170,10 +171,28 @@ int dm_mgr_properities_db_create(kk_tsl_t* dev_shadow,char *deviceCode,int devTy
...
@@ -170,10 +171,28 @@ int dm_mgr_properities_db_create(kk_tsl_t* dev_shadow,char *deviceCode,int devTy
complex_struct
=
pProperty
->
data_value
.
value
;
complex_struct
=
pProperty
->
data_value
.
value
;
for
(
index
=
0
;
index
<
complex_struct
->
size
;
index
++
)
{
for
(
index
=
0
;
index
<
complex_struct
->
size
;
index
++
)
{
current_data
=
(
kk_tsl_data_t
*
)
complex_struct
->
value
+
index
;
current_data
=
(
kk_tsl_data_t
*
)
complex_struct
->
value
+
index
;
memset
(
tmp_identifiers
,
0x0
,
sizeof
(
tmp_identifiers
));
if
(
current_data
->
data_value
.
type
!=
KK_TSL_DATA_TYPE_STRUCT
){
sprintf
(
tmp_identifiers
,
"%s.%s"
,
pProperty
->
identifier
,
current_data
->
identifier
);
memset
(
tmp_identifiers
,
0x0
,
sizeof
(
tmp_identifiers
));
INFO_PRINT
(
"dm_mgr_properities_db_create tmp_identifiers:%s!!
\n
"
,
tmp_identifiers
);
sprintf
(
tmp_identifiers
,
"%s.%s"
,
pProperty
->
identifier
,
current_data
->
identifier
);
kk_property_db_insert
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
type
,
devType
);
INFO_PRINT
(
"dm_mgr_properities_db_create tmp_identifiers:%s!!
\n
"
,
tmp_identifiers
);
kk_property_db_insert
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
type
,
devType
);
}
else
{
kk_tsl_data_value_complex_t
*
complex_struct_1
=
NULL
;
complex_struct_1
=
current_data
->
data_value
.
value
;
for
(
index1
=
0
;
index1
<
complex_struct_1
->
size
;
index1
++
){
kk_tsl_data_t
*
current_data_1
=
NULL
;
current_data_1
=
(
kk_tsl_data_t
*
)
complex_struct_1
->
value
+
index1
;
if
(
current_data_1
->
data_value
.
type
!=
KK_TSL_DATA_TYPE_STRUCT
){
memset
(
tmp_identifiers
,
0x0
,
sizeof
(
tmp_identifiers
));
sprintf
(
tmp_identifiers
,
"%s.%s.%s"
,
pProperty
->
identifier
,
current_data
->
identifier
,
current_data_1
->
identifier
);
INFO_PRINT
(
"dm_mgr_properities_db_create tmp_identifiers:%s!!
\n
"
,
tmp_identifiers
);
kk_property_db_insert
(
deviceCode
,
tmp_identifiers
,
current_data_1
->
data_value
.
type
,
devType
);
}
}
}
}
}
}
else
}
else
{
{
...
@@ -452,9 +471,8 @@ int dm_mgr_init(void)
...
@@ -452,9 +471,8 @@ int dm_mgr_init(void)
/* Init Device List */
/* Init Device List */
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
//HAL_GetProduct_Type(product_key);
//HAL_GetProduct_Code(device_name);
HAL_Get_mac
(
mac
);
HAL_Get_mac
(
mac
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
"CCU_66666"
,
mac
,
""
,
&
devId
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
"CCU_66666"
,
mac
,
""
,
&
devId
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
goto
ERROR
;
...
...
midware/midware/dm/kk_dm_msg.c
View file @
0de6644f
...
@@ -908,6 +908,44 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -908,6 +908,44 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
value
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
current_data
->
data_value
.
value
);
}
}
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_STRUCT
){
kk_tsl_data_value_complex_t
*
complex_struct_1
=
NULL
;
complex_struct_1
=
current_data
->
data_value
.
value
;
int
index1
=
0
;
kk_tsl_data_t
*
current_data_1
=
NULL
;
cJSON
*
propertyItem_2
=
NULL
;
for
(
index1
=
0
;
index1
<
complex_struct_1
->
size
;
index1
++
){
current_data_1
=
(
kk_tsl_data_t
*
)
complex_struct_1
->
value
+
index1
;
propertyItem_2
=
cJSON_GetObjectItem
(
propertyItem_1
,
current_data_1
->
identifier
);
if
(
propertyItem_2
!=
NULL
){
memset
(
tmp_identifiers
,
0x0
,
sizeof
(
tmp_identifiers
));
sprintf
(
tmp_identifiers
,
"%s.%s.%s"
,
property
->
identifier
,
current_data
->
identifier
,
current_data_1
->
identifier
);
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_INT
||
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_ENUM
||
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_BOOL
){
sprintf
(
tmpValue
,
"%d"
,
current_data_1
->
data_value
.
value_int
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
}
else
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
){
sprintf
(
tmpValue
,
"%d"
,
current_data_1
->
data_value
.
value_float
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
}
else
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
sprintf
(
tmpValue
,
"%d"
,
current_data_1
->
data_value
.
value_double
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
}
else
if
(
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
||
current_data_1
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DATE
){
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
current_data_1
->
data_value
.
value
);
}
else
{
ERROR_PRINT
(
"Unsupport Type ~~
\n
"
);
}
}
}
}
else
{
else
{
ERROR_PRINT
(
"Unsupport Type
\n
"
);
ERROR_PRINT
(
"Unsupport Type
\n
"
);
}
}
...
...
midware/midware/dm/kk_property_db.c
View file @
0de6644f
...
@@ -403,5 +403,28 @@ int kk_property_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN])
...
@@ -403,5 +403,28 @@ int kk_property_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN])
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_property_delete_by_identify
(
char
*
identify
)
{
const
char
*
deleteCmd
=
"delete from PropertiesInfo where identifier = '%s';"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
identify
);
INFO_PRINT
(
"Table delete data sqlCmd:%s
\n
"
,
sqlCmd
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
INFO_PRINT
(
"Table delete data successfully
\n
"
);
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
}
...
...
midware/tsl/tsl_handle/kk_tsl_load.c
View file @
0de6644f
...
@@ -78,6 +78,7 @@ char* kk_load_json(const char *productCode,int type)
...
@@ -78,6 +78,7 @@ char* kk_load_json(const char *productCode,int type)
fread
(
buf
,
1
,
filesize
,
fp
);
fread
(
buf
,
1
,
filesize
,
fp
);
//printf("%s!!!\n",buf);
//printf("%s!!!\n",buf);
free
(
tslPath
);
free
(
tslPath
);
fclose
(
fp
);
return
buf
;
return
buf
;
}
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
0de6644f
...
@@ -10,21 +10,41 @@ const char *kk_tsl_rpt_status_string[] = {
...
@@ -10,21 +10,41 @@ const char *kk_tsl_rpt_status_string[] = {
};
};
static
cJSON
*
kk_check_identify
(
const
char
*
identify
,
cJSON
*
root
,
int
index
,
int
status
)
static
cJSON
*
kk_check_identify
(
const
char
*
identify
,
cJSON
*
root
,
int
index
,
int
status
)
{
{
int
rev
=
0
,
startIdx
=
0
;
int
rev
=
0
,
startIdx
2
=
0
,
startIdx1
=
0
;
char
*
Identify_str
;
char
*
Identify_str
;
char
tmp_Identity
[
64
]
=
{
0
};
char
tmp_Identity
[
64
]
=
{
0
};
rev
=
kk_tsl_utils_memtok
(
identify
,
"."
,
1
,
&
startIdx
);
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
2
,
&
startIdx2
);
if
(
!
rev
){
if
(
!
rev
){
cJSON
*
str
=
NULL
;
cJSON
*
str
=
NULL
;
cJSON
*
str_r
=
NULL
;
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
str
=
rpc_cJSON_CreateObject
();
str
=
rpc_cJSON_CreateObject
();
Identify_str
=
identify
+
1
+
startIdx
;
Identify_str
=
identify
+
1
+
startIdx
2
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx
);
memcpy
(
tmp_Identity
,
identify
+
startIdx1
+
1
,
startIdx2
-
startIdx1
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str
);
str_r
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
str_r
,
tmp_Identity
,
str
);
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str_r
);
return
root
;
return
root
;
}
}
else
{
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
if
(
!
rev
){
cJSON
*
str
=
NULL
;
str
=
rpc_cJSON_CreateObject
();
Identify_str
=
identify
+
1
+
startIdx1
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str
);
return
root
;
}
}
return
NULL
;
return
NULL
;
...
@@ -54,7 +74,6 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
...
@@ -54,7 +74,6 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
root_tmp
=
kk_check_identify
(
g_tsl_zigbee_map_glb
[
index
].
map
.
Identity
,
root
,
index
,
status
);
root_tmp
=
kk_check_identify
(
g_tsl_zigbee_map_glb
[
index
].
map
.
Identity
,
root
,
index
,
status
);
if
(
root_tmp
!=
NULL
){
if
(
root_tmp
!=
NULL
){
kk_rpc_report_status
(
root_tmp
,
mac
);
kk_rpc_report_status
(
root_tmp
,
mac
);
//rpc_cJSON_Delete(root_tmp);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
else
{
else
{
...
@@ -65,7 +84,6 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
...
@@ -65,7 +84,6 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
root_tmp
=
kk_check_identify
(
g_tsl_zigbee_map
[
index
].
Identity
,
root
,
index
,
status
);
root_tmp
=
kk_check_identify
(
g_tsl_zigbee_map
[
index
].
Identity
,
root
,
index
,
status
);
if
(
root_tmp
!=
NULL
){
if
(
root_tmp
!=
NULL
){
kk_rpc_report_status
(
root_tmp
,
mac
);
kk_rpc_report_status
(
root_tmp
,
mac
);
//rpc_cJSON_Delete(root_tmp);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
else
{
else
{
...
@@ -74,7 +92,6 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
...
@@ -74,7 +92,6 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
}
}
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
kk_rpc_report_status
(
root
,
mac
);
kk_rpc_report_status
(
root
,
mac
);
//rpc_cJSON_Delete(root);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
...
@@ -105,7 +122,7 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
...
@@ -105,7 +122,7 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
g_tsl_zigbee_map
[
i
].
attributeId
==
attributeId
&&
g_tsl_zigbee_map
[
i
].
attributeId
==
attributeId
&&
g_tsl_zigbee_map
[
i
].
zigbee_report
!=
NULL
){
g_tsl_zigbee_map
[
i
].
zigbee_report
!=
NULL
){
status
=
g_tsl_zigbee_map
[
i
].
zigbee_report
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
status
=
g_tsl_zigbee_map
[
i
].
zigbee_report
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
emberAfDebugPrintln
(
"report status:%
s"
,
kk_tsl_rpt_status_string
[
status
]
);
emberAfDebugPrintln
(
"report status:%
d"
,
status
);
return
;
return
;
}
}
}
}
...
@@ -129,6 +146,38 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
...
@@ -129,6 +146,38 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
}
}
}
}
int
kk_tsl_report_global_Brightness
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
uint8_t
value
=
data
[
0
];
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_Brightness] value:%d
\n
"
,
value
);
printf
(
"[%s][%d]dataType:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
dataType
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
printf
(
"[%s][%d]len:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
len
);
if
(
len
==
1
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_tsl_report
(
eui64
,
EP
,
value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
}
return
tsl_rpt_invaild_len
;
}
return
tsl_rpt_invaild_type
;
}
int
kk_tsl_report_global_RGB
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
uint8_t
value
=
data
[
0
];
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_RGB] value:%d
\n
"
,
value
);
printf
(
"[%s][%d]dataType:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
dataType
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
printf
(
"[%s][%d]len:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
len
);
if
(
len
==
1
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_tsl_report
(
eui64
,
EP
,
value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
}
return
tsl_rpt_invaild_len
;
}
return
tsl_rpt_invaild_type
;
}
int
kk_tsl_report_global_onoff
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_global_onoff
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
View file @
0de6644f
#ifndef __KK_TSL_PROPERTY_REPORT_H
#ifndef __KK_TSL_PROPERTY_REPORT_H
#define __KK_TSL_PROPERTY_REPORT_H
#define __KK_TSL_PROPERTY_REPORT_H
#include "kk_test.h"
#include "kk_test.h"
typedef
enum
{
typedef
enum
{
tsl_rpt_success
=
0
,
tsl_rpt_success
=
0
,
tsl_rpt_err
=
-
1
,
tsl_rpt_err
=
-
1
,
tsl_rpt_invaild_val
=
-
2
,
tsl_rpt_invaild_val
=
-
2
,
tsl_rpt_invaild_len
=
-
3
,
tsl_rpt_invaild_len
=
-
3
,
tsl_rpt_invaild_type
=
-
4
,
tsl_rpt_invaild_type
=
-
4
,
}
kk_tsl_rpt_status
;
}
kk_tsl_rpt_status
;
void
kk_tsl_report_attribute
(
EmberEUI64
eui64
,
void
kk_tsl_report_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
len
,
uint8_t
*
data
);
uint8_t
*
data
);
int
kk_tsl_report_global_onoff
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_global_onoff
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_windowCovering_mode
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_windowCovering_mode
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_windowCovering_position
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_windowCovering_position
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_global_Brightness
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_global_RGB
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
#endif
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
0de6644f
This diff is collapsed.
Click to expand it.
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
View file @
0de6644f
...
@@ -13,9 +13,14 @@ int kk_tsl_set_windowCovering_OperationMode(jrpc_context * ctx,EmberNodeId node,
...
@@ -13,9 +13,14 @@ int kk_tsl_set_windowCovering_OperationMode(jrpc_context * ctx,EmberNodeId node,
int
kk_tsl_set_windowCovering_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_position
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_position
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_OnOff
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_ModeType
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_Mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_Brightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_WhiteBrightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_RGB_red
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_RGB_green
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_RGB_blue
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
View file @
0de6644f
This diff is collapsed.
Click to expand it.
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
0de6644f
This diff is collapsed.
Click to expand it.
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