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
f7e37dd1
Commit
f7e37dd1
authored
Sep 22, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增彩灯设备RBG上报管理
parent
89eb1e07
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
472 additions
and
154 deletions
+472
-154
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.h
...form/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.h
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
+3
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
+1
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+48
-97
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+13
-20
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zb_com.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zb_com.h
+26
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
+27
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+11
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.c
+226
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.h
+57
-0
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
+25
-2
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
+1
-1
platform/zigbee/platform/base/hal/micro/unix/host/micro.c
platform/zigbee/platform/base/hal/micro/unix/host/micro.c
+1
-1
platform/zigbee/protocol/zigbee/app/framework/plugin-host/file-descriptor-dispatch/file-descriptor-dispatch.h
...-host/file-descriptor-dispatch/file-descriptor-dispatch.h
+9
-9
platform/zigbee/protocol/zigbee/app/framework/plugin-host/gateway/gateway-support.c
...igbee/app/framework/plugin-host/gateway/gateway-support.c
+12
-12
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
.../zigbee/protocol/zigbee/app/framework/util/af-main-host.c
+4
-1
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
f7e37dd1
...
...
@@ -291,6 +291,7 @@ APPLICATION_FILES= \
./ZB/kk_plat_ota.c
\
./ZB/kk_rgb_hsl_convert.c
\
./ZB/kk_color_space.c
\
./ZB/sub_device_manage.c
\
./kk_test.c
\
./rpc_api/src/rpc_common.c
\
./rpc_api/src/rpc_onoff.c
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_color_space.h
View file @
f7e37dd1
...
...
@@ -7,8 +7,8 @@
void
RGB_to_HSL_base
(
unsigned
char
red
,
unsigned
char
green
,
unsigned
char
blue
,
double
*
H
,
double
*
S
,
double
*
L
);
void
RGB_to_HSL
(
unsigned
char
red
,
unsigned
char
green
,
unsigned
char
blue
,
unsigned
short
*
H
,
unsigned
char
*
S
,
unsigned
char
*
L
);
void
HSL_to_RGB_base
(
double
H
,
double
S
,
double
L
,
unsigned
char
*
red
,
unsigned
char
*
green
,
unsigned
char
*
blue
);
void
HSL_to_RGB
(
unsigned
short
H
,
unsigned
char
S
,
unsigned
char
L
,
unsigned
char
*
red
,
unsigned
char
*
green
,
unsigned
char
*
blue
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
View file @
f7e37dd1
...
...
@@ -2,6 +2,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "kk_product_code.h"
#include "kk_zb_com.h"
...
...
@@ -130,6 +132,7 @@ void kk_read_attr_response(EmberNodeId nodeId,
}
}
kk_colorlight_attr_read
(
nodeId
,
ep
,
cluster
,
attribute
,
status
,
dataType
,
dataSize
,
data
);
}
void
emberAfPluginDeviceTableNewDeviceCallback
(
EmberEUI64
nodeEui64
)
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
View file @
f7e37dd1
#ifndef __KK_DEVICE_MANAGER_H
#define __KK_DEVICE_MANAGER_H
#include "kk_test.h"
#include "kk_product_code.h"
#include "kk_zb_com.h"
/****************** ******************************************************************
* File Name : kk_device_manager.h
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
View file @
f7e37dd1
...
...
@@ -63,6 +63,7 @@ static kk_device_table_s *kk_device_table_create()
}
MEMSET
(
node
,
0
,
sizeof
(
kk_device_table_s
));
MEMSET
(
&
node
->
manage
,
0
,
sizeof
(
SubDevManage_s
));
return
node
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
f7e37dd1
...
...
@@ -143,9 +143,7 @@ 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
{
}
...
...
@@ -368,122 +366,75 @@ int kk_tsl_report_CO2(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,Emb
return
kk_tsl_report_Concentration
(
eui64
,
EP
,
clusterId
,
attributeId
,
dataType
,
len
,
data
);
}
static
int
s_HSLCount
=
0
;
static
unsigned
short
s_H
=
0
;
static
unsigned
char
s_S
=
0
;
static
unsigned
char
s_L
=
0
;
static
int
kk_tsl_report_colorControl_RGB_Str
(
EmberEUI64
eui64
)
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
];
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
};
unsigned
char
r
,
g
,
b
;
if
(
s_HSLCount
>=
3
&&
s_H
!=
0
&&
s_S
!=
0
){
HSL_to_RGB
(
s_H
*
360
/
254
,
s_S
*
100
/
254
,
s_L
,
&
r
,
&
g
,
&
b
);
s_HSLCount
=
0
;
s_H
=
0
;
s_S
=
0
;
//printf("[%s][%d]%d %d %d\n",__FUNCTION__,__LINE__,r,g,b);
UTIL_LOG_INFO
(
"[tsl report:kk_tsl_report_global_Brightness] value:%d
\n
"
,
value
);
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
,
r
);
}
}
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
);
}
}
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
,
b
);
}
}
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
;
}
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
){
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
L
=
value
;
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
HSL_flag
|=
BIT
(
2
);
dev
->
manage
.
dev
.
ColorLighting
.
time
=
halCommonGetInt32uMillisecondTick
();
emberAfCorePrintln
(
"HSL.L = %d"
,
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
L
);
kk_tsl_report
(
eui64
,
EP
,
value
,
clusterId
,
attributeId
);
s_L
=
value
;
s_HSLCount
++
;
kk_tsl_report_colorControl_RGB_Str
(
eui64
);
if
(
s_HSLCount
>=
3
){
s_HSLCount
=
0
;
}
}
return
tsl_rpt_success
;
}
return
tsl_rpt_invaild_len
;
}
return
tsl_rpt_invaild_type
;
}
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
};
UTIL_LOG_INFO
(
"[tsl report:kk_tsl_report_global_RGB] value:%d
\n
"
,
value
);
dev
=
kk_device_find_by_mac
(
eui64
);
if
(
dev
==
NULL
){
return
tsl_rpt_err
;
}
emberAfAppPrintln
(
"[tsl report:kk_tsl_report_global_RGB] value:%d
\n
"
,
value
);
if
(
dataType
==
ZCL_INT8U_ATTRIBUTE_TYPE
){
if
(
attributeId
==
0x0001
){
s_S
=
value
;
s_HSLCount
++
;
kk_tsl_report_colorControl_RGB_Str
(
eui64
);
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
S
=
value
*
100
/
254
;
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
HSL_flag
|=
BIT
(
1
);
dev
->
manage
.
dev
.
ColorLighting
.
time
=
halCommonGetInt32uMillisecondTick
();
emberAfCorePrintln
(
"HSL.S = %d"
,
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
S
);
}
else
if
(
attributeId
==
0x0
){
s_H
=
value
;
s_HSLCount
++
;
kk_tsl_report_colorControl_RGB_Str
(
eui64
);
else
if
(
attributeId
==
0x0000
){
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
H
=
value
*
360
/
254
;
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
HSL_flag
|=
BIT
(
0
);
dev
->
manage
.
dev
.
ColorLighting
.
time
=
halCommonGetInt32uMillisecondTick
();
emberAfCorePrintln
(
"HSL.H = %d"
,
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
H
);
}
}
return
tsl_rpt_
success
;
return
tsl_rpt_
err
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
f7e37dd1
...
...
@@ -140,10 +140,8 @@ cJSON *kk_tsl_property_operation(jrpc_context * ctx, cJSON *params, cJSON *id,cJ
}
else
{
propertyItem
=
rpc_cJSON_GetObjectItem
(
params
,
item
->
identity
);
if
(
propertyItem
!=
NULL
){
// printf("[%s][%d]item->identity:%s\n",__FUNCTION__,__LINE__,item->identity);
findFlag
=
1
;
}
}
...
...
@@ -156,12 +154,7 @@ cJSON *kk_tsl_property_operation(jrpc_context * ctx, cJSON *params, cJSON *id,cJ
value
=
propertyItem
->
valueint
;
}
func
=
item
->
controlFunc
;
if
(
func
!=
NULL
){
res
=
func
(
ctx
,
nodeId
,
item
->
endpoint
,
&
value
);
}
else
{
// printf("[%s][%d] can not find the func!!!\n",__FUNCTION__,__LINE__);
}
findFlag
=
0
;
}
item
=
item
->
next
;
...
...
@@ -309,24 +302,25 @@ error_return:
static
uint8_t
s_RgbCount
=
0
;
static
COLOR_RGB
s_rgb
;
static
int
kk_zclColorControlMovetohueandsat
(
EmberNodeId
node
,
unsigned
char
ep
)
{
unsigned
short
h
;
unsigned
short
s
,
l
;
int
h
,
s
,
l
;
COLOR_HSL
hsl
;
EmberStatus
status
=
0
;
if
(
s_RgbCount
>=
3
){
//RGBtoHSL(&s_rgb,&hsl);
RGB_to_HSL_base
(
s_rgb
.
red
,
s_rgb
.
green
,
s_rgb
.
blue
,
h
,
s
,
l
);
emberAfAppPrintln
(
"[kk_zclColorControlMovetohueandsat]"
);
RGB_to_HSL
(
s_rgb
.
red
,
s_rgb
.
green
,
s_rgb
.
blue
,
&
h
,
&
s
,
&
l
);
emberAfAppPrintln
(
"[kk_zclColorControlMovetohueandsat] h:%d,s:%d,l:%d
\n
,"
,
h
,
s
,
l
);
status
=
zclColorControlMovetohueandsat
(
node
,
ep
,
h
*
254
/
360
,
s
*
254
/
100
,
0
,
0
,
0
,
0
);
status
|=
zclLevel_MoveToLevel
(
node
,
ep
,
l
,
0
,
NULL
,
NULL
);
kk_device_table_s
*
dev
=
kk_device_find_by_node
(
node
);
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
L
=
l
;
dev
->
manage
.
dev
.
ColorLighting
.
CloorSetFlag
=
true
;
emberAfAppPrintln
(
"Save l:%d"
,
l
);
status
=
zclColorControlMovetohueandsat
(
node
,
ep
,
h
*
254
,
s
*
254
,
0
,
0
,
0
,
0
);
s_RgbCount
=
0
;
}
return
status
;
return
0
;
}
int
kk_tsl_set_colorlight_RGB_red
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
)
{
...
...
@@ -394,7 +388,6 @@ int kk_tsl_set_colorlight_mode(jrpc_context * ctx,EmberNodeId node,unsigned char
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
);
...
...
@@ -405,7 +398,7 @@ int kk_tsl_set_colorlight_mode(jrpc_context * ctx,EmberNodeId node,unsigned char
emberAfCorePrintln
(
"
\n
"
);
break
;
}
mode
=
mode
->
next
;
mode
->
next
;
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zb_com.h
View file @
f7e37dd1
#ifndef __KK_ZB_COM_H
#define __KK_ZB_COM_H
#include "app/framework/include/af.h"
#include "zb_device_id.h"
typedef
struct
{
unsigned
char
CloorModeFlag
;
unsigned
char
CapabilitiesFlag
;
unsigned
char
CloorMode
;
unsigned
char
Capabilities
;
unsigned
int
time
;
unsigned
char
CloorSetFlag
;
union
{
struct
{
unsigned
char
HSL_flag
;
//bit 0:H; bit 1:S; bit 2:L
unsigned
short
H
;
unsigned
char
S
;
unsigned
char
L
;
}
HSL
;
}
color
;
}
ColorLighting_s
;
typedef
struct
{
union
{
ColorLighting_s
ColorLighting
;
}
dev
;
}
SubDevManage_s
;
typedef
struct
kk_device_table_s
{
EmberEUI64
mac
;
...
...
@@ -10,6 +33,7 @@ typedef struct kk_device_table_s{
uint16_t
deviceId
;
uint16_t
identifyCnt
;
char
productCode
[
33
];
SubDevManage_s
manage
;
struct
kk_device_table_s
*
next
;
}
kk_device_table_s
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
View file @
f7e37dd1
...
...
@@ -113,6 +113,33 @@ EmberStatus kk_zdo_leave_request(EmberNodeId target,bool removeChildren,bool rej
emberAfAppPrintln
(
"Leave %p0x%X"
,
"Request: "
,
status
);
}
EmberStatus
zclGReadAttrs
(
uint16_t
node
,
uint8_t
srcEP
,
uint8_t
dstEP
,
bool
multicast
,
uint16_t
clusterId
,
uint8_t
len
,
uint16_t
*
attrIds
,
bool
svr
)
{
EmberStatus
status
;
zclBufferSetup
(
ZCL_GLOBAL_COMMAND
|
((
svr
==
true
)
?
ZCL_FRAME_CONTROL_CLIENT_TO_SERVER
:
ZCL_FRAME_CONTROL_SERVER_TO_CLIENT
),
clusterId
,
ZCL_READ_ATTRIBUTES_COMMAND_ID
);
for
(
uint8_t
i
=
0
;
i
<
len
;
i
++
){
zclBufferAddByte
(
LOW_BYTE
(
attrIds
[
i
]));
zclBufferAddByte
(
HIGH_BYTE
(
attrIds
[
i
]));
}
rpcBufferPrint
();
status
=
rpcSendCommand
(
node
,
srcEP
,
dstEP
,
multicast
);
return
status
;
}
EmberStatus
zclGRead
(
uint16_t
node
,
uint8_t
srcEP
,
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
f7e37dd1
...
...
@@ -155,6 +155,16 @@ EmberStatus zclGRead(uint16_t node,
uint16_t
clusterId
,
uint16_t
attrId
,
bool
svr
);
EmberStatus
zclGReadAttrs
(
uint16_t
node
,
uint8_t
srcEP
,
uint8_t
dstEP
,
bool
multicast
,
uint16_t
clusterId
,
uint8_t
len
,
uint16_t
*
attrIds
,
bool
svr
);
EmberStatus
zclGWrite
(
uint16_t
node
,
uint8_t
srcEP
,
uint8_t
dstEP
,
...
...
@@ -167,7 +177,6 @@ EmberStatus zclGWrite(uint16_t node,
bool
svr
);
EmberStatus
zclOnOff_On
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
zclOnOff_Off
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
zclOnOff_Toggle
(
uint16_t
node
,
uint8_t
ep
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.c
0 → 100644
View file @
f7e37dd1
#include "sub_device_manage.h"
#include "kk_device_manager.h"
#include "kk_zb_com.h"
typedef
void
(
*
subDevManageFunc
)(
kk_device_table_s
*
dev
);
typedef
struct
{
uint16_t
deviceId
;
subDevManageFunc
func
;
}
SubDevDispatch_s
;
void
kk_ColorLighting_manage
(
kk_device_table_s
*
dev
);
SubDevDispatch_s
SubDevDispatch
[]
=
{
{
DEVICE_ID_HA_DIMMABLE_LIGHT
,
kk_ColorLighting_manage
},
{
DEVICE_ID_HA_COLOR_DIMMABLE_LIGHT
,
kk_ColorLighting_manage
},
};
static
int
report_colorLighting_RGB
(
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
};
emberAfCorePrintln
(
"[report_colorLighting_RGB] %d"
,
__LINE__
);
unsigned
short
H
=
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
H
;
unsigned
char
S
=
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
S
;
unsigned
char
L
=
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
L
;
unsigned
char
red
,
green
,
blue
;
HSL_to_RGB
(
H
,
S
,
L
,
&
red
,
&
green
,
&
blue
);
emberAfAppPrintln
(
"%d,%d,%d"
,
H
,
S
,
L
);
emberAfAppPrintln
(
"%d,%d,%d"
,
red
,
green
,
blue
);
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
,
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
,
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
,
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
,
dev
->
mac
);
return
tsl_rpt_success
;
}
return
tsl_rpt_err
;
}
void
kk_colorlight_attr_read
(
uint16_t
nodeId
,
uint8_t
ep
,
uint16_t
cluster
,
uint16_t
attribute
,
uint8_t
status
,
uint8_t
dataType
,
uint8_t
dataSize
,
uint8_t
*
data
)
{
kk_device_table_s
*
dev
;
ColorLighting_s
*
ptr
;
if
(
cluster
!=
ZCL_COLOR_CONTROL_CLUSTER_ID
)
return
;
if
(
ep
!=
KK_PRIMARY_EP
)
return
;
UTIL_LOG_INFO
(
"
\n
********************kk_colorlight_attr_read********************
\n
"
);
dev
=
kk_device_find_by_node
(
nodeId
);
if
(
dev
==
NULL
)
return
;
ptr
=
&
dev
->
manage
.
dev
.
ColorLighting
;
if
(
attribute
==
ZCL_COLOR_CONTROL_COLOR_MODE_ATTRIBUTE_ID
){
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
ptr
->
CloorModeFlag
=
DevManage_Success
;
ptr
->
CloorMode
=
*
data
;
emberAfCorePrintln
(
"[CloorMode]val:%d"
,
*
data
);
}
else
if
(
status
==
EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE
){
ptr
->
CloorModeFlag
=
DevManage_NotSupport
;
emberAfCorePrintln
(
"[CloorMode]not support!!!"
);
}
else
{
ptr
->
CloorModeFlag
=
DevManage_Fail
;
emberAfCorePrintln
(
"[CloorMode]fail,status=0X%X!!!"
,
status
);
}
}
if
(
attribute
==
ZCL_COLOR_CONTROL_COLOR_CAPABILITIES_ATTRIBUTE_ID
){
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
ptr
->
CapabilitiesFlag
=
DevManage_Success
;
ptr
->
Capabilities
=
*
data
;
emberAfCorePrintln
(
"[Capabilities]val:%d"
,
*
data
);
}
else
if
(
status
==
EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE
){
ptr
->
CapabilitiesFlag
=
DevManage_NotSupport
;
emberAfCorePrintln
(
"[Capabilities]not support!!!"
);
}
else
{
ptr
->
CapabilitiesFlag
=
DevManage_Fail
;
emberAfCorePrintln
(
"[Capabilities]fail,status=0X%X!!!"
,
status
);
}
}
}
void
kk_ColorLighting_manage
(
kk_device_table_s
*
dev
)
{
EmberAfStatus
status
;
ColorLighting_s
*
ptr
;
if
(
dev
==
NULL
)
return
;
ptr
=
&
dev
->
manage
.
dev
.
ColorLighting
;
uint32_t
time
=
halCommonGetInt32uMillisecondTick
();
if
(
ptr
->
CloorModeFlag
==
DevManage_Unkown
||
ptr
->
CapabilitiesFlag
==
DevManage_Unkown
){
uint16_t
attr
[
2
]
=
{
ZCL_COLOR_CONTROL_COLOR_MODE_ATTRIBUTE_ID
,
ZCL_COLOR_CONTROL_COLOR_CAPABILITIES_ATTRIBUTE_ID
};
status
=
zclGReadAttrs
(
dev
->
nodeId
,
1
,
1
,
false
,
ZCL_COLOR_CONTROL_CLUSTER_ID
,
2
,
attr
,
true
);
emberAfCorePrintln
(
"[ColorLighting_manage] read mode and capabilities from 0x%04X"
,
dev
->
nodeId
);
}
if
(
ptr
->
color
.
HSL
.
HSL_flag
!=
0
){
if
(
ptr
->
time
!=
0
){
if
((
time
-
ptr
->
time
)
>=
1000
*
3
){
if
(
ptr
->
CloorSetFlag
==
true
&&
ptr
->
color
.
HSL
.
HSL_flag
==
0x03
){
report_colorLighting_RGB
(
dev
);
ptr
->
CloorSetFlag
=
false
;
emberAfCorePrintln
(
"$$$$$$$$[ColorLighting_manage] %d"
,
__LINE__
);
return
;
}
ptr
->
time
=
0
;
ptr
->
color
.
HSL
.
HSL_flag
=
0
;
ptr
->
CloorSetFlag
=
false
;
emberAfCorePrintln
(
"!!!!!!!!!![ColorLighting_manage] %d"
,
__LINE__
);
return
;
}
}
if
(
ptr
->
CloorSetFlag
==
true
&&
ptr
->
color
.
HSL
.
HSL_flag
==
0x07
){
report_colorLighting_RGB
(
dev
);
ptr
->
CloorSetFlag
=
false
;
ptr
->
color
.
HSL
.
HSL_flag
=
0
;
ptr
->
time
=
0
;
emberAfCorePrintln
(
"@@@@@@@@@@[ColorLighting_manage] %d"
,
__LINE__
);
return
;
}
}
}
void
kk_sub_dev_manage
(
void
)
{
static
uint32_t
LastTime
;
uint32_t
time
=
halCommonGetInt32uMillisecondTick
();
kk_device_table_s
*
ptr
=
kk_get_device_table_pointer
();
if
((
time
-
LastTime
)
>=
1000
){
LastTime
=
time
;
while
(
ptr
!=
NULL
){
for
(
int
i
=
0
;
i
<
sizeof
(
SubDevDispatch
)
/
sizeof
(
SubDevDispatch_s
);
i
++
){
if
(
ptr
->
deviceId
==
SubDevDispatch
[
i
].
deviceId
&&
SubDevDispatch
[
i
].
func
!=
NULL
){
SubDevDispatch
[
i
].
func
(
ptr
);
}
}
ptr
=
ptr
->
next
;
}
}
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.h
0 → 100644
View file @
f7e37dd1
#ifndef __SUB_DEVICE_MANAGE_H
#define __SUB_DEVICE_MANAGE_H
#include "kk_zb_com.h"
typedef
enum
{
ColorMode_HSL
=
0x00
,
ColorMode_XY
=
0x01
,
ColorMode_Temperature
=
0x02
}
ColorModeAttrVal
;
typedef
enum
{
DevManage_Unkown
=
0x00
,
DevManage_Success
=
0x01
,
DevManage_NotSupport
=
0x02
,
DevManage_Fail
=
0x03
,
}
DevManageAttrEnum
;
void
kk_colorlight_attr_read
(
uint16_t
nodeId
,
uint8_t
ep
,
uint16_t
cluster
,
uint16_t
attribute
,
uint8_t
status
,
uint8_t
dataType
,
uint8_t
dataSize
,
uint8_t
*
data
);
void
kk_ColorLighting_manage
(
kk_device_table_s
*
dev
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
View file @
f7e37dd1
...
...
@@ -200,6 +200,7 @@ void emberAfMainTickCallback(void)
static
unsigned
int
last_time
;
unsigned
int
time
=
halCommonGetInt32uMillisecondTick
();
kk_sub_dev_manage
();
if
((
time
-
last_time
)
>=
3000
){
last_time
=
time
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
f7e37dd1
...
...
@@ -12,7 +12,7 @@
#include "kk_tsl_property_set.h"
#include "kk_msg_report.h"
#include "kk_device_table_db.h"
#include "sub_device_manage.h"
#define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add"
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
f7e37dd1
...
...
@@ -849,8 +849,8 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
free
(
bufferTemp
);
}
else
{
rpc_cJSON_AddStatusToObject
(
item_attr
,
Status
);
bufferSize
+=
2
;
emberAfAppPrintln
(
"Status=
%d
\n
"
,
Status
);
bufferSize
+=
3
;
emberAfAppPrintln
(
"Status=
0x%X
\n
"
,
Status
);
attributeId
=
HIGH_LOW_TO_INT
(
bufferPtr
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_HIGH_BITS
],
bufferPtr
[
ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS
]);
kk_read_attr_response
(
nodeId
,
ep
,
...
...
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
View file @
f7e37dd1
...
...
@@ -110,8 +110,31 @@ void kk_message_process(char *messageString)
test_123
(
cnt
);
}
if
(
MEMCOMPARE
(
messageString
,
"AT+COLOR
\r\n
"
,
len
)
==
0
){
//zclColorControlMovetohueandsat(node,ep,h,s,0,0,0,0);
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST1
\r\n
"
,
len
)
==
0
){
uint16_t
h
;
unsigned
char
s
,
l
;
RGB_to_HSL
(
100
,
150
,
200
,
&
h
,
&
s
,
&
l
);
emberAfAppPrintln
(
"%d,%d,%d"
,
h
,
s
,
l
);
emberAfAppPrintln
(
"%d,%d,%d"
,
h
*
254
/
360
,
s
*
254
/
100
,
l
);
kk_device_table_s
*
dev
=
kk_device_find_by_node
(
0x5996
);
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
L
=
l
;
zclLevel_MoveToLevel
(
0x5996
,
1
,
l
,
0
,
NULL
,
NULL
);
zclColorControlMovetohueandsat
(
0x5996
,
1
,
h
*
254
/
360
,
s
*
254
/
100
,
0
,
0
,
0
,
0
);
emberAfAppPrint
(
"AT+TEST1
\r\n
"
);
}
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST2
\r\n
"
,
len
)
==
0
){
uint16_t
h
;
unsigned
char
s
,
l
;
RGB_to_HSL
(
20
,
24
,
22
,
&
h
,
&
s
,
&
l
);
emberAfAppPrintln
(
"%d,%d,%d"
,
h
,
s
,
l
);
emberAfAppPrintln
(
"%d,%d,%d"
,
h
*
254
/
360
,
s
*
254
/
100
,
l
);
kk_device_table_s
*
dev
=
kk_device_find_by_node
(
0x5996
);
dev
->
manage
.
dev
.
ColorLighting
.
color
.
HSL
.
L
=
l
;
zclLevel_MoveToLevel
(
0x5996
,
1
,
l
,
0
,
NULL
,
NULL
);
zclColorControlMovetohueandsat
(
0x5996
,
1
,
h
*
254
/
360
,
s
*
254
/
100
,
0
,
0
,
0
,
0
);
emberAfAppPrint
(
"AT+TEST2
\r\n
"
);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
View file @
f7e37dd1
...
...
@@ -28,7 +28,7 @@
#include "app/util/serial/command-interpreter2.h"
#include "app/util/zigbee-framework/zigbee-device-common.h"
#include "network-cli.h"
#include "kk_zb_com.h"
#define emberAfAppPrint(...) emberAfPrint(EMBER_AF_PRINT_APP, __VA_ARGS__)
...
...
platform/zigbee/platform/base/hal/micro/unix/host/micro.c
View file @
f7e37dd1
platform/zigbee/protocol/zigbee/app/framework/plugin-host/file-descriptor-dispatch/file-descriptor-dispatch.h
View file @
f7e37dd1
platform/zigbee/protocol/zigbee/app/framework/plugin-host/gateway/gateway-support.c
View file @
f7e37dd1
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
View file @
f7e37dd1
...
...
@@ -1209,7 +1209,10 @@ void emAfCliVersionCommand(void)
if
(
ncpStackType
!=
EZSP_STACK_TYPE_MESH
)
{
emberAfAppPrint
(
"ERROR: stack type 0x%x is not expected!"
,
ncpStackType
);
assert
(
false
);
ezspErrorHandler
(
EZSP_ASH_NCP_FATAL_ERROR
);
UTIL_LOG_ERR
(
"
\n
!!!!!!!!!!!!!ncpStackType != EZSP_STACK_TYPE_MESH!!!!!!!!!
\n
"
);
//assert(false);
}
// verify that the NCP EZSP Protocol version is what is expected
...
...
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