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
a615faf9
Commit
a615faf9
authored
Sep 18, 2020
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
Yjq See merge request chenweican/k-sdk!11
parents
d6172530
2a352fcf
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1944 additions
and
1249 deletions
+1944
-1249
common/curl/README.txt
common/curl/README.txt
+8
-8
common/curl/example_curl.c
common/curl/example_curl.c
+51
-51
common/curl/include/libcurl_ubuntu.so
common/curl/include/libcurl_ubuntu.so
+0
-0
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+0
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_3001.json
...uilder/Z3GatewayHost/ZB/dev_config_table/device_3001.json
+0
-4
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+473
-473
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
+52
-52
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
+499
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+201
-0
platform/zigbee/protocol/zigbee/app/framework/plugin/device-table/device-table.c
...l/zigbee/app/framework/plugin/device-table/device-table.c
+606
-606
process_check.sh
process_check.sh
+21
-21
rc.local
rc.local
+33
-33
No files found.
common/curl/README.txt
View file @
a615faf9
1. 版本:tiny-curl-7.72.0
1. 版本:tiny-curl-7.72.0
download:https://curl.haxx.se/tiny/
download:https://curl.haxx.se/tiny/
2. 编译so选项:./configure --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-file --disable-gopher --disable-imap --disable-ldaps --disable-pop3 --disable-proxy --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib
2. 编译so选项:./configure --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-file --disable-gopher --disable-imap --disable-ldaps --disable-pop3 --disable-proxy --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib
3. 交叉编译选项 9531: ./configure --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-file --disable-gopher --disable-imap --disable-ldaps --disable-pop3 --disable-proxy --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib --host=mips-openwrt-linux CC=mips-openwrt-linux-gcc --prefix=$PWD/__install
3. 交叉编译选项 9531: ./configure --disable-dict --disable-ftp --disable-imap --disable-ldap --disable-file --disable-gopher --disable-imap --disable-ldaps --disable-pop3 --disable-proxy --disable-rtsp --disable-smtp --disable-telnet --disable-tftp --disable-zlib --without-ca-bundle --without-gnutls --without-libidn --without-librtmp --without-libssh2 --without-nss --without-zlib --host=mips-openwrt-linux CC=mips-openwrt-linux-gcc --prefix=$PWD/__install
4. 编译example:gcc -o example_curl example_curl.c -L. -lcurl_ubuntu
4. 编译example:gcc -o example_curl example_curl.c -L. -lcurl_ubuntu
common/curl/example_curl.c
View file @
a615faf9
#include "include/curl.h"
#include "include/curl.h"
size_t
kk_write_func
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
stream
)
size_t
kk_write_func
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FILE
*
stream
)
{
{
return
fwrite
(
ptr
,
size
,
nmemb
,
stream
);
return
fwrite
(
ptr
,
size
,
nmemb
,
stream
);
}
}
int
kk_progress_func
(
char
*
progress_data
,
int
kk_progress_func
(
char
*
progress_data
,
double
t
,
/* dltotal */
double
t
,
/* dltotal */
double
d
,
/* dlnow */
double
d
,
/* dlnow */
double
ultotal
,
double
ultotal
,
double
ulnow
)
double
ulnow
)
{
{
printf
(
"%s %g / %g (%g %%)
\n
"
,
progress_data
,
d
,
t
,
d
*
100
.
0
/
t
);
printf
(
"%s %g / %g (%g %%)
\n
"
,
progress_data
,
d
,
t
,
d
*
100
.
0
/
t
);
return
0
;
return
0
;
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
CURL
*
curl
;
CURL
*
curl
;
CURLcode
res
;
CURLcode
res
;
FILE
*
outfile
;
FILE
*
outfile
;
char
*
url
=
argv
[
1
];
//"https://pics0.baidu.com/feed/6609c93d70cf3bc7fecc2bfb9d12faa6cc112af6.jpeg?token=517920fbf7c2fef6ff3ab5ff55bbd8d7";
char
*
url
=
argv
[
1
];
//"https://pics0.baidu.com/feed/6609c93d70cf3bc7fecc2bfb9d12faa6cc112af6.jpeg?token=517920fbf7c2fef6ff3ab5ff55bbd8d7";
char
*
progress_data
=
"* "
;
char
*
progress_data
=
"* "
;
if
(
argc
<
3
){
if
(
argc
<
3
){
printf
(
"==inpunt params error, Usage:example_curl <url> <fileName>
\n
"
);
printf
(
"==inpunt params error, Usage:example_curl <url> <fileName>
\n
"
);
return
0
;
return
0
;
}
}
curl
=
curl_easy_init
();
curl
=
curl_easy_init
();
if
(
curl
)
if
(
curl
)
{
{
outfile
=
fopen
(
argv
[
2
],
"wb"
);
//fopen("test.jpg", "wb");
outfile
=
fopen
(
argv
[
2
],
"wb"
);
//fopen("test.jpg", "wb");
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
outfile
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
outfile
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
kk_write_func
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
kk_write_func
);
curl_easy_setopt
(
curl
,
CURLOPT_NOPROGRESS
,
0
);
curl_easy_setopt
(
curl
,
CURLOPT_NOPROGRESS
,
0
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSFUNCTION
,
kk_progress_func
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSFUNCTION
,
kk_progress_func
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSDATA
,
progress_data
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSDATA
,
progress_data
);
res
=
curl_easy_perform
(
curl
);
res
=
curl_easy_perform
(
curl
);
fclose
(
outfile
);
fclose
(
outfile
);
/* always cleanup */
/* always cleanup */
curl_easy_cleanup
(
curl
);
curl_easy_cleanup
(
curl
);
}
}
return
0
;
return
0
;
}
}
common/curl/include/libcurl_ubuntu.so
0 → 100644
View file @
a615faf9
File added
midware/midware/dm/kk_property_db.c
View file @
a615faf9
...
@@ -141,7 +141,6 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
...
@@ -141,7 +141,6 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
char
*
zErrMsg
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
if
(
_kk_check_property_exist
(
deviceCode
,
identifier
)
==
1
)
if
(
_kk_check_property_exist
(
deviceCode
,
identifier
)
==
1
)
{
{
WARNING_PRINT
(
"[%s][%d] DATA ALREADY EXIST!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
WARNING_PRINT
(
"[%s][%d] DATA ALREADY EXIST!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_3001.json
View file @
a615faf9
...
@@ -8,7 +8,3 @@
...
@@ -8,7 +8,3 @@
"attribute"
:
"0x0000"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_global_onoff"
,
"reportFunc"
:
"kk_tsl_report_global_onoff"
,
"controlFunc"
:
"zclOnOff"
"controlFunc"
:
"zclOnOff"
}
]
}
\ No newline at end of file
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
a615faf9
#include "kk_tsl_property_report.h"
#include "kk_tsl_property_report.h"
#include "kk_device_manager.h"
#include "kk_device_manager.h"
#include "kk_rgb_hsl_convert.h"
#include "kk_rgb_hsl_convert.h"
const
char
*
kk_tsl_rpt_status_string
[]
=
{
const
char
*
kk_tsl_rpt_status_string
[]
=
{
"Success"
,
"Success"
,
"Error"
,
"Error"
,
"Invaild Value"
,
"Invaild Value"
,
"Invaild Len"
,
"Invaild Len"
,
"Invaild Type"
"Invaild Type"
};
};
//todo: fix it
//todo: fix it
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
,
startIdx2
=
0
,
startIdx1
=
0
;
int
rev
=
0
,
startIdx2
=
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
,
'.'
,
2
,
&
startIdx2
);
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
2
,
&
startIdx2
);
if
(
!
rev
){
if
(
!
rev
){
cJSON
*
str
=
NULL
;
cJSON
*
str
=
NULL
;
cJSON
*
str_r
=
NULL
;
cJSON
*
str_r
=
NULL
;
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
str
=
rpc_cJSON_CreateObject
();
str
=
rpc_cJSON_CreateObject
();
Identify_str
=
identify
+
1
+
startIdx2
;
Identify_str
=
identify
+
1
+
startIdx2
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
+
startIdx1
+
1
,
startIdx2
-
startIdx1
);
memcpy
(
tmp_Identity
,
identify
+
startIdx1
+
1
,
startIdx2
-
startIdx1
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
str_r
=
rpc_cJSON_CreateObject
();
str_r
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
str_r
,
tmp_Identity
,
str
);
rpc_cJSON_AddItemToObject
(
str_r
,
tmp_Identity
,
str
);
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str_r
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str_r
);
return
root
;
return
root
;
}
}
else
{
else
{
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
if
(
!
rev
){
if
(
!
rev
){
cJSON
*
str
=
NULL
;
cJSON
*
str
=
NULL
;
str
=
rpc_cJSON_CreateObject
();
str
=
rpc_cJSON_CreateObject
();
Identify_str
=
identify
+
1
+
startIdx1
;
Identify_str
=
identify
+
1
+
startIdx1
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str
);
return
root
;
return
root
;
}
}
}
}
return
NULL
;
return
NULL
;
}
}
static
int
kk_tsl_report
(
EmberEUI64
mac
,
uint8_t
EP
,
int
status
,
uint16_t
clusterId
,
uint16_t
attributeId
)
static
int
kk_tsl_report
(
EmberEUI64
mac
,
uint8_t
EP
,
int
status
,
uint16_t
clusterId
,
uint16_t
attributeId
)
{
{
cJSON
*
root
,
*
root_tmp
;
cJSON
*
root
,
*
root_tmp
;
int
index
;
int
index
;
char
*
Identify
;
char
*
Identify
;
kk_device_table_s
*
dev
;
kk_device_table_s
*
dev
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
char
macString
[
RPC_EUI64_STRING_LENGTH
];
char
macString
[
RPC_EUI64_STRING_LENGTH
];
rpc_eui64ToString
(
mac
,
macString
);
rpc_eui64ToString
(
mac
,
macString
);
root
=
rpc_cJSON_CreateObject
();
root
=
rpc_cJSON_CreateObject
();
dev
=
kk_device_find_by_mac
(
mac
);
dev
=
kk_device_find_by_mac
(
mac
);
if
(
dev
==
NULL
){
if
(
dev
==
NULL
){
return
tsl_rpt_err
;
return
tsl_rpt_err
;
}
}
printf
(
"[%s][%d]dev->productCode:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
dev
->
productCode
);
printf
(
"[%s][%d]dev->productCode:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
dev
->
productCode
);
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
if
(
dev_info
==
NULL
){
if
(
dev_info
==
NULL
){
return
tsl_rpt_err
;
return
tsl_rpt_err
;
}
}
item
=
&
dev_info
->
item
;
item
=
&
dev_info
->
item
;
while
(
item
!=
NULL
){
while
(
item
!=
NULL
){
if
(
EP
==
item
->
endpoint
&&
if
(
EP
==
item
->
endpoint
&&
clusterId
==
item
->
cluster
&&
clusterId
==
item
->
cluster
&&
attributeId
==
item
->
attribute
){
attributeId
==
item
->
attribute
){
Identify
=
item
->
identity
;
Identify
=
item
->
identity
;
break
;
break
;
}
}
item
=
item
->
next
;
item
=
item
->
next
;
}
}
root_tmp
=
kk_check_identify
(
Identify
,
root
,
index
,
status
);
root_tmp
=
kk_check_identify
(
Identify
,
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
);
}
}
else
{
else
{
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
kk_msg_report_property
(
root
,
mac
);
kk_msg_report_property
(
root
,
mac
);
}
}
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
//typedef int(*kk_rpc_report)(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
//typedef int(*kk_rpc_report)(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
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
i
,
j
,
num
,
status
;
int
i
,
j
,
num
,
status
;
sub_dev_node_t
*
node
=
NULL
;
sub_dev_node_t
*
node
=
NULL
;
int
res
=
0
;
int
res
=
0
;
char
macString
[
RPC_EUI64_STRING_LENGTH
];
char
macString
[
RPC_EUI64_STRING_LENGTH
];
kk_device_table_s
*
dev
;
kk_device_table_s
*
dev
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
kk_rpc_report
func
;
kk_rpc_report
func
;
UTIL_LOG_INFO
(
"
\n
********************kk tsl report attribute********************
\n
"
);
UTIL_LOG_INFO
(
"
\n
********************kk tsl report attribute********************
\n
"
);
emberAfDebugPrint
(
"mac:"
);
emberAfDebugPrint
(
"mac:"
);
emberAfDebugPrintln
(
",ep:%d,clu:0x%04X,attr:0x%04X,dataType=0x%02x,len=%d,data:"
,
emberAfDebugPrintln
(
",ep:%d,clu:0x%04X,attr:0x%04X,dataType=0x%02x,len=%d,data:"
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
);
EP
,
clusterId
,
attributeId
,
dataType
,
len
);
emberAfDebugPrintBuffer
(
data
,
len
,
true
);
emberAfDebugPrintBuffer
(
data
,
len
,
true
);
//rpc_eui64ToString(eui64,macString);
//rpc_eui64ToString(eui64,macString);
dev
=
kk_device_find_by_mac
(
eui64
);
dev
=
kk_device_find_by_mac
(
eui64
);
if
(
dev
==
NULL
){
if
(
dev
==
NULL
){
return
;
return
;
}
}
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
if
(
dev_info
==
NULL
){
if
(
dev_info
==
NULL
){
return
;
return
;
}
}
item
=
&
dev_info
->
item
;
item
=
&
dev_info
->
item
;
while
(
item
!=
NULL
){
while
(
item
!=
NULL
){
if
(
EP
==
item
->
endpoint
&&
if
(
EP
==
item
->
endpoint
&&
clusterId
==
item
->
cluster
&&
clusterId
==
item
->
cluster
&&
attributeId
==
item
->
attribute
){
attributeId
==
item
->
attribute
){
func
=
item
->
reportFunc
;
func
=
item
->
reportFunc
;
if
(
func
!=
NULL
){
if
(
func
!=
NULL
){
func
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
func
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
}
else
{
}
else
{
}
}
return
;
return
;
}
}
item
=
item
->
next
;
item
=
item
->
next
;
}
}
}
}
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
)
{
{
uint8_t
OnOff
;
uint8_t
OnOff
;
emberAfAppPrintln
(
"[tsl report:Gloabl] OnOff~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Gloabl] OnOff~~~~~~~~~"
);
if
(
dataType
==
ZCL_BOOLEAN_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_BOOLEAN_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
OnOff
=
data
[
0
];
OnOff
=
data
[
0
];
if
(
OnOff
==
0
||
OnOff
==
1
){
if
(
OnOff
==
0
||
OnOff
==
1
){
kk_tsl_report
(
eui64
,
EP
,
OnOff
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
OnOff
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_val
;
return
tsl_rpt_invaild_val
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
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
)
{
{
uint8_t
mode
;
uint8_t
mode
;
emberAfAppPrintln
(
"[tsl report:Window Covering] Mode~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Window Covering] Mode~~~~~~~~~"
);
if
(
dataType
==
ZCL_BITMAP8_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_BITMAP8_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
if
(
data
[
0
]
&
BIT
(
1
)){
if
(
data
[
0
]
&
BIT
(
1
)){
mode
=
WC_calibration_mode
;
mode
=
WC_calibration_mode
;
}
else
if
(
data
[
0
]
&
BIT
(
0
)){
}
else
if
(
data
[
0
]
&
BIT
(
0
)){
mode
=
WC_reversed_dir
;
mode
=
WC_reversed_dir
;
}
else
{
}
else
{
mode
=
WC_normal_dir
;
mode
=
WC_normal_dir
;
}
}
kk_tsl_report
(
eui64
,
EP
,
mode
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
mode
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
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
)
{
{
uint8_t
position
;
uint8_t
position
;
emberAfAppPrintln
(
"[tsl report:Window Covering] Position~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Window Covering] Position~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
position
=
data
[
0
];
position
=
data
[
0
];
kk_tsl_report
(
eui64
,
EP
,
position
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
position
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_metering_summationDelivered
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_metering_summationDelivered
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
uint64_t
summation
;
uint64_t
summation
;
emberAfAppPrintln
(
"[tsl report:meter(Smart Energy)] Summation Delivered~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:meter(Smart Energy)] Summation Delivered~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT48U_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT48U_ATTRIBUTE_TYPE
){
if
(
len
==
6
){
if
(
len
==
6
){
summation
=
KK_GET_U48
(
data
);
summation
=
KK_GET_U48
(
data
);
kk_tsl_report
(
eui64
,
EP
,
summation
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
summation
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_ias_zoneStatus
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_ias_zoneStatus
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
uint64_t
Status
;
uint64_t
Status
;
emberAfAppPrintln
(
"[tsl report:IAS] Zone Status~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:IAS] Zone Status~~~~~~~~~"
);
if
(
dataType
==
ZCL_BITMAP16_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_BITMAP16_ATTRIBUTE_TYPE
){
if
(
len
==
2
){
if
(
len
==
2
){
Status
=
KK_GET_U16
(
data
);
Status
=
KK_GET_U16
(
data
);
kk_tsl_report
(
eui64
,
EP
,
Status
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
Status
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_global_Level
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_global_Level
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
uint8_t
level
;
uint8_t
level
;
emberAfAppPrintln
(
"[tsl report:Gloabl] Level~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Gloabl] Level~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
level
=
data
[
0
];
level
=
data
[
0
];
kk_tsl_report
(
eui64
,
EP
,
level
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
level
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_temperature_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_temperature_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
int16_t
Value
;
int16_t
Value
;
emberAfAppPrintln
(
"[tsl report:temperature measurement] Measure Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:temperature measurement] Measure Value~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT16S_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT16S_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
Value
=
KK_GET_U16
(
data
);
Value
=
KK_GET_U16
(
data
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_illuminance_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_illuminance_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
uint16_t
Value
;
uint16_t
Value
;
emberAfAppPrintln
(
"[tsl report:illuminance measurement] Measure Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:illuminance measurement] Measure Value~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT16U_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT16U_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
Value
=
KK_GET_U16
(
data
);
Value
=
KK_GET_U16
(
data
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_local_temperature
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_local_temperature
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
int16_t
Value
;
int16_t
Value
;
emberAfAppPrintln
(
"[tsl report:local temperature] Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:local temperature] Value~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT16S_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT16S_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
Value
=
KK_GET_U16
(
data
);
Value
=
KK_GET_U16
(
data
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_OccupiedHeatingSetpoint
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_OccupiedHeatingSetpoint
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
int16_t
Value
;
int16_t
Value
;
emberAfAppPrintln
(
"[tsl report:Occupied Heating Setpoint] Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Occupied Heating Setpoint] Value~~~~~~~~~"
);
if
(
dataType
==
ZCL_INT16S_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT16S_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
Value
=
KK_GET_U16
(
data
);
Value
=
KK_GET_U16
(
data
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_Concentration
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_Concentration
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
int32_t
Value
;
int32_t
Value
;
emberAfAppPrintln
(
"[tsl report:Formaldehyde] Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Formaldehyde] Value~~~~~~~~~"
);
if
(
dataType
==
ZCL_FLOAT_SINGLE_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_FLOAT_SINGLE_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
Value
=
KK_GET_U32
(
data
);
Value
=
KK_GET_U32
(
data
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
Value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
int
kk_tsl_report_Formaldehyde
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_Formaldehyde
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
emberAfAppPrintln
(
"[tsl report:Formaldehyde] Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:Formaldehyde] Value~~~~~~~~~"
);
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
}
}
int
kk_tsl_report_PM2_5
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_PM2_5
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
emberAfAppPrintln
(
"[tsl report:PM2.5] Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:PM2.5] Value~~~~~~~~~"
);
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
}
}
int
kk_tsl_report_CO2
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_CO2
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
emberAfAppPrintln
(
"[tsl report:CO2] Value~~~~~~~~~"
);
emberAfAppPrintln
(
"[tsl report:CO2] Value~~~~~~~~~"
);
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
}
}
int
kk_tsl_report_colorControl_Brightness
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_colorControl_Brightness
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
uint8_t
value
=
data
[
0
];
uint8_t
value
=
data
[
0
];
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_Brightness] value:%d
\n
"
,
value
);
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_Brightness] value:%d
\n
"
,
value
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
if
(
len
==
1
){
kk_tsl_report
(
eui64
,
EP
,
value
,
clusterId
,
attributeId
);
kk_tsl_report
(
eui64
,
EP
,
value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
return
tsl_rpt_invaild_len
;
return
tsl_rpt_invaild_len
;
}
}
return
tsl_rpt_invaild_type
;
return
tsl_rpt_invaild_type
;
}
}
static
int
s_HSLCount
=
0
;
static
int
s_HSLCount
=
0
;
COLOR_HSL
g_hsl
=
{
0
,
0
,
0
};
COLOR_HSL
g_hsl
=
{
0
,
0
,
0
};
int
kk_tsl_report_colorControl_RGB
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
int
kk_tsl_report_colorControl_RGB
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
)
{
{
uint8_t
value
=
data
[
0
];
uint8_t
value
=
data
[
0
];
kk_device_table_s
*
dev
;
kk_device_table_s
*
dev
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
cJSON
*
root
;
cJSON
*
root
;
int
rev
=
0
;
int
rev
=
0
;
int
startIdx
=
0
;
int
startIdx
=
0
;
cJSON
*
root_color
=
NULL
;
cJSON
*
root_color
=
NULL
;
char
tmp_Identity
[
64
]
=
{
0
};
char
tmp_Identity
[
64
]
=
{
0
};
COLOR_RGB
g_rgb
=
{
0
,
0
,
0
};
COLOR_RGB
g_rgb
=
{
0
,
0
,
0
};
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_RGB] value:%d
\n
"
,
value
);
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_RGB] value:%d
\n
"
,
value
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
attributeId
==
0x0001
){
if
(
attributeId
==
0x0001
){
g_hsl
.
saturation
=
value
;
g_hsl
.
saturation
=
value
;
s_HSLCount
++
;
s_HSLCount
++
;
}
}
else
if
(
attributeId
==
0x0
){
else
if
(
attributeId
==
0x0
){
g_hsl
.
hue
=
value
;
g_hsl
.
hue
=
value
;
s_HSLCount
++
;
s_HSLCount
++
;
}
}
}
}
if
(
s_HSLCount
>=
2
){
if
(
s_HSLCount
>=
2
){
s_HSLCount
=
0
;
s_HSLCount
=
0
;
HSLtoRGB
(
&
g_hsl
,
&
g_rgb
);
HSLtoRGB
(
&
g_hsl
,
&
g_rgb
);
dev
=
kk_device_find_by_mac
(
eui64
);
dev
=
kk_device_find_by_mac
(
eui64
);
if
(
dev
==
NULL
){
if
(
dev
==
NULL
){
return
tsl_rpt_err
;
return
tsl_rpt_err
;
}
}
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
if
(
dev_info
==
NULL
){
if
(
dev_info
==
NULL
){
return
tsl_rpt_err
;
return
tsl_rpt_err
;
}
}
item
=
&
dev_info
->
item
;
item
=
&
dev_info
->
item
;
while
(
item
!=
NULL
){
while
(
item
!=
NULL
){
if
(
strstr
(
item
->
identity
,
".red"
)
!=
NULL
){
if
(
strstr
(
item
->
identity
,
".red"
)
!=
NULL
){
if
(
root_color
==
NULL
){
if
(
root_color
==
NULL
){
root_color
=
rpc_cJSON_CreateObject
();
root_color
=
rpc_cJSON_CreateObject
();
}
}
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
if
(
!
rev
){
if
(
!
rev
){
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
red
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
red
);
}
}
}
}
else
if
(
strstr
(
item
->
identity
,
".green"
)
!=
NULL
){
else
if
(
strstr
(
item
->
identity
,
".green"
)
!=
NULL
){
if
(
root_color
==
NULL
){
if
(
root_color
==
NULL
){
root_color
=
rpc_cJSON_CreateObject
();
root_color
=
rpc_cJSON_CreateObject
();
}
}
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
if
(
!
rev
){
if
(
!
rev
){
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
green
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
green
);
}
}
}
}
else
if
(
strstr
(
item
->
identity
,
".blue"
)
!=
NULL
){
else
if
(
strstr
(
item
->
identity
,
".blue"
)
!=
NULL
){
if
(
root_color
==
NULL
){
if
(
root_color
==
NULL
){
root_color
=
rpc_cJSON_CreateObject
();
root_color
=
rpc_cJSON_CreateObject
();
}
}
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
if
(
!
rev
){
if
(
!
rev
){
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
blue
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
blue
);
}
}
}
}
item
=
item
->
next
;
item
=
item
->
next
;
}
}
if
(
root_color
!=
NULL
){
if
(
root_color
!=
NULL
){
root
=
rpc_cJSON_CreateObject
();
root
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
root_color
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
root_color
);
kk_msg_report_property
(
root
,
eui64
);
kk_msg_report_property
(
root
,
eui64
);
return
tsl_rpt_success
;
return
tsl_rpt_success
;
}
}
}
}
return
tsl_rpt_err
;
return
tsl_rpt_err
;
}
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
View file @
a615faf9
#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_zb_com.h"
#include "kk_zb_com.h"
#include "kk_msg_report.h"
#include "kk_msg_report.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_ias_zoneStatus
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_ias_zoneStatus
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_metering_summationDelivered
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_metering_summationDelivered
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_global_Level
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_global_Level
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_temperature_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_temperature_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_illuminance_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_illuminance_measure
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_local_temperature
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_local_temperature
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_OccupiedHeatingSetpoint
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_OccupiedHeatingSetpoint
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_Formaldehyde
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_Formaldehyde
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_PM2_5
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_PM2_5
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_CO2
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_CO2
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_colorControl_Brightness
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_colorControl_Brightness
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_colorControl_RGB
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
int
kk_tsl_report_colorControl_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_zigbee_api.c
View file @
a615faf9
...
@@ -1417,3 +1417,502 @@ EmberStatus zclThermostat_GetRelayStatusLog(uint16_t node,
...
@@ -1417,3 +1417,502 @@ EmberStatus zclThermostat_GetRelayStatusLog(uint16_t node,
/*********************************************************************************************/
EmberStatus
zone_enroll_response_command
(
uint16_t
node
,
uint8_t
ep
,
EnrollResponseCode
code
,
uint8_t
id
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ZONE_CLUSTER_ID
,
ZCL_ZONE_ENROLL_RESPONSE_COMMAND_ID
);
zclBufferAddByte
(
code
);
zclBufferAddByte
(
id
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[zone_enroll_response_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
initiate_normal_operation_mode_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ZONE_CLUSTER_ID
,
ZCL_INITIATE_NORMAL_OPERATION_MODE_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[initiate_normal_operation_mode_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
initiate_test_mode_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
duration
,
uint8_t
level
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ZONE_CLUSTER_ID
,
ZCL_INITIATE_TEST_MODE_COMMAND_ID
);
zclBufferAddByte
(
duration
);
zclBufferAddByte
(
level
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[initiate_test_mode_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
zone_status_change_notification
(
uint16_t
node
,
uint8_t
ep
,
uint16_t
zoneStatus
,
uint8_t
extStatus
,
uint8_t
id
,
uint16_t
delay
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ZONE_CLUSTER_ID
,
ZCL_ZONE_STATUS_CHANGE_NOTIFICATION_COMMAND_ID
);
zclBufferAddWord
(
zoneStatus
);
zclBufferAddByte
(
extStatus
);
zclBufferAddByte
(
id
);
zclBufferAddWord
(
delay
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[zone_status_change_notification] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
zone_enroll_request_command
(
uint16_t
node
,
uint8_t
ep
,
uint16_t
type
,
uint16_t
code
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ZONE_CLUSTER_ID
,
ZCL_ZONE_ENROLL_REQUEST_COMMAND_ID
);
zclBufferAddWord
(
type
);
zclBufferAddWord
(
code
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[zone_enroll_request_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
///////////////////////////
EmberStatus
arm_command
(
uint16_t
node
,
uint8_t
ep
,
ArmMode
mode
,
char
*
code
,
uint8_t
id
)
{
int
i
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_ARM_COMMAND_ID
);
zclBufferAddByte
(
mode
);
for
(
i
=
0
;
i
<
strlen
(
code
);
i
++
){
zclBufferAddByte
(
code
[
i
]);
}
zclBufferAddByte
(
id
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[arm_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
bypass_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
num
,
uint8_t
*
id
,
char
*
code
)
{
int
i
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_BYPASS_COMMAND_ID
);
zclBufferAddByte
(
num
);
for
(
i
=
0
;
i
<
num
;
i
++
){
zclBufferAddByte
(
id
[
i
]);
}
for
(
i
=
0
;
i
<
strlen
(
code
);
i
++
){
zclBufferAddByte
(
code
[
i
]);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[bypass_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
emergency_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_EMERGENCY_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[emergency_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
fire_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_FIRE_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[fire_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
panic_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_PANIC_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[panic_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_zone_id_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_ZONE_ID_MAP_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_zone_id_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_zone_information_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_ZONE_INFORMATION_COMMAND_ID
);
zclBufferAddByte
(
id
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_zone_information_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_panel_status_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_PANEL_STATUS_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_panel_status_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_bypassed_zone_list_command
(
uint16_t
node
,
uint8_t
ep
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_BYPASSED_ZONE_LIST_COMMAND_ID
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_bypassed_zone_list_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_zone_status_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
statrId
,
uint8_t
maxNum
,
bool
flag
,
uint16_t
mask
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_ZONE_STATUS_COMMAND_ID
);
zclBufferAddByte
(
statrId
);
zclBufferAddByte
(
maxNum
);
zclBufferAddByte
(
flag
);
zclBufferAddWord
(
mask
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_zone_status_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
arm_response
(
uint16_t
node
,
uint8_t
ep
,
ArmNotification
arm
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_ARM_RESPONSE_COMMAND_ID
);
zclBufferAddByte
(
arm
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[arm_response] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_zone_id_map_response
(
uint16_t
node
,
uint8_t
ep
,
uint16_t
*
map
)
//16
{
int
i
=
0
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_ZONE_ID_MAP_RESPONSE_COMMAND_ID
);
for
(
int
i
=
0
;
i
<
16
;
i
++
){
zclBufferAddWord
(
map
[
i
]);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_zone_id_map_response] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_zone_information_response
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
,
uint16_t
type
,
uint8_t
*
ieee
,
char
*
label
)
{
int
i
=
0
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_ZONE_INFORMATION_RESPONSE_COMMAND_ID
);
zclBufferAddByte
(
id
);
zclBufferAddWord
(
type
);
for
(;
i
<
8
;
i
++
){
zclBufferAddByte
(
ieee
[
i
]);
}
for
(
i
=
0
;
i
<
strlen
(
label
);
i
++
){
zclBufferAddByte
(
label
[
i
]);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_zone_information_response] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
zone_status_changed
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
,
uint16_t
zonestatus
,
uint8_t
audible
,
char
*
label
)
{
int
i
=
0
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_ZONE_STATUS_CHANGED_COMMAND_ID
);
zclBufferAddByte
(
id
);
zclBufferAddWord
(
zonestatus
);
zclBufferAddByte
(
audible
);
for
(
i
=
0
;
i
<
strlen
(
label
);
i
++
){
zclBufferAddByte
(
label
[
i
]);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[zone_status_changed] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
panel_status_changed
(
uint16_t
node
,
uint8_t
ep
,
PanelStatus
panel
,
uint8_t
remain
,
uint8_t
audible
,
AlarmStatus
alarm
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_PANEL_STATUS_CHANGED_COMMAND_ID
);
zclBufferAddByte
(
panel
);
zclBufferAddByte
(
remain
);
zclBufferAddByte
(
audible
);
zclBufferAddByte
(
alarm
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[panel_status_changed] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_panel_status_response
(
uint16_t
node
,
uint8_t
ep
,
PanelStatus
panel
,
uint8_t
remain
,
uint8_t
audible
,
AlarmStatus
alarm
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_PANEL_STATUS_RESPONSE_COMMAND_ID
);
zclBufferAddByte
(
panel
);
zclBufferAddByte
(
remain
);
zclBufferAddByte
(
audible
);
zclBufferAddByte
(
alarm
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_panel_status_response] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
set_bypassed_zone_list
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
num
,
uint8_t
*
id
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_SET_BYPASSED_ZONE_LIST_COMMAND_ID
);
zclBufferAddByte
(
num
);
for
(
int
i
=
0
;
i
<
num
;
i
++
){
zclBufferAddByte
(
id
[
i
]);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[set_bypassed_zone_list] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
bypass_response
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
num
,
BypassResult
*
id
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_BYPASS_RESPONSE_COMMAND_ID
);
zclBufferAddByte
(
num
);
for
(
int
i
=
0
;
i
<
num
;
i
++
){
zclBufferAddByte
(
id
[
i
]);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[bypass_response] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
get_zone_status_response
(
uint16_t
node
,
uint8_t
ep
,
bool
complete
,
uint8_t
num
,
ZoneStatus_s
**
ZoneStatus
)
{
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_ACE_CLUSTER_ID
,
ZCL_GET_ZONE_STATUS_RESPONSE_COMMAND_ID
);
zclBufferAddByte
(
complete
);
zclBufferAddByte
(
num
);
for
(
int
i
=
0
;
i
<
num
;
i
++
){
zclBufferAddByte
(
ZoneStatus
[
i
]
->
zoneId
);
zclBufferAddWord
(
ZoneStatus
[
i
]
->
zoneStatus
);
}
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[get_zone_status_response] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
start_warning
(
uint16_t
node
,
uint8_t
ep
,
WarningModes
mode
,
StrobeField
strobe
,
SirenLevel
siren
,
uint16_t
duration
,
uint8_t
cycle
,
StrobeLevel
level
)
{
uint8_t
map
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_WD_CLUSTER_ID
,
ZCL_START_WARNING_COMMAND_ID
);
map
=
(
mode
<<
4
)
|
(
strobe
<<
2
)
|
siren
;
zclBufferAddByte
(
map
);
zclBufferAddWord
(
duration
);
zclBufferAddByte
(
cycle
);
zclBufferAddByte
(
level
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[start_warning] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
EmberStatus
squawk_command
(
uint16_t
node
,
uint8_t
ep
,
WarningModes
mode
,
StrobeField
strobe
,
SquawkModeField
squawk
)
{
uint8_t
map
;
EmberStatus
status
;
zcl_clu_client_cmd_buffer_setup
(
ZCL_IAS_WD_CLUSTER_ID
,
ZCL_SQUAWK_COMMAND_ID
);
map
=
(
mode
<<
4
)
|
(
strobe
<<
3
)
|
squawk
;
zclBufferAddByte
(
map
);
status
=
rpcSendCommand
(
node
,
1
,
ep
,
false
);
emberAfCorePrintln
(
"[squawk_command] status:0x%02x
\r\n
"
,
status
);
return
status
;
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
a615faf9
...
@@ -40,6 +40,96 @@ kk_rpc_report_api_s kk_rpc_report_api[];
...
@@ -40,6 +40,96 @@ kk_rpc_report_api_s kk_rpc_report_api[];
uint8_t
kk_get_rpc_set_api_size
(
void
);
uint8_t
kk_get_rpc_set_api_size
(
void
);
uint8_t
kk_get_rpc_report_api_size
(
void
);
uint8_t
kk_get_rpc_report_api_size
(
void
);
typedef
enum
{
EnrollResponseCode_Success
=
0x00
,
EnrollResponseCode_NoSupported
=
0x01
,
EnrollResponseCode_NoEnrollPermit
=
0x02
,
EnrollResponseCode_TooManyZones
=
0x03
,
}
EnrollResponseCode
;
typedef
enum
{
ArmMode_Disarm
=
0x00
,
ArmMode_ArmDayOrHomeZonesOnly
=
0x01
,
ArmMode_ArmNightOrSleepZonesOnly
=
0x02
,
ArmMode_ArmAllZones
=
0x03
,
}
ArmMode
;
typedef
enum
{
ArmNotification_AllZonesDisarmed
=
0x01
,
ArmNotification_OnlyDayOrHomeZonesArmed
=
0x02
,
ArmNotification_OnlyNightOrSleepZonesArmed
=
0x03
,
ArmNotification_AllZonesArmed
=
0x04
,
ArmNotification_InvalidArmOrDisarmCode
=
0x05
,
ArmNotification_NotReadyToArm
=
0x06
,
ArmNotification_AlreadyDisarmed
}
ArmNotification
;
typedef
enum
{
PanelStatus_PanelDisarmedAndReadyToArm
=
0x00
,
PanelStatus_ArmedStay
=
0x01
,
PanelStatus_ArmedNight
=
0x02
,
PanelStatus_ArmedAway
=
0x03
,
PanelStatus_ExitDelay
=
0x04
,
PanelStatus_EntryDelay
=
0x05
,
PanelStatus_NotReadyToArm
=
0x06
,
PanelStatus_InAlarm
=
0x07
,
PanelStatus_ArmingStay
=
0x08
,
PanelStatus_ArmingNight
=
0x09
,
PanelStatus_ArmingAway
=
0x0a
,
}
PanelStatus
;
typedef
enum
{
AlarmStatus_NoAlarm
=
0x00
,
AlarmStatus_Burglar
=
0x01
,
AlarmStatus_Fire
=
0x02
,
AlarmStatus_Emergency
=
0x03
,
AlarmStatus_PolicePanic
=
0x04
,
AlarmStatus_FirePanic
=
0x05
,
AlarmStatus_EmergencyPanic
=
0x06
,
}
AlarmStatus
;
typedef
enum
{
BypassResult_ZoneBypassed
=
0x00
,
BypassResult_ZoneNotBypassed
=
0x01
,
BypassResult_NotAllowed
=
0x02
,
BypassResult_InvalidZoneID
=
0x03
,
BypassResult_UnknownZoneID
=
0x04
,
BypassResult_InvalidArmOrDisarmCode
=
0x05
,
}
BypassResult
;
typedef
struct
{
uint8_t
zoneId
;
uint16_t
zoneStatus
;
}
ZoneStatus_s
;
typedef
enum
{
WarningModes_Stop
=
0x00
,
WarningModes_Burglar
=
0x01
,
WarningModes_Fire
=
0x02
,
WarningModes_Emergency
=
0x03
,
WarningModes_PolicePanic
=
0x04
,
WarningModes_FirePanic
=
0x05
,
WarningModes_EmergencyPanic
=
0x06
,
}
WarningModes
;
typedef
enum
{
StrobeField_NoStrobe
=
0x00
,
StrobeField_UseStrobe
=
0x01
,
}
StrobeField
;
typedef
enum
{
SirenLevel_LowLevelSound
=
0x00
,
SirenLevel_MediumLevelSound
=
0x01
,
SirenLevel_HighLevelSound
=
0x02
,
SirenLevel_VeryHighLevelSound
=
0x03
,
}
SirenLevel
;
typedef
enum
{
StrobeLevel_LowLevelSound
=
0x00
,
StrobeLevel_MediumLevelSound
=
0x01
,
StrobeLevel_HighLevelSound
=
0x02
,
StrobeLevel_VeryHighLevelSound
=
0x03
,
}
StrobeLevel
;
typedef
enum
{
SquawkModeField_Arm
=
0x00
,
SquawkModeField_Disarmed
=
0x01
,
}
SquawkModeField
;
EmberStatus
kk_network_leave
(
void
);
EmberStatus
kk_network_leave
(
void
);
...
@@ -418,4 +508,115 @@ EmberStatus zclThermostat_GetRelayStatusLog(uint16_t node,
...
@@ -418,4 +508,115 @@ EmberStatus zclThermostat_GetRelayStatusLog(uint16_t node,
uint8_t
ep
);
uint8_t
ep
);
//IAS
EmberStatus
arm_command
(
uint16_t
node
,
uint8_t
ep
,
ArmMode
mode
,
char
*
code
,
uint8_t
id
);
EmberStatus
bypass_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
num
,
uint8_t
*
id
,
char
*
code
);
EmberStatus
emergency_command
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
fire_command
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
panic_command
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
get_zone_id_command
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
get_zone_information_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
);
EmberStatus
get_panel_status_command
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
get_bypassed_zone_list_command
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
get_zone_status_command
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
statrId
,
uint8_t
maxNum
,
bool
flag
,
uint16_t
mask
);
EmberStatus
arm_response
(
uint16_t
node
,
uint8_t
ep
,
ArmNotification
arm
);
EmberStatus
get_zone_id_map_response
(
uint16_t
node
,
uint8_t
ep
,
uint16_t
*
map
);
//16
EmberStatus
get_zone_information_response
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
,
uint16_t
type
,
uint8_t
*
ieee
,
char
*
label
);
EmberStatus
zone_status_changed
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
,
uint16_t
zonestatus
,
uint8_t
audible
,
char
*
label
);
EmberStatus
panel_status_changed
(
uint16_t
node
,
uint8_t
ep
,
PanelStatus
panel
,
uint8_t
remain
,
uint8_t
audible
,
AlarmStatus
alarm
);
EmberStatus
get_panel_status_response
(
uint16_t
node
,
uint8_t
ep
,
PanelStatus
panel
,
uint8_t
remain
,
uint8_t
audible
,
AlarmStatus
alarm
);
EmberStatus
set_bypassed_zone_list
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
num
,
uint8_t
*
id
);
EmberStatus
bypass_response
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
num
,
BypassResult
*
id
);
EmberStatus
get_zone_status_response
(
uint16_t
node
,
uint8_t
ep
,
bool
complete
,
uint8_t
num
,
ZoneStatus_s
**
ZoneStatus
);
EmberStatus
start_warning
(
uint16_t
node
,
uint8_t
ep
,
WarningModes
mode
,
StrobeField
strobe
,
SirenLevel
siren
,
uint16_t
duration
,
uint8_t
cycle
,
StrobeLevel
level
);
EmberStatus
squawk_command
(
uint16_t
node
,
uint8_t
ep
,
WarningModes
mode
,
StrobeField
strobe
,
SquawkModeField
squawk
);
#endif
#endif
platform/zigbee/protocol/zigbee/app/framework/plugin/device-table/device-table.c
View file @
a615faf9
// Copyright 2016 Silicon Laboratories, Inc. *80*
// Copyright 2016 Silicon Laboratories, Inc. *80*
#include PLATFORM_HEADER
#include PLATFORM_HEADER
#ifdef EZSP_HOST
#ifdef EZSP_HOST
// Includes needed for functions related to the EZSP host
// Includes needed for functions related to the EZSP host
#include "stack/include/error.h"
#include "stack/include/error.h"
#include "stack/include/ember-types.h"
#include "stack/include/ember-types.h"
#include "app/util/ezsp/ezsp-protocol.h"
#include "app/util/ezsp/ezsp-protocol.h"
#include "app/util/ezsp/ezsp.h"
#include "app/util/ezsp/ezsp.h"
#include "app/util/ezsp/serial-interface.h"
#include "app/util/ezsp/serial-interface.h"
#include "app/util/zigbee-framework/zigbee-device-common.h"
#include "app/util/zigbee-framework/zigbee-device-common.h"
#else
#else
#include "stack/include/ember.h"
#include "stack/include/ember.h"
#endif
#endif
#include "af.h"
#include "af.h"
#include "af-main.h"
#include "af-main.h"
#include "attribute-storage.h"
#include "attribute-storage.h"
#include "common.h"
#include "common.h"
#include "hal/hal.h"
#include "hal/hal.h"
#include "app/util/serial/command-interpreter2.h"
#include "app/util/serial/command-interpreter2.h"
#include "stack/include/event.h"
#include "stack/include/event.h"
#include "app/framework/plugin/concentrator/source-route-host.h"
#include "app/framework/plugin/concentrator/source-route-host.h"
#include "app/framework/plugin/device-table/device-table.h"
#include "app/framework/plugin/device-table/device-table.h"
#include "app/framework/plugin/device-table/device-table-internal.h"
#include "app/framework/plugin/device-table/device-table-internal.h"
#include "app/framework/util/util.h"
#include "app/framework/util/util.h"
#include <stdlib.h>
#include <stdlib.h>
#include <kk_test.h>
#include <kk_test.h>
void
emAfDeviceTableSave
(
void
);
void
emAfDeviceTableSave
(
void
);
void
emAfDeviceTableLoad
(
void
);
void
emAfDeviceTableLoad
(
void
);
// Framework message send global data
// Framework message send global data
extern
uint8_t
appZclBuffer
[];
extern
uint8_t
appZclBuffer
[];
extern
uint16_t
appZclBufferLen
;
extern
uint16_t
appZclBufferLen
;
extern
bool
zclCmdIsBuilt
;
extern
bool
zclCmdIsBuilt
;
extern
EmberApsFrame
globalApsFrame
;
extern
EmberApsFrame
globalApsFrame
;
extern
void
emAfApsFrameEndpointSetup
(
uint8_t
srcEndpoint
,
extern
void
emAfApsFrameEndpointSetup
(
uint8_t
srcEndpoint
,
uint8_t
dstEndpoint
);
uint8_t
dstEndpoint
);
static
EmberAfPluginDeviceTableEntry
deviceTable
[
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
];
static
EmberAfPluginDeviceTableEntry
deviceTable
[
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
];
EmberStatus
emberAfGetChildData
(
uint8_t
index
,
EmberStatus
emberAfGetChildData
(
uint8_t
index
,
EmberChildData
*
childData
);
EmberChildData
*
childData
);
// Device discovery global declarations
// Device discovery global declarations
void
emAfDeviceTableInitiateRouteRepair
(
EmberNodeId
nodeId
);
void
emAfDeviceTableInitiateRouteRepair
(
EmberNodeId
nodeId
);
static
void
clearDeviceTableIndex
(
uint16_t
index
);
static
void
clearDeviceTableIndex
(
uint16_t
index
);
EmberAfPluginDeviceTableEntry
*
emberAfDeviceTablePointer
(
void
)
EmberAfPluginDeviceTableEntry
*
emberAfDeviceTablePointer
(
void
)
{
{
return
deviceTable
;
return
deviceTable
;
}
}
uint16_t
emberAfDeviceTableGetNodeIdFromIndex
(
uint16_t
index
)
uint16_t
emberAfDeviceTableGetNodeIdFromIndex
(
uint16_t
index
)
{
{
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
return
deviceTable
[
index
].
nodeId
;
return
deviceTable
[
index
].
nodeId
;
}
}
uint8_t
emAfDeviceTableGetFirstEndpointFromIndex
(
uint16_t
index
)
uint8_t
emAfDeviceTableGetFirstEndpointFromIndex
(
uint16_t
index
)
{
{
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
return
deviceTable
[
index
].
endpoint
;
return
deviceTable
[
index
].
endpoint
;
}
}
static
void
matchReverseEui64
(
EmberEUI64
eui64a
,
EmberEUI64
eui64b
)
static
void
matchReverseEui64
(
EmberEUI64
eui64a
,
EmberEUI64
eui64b
)
{
{
uint8_t
i
;
uint8_t
i
;
for
(
i
=
0
;
i
<
EUI64_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EUI64_SIZE
;
i
++
)
{
if
(
eui64a
[
i
]
!=
eui64b
[(
EUI64_SIZE
-
1
)
-
i
])
{
if
(
eui64a
[
i
]
!=
eui64b
[(
EUI64_SIZE
-
1
)
-
i
])
{
return
;
return
;
}
}
}
}
emberAfCorePrintln
(
"MATCH_EUI: EUI matches backwards"
);
emberAfCorePrintln
(
"MATCH_EUI: EUI matches backwards"
);
emberAfCorePrint
(
"A:"
);
emberAfCorePrint
(
"A:"
);
emAfDeviceTablePrintEUI64
(
eui64a
);
emAfDeviceTablePrintEUI64
(
eui64a
);
emberAfCorePrint
(
" B:"
);
emberAfCorePrint
(
" B:"
);
emAfDeviceTablePrintEUI64
(
eui64b
);
emAfDeviceTablePrintEUI64
(
eui64b
);
emberAfCorePrintln
(
""
);
emberAfCorePrintln
(
""
);
}
}
static
void
checkNullEui64
(
EmberEUI64
eui64a
,
EmberEUI64
eui64b
)
static
void
checkNullEui64
(
EmberEUI64
eui64a
,
EmberEUI64
eui64b
)
{
{
uint8_t
i
;
uint8_t
i
;
for
(
i
=
0
;
i
<
EUI64_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EUI64_SIZE
;
i
++
)
{
if
(
eui64a
[
i
]
!=
0xff
if
(
eui64a
[
i
]
!=
0xff
||
eui64b
[
i
]
!=
0xff
)
{
||
eui64b
[
i
]
!=
0xff
)
{
return
;
return
;
}
}
}
}
emberAfCorePrintln
(
"MatchEUI: two null EUI"
);
emberAfCorePrintln
(
"MatchEUI: two null EUI"
);
}
}
static
bool
matchEui64
(
EmberEUI64
a
,
EmberEUI64
b
)
static
bool
matchEui64
(
EmberEUI64
a
,
EmberEUI64
b
)
{
{
checkNullEui64
(
a
,
b
);
checkNullEui64
(
a
,
b
);
if
(
MEMCOMPARE
(
a
,
b
,
EUI64_SIZE
)
==
0
)
{
if
(
MEMCOMPARE
(
a
,
b
,
EUI64_SIZE
)
==
0
)
{
return
true
;
return
true
;
}
else
{
}
else
{
// Test to see if the EUI64 is backwards
// Test to see if the EUI64 is backwards
matchReverseEui64
(
a
,
b
);
matchReverseEui64
(
a
,
b
);
return
false
;
return
false
;
}
}
}
}
bool
emberAfDeviceTableMatchEui64
(
EmberEUI64
eui64a
,
EmberEUI64
eui64b
)
bool
emberAfDeviceTableMatchEui64
(
EmberEUI64
eui64a
,
EmberEUI64
eui64b
)
{
{
return
matchEui64
(
eui64a
,
eui64b
);
return
matchEui64
(
eui64a
,
eui64b
);
}
}
static
void
unsetEui64
(
EmberEUI64
eui64
)
static
void
unsetEui64
(
EmberEUI64
eui64
)
{
{
uint8_t
i
;
uint8_t
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
eui64
[
i
]
=
0xff
;
eui64
[
i
]
=
0xff
;
}
}
}
}
static
void
clearDeviceTableIndex
(
uint16_t
index
)
static
void
clearDeviceTableIndex
(
uint16_t
index
)
{
{
uint8_t
i
;
uint8_t
i
;
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
deviceTable
[
index
].
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
deviceTable
[
index
].
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
unsetEui64
(
deviceTable
[
index
].
eui64
);
unsetEui64
(
deviceTable
[
index
].
eui64
);
deviceTable
[
index
].
state
=
EMBER_AF_PLUGIN_DEVICE_TABLE_STATE_NULL
;
deviceTable
[
index
].
state
=
EMBER_AF_PLUGIN_DEVICE_TABLE_STATE_NULL
;
deviceTable
[
index
].
endpoint
=
0
;
deviceTable
[
index
].
endpoint
=
0
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
i
++
)
{
deviceTable
[
index
].
clusterIds
[
i
]
=
ZCL_NULL_CLUSTER_ID
;
deviceTable
[
index
].
clusterIds
[
i
]
=
ZCL_NULL_CLUSTER_ID
;
}
}
deviceTable
[
index
].
clusterOutStartPosition
=
0
;
deviceTable
[
index
].
clusterOutStartPosition
=
0
;
}
}
void
emAfPluginDeviceTableDeleteEntry
(
uint16_t
index
)
void
emAfPluginDeviceTableDeleteEntry
(
uint16_t
index
)
{
{
uint16_t
currentIndex
;
uint16_t
currentIndex
;
while
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
while
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
currentIndex
=
index
;
currentIndex
=
index
;
// Need to compute the next index before deleting the current one. Or else
// Need to compute the next index before deleting the current one. Or else
// the call to next endpoint will yield a bogus result.
// the call to next endpoint will yield a bogus result.
index
=
emAfDeviceTableFindNextEndpoint
(
index
);
index
=
emAfDeviceTableFindNextEndpoint
(
index
);
clearDeviceTableIndex
(
currentIndex
);
clearDeviceTableIndex
(
currentIndex
);
emberAfPluginDeviceTableIndexRemovedCallback
(
currentIndex
);
emberAfPluginDeviceTableIndexRemovedCallback
(
currentIndex
);
}
}
}
}
void
emAfDeviceTableInit
(
void
)
void
emAfDeviceTableInit
(
void
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
clearDeviceTableIndex
(
i
);
clearDeviceTableIndex
(
i
);
}
}
}
}
void
emberAfDeviceTableClear
(
void
)
void
emberAfDeviceTableClear
(
void
)
{
{
emAfDeviceTableInit
();
emAfDeviceTableInit
();
emAfDeviceTableSave
();
emAfDeviceTableSave
();
//emberAfPluginDeviceTableClearedCallback();
//emberAfPluginDeviceTableClearedCallback();
}
}
uint16_t
emberAfDeviceTableGetIndexFromEui64AndEndpoint
(
EmberEUI64
eui64
,
uint16_t
emberAfDeviceTableGetIndexFromEui64AndEndpoint
(
EmberEUI64
eui64
,
uint8_t
endpoint
)
uint8_t
endpoint
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
matchEui64
(
deviceTable
[
i
].
eui64
,
eui64
)
if
(
matchEui64
(
deviceTable
[
i
].
eui64
,
eui64
)
&&
deviceTable
[
i
].
endpoint
==
endpoint
)
{
&&
deviceTable
[
i
].
endpoint
==
endpoint
)
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
uint16_t
emberAfDeviceTableGetNodeIdFromEui64
(
EmberEUI64
eui64
)
uint16_t
emberAfDeviceTableGetNodeIdFromEui64
(
EmberEUI64
eui64
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
matchEui64
(
deviceTable
[
i
].
eui64
,
eui64
)
)
{
if
(
matchEui64
(
deviceTable
[
i
].
eui64
,
eui64
)
)
{
return
deviceTable
[
i
].
nodeId
;
return
deviceTable
[
i
].
nodeId
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
}
}
bool
emberAfDeviceTableGetEui64FromNodeId
(
EmberNodeId
emberNodeId
,
EmberEUI64
eui64
)
bool
emberAfDeviceTableGetEui64FromNodeId
(
EmberNodeId
emberNodeId
,
EmberEUI64
eui64
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
==
emberNodeId
)
{
if
(
deviceTable
[
i
].
nodeId
==
emberNodeId
)
{
MEMCOPY
(
eui64
,
deviceTable
[
i
].
eui64
,
EUI64_SIZE
);
MEMCOPY
(
eui64
,
deviceTable
[
i
].
eui64
,
EUI64_SIZE
);
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
}
}
uint16_t
emberAfDeviceTableGetIndexFromNodeId
(
EmberNodeId
emberNodeId
)
uint16_t
emberAfDeviceTableGetIndexFromNodeId
(
EmberNodeId
emberNodeId
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
==
emberNodeId
)
{
if
(
deviceTable
[
i
].
nodeId
==
emberNodeId
)
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
uint16_t
emAfDeviceTableFindFreeDeviceTableIndex
(
void
)
uint16_t
emAfDeviceTableFindFreeDeviceTableIndex
(
void
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
==
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
if
(
deviceTable
[
i
].
nodeId
==
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
uint16_t
emberAfDeviceTableGetEndpointFromNodeIdAndEndpoint
(
EmberNodeId
emberNodeId
,
uint16_t
emberAfDeviceTableGetEndpointFromNodeIdAndEndpoint
(
EmberNodeId
emberNodeId
,
uint8_t
endpoint
)
uint8_t
endpoint
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
==
emberNodeId
if
(
deviceTable
[
i
].
nodeId
==
emberNodeId
&&
deviceTable
[
i
].
endpoint
==
endpoint
)
{
&&
deviceTable
[
i
].
endpoint
==
endpoint
)
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
void
emAfDeviceTableCopyDeviceTableEntry
(
uint16_t
fromIndex
,
uint16_t
toIndex
)
void
emAfDeviceTableCopyDeviceTableEntry
(
uint16_t
fromIndex
,
uint16_t
toIndex
)
{
{
EmberAfPluginDeviceTableEntry
*
from
=
&
(
deviceTable
[
fromIndex
]);
EmberAfPluginDeviceTableEntry
*
from
=
&
(
deviceTable
[
fromIndex
]);
EmberAfPluginDeviceTableEntry
*
to
=
&
(
deviceTable
[
toIndex
]);
EmberAfPluginDeviceTableEntry
*
to
=
&
(
deviceTable
[
toIndex
]);
// make sure the fromIndex is in the valud range.
// make sure the fromIndex is in the valud range.
assert
(
fromIndex
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
assert
(
fromIndex
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
// make sure the fromIndex has a valid entry
// make sure the fromIndex has a valid entry
assert
(
deviceTable
[
fromIndex
].
nodeId
assert
(
deviceTable
[
fromIndex
].
nodeId
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
);
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
);
// make sure the toIndex is in the valud range.
// make sure the toIndex is in the valud range.
assert
(
toIndex
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
assert
(
toIndex
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
);
MEMCOPY
(
to
,
from
,
sizeof
(
EmberAfPluginDeviceTableEntry
));
MEMCOPY
(
to
,
from
,
sizeof
(
EmberAfPluginDeviceTableEntry
));
}
}
uint8_t
emAfDeviceTableNumberOfEndpointsFromIndex
(
uint16_t
index
)
uint8_t
emAfDeviceTableNumberOfEndpointsFromIndex
(
uint16_t
index
)
{
{
uint8_t
count
=
0
;
uint8_t
count
=
0
;
uint16_t
currentNodeId
=
emberAfDeviceTableGetNodeIdFromIndex
(
index
);
uint16_t
currentNodeId
=
emberAfDeviceTableGetNodeIdFromIndex
(
index
);
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
==
currentNodeId
)
{
if
(
deviceTable
[
i
].
nodeId
==
currentNodeId
)
{
count
++
;
count
++
;
}
}
}
}
return
count
;
return
count
;
}
}
static
uint16_t
findIndexFromNodeIdAndIndex
(
uint16_t
nodeId
,
uint16_t
index
)
static
uint16_t
findIndexFromNodeIdAndIndex
(
uint16_t
nodeId
,
uint16_t
index
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
index
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
index
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
nodeId
==
emberAfDeviceTableGetNodeIdFromIndex
(
i
))
{
if
(
nodeId
==
emberAfDeviceTableGetNodeIdFromIndex
(
i
))
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
static
uint16_t
findIndexFromEui64AndIndex
(
EmberEUI64
eui64
,
uint16_t
index
)
static
uint16_t
findIndexFromEui64AndIndex
(
EmberEUI64
eui64
,
uint16_t
index
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
index
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
index
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
matchEui64
(
eui64
,
deviceTable
[
i
].
eui64
))
{
if
(
matchEui64
(
eui64
,
deviceTable
[
i
].
eui64
))
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
uint16_t
emAfDeviceTableFindFirstEndpointNodeId
(
uint16_t
nodeId
)
uint16_t
emAfDeviceTableFindFirstEndpointNodeId
(
uint16_t
nodeId
)
{
{
return
findIndexFromNodeIdAndIndex
(
nodeId
,
0
);
return
findIndexFromNodeIdAndIndex
(
nodeId
,
0
);
}
}
uint16_t
emAfDeviceTableFindNextEndpoint
(
uint16_t
index
)
uint16_t
emAfDeviceTableFindNextEndpoint
(
uint16_t
index
)
{
{
return
findIndexFromEui64AndIndex
(
deviceTable
[
index
].
eui64
,
return
findIndexFromEui64AndIndex
(
deviceTable
[
index
].
eui64
,
index
+
1
);
index
+
1
);
}
}
uint16_t
emAfDeviceTableFindFirstEndpointIeee
(
EmberEUI64
eui64
)
uint16_t
emAfDeviceTableFindFirstEndpointIeee
(
EmberEUI64
eui64
)
{
{
return
findIndexFromEui64AndIndex
(
eui64
,
0
);
return
findIndexFromEui64AndIndex
(
eui64
,
0
);
}
}
uint16_t
emberAfDeviceTableGetFirstIndexFromEui64
(
EmberEUI64
eui64
)
uint16_t
emberAfDeviceTableGetFirstIndexFromEui64
(
EmberEUI64
eui64
)
{
{
return
emAfDeviceTableFindFirstEndpointIeee
(
eui64
);
return
emAfDeviceTableFindFirstEndpointIeee
(
eui64
);
}
}
EmberAfStatus
emAfDeviceTableAddNewEndpoint
(
uint16_t
index
,
uint8_t
newEndpoint
)
EmberAfStatus
emAfDeviceTableAddNewEndpoint
(
uint16_t
index
,
uint8_t
newEndpoint
)
{
{
uint16_t
newIndex
=
emAfDeviceTableFindFreeDeviceTableIndex
();
uint16_t
newIndex
=
emAfDeviceTableFindFreeDeviceTableIndex
();
if
(
newIndex
==
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
if
(
newIndex
==
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
return
EMBER_ZCL_STATUS_FAILURE
;
return
EMBER_ZCL_STATUS_FAILURE
;
}
}
emAfDeviceTableCopyDeviceTableEntry
(
index
,
newIndex
);
emAfDeviceTableCopyDeviceTableEntry
(
index
,
newIndex
);
deviceTable
[
newIndex
].
endpoint
=
newEndpoint
;
deviceTable
[
newIndex
].
endpoint
=
newEndpoint
;
return
EMBER_ZCL_STATUS_SUCCESS
;
return
EMBER_ZCL_STATUS_SUCCESS
;
}
}
uint16_t
emAfDeviceTableFindIndexNodeIdEndpoint
(
uint16_t
nodeId
,
uint16_t
emAfDeviceTableFindIndexNodeIdEndpoint
(
uint16_t
nodeId
,
uint8_t
endpoint
)
uint8_t
endpoint
)
{
{
uint16_t
i
;
uint16_t
i
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
==
nodeId
if
(
deviceTable
[
i
].
nodeId
==
nodeId
&&
deviceTable
[
i
].
endpoint
==
endpoint
)
{
&&
deviceTable
[
i
].
endpoint
==
endpoint
)
{
return
i
;
return
i
;
}
}
}
}
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
return
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
;
}
}
EmberAfPluginDeviceTableEntry
*
emberAfDeviceTableFindDeviceTableEntry
(
uint16_t
index
)
EmberAfPluginDeviceTableEntry
*
emberAfDeviceTableFindDeviceTableEntry
(
uint16_t
index
)
{
{
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
);
assert
(
index
<
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
);
return
&
(
deviceTable
[
index
]);
return
&
(
deviceTable
[
index
]);
}
}
void
emAfDeviceTableUpdateNodeId
(
uint16_t
currentNodeId
,
uint16_t
newNodeId
)
void
emAfDeviceTableUpdateNodeId
(
uint16_t
currentNodeId
,
uint16_t
newNodeId
)
{
{
uint16_t
index
=
emAfDeviceTableFindFirstEndpointNodeId
(
currentNodeId
);
uint16_t
index
=
emAfDeviceTableFindFirstEndpointNodeId
(
currentNodeId
);
while
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
while
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
deviceTable
[
index
].
nodeId
=
newNodeId
;
deviceTable
[
index
].
nodeId
=
newNodeId
;
index
=
emAfDeviceTableFindNextEndpoint
(
index
);
index
=
emAfDeviceTableFindNextEndpoint
(
index
);
}
}
}
}
void
emAfDeviceTableUpdateDeviceState
(
uint16_t
index
,
uint8_t
newState
)
void
emAfDeviceTableUpdateDeviceState
(
uint16_t
index
,
uint8_t
newState
)
{
{
while
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
while
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
deviceTable
[
index
].
state
=
newState
;
deviceTable
[
index
].
state
=
newState
;
index
=
emAfDeviceTableFindNextEndpoint
(
index
);
index
=
emAfDeviceTableFindNextEndpoint
(
index
);
}
}
}
}
uint32_t
emberAfDeviceTableTimeSinceLastMessage
(
uint16_t
index
)
uint32_t
emberAfDeviceTableTimeSinceLastMessage
(
uint16_t
index
)
{
{
uint32_t
timeSinceLastMessage
=
halCommonGetInt32uMillisecondTick
();
uint32_t
timeSinceLastMessage
=
halCommonGetInt32uMillisecondTick
();
timeSinceLastMessage
-=
deviceTable
[
index
].
lastMsgTimestamp
;
timeSinceLastMessage
-=
deviceTable
[
index
].
lastMsgTimestamp
;
timeSinceLastMessage
/=
MILLISECOND_TICKS_PER_SECOND
;
timeSinceLastMessage
/=
MILLISECOND_TICKS_PER_SECOND
;
return
timeSinceLastMessage
;
return
timeSinceLastMessage
;
}
}
// AF Framework callbacks. This is where the plugin implements the callbacks.
// AF Framework callbacks. This is where the plugin implements the callbacks.
void
emberAfPluginDeviceTableInitCallback
(
void
)
void
emberAfPluginDeviceTableInitCallback
(
void
)
{
{
emAfDeviceTableInit
();
emAfDeviceTableInit
();
// Load on Init
// Load on Init
emAfDeviceTableLoad
();
emAfDeviceTableLoad
();
emberAfPluginDeviceTableInitialized
();
emberAfPluginDeviceTableInitialized
();
}
}
void
emberAfPluginDeviceTableStackStatusCallback
(
EmberStatus
status
)
void
emberAfPluginDeviceTableStackStatusCallback
(
EmberStatus
status
)
{
{
// If we leave the network, this plugin needs to clear out all of its device
// If we leave the network, this plugin needs to clear out all of its device
// state.
// state.
emberAfCorePrintln
(
"%d %d"
,
status
,
emberNetworkState
());
emberAfCorePrintln
(
"%d %d"
,
status
,
emberNetworkState
());
if
(
status
==
EMBER_NETWORK_DOWN
if
(
status
==
EMBER_NETWORK_DOWN
&&
emberNetworkState
()
==
EMBER_NO_NETWORK
)
{
&&
emberNetworkState
()
==
EMBER_NO_NETWORK
)
{
emberAfCorePrintln
(
"DeviceTable: Clear State"
);
emberAfCorePrintln
(
"DeviceTable: Clear State"
);
emberAfDeviceTableClear
();
emberAfDeviceTableClear
();
//kk_device_table_clear();
//kk_device_table_clear();
}
}
}
}
// --------------------------------
// --------------------------------
// Save/Load the devices
// Save/Load the devices
void
emAfDeviceTableSave
(
void
)
void
emAfDeviceTableSave
(
void
)
{
{
#if defined(EZSP_HOST) && !defined(EMBER_TEST)
#if defined(EZSP_HOST) && !defined(EMBER_TEST)
FILE
*
fp
;
FILE
*
fp
;
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
uint8_t
i
;
uint8_t
i
;
uint8_t
j
;
uint8_t
j
;
// Save device table
// Save device table
fp
=
fopen
(
"devices.txt"
,
"w"
);
fp
=
fopen
(
"devices.txt"
,
"w"
);
for
(
i
=
0
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
i
++
)
{
if
(
deviceTable
[
i
].
nodeId
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
if
(
deviceTable
[
i
].
nodeId
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
fprintf
(
fp
,
fprintf
(
fp
,
"%x %x %x "
,
"%x %x %x "
,
deviceTable
[
i
].
nodeId
,
deviceTable
[
i
].
nodeId
,
deviceTable
[
i
].
endpoint
,
deviceTable
[
i
].
endpoint
,
deviceTable
[
i
].
deviceId
);
deviceTable
[
i
].
deviceId
);
for
(
j
=
0
;
j
<
8
;
j
++
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
fprintf
(
fp
,
"%x "
,
deviceTable
[
i
].
eui64
[
j
]);
fprintf
(
fp
,
"%x "
,
deviceTable
[
i
].
eui64
[
j
]);
}
}
for
(
j
=
0
;
j
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
j
++
)
{
for
(
j
=
0
;
j
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
j
++
)
{
fprintf
(
fp
,
"%x "
,
deviceTable
[
i
].
clusterIds
[
j
]);
fprintf
(
fp
,
"%x "
,
deviceTable
[
i
].
clusterIds
[
j
]);
}
}
fprintf
(
fp
,
"%d "
,
deviceTable
[
i
].
clusterOutStartPosition
);
fprintf
(
fp
,
"%d "
,
deviceTable
[
i
].
clusterOutStartPosition
);
}
}
}
}
// Write ffffffff to mark the end
// Write ffffffff to mark the end
fprintf
(
fp
,
"
\r\n
ffffffff
\r\n
"
);
fprintf
(
fp
,
"
\r\n
ffffffff
\r\n
"
);
fclose
(
fp
);
fclose
(
fp
);
#endif // defined(EZSP_HOST) && !defined(EMBER_TEST)
#endif // defined(EZSP_HOST) && !defined(EMBER_TEST)
}
}
void
emAfDeviceTableLoad
(
void
)
void
emAfDeviceTableLoad
(
void
)
{
{
#if defined(EZSP_HOST) && !defined(EMBER_TEST)
#if defined(EZSP_HOST) && !defined(EMBER_TEST)
uint16_t
i
;
uint16_t
i
;
uint16_t
j
;
uint16_t
j
;
FILE
*
fp
;
FILE
*
fp
;
unsigned
int
data
,
data2
,
data3
;
unsigned
int
data
,
data2
,
data3
;
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
fp
=
fopen
(
"devices.txt"
,
"r"
);
fp
=
fopen
(
"devices.txt"
,
"r"
);
if
(
!
fp
)
{
if
(
!
fp
)
{
return
;
return
;
}
}
for
(
i
=
0
;
for
(
i
=
0
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
&&
feof
(
fp
)
==
false
;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
&&
feof
(
fp
)
==
false
;
i
++
)
{
i
++
)
{
fscanf
(
fp
,
"%x %x %x"
,
&
data2
,
&
data
,
&
data3
);
fscanf
(
fp
,
"%x %x %x"
,
&
data2
,
&
data
,
&
data3
);
deviceTable
[
i
].
endpoint
=
(
uint8_t
)
data
;
deviceTable
[
i
].
endpoint
=
(
uint8_t
)
data
;
deviceTable
[
i
].
nodeId
=
(
uint16_t
)
data2
;
deviceTable
[
i
].
nodeId
=
(
uint16_t
)
data2
;
deviceTable
[
i
].
deviceId
=
(
uint16_t
)
data3
;
deviceTable
[
i
].
deviceId
=
(
uint16_t
)
data3
;
if
(
deviceTable
[
i
].
nodeId
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
if
(
deviceTable
[
i
].
nodeId
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
for
(
j
=
0
;
j
<
8
;
j
++
)
{
fscanf
(
fp
,
"%x"
,
&
data
);
fscanf
(
fp
,
"%x"
,
&
data
);
deviceTable
[
i
].
eui64
[
j
]
=
(
uint8_t
)
data
;
deviceTable
[
i
].
eui64
[
j
]
=
(
uint8_t
)
data
;
}
}
for
(
j
=
0
;
j
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
j
++
)
{
for
(
j
=
0
;
j
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
j
++
)
{
fscanf
(
fp
,
"%x"
,
&
data
);
fscanf
(
fp
,
"%x"
,
&
data
);
deviceTable
[
i
].
clusterIds
[
j
]
=
(
uint16_t
)
data
;
deviceTable
[
i
].
clusterIds
[
j
]
=
(
uint16_t
)
data
;
}
}
fscanf
(
fp
,
"%d"
,
&
data
);
fscanf
(
fp
,
"%d"
,
&
data
);
deviceTable
[
i
].
clusterOutStartPosition
=
(
uint16_t
)
data
;
deviceTable
[
i
].
clusterOutStartPosition
=
(
uint16_t
)
data
;
deviceTable
[
i
].
state
=
EMBER_AF_PLUGIN_DEVICE_TABLE_STATE_JOINED
;
deviceTable
[
i
].
state
=
EMBER_AF_PLUGIN_DEVICE_TABLE_STATE_JOINED
;
//kk_sub_tsl_add(deviceTable[i].eui64,TEST_PRODUCT_CODE);
//kk_sub_tsl_add(deviceTable[i].eui64,TEST_PRODUCT_CODE);
}
}
deviceTable
[
i
].
lastMsgTimestamp
=
halCommonGetInt32uMillisecondTick
();
deviceTable
[
i
].
lastMsgTimestamp
=
halCommonGetInt32uMillisecondTick
();
}
}
fclose
(
fp
);
fclose
(
fp
);
// Set the rest of the device table to null.
// Set the rest of the device table to null.
for
(;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
for
(;
i
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
i
++
)
{
deviceTable
[
i
].
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
deviceTable
[
i
].
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
}
}
#endif // #if defined(EZSP_HOST) && !defined(EMBER_TEST)
#endif // #if defined(EZSP_HOST) && !defined(EMBER_TEST)
}
}
// --------------------------------
// --------------------------------
// Message send section
// Message send section
// Command to send the CIE IEEE address to the IAS Zone cluster
// Command to send the CIE IEEE address to the IAS Zone cluster
void
emAfDeviceTableSendCieAddressWrite
(
EmberNodeId
nodeId
,
uint8_t
endpoint
)
void
emAfDeviceTableSendCieAddressWrite
(
EmberNodeId
nodeId
,
uint8_t
endpoint
)
{
{
EmberEUI64
eui64
;
EmberEUI64
eui64
;
uint8_t
outgoingBuffer
[
15
];
uint8_t
outgoingBuffer
[
15
];
uint32_t
i
;
uint32_t
i
;
emberAfGetEui64
(
eui64
);
emberAfGetEui64
(
eui64
);
globalApsFrame
.
options
=
EMBER_AF_DEFAULT_APS_OPTIONS
;
globalApsFrame
.
options
=
EMBER_AF_DEFAULT_APS_OPTIONS
;
globalApsFrame
.
clusterId
=
ZCL_IAS_ZONE_CLUSTER_ID
;
globalApsFrame
.
clusterId
=
ZCL_IAS_ZONE_CLUSTER_ID
;
globalApsFrame
.
sourceEndpoint
=
0x01
;
globalApsFrame
.
sourceEndpoint
=
0x01
;
globalApsFrame
.
destinationEndpoint
=
endpoint
;
globalApsFrame
.
destinationEndpoint
=
endpoint
;
outgoingBuffer
[
0
]
=
0x00
;
outgoingBuffer
[
0
]
=
0x00
;
outgoingBuffer
[
1
]
=
emberAfNextSequence
();
outgoingBuffer
[
1
]
=
emberAfNextSequence
();
outgoingBuffer
[
2
]
=
ZCL_WRITE_ATTRIBUTES_COMMAND_ID
;
outgoingBuffer
[
2
]
=
ZCL_WRITE_ATTRIBUTES_COMMAND_ID
;
outgoingBuffer
[
3
]
=
LOW_BYTE
(
ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID
);
outgoingBuffer
[
3
]
=
LOW_BYTE
(
ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID
);
outgoingBuffer
[
4
]
=
HIGH_BYTE
(
ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID
);
outgoingBuffer
[
4
]
=
HIGH_BYTE
(
ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID
);
outgoingBuffer
[
5
]
=
ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE
;
outgoingBuffer
[
5
]
=
ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
outgoingBuffer
[
6
+
i
]
=
eui64
[
i
];
outgoingBuffer
[
6
+
i
]
=
eui64
[
i
];
}
}
emberAfSendUnicast
(
EMBER_OUTGOING_DIRECT
,
emberAfSendUnicast
(
EMBER_OUTGOING_DIRECT
,
nodeId
,
nodeId
,
&
globalApsFrame
,
&
globalApsFrame
,
14
,
14
,
outgoingBuffer
);
outgoingBuffer
);
}
}
void
emberAfDeviceTableCliIndexSendWithEndpoint
(
uint16_t
index
,
void
emberAfDeviceTableCliIndexSendWithEndpoint
(
uint16_t
index
,
uint8_t
endpoint
)
uint8_t
endpoint
)
{
{
EmberNodeId
nodeId
;
EmberNodeId
nodeId
;
EmberStatus
status
;
EmberStatus
status
;
nodeId
=
emberAfDeviceTableGetNodeIdFromIndex
(
index
);
nodeId
=
emberAfDeviceTableGetNodeIdFromIndex
(
index
);
emAfApsFrameEndpointSetup
(
emberAfPrimaryEndpoint
(),
endpoint
);
emAfApsFrameEndpointSetup
(
emberAfPrimaryEndpoint
(),
endpoint
);
status
=
emberAfSendUnicast
(
EMBER_OUTGOING_DIRECT
,
status
=
emberAfSendUnicast
(
EMBER_OUTGOING_DIRECT
,
nodeId
,
nodeId
,
&
globalApsFrame
,
&
globalApsFrame
,
appZclBufferLen
,
appZclBufferLen
,
appZclBuffer
);
appZclBuffer
);
zclCmdIsBuilt
=
false
;
zclCmdIsBuilt
=
false
;
}
}
void
emberAfDeviceTableCliIndexSend
(
uint16_t
index
)
void
emberAfDeviceTableCliIndexSend
(
uint16_t
index
)
{
{
uint8_t
endpoint
=
emAfDeviceTableGetFirstEndpointFromIndex
(
index
);
uint8_t
endpoint
=
emAfDeviceTableGetFirstEndpointFromIndex
(
index
);
emberAfDeviceTableCliIndexSendWithEndpoint
(
index
,
endpoint
);
emberAfDeviceTableCliIndexSendWithEndpoint
(
index
,
endpoint
);
}
}
void
emberAfDeviceTableSend
(
EmberEUI64
eui64
,
uint8_t
endpoint
)
void
emberAfDeviceTableSend
(
EmberEUI64
eui64
,
uint8_t
endpoint
)
{
{
uint16_t
index
=
emberAfDeviceTableGetFirstIndexFromEui64
(
eui64
);
uint16_t
index
=
emberAfDeviceTableGetFirstIndexFromEui64
(
eui64
);
if
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
if
(
index
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_INDEX
)
{
emberAfDeviceTableCliIndexSendWithEndpoint
(
index
,
endpoint
);
emberAfDeviceTableCliIndexSendWithEndpoint
(
index
,
endpoint
);
}
}
}
}
void
emberAfDeviceTableCommandIndexSendWithEndpoint
(
uint16_t
index
,
void
emberAfDeviceTableCommandIndexSendWithEndpoint
(
uint16_t
index
,
uint8_t
endpoint
)
uint8_t
endpoint
)
{
{
EmberNodeId
nodeId
;
EmberNodeId
nodeId
;
EmberStatus
status
;
EmberStatus
status
;
nodeId
=
emberAfDeviceTableGetNodeIdFromIndex
(
index
);
nodeId
=
emberAfDeviceTableGetNodeIdFromIndex
(
index
);
if
(
emberAfCurrentCommand
()
==
NULL
)
{
if
(
emberAfCurrentCommand
()
==
NULL
)
{
emAfCommandApsFrame
->
sourceEndpoint
=
emberAfPrimaryEndpoint
();
emAfCommandApsFrame
->
sourceEndpoint
=
emberAfPrimaryEndpoint
();
}
else
{
}
else
{
emAfCommandApsFrame
->
sourceEndpoint
=
emberAfCurrentEndpoint
();
emAfCommandApsFrame
->
sourceEndpoint
=
emberAfCurrentEndpoint
();
}
}
emAfCommandApsFrame
->
destinationEndpoint
=
endpoint
;
emAfCommandApsFrame
->
destinationEndpoint
=
endpoint
;
emberAfCorePrintln
(
"device table send with ep: 0x%2X, %d"
,
emberAfCorePrintln
(
"device table send with ep: 0x%2X, %d"
,
nodeId
,
nodeId
,
endpoint
);
endpoint
);
status
=
emberAfSendCommandUnicast
(
EMBER_OUTGOING_DIRECT
,
nodeId
);
status
=
emberAfSendCommandUnicast
(
EMBER_OUTGOING_DIRECT
,
nodeId
);
zclCmdIsBuilt
=
false
;
zclCmdIsBuilt
=
false
;
}
}
void
emberAfDeviceTableCommandIndexSend
(
uint16_t
index
)
void
emberAfDeviceTableCommandIndexSend
(
uint16_t
index
)
{
{
uint8_t
endpoint
=
emAfDeviceTableGetFirstEndpointFromIndex
(
index
);
uint8_t
endpoint
=
emAfDeviceTableGetFirstEndpointFromIndex
(
index
);
emberAfDeviceTableCommandIndexSendWithEndpoint
(
index
,
endpoint
);
emberAfDeviceTableCommandIndexSendWithEndpoint
(
index
,
endpoint
);
}
}
void
emberAfDeviceTableCommandSendWithEndpoint
(
EmberEUI64
eui64
,
void
emberAfDeviceTableCommandSendWithEndpoint
(
EmberEUI64
eui64
,
uint8_t
endpoint
)
uint8_t
endpoint
)
{
{
uint16_t
index
=
emberAfDeviceTableGetFirstIndexFromEui64
(
eui64
);
uint16_t
index
=
emberAfDeviceTableGetFirstIndexFromEui64
(
eui64
);
emberAfDeviceTableCommandIndexSendWithEndpoint
(
index
,
endpoint
);
emberAfDeviceTableCommandIndexSendWithEndpoint
(
index
,
endpoint
);
}
}
process_check.sh
View file @
a615faf9
#!/bin/sh
#!/bin/sh
#判断进程是否存在,如果不存在就启动它
#判断进程是否存在,如果不存在就启动它
while
true
while
true
do
do
sleep
30
sleep
30
PIDS
=
`
ps|grep kk_midware |grep
-v
grep
|
awk
'{print $1}'
`
PIDS
=
`
ps|grep kk_midware |grep
-v
grep
|
awk
'{print $1}'
`
if
[
"
$PIDS
"
!=
""
]
;
then
if
[
"
$PIDS
"
!=
""
]
;
then
echo
"kk_midware is runing!"
echo
"kk_midware is runing!"
else
else
/home/kk/kk_midware
>
/dev/null 2>&1 &
/home/kk/kk_midware
>
/dev/null 2>&1 &
#运行进程
#运行进程
fi
fi
sleep
30
sleep
30
PIDS
=
`
ps|grep kcloud |grep
-v
grep
|
awk
'{print $1}'
`
PIDS
=
`
ps|grep kcloud |grep
-v
grep
|
awk
'{print $1}'
`
if
[
"
$PIDS
"
!=
""
]
;
then
if
[
"
$PIDS
"
!=
""
]
;
then
echo
"kcloud is runing!"
echo
"kcloud is runing!"
else
else
/home/kk/kcloud
>
/dev/null 2>&1 &
/home/kk/kcloud
>
/dev/null 2>&1 &
#运行进程
#运行进程
fi
fi
done
done
rc.local
View file @
a615faf9
# Put your custom commands here that should be executed once
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
# the system init finished. By default this file does nothing.
nanomsg_File="/home/kk/lib/libnanomsg.so.5"
nanomsg_File="/home/kk/lib/libnanomsg.so.5"
ev_File="/home/kk/lib/libev.so.4"
ev_File="/home/kk/lib/libev.so.4"
cd /sbin/
cd /sbin/
insmod /sbin/ssd1306-revision.ko
insmod /sbin/ssd1306-revision.ko
/sbin/oled >/dev/null 2>&1 &
/sbin/oled >/dev/null 2>&1 &
sleep 1
sleep 1
export LD_LIBRARY_PATH=/home/kk/lib
export LD_LIBRARY_PATH=/home/kk/lib
cd /home/kk/lib
cd /home/kk/lib
if [ ! -f "$nanomsg_File" ]; then
if [ ! -f "$nanomsg_File" ]; then
ln libnanomsg.so libnanomsg.so.5
ln libnanomsg.so libnanomsg.so.5
fi
fi
if [ ! -f "$ev_File" ]; then
if [ ! -f "$ev_File" ]; then
ln libev.so libev.so.4
ln libev.so libev.so.4
fi
fi
CCU_ID=`cat /etc/dropbear/accessory/hj/hj_ccuid`
CCU_ID=`cat /etc/dropbear/accessory/hj/hj_ccuid`
/sbin/logread -f -r 120.55.149.201 514 -p /var/run/logread.cloud_log.pid -u -h $CCU_ID >/dev/null 2>&1 &
/sbin/logread -f -r 120.55.149.201 514 -p /var/run/logread.cloud_log.pid -u -h $CCU_ID >/dev/null 2>&1 &
/sbin/logread -f -e "ccu_err_info" -F /etc/dropbear/accessory/hj/err.log -p /var/run/logread.err_log.pid -S 512 >/dev/null 2>&1 &
/sbin/logread -f -e "ccu_err_info" -F /etc/dropbear/accessory/hj/err.log -p /var/run/logread.err_log.pid -S 512 >/dev/null 2>&1 &
sleep 1
sleep 1
/home/kk/run.sh >/dev/null 2>&1 &
/home/kk/run.sh >/dev/null 2>&1 &
sleep 10
sleep 10
/home/kk/process_check.sh >/dev/null 2>&1 &
/home/kk/process_check.sh >/dev/null 2>&1 &
cd /sbin
cd /sbin
/sbin/logd-check.sh >/dev/null 2>&1 &
/sbin/logd-check.sh >/dev/null 2>&1 &
sleep 1
sleep 1
ntpd -n -q -d -p stdtime.gov.hk &
ntpd -n -q -d -p stdtime.gov.hk &
exit 0
exit 0
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