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
47e91b73
Commit
47e91b73
authored
Sep 21, 2020
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
彩灯模式添加 See merge request chenweican/k-sdk!17
parents
149ec289
a559c400
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
423 additions
and
16 deletions
+423
-16
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_3073.json
...uilder/Z3GatewayHost/ZB/dev_config_table/device_3073.json
+52
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.c
...form/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.c
+83
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.h
...form/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.h
+31
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
+143
-6
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
+8
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
+26
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+3
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+44
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
+2
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
+9
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+10
-2
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
+10
-0
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
47e91b73
...
...
@@ -290,6 +290,7 @@ APPLICATION_FILES= \
./ZB/kk_msg_report.c
\
./ZB/kk_plat_ota.c
\
./ZB/kk_rgb_hsl_convert.c
\
./ZB/kk_color_space.c
\
./kk_test.c
\
./rpc_api/src/rpc_common.c
\
./rpc_api/src/rpc_onoff.c
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_3073.json
View file @
47e91b73
...
...
@@ -3,7 +3,7 @@
"config"
:[
{
"identity"
:
"PowerSwitch"
,
"endpoint"
:
1
,
"endpoint"
:
255
,
"cluster"
:
"0x0006"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_global_onoff"
,
...
...
@@ -63,7 +63,57 @@
"cluster"
:
"0xFCC0"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_colorControl_mode"
,
"controlFunc"
:
"kk_tsl_set_colorlight_mode"
"controlFunc"
:
"kk_tsl_set_colorlight_mode"
,
"extra data"
:[
{
"mode_1"
:
"红色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 05 00 00 00 00 0A 00 ff 7f 00 10 00 00 00 00 00"
},
{
"mode_2"
:
"粉色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 02 00 00 00 00 03 f7 22 28 00 04 00 00 00 00 00"
},
{
"mode_3"
:
"紫色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 03 00 00 00 00 03 d4 ff 32 00 04 00 00 00 00 00"
},
{
"mode_4"
:
"黄色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 04 00 00 00 00 03 26 63 32 00 04 00 00 00 00 00"
},
{
"mode_5"
:
"绿色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 05 00 00 00 00 03 55 ff 32 00 04 00 00 00 00 00"
},
{
"mode_6"
:
"浅蓝色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 06 00 00 00 00 03 83 1d 35 00 02 00 00 00 00 00"
},
{
"mode_7"
:
"深蓝色渐变"
,
"data"
:
"17 01 02 00 01 01 1A 02 07 00 00 00 00 03 aa ff 32 00 02 00 00 00 00 00"
},
{
"mode_8"
:
"多种渐变A"
,
"data"
:
"2b 01 02 00 01 01 1A 02 08 00 ff 32 00 0e 27 ff 32 00 0e 17 ff 32 00 0e 85 ff 32 00 0e 74 E2 2f 00 0e aa ff 32 00 0e d4 ff 32 00 10"
},
{
"mode_9"
:
"多种渐变B"
,
"data"
:
"2b 01 02 00 01 01 1A 02 09 00 ff 32 32 0e 27 ff 32 32 0e 17 ff 32 32 0e 85 ff 32 32 0e 74 E2 2f 32 0e aa ff 32 32 0e d4 ff 32 32 10"
},
{
"mode_10"
:
"a多种渐变"
,
"data"
:
"44 01 02 00 01 01 1A 02 0a 47 ff 32 00 08 00 00 00 00 08 77 ff 31 00 08 00 00 00 00 08 47 ff 32 00 08 00 00 00 00 08 77 ff 31 00 08 00 00 00 00 08 47 ff 32 00 08 00 00 00 00 08 47 ff 32 00 08 00 00 00 00 0c"
},
{
"mode_11"
:
"b多种渐变"
,
"data"
:
"44 01 02 00 01 01 1A 02 0b 00 ff 32 00 08 00 00 00 00 08 27 ff 32 00 08 00 00 00 00 08 85 ff 32 00 08 00 00 00 00 08 74 E2 2f 00 08 00 00 00 00 08 d4 ff 32 00 08 00 00 00 00 08 b0 ff 38 00 08 00 00 00 00 0c"
},
{
"mode_12"
:
"c多种渐变"
,
"data"
:
"44 01 02 00 01 01 1A 02 0c 00 ff 32 00 02 00 00 00 00 0e 27 ff 32 00 02 00 00 00 00 0e 85 ff 32 00 02 00 00 00 00 0e 74 E2 2f 00 02 00 00 00 00 0e d4 ff 32 00 02 00 00 00 00 0e b0 ff 38 00 02 00 00 00 00 12"
}
]
}
]
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.c
0 → 100644
View file @
47e91b73
#include "kk_color_space.h"
static
float
hue_to_rgb
(
float
m1
,
float
m2
,
float
h
)
{
h
=
(
h
<
0
)
?
h
+
1
:
((
h
>
1
)
?
h
-
1
:
h
);
if
(
h
*
6
<
1
)
{
return
(
m1
+
(
m2
-
m1
)
*
h
*
6
);
}
else
if
(
h
*
2
<
1
)
{
return
m2
;
}
else
if
(
h
*
3
<
2
)
{
return
m1
+
(
m2
-
m1
)
*
(
0
.
66666
-
h
)
*
6
;
}
else
{
return
m1
;
}
}
void
hsl_to_rgb
(
float
h
,
float
s
,
float
l
,
unsigned
char
*
r
,
unsigned
char
*
g
,
unsigned
char
*
b
)
{
float
m1
,
m2
;
m2
=
(
l
<=
0
.
5
)
?
l
*
(
s
+
1
)
:
l
+
s
-
l
*
s
;
m1
=
l
*
2
-
m2
;
*
r
=
255
*
hue_to_rgb
(
m1
,
m2
,
h
+
0
.
33333
);
*
g
=
255
*
hue_to_rgb
(
m1
,
m2
,
h
);
*
b
=
255
*
hue_to_rgb
(
m1
,
m2
,
h
-
0
.
33333
);
}
void
rgb_to_hsl
(
unsigned
char
r
,
unsigned
char
g
,
unsigned
char
b
,
unsigned
short
*
H
,
unsigned
char
*
S
,
unsigned
char
*
L
)
{
float
min
=
0
,
max
=
0
,
delta
=
0
;
float
h
=
0
,
s
=
0
,
l
=
0
,
R
=
0
,
G
=
0
,
B
=
0
;
R
=
r
/
255
.
0
;
G
=
g
/
255
.
0
;
B
=
b
/
255
.
0
;
min
=
R
<
G
?
R
:
G
;
min
=
B
<
min
?
B
:
min
;
max
=
R
>
G
?
R
:
G
;
max
=
B
>
max
?
B
:
max
;
delta
=
max
-
min
;
l
=
(
min
+
max
)
/
2
.
0
;
s
=
0
;
if
(
l
>
0
&&
l
<
1
)
{
s
=
delta
/
(
l
<
0
.
5
?
(
2
*
l
)
:
(
2
-
2
*
l
));
}
h
=
0
;
if
(
delta
>
0
)
{
if
(
max
==
R
&&
max
!=
G
)
{
h
+=
(
G
-
B
)
/
delta
;
}
else
if
(
max
==
G
&&
max
!=
B
)
{
h
+=
(
2
+
(
B
-
R
)
/
delta
);
}
else
if
(
max
==
B
&&
max
!=
R
)
{
h
+=
(
4
+
(
R
-
G
)
/
delta
);
}
{
h
/=
6
.
0
;
}
}
*
H
=
(
unsigned
char
)
h
;
*
S
=
(
unsigned
char
)
s
;
*
L
=
(
unsigned
char
)
l
;
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.h
0 → 100644
View file @
47e91b73
#ifndef __KK_COLOR_SPACE_H
#define __KK_COLOR_SPACE_H
#include <stdio.h>
void
rgb_to_hsl
(
unsigned
char
r
,
unsigned
char
g
,
unsigned
char
b
,
unsigned
short
*
H
,
unsigned
char
*
S
,
unsigned
char
*
L
);
void
hsl_to_rgb
(
float
h
,
float
s
,
float
l
,
unsigned
char
*
r
,
unsigned
char
*
g
,
unsigned
char
*
b
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
View file @
47e91b73
...
...
@@ -165,7 +165,7 @@ void kk_productCode_tick()
while
(
ptr
!=
NULL
){
emberAfCorePrintln
(
"%d"
,
strlen
(
ptr
->
productCode
));
//
emberAfCorePrintln("%d",strlen(ptr->productCode));
if
(
strlen
(
ptr
->
productCode
)
==
0
){
if
(
ptr
->
nodeId
!=
0xffff
&&
ptr
->
identifyCnt
!=
0
){
...
...
@@ -254,7 +254,8 @@ error_return:
#define KK_DEVICE_MAP_TABLE_FILE "./ZB/dev_map_table.json"
#define KK_DEVICE_MAP_TABLE_ARRAY_IDENTIFY "mapTable"
#define KK_DEVICE_CONFIG_MAP_TABLE_ARRAY_IDENTIFY "config"
#define KK_DEVICE_CONFIG_MAP_TABLE_ARRAY_IDENTIFY "config"
#define KK_DEVICE_CONFIG_MAP_TABLE_EXTRA_DATA_IDENTIFY "extra data"
typedef
struct
kk_dev_map
{
char
*
modleId
;
...
...
@@ -496,6 +497,7 @@ kk_rpc_set kk_find_rpc_set_function_api(const char *name)
return
kk_rpc_set_api
[
i
].
set
;
}
}
return
NULL
;
}
kk_rpc_report
kk_find_rpc_report_function_api
(
const
char
*
name
)
{
...
...
@@ -505,6 +507,7 @@ kk_rpc_report kk_find_rpc_report_function_api(const char *name)
return
kk_rpc_report_api
[
i
].
report
;
}
}
return
NULL
;
}
bool
kk_device_config_exist_check
(
const
char
*
productCode
)
...
...
@@ -525,6 +528,9 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
kk_dev_config_item
*
item
,
*
itemPre
,
*
newItem
;
ptr
=
kk_device_config_find
(
productCode
);
if
(
ptr
==
NULL
){
ptr
=
(
kk_dev_config_map
*
)
malloc
(
sizeof
(
kk_dev_config_map
));
...
...
@@ -556,7 +562,7 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
ptr
->
item
.
reportFunc
=
kk_find_rpc_report_function_api
(
reportFuncName
);
ptr
->
item
.
controlFunc
=
kk_find_rpc_set_function_api
(
controlFuncName
);
if
(
dev_config_map
==
NULL
){
dev_config_map
=
ptr
;
...
...
@@ -605,7 +611,7 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
newItem
->
reportFunc
=
kk_find_rpc_report_function_api
(
reportFuncName
);
newItem
->
controlFunc
=
kk_find_rpc_set_function_api
(
controlFuncName
);
itemPre
->
next
=
newItem
;
...
...
@@ -613,16 +619,99 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
return
true
;
}
void
kk_append_extra_data_to_list
(
const
char
*
productCode
,
kk_dev_config_item_extra_data
*
data
)
{
kk_dev_config_map
*
map
=
kk_device_config_find
(
productCode
);
if
(
data
==
NULL
)
return
;
if
(
map
!=
NULL
){
kk_dev_config_item
*
item
=
&
map
->
item
;
while
(
item
!=
NULL
){
if
(
item
->
identity
!=
NULL
&&
data
->
tag
!=
NULL
&&
(
strcmp
(
item
->
identity
,
data
->
tag
)
==
0
)){
data
->
tag
=
item
->
identity
;
//note!!!
item
->
data
=
data
;
return
;
}
item
=
item
->
next
;
}
}
}
bool
get_extra_data_from_hexString
(
char
*
tag
,
char
*
str
,
kk_dev_config_item_extra_data
*
extra
)
{
if
(
str
==
NULL
)
return
false
;
int
len
=
strlen
(
str
);
if
(
len
<
2
)
return
false
;
len
=
len
/
3
+
1
;
uint8_t
*
data
=
(
uint8_t
*
)
malloc
(
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++
){
data
[
i
]
=
(
rpc_convert_char
(
str
[
3
*
i
])
<<
4
)
|
rpc_convert_char
((
str
[
3
*
i
+
1
]));
}
extra
->
len
=
len
;
extra
->
data
=
data
;
extra
->
tag
=
tag
;
return
true
;
}
kk_dev_config_item_extra_data
*
kk_find_extra_data_by_productCode
(
const
char
*
productCode
,
const
char
*
tag
)
{
kk_dev_config_map
*
map
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
kk_dev_config_item_extra_data
*
data
;
map
=
kk_device_config_find
(
productCode
);
item
=
&
map
->
item
;
while
(
item
!=
NULL
){
if
(
item
->
data
!=
NULL
){
data
=
item
->
data
;
while
(
data
!=
NULL
){
if
(
!
strcmp
(
item
->
identity
,
tag
)){
return
item
->
data
;
}
data
=
data
->
next
;
}
}
item
=
item
->
next
;
}
return
NULL
;
}
kk_dev_config_item_extra_data
*
kk_find_extra_data
(
EmberNodeId
node
,
const
char
*
tag
)
{
EmberEUI64
mac
;
char
*
productCode
=
NULL
;
kk_dev_config_map
*
map
=
NULL
;
if
(
emberLookupEui64ByNodeId
(
node
,
mac
)
==
EMBER_SUCCESS
){
productCode
=
kk_device_find_productCode
(
mac
);
map
=
kk_device_config_find
(
productCode
);
return
kk_find_extra_data_by_productCode
(
productCode
,
tag
);
}
return
NULL
;
}
void
kk_add_dev_config_map_table_to_list
(
cJSON
*
root
,
const
char
*
productCode
)
{
uint8_t
ep
;
uint16_t
clu
;
uint16_t
attr
;
int
i
,
len
,
s
ize
;
int
i
,
j
,
len
,
size
,
extraS
ize
;
cJSON
*
item
,
*
identity
;
cJSON
*
endpoint
,
*
cluster
,
*
attribute
,
*
reportFuncName
,
*
controlFuncName
;
cJSON
*
extraRoot
,
*
extraData
,
*
extraDataItem
;
cJSON
*
table
=
rpc_cJSON_GetObjectItem
(
root
,
KK_DEVICE_CONFIG_MAP_TABLE_ARRAY_IDENTIFY
);
kk_dev_config_item_extra_data
*
pData
=
NULL
,
*
ptr
=
NULL
;
if
(
table
==
NULL
){
UTIL_LOG_INFO
(
"can not add dev map to list!!!
\n
"
);
...
...
@@ -638,7 +727,44 @@ void kk_add_dev_config_map_table_to_list(cJSON * root,const char *productCode)
attribute
=
cJSON_GetObjectItem
(
item
,
"attribute"
);
reportFuncName
=
cJSON_GetObjectItem
(
item
,
"reportFunc"
);
controlFuncName
=
cJSON_GetObjectItem
(
item
,
"controlFunc"
);
extraRoot
=
cJSON_GetObjectItem
(
item
,
KK_DEVICE_CONFIG_MAP_TABLE_EXTRA_DATA_IDENTIFY
);
if
(
extraRoot
!=
NULL
){
extraSize
=
rpc_cJSON_GetArraySize
(
extraRoot
);
emberAfCorePrintln
(
"extraSize:%d
\n
"
,
extraSize
);
for
(
j
=
0
;
j
<
extraSize
;
j
++
){
extraData
=
rpc_cJSON_GetArrayItem
(
extraRoot
,
j
);
if
(
!
strcmp
(
"3073"
,
productCode
)){
char
buffer
[
20
]
=
{
0
};
sprintf
(
buffer
,
"mode_%d"
,
j
+
1
);
extraDataItem
=
cJSON_GetObjectItem
(
extraData
,
buffer
);
if
(
extraDataItem
!=
NULL
){
emberAfCorePrintln
(
"extraDataItem:%s
\n
"
,
extraDataItem
->
valuestring
);
extraDataItem
=
cJSON_GetObjectItem
(
extraData
,
"data"
);
if
(
extraDataItem
!=
NULL
){
kk_dev_config_item_extra_data
*
extra
=
(
kk_dev_config_item_extra_data
*
)
malloc
(
sizeof
(
kk_dev_config_item_extra_data
));
memset
(
extra
,
0
,
sizeof
(
kk_dev_config_item_extra_data
));
emberAfCorePrintln
(
"extraDataItem:%s
\n
"
,
extraDataItem
->
valuestring
);
get_extra_data_from_hexString
(
identity
->
valuestring
,
extraDataItem
->
valuestring
,
extra
);
if
(
ptr
==
NULL
){
ptr
=
extra
;
pData
=
extra
;
}
else
{
ptr
->
next
=
extra
;
ptr
=
extra
;
}
}
}
}
}
}
ep
=
endpoint
->
valueint
;
...
...
@@ -656,6 +782,9 @@ void kk_add_dev_config_map_table_to_list(cJSON * root,const char *productCode)
}
kk_device_config_add
(
productCode
,
identity
->
valuestring
,
ep
,
clu
,
attr
,
reportFuncName
->
valuestring
,
controlFuncName
->
valuestring
);
kk_append_extra_data_to_list
(
productCode
,
pData
);
}
kk_device_config_map_print
();
}
...
...
@@ -729,9 +858,10 @@ bool kk_device_config_map_add(const char *productCode)
}
void
kk_device_config_map_print
(
void
)
{
int
cnt1
,
cnt2
=
1
;
int
cnt1
=
1
,
cnt2
=
1
,
cnt3
=
1
;
kk_dev_config_map
*
ptr
=
dev_config_map
;
kk_dev_config_item
*
item
;
kk_dev_config_item_extra_data
*
extra
;
UTIL_LOG_INFO
(
"
\n
***************device config map list print***************
\n
"
);
while
(
ptr
!=
NULL
){
...
...
@@ -747,6 +877,13 @@ void kk_device_config_map_print(void)
emberAfCorePrintln
(
"attribute:0x%04X
\n
"
,
item
->
attribute
);
emberAfCorePrintln
(
"reportFunc:%s
\n
"
,
item
->
reportFuncName
);
emberAfCorePrintln
(
"controlFunc:%s
\n
"
,
item
->
controlFuncName
);
extra
=
item
->
data
;
while
(
extra
!=
NULL
){
emberAfCorePrintln
(
"~~~~~~~~~~~%d~~~~~~~~~~"
,
cnt3
++
);
emberAfCorePrintBuffer
(
extra
->
data
,
extra
->
len
,
true
);
emberAfCorePrintln
(
"
\n
"
);
extra
=
extra
->
next
;
}
item
=
item
->
next
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
View file @
47e91b73
...
...
@@ -47,6 +47,12 @@ typedef int (*kk_rpc_set)(jrpc_context * ctx,EmberNodeId node,unsigned char ep,v
typedef
int
(
*
kk_rpc_report
)(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
typedef
struct
kk_dev_config_item_extra_data
{
char
*
tag
;
uint8_t
len
;
uint8_t
*
data
;
struct
kk_dev_config_item_extra_data
*
next
;
}
kk_dev_config_item_extra_data
;
typedef
struct
kk_dev_config_item
{
char
*
identity
;
...
...
@@ -57,6 +63,7 @@ typedef struct kk_dev_config_item{
uint8_t
endpoint
;
uint16_t
cluster
;
uint16_t
attribute
;
kk_dev_config_item_extra_data
*
data
;
struct
kk_dev_config_item
*
next
;
}
kk_dev_config_item
;
...
...
@@ -69,6 +76,7 @@ typedef struct kk_dev_config_map{
kk_dev_config_item_extra_data
*
kk_find_extra_data
(
EmberNodeId
node
,
const
char
*
tag
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
View file @
47e91b73
...
...
@@ -177,7 +177,7 @@ void kk_device_joined(EmberNodeId node)
UTIL_LOG_INFO
(
"
\n
********************kk device joined********************
\n
"
);
if
(
emberAfDeviceTableGetEui64FromNodeId
(
node
,
mac
)){
if
(
emberAfDeviceTableGetEui64FromNodeId
(
node
,
mac
)
==
true
){
deviceTableIndex
=
emberAfDeviceTableGetIndexFromNodeId
(
node
);
if
(
deviceTableIndex
!=
0xffff
){
devPtr
=
emberAfDeviceTablePointer
();
...
...
@@ -534,5 +534,30 @@ void emberAfPluginDeviceTableInitialized(void)
kk_load_dev_map_table
();
kk_device_map_print
();
kk_device_config_load_from_db
();
//kk_device_config_map_add("3073");
}
void
test_123
(
int
val
)
{
uint8_t
buffer
[
258
];
int
ix
=
1
;
kk_dev_config_item_extra_data
*
mode
=
kk_find_extra_data_by_productCode
(
"3073"
,
"Mode"
);
while
(
mode
!=
NULL
){
if
(
ix
++==
10
){
emberAfCorePrintln
(
"~~~~~~~~~~~data_%d~~~~~~~~~~"
,
val
,
mode
->
len
);
buffer
[
0
]
=
mode
->
len
;
memcpy
(
&
buffer
[
1
],
mode
->
data
,
buffer
[
0
]
-
1
);
emberAfCorePrintBuffer
(
buffer
,
buffer
[
0
]
+
1
,
true
);
emberAfCorePrintln
(
"
\n
"
);
kk_private_protocol
(
0xb350
,
buffer
[
0
]
+
1
,
buffer
);
break
;
}
mode
=
mode
->
next
;
}
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
47e91b73
...
...
@@ -113,14 +113,13 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
int
i
,
j
,
num
,
status
;
int
res
=
0
;
char
macString
[
RPC_EUI64_STRING_LENGTH
];
kk_device_table_s
*
dev
;
kk_device_table_s
*
dev
=
NULL
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
kk_rpc_report
func
;
UTIL_LOG_INFO
(
"
\n
********************kk tsl report attribute********************
\n
"
);
emberAfDebugPrint
(
"mac:"
);
emberAfDebugPrintln
(
",ep:%d,clu:0x%04X,attr:0x%04X,dataType=0x%02x,len=%d,data:"
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
);
emberAfDebugPrintBuffer
(
data
,
len
,
true
);
...
...
@@ -144,7 +143,9 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
func
=
item
->
reportFunc
;
if
(
func
!=
NULL
){
emberAfDebugPrintln
(
"123123123"
);
func
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
emberAfDebugPrintln
(
"456456456"
);
}
else
{
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
47e91b73
#include "kk_tsl_property_set.h"
#include "kk_rgb_hsl_convert.h"
static
uint8_t
kk_global_buffer
[
256
];
static
uint8_t
kk_global_len
;
//emberAfAppPrintln("[tsl report:Gloabl] OnOff~~~~~~~~~");
...
...
@@ -301,13 +304,16 @@ static COLOR_RGB s_rgb;
static
int
kk_zclColorControlMovetohueandsat
(
EmberNodeId
node
,
unsigned
char
ep
)
{
int
h
,
s
,
v
;
int
h
,
s
,
l
;
COLOR_HSL
hsl
;
EmberStatus
status
=
0
;
if
(
s_RgbCount
>=
3
){
RGBtoHSL
(
&
s_rgb
,
&
hsl
);
emberAfAppPrintln
(
"[kk_zclColorControlMovetohueandsat]"
);
status
=
zclColorControlMovetohueandsat
(
node
,
ep
,
hsl
.
hue
,
hsl
.
saturation
,
0
,
0
,
0
,
0
);
rgb_to_hsl
(
s_rgb
.
red
,
s_rgb
.
green
,
s_rgb
.
blue
,
h
,
s
,
l
);
status
=
zclColorControlMovetohueandsat
(
node
,
ep
,
h
*
254
,
s
*
254
,
0
,
0
,
0
,
0
);
s_RgbCount
=
0
;
}
return
0
;
...
...
@@ -361,6 +367,42 @@ int kk_tsl_set_colorlight_Brightness(jrpc_context * ctx,EmberNodeId node,unsigne
return
status
;
}
int
kk_tsl_set_colorlight_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
int
value
=
*
(
uint8_t
*
)
data
;
EmberStatus
status
=
EMBER_ERR_FATAL
;
kk_dev_config_item_extra_data
*
mode
;
int
ix
=
1
;
emberAfAppPrintln
(
"[tsl set:kk_tsl_set_colorlight_mode],value=0x%02x"
,
value
);
if
(
node
==
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
){
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
return
-
1
;
}
mode
=
kk_find_extra_data
(
node
,
"Mode"
);
while
(
mode
!=
NULL
){
if
(
ix
++==
value
){
kk_global_len
=
mode
->
len
+
1
;
kk_global_buffer
[
0
]
=
mode
->
len
;
memcpy
(
&
kk_global_buffer
[
1
],
mode
->
data
,
kk_global_buffer
[
0
]
-
1
);
kk_private_protocol
(
node
,
kk_global_len
,
kk_global_buffer
);
emberAfCorePrintln
(
"~~~~~~~~~~~data~~~~~~~~~~"
);
emberAfCorePrintBuffer
(
mode
->
data
,
mode
->
len
,
true
);
emberAfCorePrintln
(
"
\n
"
);
break
;
}
mode
->
next
;
}
return
status
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
View file @
47e91b73
#ifndef __KK_TSL_PROPERTY_SET_H
#define __KK_TSL_PROPERTY_SET_H
#include "kk_test.h"
#include "kk_color_space.h"
cJSON
*
kk_topo_change_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
...
...
@@ -19,6 +20,7 @@ int kk_tsl_set_colorlight_RGB_green(jrpc_context * ctx,EmberNodeId node,unsigned
int
kk_tsl_set_colorlight_RGB_blue
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_Brightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
#define RPC_KK_TEST_FUNCTION_TABLE \
{(
rpc_function
*
)
kk_tsl_property_operation
,
"/thing/service/property/set"
}
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
View file @
47e91b73
...
...
@@ -17,6 +17,15 @@ uint8_t kk_get_rpc_report_api_size(void )
{
return
sizeof
(
kk_rpc_report_api
)
/
sizeof
(
kk_rpc_report_api_s
);
}
//kk private api
#define KK_PRIVATE_PROTOCOL_CLUSTER 0xFCC0
#define KK_PRIVATE_PROTOCOL_ATTRIBUTE 0x0000
EmberAfStatus
kk_private_protocol
(
uint16_t
node
,
uint8_t
dataLen
,
uint8_t
*
data
)
{
EmberAfStatus
status
=
zclGWrite
(
node
,
1
,
1
,
false
,
KK_PRIVATE_PROTOCOL_CLUSTER
,
KK_PRIVATE_PROTOCOL_ATTRIBUTE
,
ZCL_CHAR_STRING_ATTRIBUTE_TYPE
,
dataLen
,
data
,
true
);
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
47e91b73
...
...
@@ -19,19 +19,20 @@ typedef struct{
void
kk_rpc_test
(
void
);
#define KK_RPC_SET_FUNCTION_TABLE {\
{
"kk_permit_join"
,
kk_permit_join
},
\
{
"zclOnOff"
,
kk_tsl_set_gloabl_OnOff
},
\
{
"zclOnOff_Off"
,
zclOnOff_Off
},
\
{
"kk_tsl_set_colorlight_RGB_red"
,
kk_tsl_set_colorlight_RGB_red
},
\
{
"kk_tsl_set_colorlight_RGB_green"
,
kk_tsl_set_colorlight_RGB_green
},
\
{
"kk_tsl_set_colorlight_RGB_blue"
,
kk_tsl_set_colorlight_RGB_blue
},
\
{
"kk_tsl_set_colorlight_Brightness"
,
kk_tsl_set_colorlight_Brightness
},
\
{
"kk_
permit_join"
,
kk_permit_join
},
\
{
"kk_
tsl_report_colorControl_mode"
,
kk_tsl_set_colorlight_mode
},
\
}
#define KK_RPC_REPORT_FUNCTION_TABLE {\
{
"kk_tsl_report_global_onoff"
,
kk_tsl_report_global_onoff
},
\
{
"kk_tsl_report_colorControl_Brightness"
,
kk_tsl_report_colorControl_Brightness
},
\
{
"kk_tsl_report_colorControl_RGB"
,
kk_tsl_report_colorControl_RGB
},
\
}
kk_rpc_set_api_s
kk_rpc_set_api
[];
...
...
@@ -133,6 +134,13 @@ typedef enum{
}
SquawkModeField
;
EmberAfStatus
kk_private_protocol
(
uint16_t
node
,
uint8_t
dataLen
,
uint8_t
*
data
);
EmberStatus
kk_network_leave
(
void
);
EmberStatus
kk_network_form
(
bool
centralized
,
EmberPanId
panId
,
int8_t
radioTxPower
,
uint8_t
channel
);
void
kk_print_network_info
(
void
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
47e91b73
...
...
@@ -201,7 +201,7 @@ void emberAfMainTickCallback(void)
static
unsigned
int
last_time
;
unsigned
int
time
=
halCommonGetInt32uMillisecondTick
();
if
((
time
-
last_time
)
>=
3000
){
if
((
time
-
last_time
)
>=
3000
){
last_time
=
time
;
kk_productCode_tick
();
//printf("kk_productCode_tick!\n");
...
...
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
View file @
47e91b73
...
...
@@ -88,6 +88,7 @@ void kk_read_ncp_configuration_without_memory_allocation(void)
extern
void
kk_print_network_info
(
void
);
extern
void
test_123
(
int
val
);
void
kk_message_process
(
char
*
messageString
)
{
...
...
@@ -103,6 +104,15 @@ void kk_message_process(char *messageString)
if
(
MEMCOMPARE
(
messageString
,
"AT+GETINFO
\r\n
"
,
len
)
==
0
){
kk_print_network_info
();
}
if
(
MEMCOMPARE
(
messageString
,
"AT+MODE
\r\n
"
,
len
)
==
0
){
static
int
cnt
=
1
;
if
(
cnt
++>
11
)
cnt
=
1
;
test_123
(
cnt
);
}
if
(
MEMCOMPARE
(
messageString
,
"AT+COLOR
\r\n
"
,
len
)
==
0
){
//zclColorControlMovetohueandsat(node,ep,h,s,0,0,0,0);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//api
...
...
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