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
e6ffee28
Commit
e6ffee28
authored
Sep 17, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,增加彩带灯在新框架上的控制和属性上报;2,去掉原来的zigbee map文件
【提交人】陈伟灿
parent
863ae218
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
592 additions
and
219 deletions
+592
-219
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_1022.json
...uilder/Z3GatewayHost/ZB/dev_config_table/device_1022.json
+70
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_3073.json
...uilder/Z3GatewayHost/ZB/dev_config_table/device_3073.json
+14
-14
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
+3
-3
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
+3
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_rgb_hsl_convert.c
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_rgb_hsl_convert.c
+114
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_rgb_hsl_convert.h
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_rgb_hsl_convert.h
+22
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+184
-32
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
+2
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+166
-63
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
+6
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+7
-2
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+0
-4
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+0
-1
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
+0
-56
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
...form/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
+0
-41
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
e6ffee28
...
@@ -289,9 +289,9 @@ APPLICATION_FILES= \
...
@@ -289,9 +289,9 @@ APPLICATION_FILES= \
./ZB/kk_device_table_db.c
\
./ZB/kk_device_table_db.c
\
./ZB/kk_msg_report.c
\
./ZB/kk_msg_report.c
\
./ZB/kk_plat_ota.c
\
./ZB/kk_plat_ota.c
\
./ZB/kk_rgb_hsl_convert.c
\
./kk_test.c
\
./kk_test.c
\
./kk_sub_tsl.c
\
./kk_sub_tsl.c
\
./kk_tsl_zigbee_map.c
\
./rpc_api/src/rpc_common.c
\
./rpc_api/src/rpc_common.c
\
./rpc_api/src/rpc_onoff.c
\
./rpc_api/src/rpc_onoff.c
\
./rpc_api/src/rpc_global_cmd.c
\
./rpc_api/src/rpc_global_cmd.c
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_1022.json
0 → 100644
View file @
e6ffee28
{
"productCode"
:
"1022"
,
"config"
:[
{
"identity"
:
"PowerSwitch"
,
"endpoint"
:
1
,
"cluster"
:
"0x0006"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_global_onoff"
,
"controlFunc"
:
"zclOnOff"
},{
"identity"
:
"RGBColor.red"
,
"endpoint"
:
1
,
"cluster"
:
"0xFFFF"
,
"attribute"
:
"0xFFFF"
,
"reportFunc"
:
""
,
"controlFunc"
:
"kk_tsl_set_colorlight_RGB_red"
},{
"identity"
:
"RGBColor.green"
,
"endpoint"
:
1
,
"cluster"
:
"0xFFFF"
,
"attribute"
:
"0xFFFF"
,
"reportFunc"
:
""
,
"controlFunc"
:
"kk_tsl_set_colorlight_RGB_green"
},{
"identity"
:
"RGBColor.blue"
,
"endpoint"
:
1
,
"cluster"
:
"0xFFFF"
,
"attribute"
:
"0xFFFF"
,
"reportFunc"
:
""
,
"controlFunc"
:
"kk_tsl_set_colorlight_RGB_blue"
},{
"identity"
:
"CurrentHue"
,
"endpoint"
:
1
,
"cluster"
:
"0x0300"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_colorControl_RGB"
,
"controlFunc"
:
""
},{
"identity"
:
"CurrentSaturation"
,
"endpoint"
:
1
,
"cluster"
:
"0x0300"
,
"attribute"
:
"0x0001"
,
"reportFunc"
:
"kk_tsl_report_colorControl_RGB"
,
"controlFunc"
:
""
},{
"identity"
:
"Brightness"
,
"endpoint"
:
1
,
"cluster"
:
"0x0008"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_colorControl_Brightness"
,
"controlFunc"
:
"kk_tsl_set_colorlight_Brightness"
},{
"identity"
:
"WhiteBrightness"
,
"endpoint"
:
2
,
"cluster"
:
"0x0008"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_colorControl_Brightness"
,
"controlFunc"
:
"kk_tsl_set_colorlight_Brightness"
},{
"identity"
:
"Mode"
,
"endpoint"
:
1
,
"cluster"
:
"0xFCC0"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_colorControl_mode"
,
"controlFunc"
:
"kk_tsl_set_colorlight_mode"
}
]
}
\ No newline at end of file
platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table/device_3073.json
View file @
e6ffee28
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"productCode"
:
"3073"
,
"productCode"
:
"3073"
,
"config"
:[
"config"
:[
{
{
"identity"
:
"PowerSwitch
_1
"
,
"identity"
:
"PowerSwitch"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
"cluster"
:
"0x0006"
,
"cluster"
:
"0x0006"
,
"attribute"
:
"0x0000"
,
"attribute"
:
"0x0000"
,
...
@@ -11,37 +11,37 @@
...
@@ -11,37 +11,37 @@
},{
},{
"identity"
:
"RGBColor.red"
,
"identity"
:
"RGBColor.red"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
"cluster"
:
""
,
"cluster"
:
"
0xFFFF
"
,
"attribute"
:
""
,
"attribute"
:
"
0xFFFF
"
,
"reportFunc"
:
""
,
"reportFunc"
:
""
,
"controlFunc"
:
"
xxx
"
"controlFunc"
:
"
kk_tsl_set_colorlight_RGB_red
"
},{
},{
"identity"
:
"RGBColor.green"
,
"identity"
:
"RGBColor.green"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
"cluster"
:
""
,
"cluster"
:
"
0xFFFF
"
,
"attribute"
:
""
,
"attribute"
:
"
0xFFFF
"
,
"reportFunc"
:
""
,
"reportFunc"
:
""
,
"controlFunc"
:
"
xxx
"
"controlFunc"
:
"
kk_tsl_set_colorlight_RGB_green
"
},{
},{
"identity"
:
"RGBColor.blue"
,
"identity"
:
"RGBColor.blue"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
"cluster"
:
""
,
"cluster"
:
"
0xFFFF
"
,
"attribute"
:
""
,
"attribute"
:
"
0xFFFF
"
,
"reportFunc"
:
""
,
"reportFunc"
:
""
,
"controlFunc"
:
"
xxx
"
"controlFunc"
:
"
kk_tsl_set_colorlight_RGB_blue
"
},{
},{
"identity"
:
"CurrentHue"
,
"identity"
:
"CurrentHue"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
"cluster"
:
"0x0300"
,
"cluster"
:
"0x0300"
,
"attribute"
:
"0x0000"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_
global_onoff
"
,
"reportFunc"
:
"kk_tsl_report_
colorControl_RGB
"
,
"controlFunc"
:
""
"controlFunc"
:
""
},{
},{
"identity"
:
"CurrentSaturation"
,
"identity"
:
"CurrentSaturation"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
"cluster"
:
"0x0300"
,
"cluster"
:
"0x0300"
,
"attribute"
:
"0x0001"
,
"attribute"
:
"0x0001"
,
"reportFunc"
:
"kk_tsl_report_
global_onoff
"
,
"reportFunc"
:
"kk_tsl_report_
colorControl_RGB
"
,
"controlFunc"
:
""
"controlFunc"
:
""
},{
},{
"identity"
:
"Brightness"
,
"identity"
:
"Brightness"
,
...
@@ -55,8 +55,8 @@
...
@@ -55,8 +55,8 @@
"endpoint"
:
2
,
"endpoint"
:
2
,
"cluster"
:
"0x0008"
,
"cluster"
:
"0x0008"
,
"attribute"
:
"0x0000"
,
"attribute"
:
"0x0000"
,
"reportFunc"
:
"kk_tsl_report_colorControl_
White
Brightness"
,
"reportFunc"
:
"kk_tsl_report_colorControl_Brightness"
,
"controlFunc"
:
"kk_tsl_set_colorlight_
White
Brightness"
"controlFunc"
:
"kk_tsl_set_colorlight_Brightness"
},{
},{
"identity"
:
"Mode"
,
"identity"
:
"Mode"
,
"endpoint"
:
1
,
"endpoint"
:
1
,
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
View file @
e6ffee28
...
@@ -464,7 +464,7 @@ void kk_device_config_item_report(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId c
...
@@ -464,7 +464,7 @@ void kk_device_config_item_report(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId c
kk_dev_config_item
*
item
;
kk_dev_config_item
*
item
;
kk_dev_config_map
*
cfgMap
;
kk_dev_config_map
*
cfgMap
;
char
*
pCode
;
char
*
pCode
;
kk_
zigbee_property
_report
func
;
kk_
rpc
_report
func
;
pCode
=
kk_device_find_productCode
(
eui64
);
pCode
=
kk_device_find_productCode
(
eui64
);
cfgMap
=
kk_device_config_find
(
pCode
);
cfgMap
=
kk_device_config_find
(
pCode
);
...
@@ -554,8 +554,8 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
...
@@ -554,8 +554,8 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
memcpy
(
ptr
->
item
.
controlFuncName
,
controlFuncName
,
len
);
memcpy
(
ptr
->
item
.
controlFuncName
,
controlFuncName
,
len
);
ptr
->
item
.
controlFuncName
[
len
]
=
'\0'
;
ptr
->
item
.
controlFuncName
[
len
]
=
'\0'
;
newItem
->
reportFunc
=
kk_find_rpc_report_function_api
(
reportFuncName
);
ptr
->
item
.
reportFunc
=
kk_find_rpc_report_function_api
(
reportFuncName
);
newItem
->
controlFunc
=
kk_find_rpc_set_function_api
(
controlFuncName
);
ptr
->
item
.
controlFunc
=
kk_find_rpc_set_function_api
(
controlFuncName
);
if
(
dev_config_map
==
NULL
){
if
(
dev_config_map
==
NULL
){
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
View file @
e6ffee28
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#define __KK_DEVICE_MANAGER_H
#define __KK_DEVICE_MANAGER_H
#include "kk_test.h"
#include "kk_test.h"
#include "kk_sub_tsl.h"
#include "kk_sub_tsl.h"
#include "kk_tsl_zigbee_map.h"
#include "kk_product_code.h"
#include "kk_product_code.h"
#include "kk_zb_com.h"
#include "kk_zb_com.h"
...
@@ -19,6 +18,9 @@
...
@@ -19,6 +18,9 @@
#define KK_NETWORK_PARAMETER_TX_POWER 10
#define KK_NETWORK_PARAMETER_TX_POWER 10
#define KK_NETWORK_PARAMETER_CHANNEL 0x0B
#define KK_NETWORK_PARAMETER_CHANNEL 0x0B
#define KK_EP(x) (x)
#define KK_DUMMY_EP KK_EP(0)
#define KK_PRIMARY_EP KK_EP(1)
void
kk_productCode_tick
();
void
kk_productCode_tick
();
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_rgb_hsl_convert.c
0 → 100644
View file @
e6ffee28
#include <stdio.h>
#include "kk_rgb_hsl_convert.h"
#define min3v(v1, v2, v3) ((v1)>(v2)? ((v2)>(v3)?(v3):(v2)):((v1)>(v3)?(v3):(v2)))
#define max3v(v1, v2, v3) ((v1)<(v2)? ((v2)<(v3)?(v3):(v2)):((v1)<(v3)?(v3):(v1)))
// Converts RGB to HSL
void
RGBtoHSL
(
const
COLOR_RGB
*
rgb
,
COLOR_HSL
*
hsl
)
{
float
h
=
0
,
s
=
0
,
l
=
0
;
// normalizes red-green-blue values
float
r
=
rgb
->
red
/
255
.
0
f
;
float
g
=
rgb
->
green
/
255
.
0
f
;
float
b
=
rgb
->
blue
/
255
.
0
f
;
float
maxVal
=
max3v
(
r
,
g
,
b
);
float
minVal
=
min3v
(
r
,
g
,
b
);
// hue
if
(
maxVal
==
minVal
)
{
h
=
0
;
// undefined
}
else
if
(
maxVal
==
r
&&
g
>=
b
)
{
h
=
60
.
0
f
*
(
g
-
b
)
/
(
maxVal
-
minVal
);
}
else
if
(
maxVal
==
r
&&
g
<
b
)
{
h
=
60
.
0
f
*
(
g
-
b
)
/
(
maxVal
-
minVal
)
+
360
.
0
f
;
}
else
if
(
maxVal
==
g
)
{
h
=
60
.
0
f
*
(
b
-
r
)
/
(
maxVal
-
minVal
)
+
120
.
0
f
;
}
else
if
(
maxVal
==
b
)
{
h
=
60
.
0
f
*
(
r
-
g
)
/
(
maxVal
-
minVal
)
+
240
.
0
f
;
}
// luminance
l
=
(
maxVal
+
minVal
)
/
2
.
0
f
;
// saturation
if
(
l
==
0
||
maxVal
==
minVal
)
{
s
=
0
;
}
else
if
(
0
<
l
&&
l
<=
0
.
5
f
)
{
s
=
(
maxVal
-
minVal
)
/
(
maxVal
+
minVal
);
}
else
if
(
l
>
0
.
5
f
)
{
s
=
(
maxVal
-
minVal
)
/
(
2
-
(
maxVal
+
minVal
));
//(maxVal-minVal > 0)?
}
hsl
->
hue
=
(
h
>
360
)
?
360
:
((
h
<
0
)
?
0
:
h
);
hsl
->
saturation
=
((
s
>
1
)
?
1
:
((
s
<
0
)
?
0
:
s
))
*
100
;
hsl
->
luminance
=
((
l
>
1
)
?
1
:
((
l
<
0
)
?
0
:
l
))
*
100
;
}
// Converts HSL to RGB
void
HSLtoRGB
(
const
COLOR_HSL
*
hsl
,
COLOR_RGB
*
rgb
)
{
float
h
=
hsl
->
hue
;
// h must be [0, 360]
float
s
=
hsl
->
saturation
/
100
.
f
;
// s must be [0, 1]
float
l
=
hsl
->
luminance
/
100
.
f
;
// l must be [0, 1]
float
R
,
G
,
B
;
if
(
hsl
->
saturation
==
0
)
{
// achromatic color (gray scale)
R
=
G
=
B
=
l
*
255
.
0
f
;
}
else
{
float
q
=
(
l
<
0
.
5
f
)
?
(
l
*
(
1
.
0
f
+
s
))
:
(
l
+
s
-
(
l
*
s
));
float
p
=
(
2
.
0
f
*
l
)
-
q
;
float
Hk
=
h
/
360
.
0
f
;
float
T
[
3
];
T
[
0
]
=
Hk
+
0
.
3333333
f
;
// Tr 0.3333333f=1.0/3.0
T
[
1
]
=
Hk
;
// Tb
T
[
2
]
=
Hk
-
0
.
3333333
f
;
// Tg
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
if
(
T
[
i
]
<
0
)
T
[
i
]
+=
1
.
0
f
;
if
(
T
[
i
]
>
1
)
T
[
i
]
-=
1
.
0
f
;
if
((
T
[
i
]
*
6
)
<
1
)
{
T
[
i
]
=
p
+
((
q
-
p
)
*
6
.
0
f
*
T
[
i
]);
}
else
if
((
T
[
i
]
*
2
.
0
f
)
<
1
)
//(1.0/6.0)<=T[i] && T[i]<0.5
{
T
[
i
]
=
q
;
}
else
if
((
T
[
i
]
*
3
.
0
f
)
<
2
)
// 0.5<=T[i] && T[i]<(2.0/3.0)
{
T
[
i
]
=
p
+
(
q
-
p
)
*
((
2
.
0
f
/
3
.
0
f
)
-
T
[
i
])
*
6
.
0
f
;
}
else
T
[
i
]
=
p
;
}
R
=
T
[
0
]
*
255
.
0
f
;
G
=
T
[
1
]
*
255
.
0
f
;
B
=
T
[
2
]
*
255
.
0
f
;
}
rgb
->
red
=
(
int
)((
R
>
255
)
?
255
:
((
R
<
0
)
?
0
:
R
));
rgb
->
green
=
(
int
)((
G
>
255
)
?
255
:
((
G
<
0
)
?
0
:
G
));
rgb
->
blue
=
(
int
)((
B
>
255
)
?
255
:
((
B
<
0
)
?
0
:
B
));
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_rgb_hsl_convert.h
0 → 100644
View file @
e6ffee28
#ifndef _RGB_HSL_CONVERT_H_
#define _RGB_HSL_CONVERT_H_
typedef
struct
{
int
red
;
// [0,255]
int
green
;
// [0,255]
int
blue
;
// [0,255]
}
COLOR_RGB
;
typedef
struct
{
float
hue
;
// [0,360]
float
saturation
;
// [0,100]
float
luminance
;
// [0,100]
}
COLOR_HSL
;
void
RGBtoHSL
(
const
COLOR_RGB
*
rgb
,
COLOR_HSL
*
hsl
);
void
HSLtoRGB
(
const
COLOR_HSL
*
hsl
,
COLOR_RGB
*
rgb
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
e6ffee28
#include "kk_tsl_property_report.h"
#include "kk_tsl_property_report.h"
#include "kk_tsl_zigbee_map.h"
#include "kk_device_manager.h"
#include "kk_device_manager.h"
#include "kk_rgb_hsl_convert.h"
const
char
*
kk_tsl_rpt_status_string
[]
=
{
const
char
*
kk_tsl_rpt_status_string
[]
=
{
"Success"
,
"Success"
,
...
@@ -10,12 +10,54 @@ const char *kk_tsl_rpt_status_string[] = {
...
@@ -10,12 +10,54 @@ const char *kk_tsl_rpt_status_string[] = {
"Invaild Type"
"Invaild Type"
};
};
//todo: fix it
//todo: fix it
static
cJSON
*
kk_check_identify
(
const
char
*
identify
,
cJSON
*
root
,
int
index
,
int
status
)
{
int
rev
=
0
,
startIdx2
=
0
,
startIdx1
=
0
;
char
*
Identify_str
;
char
tmp_Identity
[
64
]
=
{
0
};
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
2
,
&
startIdx2
);
if
(
!
rev
){
cJSON
*
str
=
NULL
;
cJSON
*
str_r
=
NULL
;
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
str
=
rpc_cJSON_CreateObject
();
Identify_str
=
identify
+
1
+
startIdx2
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
+
startIdx1
+
1
,
startIdx2
-
startIdx1
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
str_r
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
str_r
,
tmp_Identity
,
str
);
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str_r
);
return
root
;
}
else
{
rev
=
kk_tsl_utils_memtok
(
identify
,
'.'
,
1
,
&
startIdx1
);
if
(
!
rev
){
cJSON
*
str
=
NULL
;
str
=
rpc_cJSON_CreateObject
();
Identify_str
=
identify
+
1
+
startIdx1
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
identify
,
startIdx1
);
rpc_cJSON_AddNumberToObject
(
str
,
Identify_str
,
status
);
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
str
);
return
root
;
}
}
return
NULL
;
}
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
;
cJSON
*
root
,
*
root_tmp
;
int
index
;
int
index
;
char
*
Identify
;
char
*
Identify
;
sub_dev_node_t
*
node
=
NULL
;
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
;
...
@@ -45,13 +87,20 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
...
@@ -45,13 +87,20 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
}
}
item
=
item
->
next
;
item
=
item
->
next
;
}
}
root_tmp
=
kk_check_identify
(
Identify
,
root
,
index
,
status
);
if
(
root_tmp
!=
NULL
){
kk_rpc_report_status
(
root_tmp
,
mac
);
}
else
{
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
kk_msg_report_property
(
root
,
mac
);
rpc_cJSON_AddNumberToObject
(
root
,
Identify
,
status
);
}
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);
void
kk_tsl_report_attribute
(
EmberEUI64
eui64
,
void
kk_tsl_report_attribute
(
EmberEUI64
eui64
,
uint8_t
EP
,
uint8_t
EP
,
...
@@ -61,44 +110,48 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
...
@@ -61,44 +110,48 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
uint8_t
len
,
uint8_t
len
,
uint8_t
*
data
)
uint8_t
*
data
)
{
{
int
i
,
j
,
num
,
status
;
int
i
,
j
,
num
,
status
;
char
macString
[
19
]
=
{
0
};
sub_dev_node_t
*
node
=
NULL
;
sub_dev_node_t
*
node
=
NULL
;
int
res
=
0
;
int
res
=
0
;
char
macString
[
RPC_EUI64_STRING_LENGTH
];
kk_device_table_s
*
dev
;
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
"
);
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);
dev
=
kk_device_find_by_mac
(
eui64
);
if
(
dev
==
NULL
){
return
;
}
num
=
kk_get_tsl_num
();
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
for
(
i
=
0
;
i
<
num
;
i
++
){
if
(
dev_info
==
NULL
){
if
(
g_tsl_zigbee_map
[
i
].
clusterId
==
clusterId
&&
g_tsl_zigbee_map
[
i
].
attributeId
==
attributeId
&&
g_tsl_zigbee_map
[
i
].
zigbee_report
!=
NULL
){
status
=
g_tsl_zigbee_map
[
i
].
zigbee_report
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
emberAfDebugPrintln
(
"report status:%s"
,
kk_tsl_rpt_status_string
[
status
]);
return
;
}
}
rpc_eui64ToString
(
eui64
,
macString
);
res
=
kk_sub_tsl_get_device_by_mac
(
macString
,
&
node
);
if
(
res
!=
tsl_rpt_success
){
emberAfAppPrintln
(
"[kk_tsl_report_attribute] error~~~~~~~~~
\n
"
);
return
;
return
;
}
}
num
=
kk_get_tsl_glb_num
();
for
(
i
=
0
;
i
<
num
;
i
++
){
item
=
&
dev_info
->
item
;
if
(
g_tsl_zigbee_map_glb
[
i
].
map
.
clusterId
==
clusterId
&&
while
(
item
!=
NULL
){
g_tsl_zigbee_map_glb
[
i
].
map
.
attributeId
==
attributeId
&&
if
(
EP
==
item
->
endpoint
&&
strncmp
(
node
->
productCode
,
g_tsl_zigbee_map_glb
[
i
].
ProductCode
,
strlen
(
node
->
productCode
))
==
0
&&
clusterId
==
item
->
cluster
&&
g_tsl_zigbee_map_glb
[
i
].
map
.
zigbee_report
!=
NULL
){
attributeId
==
item
->
attribute
){
status
=
g_tsl_zigbee_map_glb
[
i
].
map
.
zigbee_report
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
emberAfDebugPrintln
(
"--report status:%s"
,
kk_tsl_rpt_status_string
[
status
]);
func
=
item
->
reportFunc
;
return
;
if
(
func
!=
NULL
){
func
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
}
else
{
}
return
;
}
}
item
=
item
->
next
;
}
}
}
}
...
@@ -316,8 +369,107 @@ int kk_tsl_report_CO2(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,Emb
...
@@ -316,8 +369,107 @@ int kk_tsl_report_CO2(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,Emb
}
}
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
];
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_Brightness] value:%d
\n
"
,
value
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
len
==
1
){
kk_tsl_report
(
eui64
,
EP
,
value
,
clusterId
,
attributeId
);
return
tsl_rpt_success
;
}
return
tsl_rpt_invaild_len
;
}
return
tsl_rpt_invaild_type
;
}
static
int
s_HSLCount
=
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
)
{
uint8_t
value
=
data
[
0
];
kk_device_table_s
*
dev
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
cJSON
*
root
;
int
rev
=
0
;
int
startIdx
=
0
;
cJSON
*
root_color
=
NULL
;
char
tmp_Identity
[
64
]
=
{
0
};
COLOR_RGB
g_rgb
=
{
0
,
0
,
0
};
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_RGB] value:%d
\n
"
,
value
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
attributeId
==
0x0001
){
g_hsl
.
saturation
=
value
;
s_HSLCount
++
;
}
else
if
(
attributeId
==
0x0
){
g_hsl
.
hue
=
value
;
s_HSLCount
++
;
}
}
if
(
s_HSLCount
>=
2
){
s_HSLCount
=
0
;
HSLtoRGB
(
&
g_hsl
,
&
g_rgb
);
dev
=
kk_device_find_by_mac
(
eui64
);
if
(
dev
==
NULL
){
return
tsl_rpt_err
;
}
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
if
(
dev_info
==
NULL
){
return
tsl_rpt_err
;
}
item
=
&
dev_info
->
item
;
while
(
item
!=
NULL
){
if
(
strstr
(
item
->
identity
,
".red"
)
!=
NULL
){
if
(
root_color
==
NULL
){
root_color
=
rpc_cJSON_CreateObject
();
}
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
if
(
!
rev
){
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
red
);
}
}
else
if
(
strstr
(
item
->
identity
,
".green"
)
!=
NULL
){
if
(
root_color
==
NULL
){
root_color
=
rpc_cJSON_CreateObject
();
}
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
if
(
!
rev
){
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
green
);
}
}
else
if
(
strstr
(
item
->
identity
,
".blue"
)
!=
NULL
){
if
(
root_color
==
NULL
){
root_color
=
rpc_cJSON_CreateObject
();
}
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx
);
if
(
!
rev
){
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx
);
rpc_cJSON_AddNumberToObject
(
root_color
,
item
->
identity
+
1
+
startIdx
,
g_rgb
.
blue
);
}
}
item
=
item
->
next
;
}
if
(
root_color
!=
NULL
){
root
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
root
,
tmp_Identity
,
root_color
);
kk_msg_report_property
(
root
,
eui64
);
return
tsl_rpt_success
;
}
}
return
tsl_rpt_err
;
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
View file @
e6ffee28
...
@@ -40,7 +40,8 @@ int kk_tsl_report_OccupiedHeatingSetpoint(EmberEUI64 eui64,uint8_t EP,EmberAfClu
...
@@ -40,7 +40,8 @@ int kk_tsl_report_OccupiedHeatingSetpoint(EmberEUI64 eui64,uint8_t EP,EmberAfClu
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_RGB
(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
e6ffee28
#include "kk_tsl_property_set.h"
#include "kk_tsl_property_set.h"
#include "kk_rgb_hsl_convert.h"
//emberAfAppPrintln("[tsl report:Gloabl] OnOff~~~~~~~~~");
//emberAfAppPrintln("[tsl report:Gloabl] OnOff~~~~~~~~~");
//cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
//cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
int
kk_tsl_utils_memtok
(
_IN_
char
*
input
,
_IN_
char
*
delimiter
,
_IN_
int
index
,
_OU_
int
*
offset
)
{
int
item_index
=
0
;
int
count
=
0
;
int
input_len
=
0
;
if
(
input
==
NULL
||
offset
==
NULL
)
{
return
-
1
;
}
input_len
=
strlen
(
input
);
for
(
item_index
=
0
;
item_index
<
input_len
;
item_index
++
)
{
if
(
input
[
item_index
]
==
delimiter
&&
(
item_index
+
1
)
<
input_len
)
{
count
++
;
if
(
count
==
index
)
{
*
offset
=
item_index
;
return
0
;
}
}
}
return
-
1
;
}
cJSON
*
kk_tsl_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
cJSON
*
kk_tsl_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
{
sub_dev_node_t
*
node
=
NULL
;
int
res
=
0
;
int
res
=
0
;
rpc_nwk_info_s
info
;
EmberStatus
status
;;
EmberStatus
status
;
kk_device_table_s
*
dev
;
int
index
=
0
;
kk_dev_config_map
*
dev_info
=
NULL
;
zigbee_property_set
*
func
;
kk_dev_config_item
*
item
=
NULL
;
int
num
;
cJSON
*
propertyItem
=
NULL
;
uint8_t
findFlag
=
0xff
;
cJSON
*
propertyItem1
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
propertyItem2
=
NULL
;
EmberEUI64
eui64
;
kk_rpc_set
func
;
int
rev
=
0
,
startIdx1
=
0
,
startIdx2
=
0
;
char
tmp_Identity
[
64
]
=
{
0
};
int
findFlag
=
0
;
uint8_t
eui64
[
EUI64_SIZE
];
EmberNodeId
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
EmberNodeId
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
UTIL_LOG_INFO
(
"
\n
********************kk tsl property operation********************
\n
"
);
UTIL_LOG_INFO
(
"
\n
********************kk tsl property operation********************
\n
"
);
...
@@ -23,67 +53,77 @@ cJSON *kk_tsl_property_operation(jrpc_context * ctx, cJSON *params, cJSON *id,cJ
...
@@ -23,67 +53,77 @@ cJSON *kk_tsl_property_operation(jrpc_context * ctx, cJSON *params, cJSON *id,cJ
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
goto
error_return
;
}
else
{
}
else
{
res
=
kk_sub_tsl_get_device_by_mac
(
mac
->
valuestring
,
&
node
);
rpc_get_mac
(
mac
->
valuestring
,
eui64
);
if
(
res
!=
SUCCESS_RETURN
)
{
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
dev
=
kk_device_find_by_mac
(
eui64
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
if
(
dev
==
NULL
){
goto
error_return
;
}
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
if
(
dev_info
==
NULL
){
goto
error_return
;
goto
error_return
;
}
}
item
=
&
dev_info
->
item
;
num
=
kk_get_tsl_num
();
while
(
item
!=
NULL
){
for
(
index
=
0
;
index
<
num
;
index
++
){
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map
[
index
].
Identity
);
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
2
,
&
startIdx2
);
if
(
propertyItem
!=
NULL
){
if
(
!
rev
){
findFlag
=
1
;
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx1
);
break
;
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
}
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx1
);
}
propertyItem2
=
rpc_cJSON_GetObjectItem
(
params
,
tmp_Identity
);
if
(
findFlag
==
0xff
){
if
(
propertyItem2
!=
NULL
){
num
=
kk_get_tsl_glb_num
();
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
for
(
index
=
0
;
index
<
num
;
index
++
){
memcpy
(
tmp_Identity
,
item
->
identity
+
startIdx1
+
1
,
startIdx2
-
startIdx1
);
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
g_tsl_zigbee_map_glb
[
index
].
map
.
Identity
);
propertyItem1
=
rpc_cJSON_GetObjectItem
(
propertyItem2
,
tmp_Identity
);
if
(
propertyItem
!=
NULL
){
if
(
propertyItem1
!=
NULL
){
findFlag
=
2
;
propertyItem
=
rpc_cJSON_GetObjectItem
(
propertyItem1
,
item
->
identity
+
startIdx2
+
1
);
break
;
if
(
propertyItem
!=
NULL
){
findFlag
=
1
;
}
}
}
}
}
}
if
(
findFlag
!=
0xff
)
{
int
value
=
0
;
if
(
propertyItem
->
type
!=
cJSON_Number
){
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
}
else
{
value
=
propertyItem
->
valueint
;
}
if
(
rpc_get_mac
(
mac
->
valuestring
,
eui64
)
==
false
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
emberAfDebugPrint
(
"mac:"
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfDebugPrintln
(
",node:0x%04X"
,
nodeId
);
if
(
findFlag
==
1
)
res
=
g_tsl_zigbee_map
[
index
].
zigbee_set
(
ctx
,
nodeId
,
g_tsl_zigbee_map
[
index
].
endpoint
,
&
value
);
else
if
(
findFlag
==
2
)
res
=
g_tsl_zigbee_map_glb
[
index
].
map
.
zigbee_set
(
ctx
,
nodeId
,
g_tsl_zigbee_map_glb
[
index
].
map
.
endpoint
,
&
value
);
if
(
res
<
0
)
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
return
rpc_cJSON_CreateNumber
(
res
);
}
}
}
else
{
rev
=
kk_tsl_utils_memtok
(
item
->
identity
,
'.'
,
1
,
&
startIdx1
);
if
(
!
rev
){
memset
(
tmp_Identity
,
0x0
,
sizeof
(
tmp_Identity
));
memcpy
(
tmp_Identity
,
item
->
identity
,
startIdx1
);
propertyItem1
=
rpc_cJSON_GetObjectItem
(
params
,
tmp_Identity
);
if
(
propertyItem1
!=
NULL
){
propertyItem
=
rpc_cJSON_GetObjectItem
(
propertyItem1
,
item
->
identity
+
startIdx1
+
1
);
if
(
propertyItem
!=
NULL
){
findFlag
=
1
;
}
}
}
else
{
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
item
->
identity
);
if
(
propertyItem
!=
NULL
){
findFlag
=
1
;
}
}
}
if
(
findFlag
==
1
){
int
value
=
0
;
if
(
propertyItem
->
type
!=
cJSON_Number
){
value
=
rpc_get_u8
(
propertyItem
->
valuestring
);
}
else
{
value
=
propertyItem
->
valueint
;
}
func
=
item
->
controlFunc
;
res
=
func
(
ctx
,
nodeId
,
item
->
endpoint
,
&
value
);
findFlag
=
0
;
}
item
=
item
->
next
;
}
return
rpc_cJSON_CreateNumber
(
res
);
}
}
error_return:
error_return:
return
rpc_cJSON_CreateNull
();
return
rpc_cJSON_CreateNull
();
}
}
...
@@ -221,7 +261,70 @@ error_return:
...
@@ -221,7 +261,70 @@ error_return:
return
-
1
;
return
-
1
;
}
}
static
uint8_t
s_RgbCount
=
0
;
static
COLOR_RGB
s_rgb
;
static
int
kk_zclColorControlMovetohueandsat
(
EmberNodeId
node
,
unsigned
char
ep
)
{
int
h
,
s
,
v
;
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
);
s_RgbCount
=
0
;
}
return
0
;
}
int
kk_tsl_set_colorlight_RGB_red
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
int
value
=
*
(
uint8_t
*
)
data
;
EmberStatus
status
=
0
;
emberAfAppPrintln
(
"[tsl set:kk_tsl_set_colorloght_RGB_red],value=0x%02x"
,
value
);
//s_Red = value;
s_rgb
.
red
=
value
;
s_RgbCount
++
;
status
=
kk_zclColorControlMovetohueandsat
(
node
,
ep
);
return
status
;
}
int
kk_tsl_set_colorlight_RGB_green
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
int
value
=
*
(
uint8_t
*
)
data
;
EmberStatus
status
=
0
;
emberAfAppPrintln
(
"[tsl set:kk_tsl_set_colorloght_RGB_green],value=0x%02x"
,
value
);
//s_Green = value;
s_rgb
.
green
=
value
;
s_RgbCount
++
;
status
=
kk_zclColorControlMovetohueandsat
(
node
,
ep
);
return
status
;
}
int
kk_tsl_set_colorlight_RGB_blue
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
int
value
=
*
(
uint8_t
*
)
data
;
EmberStatus
status
=
0
;
emberAfAppPrintln
(
"[tsl set:kk_tsl_set_colorloght_RGB_blue],value=0x%02x"
,
value
);
//s_Blue = value;
s_rgb
.
blue
=
value
;
s_RgbCount
++
;
status
=
kk_zclColorControlMovetohueandsat
(
node
,
ep
);
return
status
;
}
int
kk_tsl_set_colorlight_Brightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
int
value
=
*
(
uint8_t
*
)
data
;
EmberStatus
status
=
0
;
emberAfAppPrintln
(
"[tsl set:kk_tsl_set_colorloght_Brightness],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
;
}
status
=
zclLevel_MoveToLevel
(
node
,
ep
,
value
,
0
,
NULL
,
NULL
);
return
status
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
View file @
e6ffee28
...
@@ -11,6 +11,12 @@ int kk_tsl_set_windowCovering_OperationMode(jrpc_context * ctx,EmberNodeId node,
...
@@ -11,6 +11,12 @@ int kk_tsl_set_windowCovering_OperationMode(jrpc_context * ctx,EmberNodeId node,
int
kk_tsl_set_windowCovering_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_position
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_windowCovering_position
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_RGB_red
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_RGB_green
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_RGB_blue
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_Brightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
#define RPC_KK_TEST_FUNCTION_TABLE \
#define RPC_KK_TEST_FUNCTION_TABLE \
{(
rpc_function
*
)
kk_tsl_property_operation
,
"/thing/service/property/set"
}
\
{(
rpc_function
*
)
kk_tsl_property_operation
,
"/thing/service/property/set"
}
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
e6ffee28
...
@@ -20,12 +20,17 @@ void kk_rpc_test(void);
...
@@ -20,12 +20,17 @@ void kk_rpc_test(void);
#define KK_RPC_SET_FUNCTION_TABLE {\
#define KK_RPC_SET_FUNCTION_TABLE {\
{
"zclOnOff"
,
kk_tsl_set_gloabl_OnOff
},
\
{
"zclOnOff"
,
kk_tsl_set_gloabl_OnOff
},
\
{
"zclOnOff_Off"
,
zclOnOff_Off
}
\
{
"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
},
\
}
}
#define KK_RPC_REPORT_FUNCTION_TABLE {\
#define KK_RPC_REPORT_FUNCTION_TABLE {\
{
"kk_tsl_report_global_onoff"
,
kk_tsl_report_global_onoff
},
\
{
"kk_tsl_report_global_onoff"
,
kk_tsl_report_global_onoff
},
\
{
"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
[];
kk_rpc_set_api_s
kk_rpc_set_api
[];
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
e6ffee28
#include "kk_test.h"
#include "kk_test.h"
#include "kk_sub_tsl.h"
#include "kk_sub_tsl.h"
#include "kk_tsl_zigbee_map.h"
extern
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[];
static
void
kk_rpc_send_message
(
cJSON
*
data
,
char
*
msgtype
,
char
*
method
,
EmberEUI64
mac
)
static
void
kk_rpc_send_message
(
cJSON
*
data
,
char
*
msgtype
,
char
*
method
,
EmberEUI64
mac
)
{
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
e6ffee28
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
int
kk_zcl_onoff_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
int
kk_zcl_onoff_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.c
deleted
100644 → 0
View file @
863ae218
#include "kk_tsl_zigbee_map.h"
#include "kk_test.h"
#include "kk_product_code.h"
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[]
=
{
{
"NetChannelState"
,
KK_DUMMY_EP
,
kk_permit_join
,
0xffff
,
0xffff
,
NULL
},
{
"WorkMode"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_mode
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_MODE_ATTRIBUTE_ID
,
kk_tsl_report_windowCovering_mode
},
{
"Position"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_position
,
ZCL_WINDOW_COVERING_CLUSTER_ID
,
ZCL_CURRENT_LIFT_PERCENTAGE_ATTRIBUTE_ID
,
kk_tsl_report_windowCovering_position
},
};
kk_tsl_zigbee_map_glb_t
g_tsl_zigbee_map_glb
[]
=
{
{
"3001"
,
"PowerSwitch_1"
,
KK_EP
(
1
),
kk_tsl_set_gloabl_OnOff
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"3002"
,
"PowerSwitch_2"
,
KK_EP
(
2
),
kk_tsl_set_gloabl_OnOff
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"3003"
,
"PowerSwitch_3"
,
KK_EP
(
3
),
kk_tsl_set_gloabl_OnOff
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
{
"3005"
,
"OperationMode"
,
KK_PRIMARY_EP
,
kk_tsl_set_windowCovering_OperationMode
,
ZCL_ON_OFF_CLUSTER_ID
,
ZCL_ON_OFF_ATTRIBUTE_ID
,
kk_tsl_report_global_onoff
},
//开
};
int
kk_get_tsl_index
(
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
g_tsl_zigbee_map
)
/
sizeof
(
kk_tsl_zigbee_map_t
);
i
++
){
if
(
EP
==
g_tsl_zigbee_map
[
i
].
endpoint
&&
clusterId
==
g_tsl_zigbee_map
[
i
].
clusterId
&&
attributeId
==
g_tsl_zigbee_map
[
i
].
attributeId
){
return
i
;
}
}
return
-
1
;
}
int
kk_get_tsl_glb_index
(
const
char
*
pCode
,
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
g_tsl_zigbee_map_glb
)
/
sizeof
(
kk_tsl_zigbee_map_glb_t
);
i
++
){
if
(
EP
==
g_tsl_zigbee_map_glb
[
i
].
map
.
endpoint
&&
clusterId
==
g_tsl_zigbee_map_glb
[
i
].
map
.
clusterId
&&
attributeId
==
g_tsl_zigbee_map_glb
[
i
].
map
.
attributeId
&&
strstr
(
g_tsl_zigbee_map_glb
[
i
].
ProductCode
,
pCode
)
!=
NULL
){
return
i
;
}
}
return
-
1
;
}
int
kk_get_tsl_num
(
void
)
{
return
sizeof
(
g_tsl_zigbee_map
)
/
sizeof
(
kk_tsl_zigbee_map_t
);
}
int
kk_get_tsl_glb_num
(
void
)
{
return
sizeof
(
g_tsl_zigbee_map_glb
)
/
sizeof
(
kk_tsl_zigbee_map_glb_t
);
}
platform/zigbee/app/builder/Z3GatewayHost/kk_tsl_zigbee_map.h
deleted
100644 → 0
View file @
863ae218
#ifndef _KK_ZIGBEE_MAP_H_
#define _KK_ZIGBEE_MAP_H_
#include "RPC_API.h"
#include "kk_tsl_common.h"
#define KK_EP(x) (x)
#define KK_DUMMY_EP KK_EP(0)
#define KK_PRIMARY_EP KK_EP(1)
#define KK_DUMMY_CLUSTER_ID 0xffff
#define KK_DUMMY_ATTRIBUTE_ID 0xffff
typedef
int
(
*
zigbee_property_set
)(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
typedef
int
(
*
kk_zigbee_property_report
)(
EmberEUI64
eui64
,
uint8_t
EP
,
EmberAfClusterId
clusterId
,
EmberAfAttributeId
attributeId
,
uint8_t
dataType
,
uint8_t
len
,
uint8_t
*
data
);
typedef
struct
{
char
*
Identity
;
unsigned
char
endpoint
;
zigbee_property_set
zigbee_set
;
unsigned
short
clusterId
;
unsigned
short
attributeId
;
kk_zigbee_property_report
zigbee_report
;
}
kk_tsl_zigbee_map_t
;
typedef
struct
{
char
*
ProductCode
;
kk_tsl_zigbee_map_t
map
;
}
kk_tsl_zigbee_map_glb_t
;
extern
kk_tsl_zigbee_map_t
g_tsl_zigbee_map
[];
extern
kk_tsl_zigbee_map_glb_t
g_tsl_zigbee_map_glb
[];
int
kk_get_tsl_index
(
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
);
int
kk_get_tsl_num
(
void
);
int
kk_get_tsl_glb_index
(
const
char
*
pCode
,
unsigned
char
EP
,
unsigned
short
clusterId
,
unsigned
short
attributeId
);
int
kk_get_tsl_glb_num
(
void
);
#endif
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