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
e3402700
Commit
e3402700
authored
Oct 22, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增属性获取功能
parent
e589be90
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
488 additions
and
80 deletions
+488
-80
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
+1
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.c
+5
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.h
+20
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.c
+50
-20
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.h
+12
-3
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.c
+220
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.h
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.h
+39
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+73
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+3
-0
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_interface_parse.h
...p/builder/Z3GatewayHost/rpc_api/inc/rpc_interface_parse.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
+56
-45
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
+2
-1
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
+1
-2
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
.../zigbee/protocol/zigbee/app/framework/util/af-main-host.c
+2
-1
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
e3402700
...
@@ -286,6 +286,7 @@ APPLICATION_FILES= \
...
@@ -286,6 +286,7 @@ APPLICATION_FILES= \
./ZB/kk_zigbee_api.c
\
./ZB/kk_zigbee_api.c
\
./ZB/kk_tsl_property_report.c
\
./ZB/kk_tsl_property_report.c
\
./ZB/kk_tsl_property_set.c
\
./ZB/kk_tsl_property_set.c
\
./ZB/kk_tsl_property_get.c
\
./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
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
View file @
e3402700
...
@@ -536,8 +536,7 @@ void emberAfPluginDeviceTableInitialized(void)
...
@@ -536,8 +536,7 @@ void emberAfPluginDeviceTableInitialized(void)
kk_load_dev_map_table
();
kk_load_dev_map_table
();
kk_device_map_print
();
kk_device_map_print
();
kk_device_config_load_from_db
();
kk_device_config_load_from_db
();
#define NCP_QUEUE_MAX_SIZE 50
ncp_queue_init
();
ncp_queue_init
(
NCP_QUEUE_MAX_SIZE
);
}
}
void
test_123
(
int
val
)
void
test_123
(
int
val
)
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.c
View file @
e3402700
...
@@ -80,6 +80,11 @@ void kk_msg_report_alarm(cJSON *data,EmberEUI64 mac)
...
@@ -80,6 +80,11 @@ void kk_msg_report_alarm(cJSON *data,EmberEUI64 mac)
kk_msg_report
(
data
,
KK_REPORT_ALARM_TYPE
,
KK_REPORT_ALARM_METHOD
,
mac
);
kk_msg_report
(
data
,
KK_REPORT_ALARM_TYPE
,
KK_REPORT_ALARM_METHOD
,
mac
);
}
}
void
kk_msg_get_property_reply
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_msg_report
(
data
,
KK_GET_PROPERTY_REPLY_MSG_TYPE
,
KK_GET_PROPERTY_REPLY_METHOD
,
mac
);
}
void
kk_msg_report_dev_joined
(
EmberEUI64
mac
,
const
char
*
productCode
)
void
kk_msg_report_dev_joined
(
EmberEUI64
mac
,
const
char
*
productCode
)
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.h
View file @
e3402700
...
@@ -19,17 +19,36 @@
...
@@ -19,17 +19,36 @@
#define KK_REPORT_PROPERTY_MSG_TYPE "/thing/event/property/post"
#define KK_SET_PROPERTY_REPLY_MSG_TYPE "/thing/service/property/set_reply"
#define KK_GET_PROPERTY_REPLY_MSG_TYPE "/thing/service/property/get_reply"
#define KK_GET_PROPERTY_MSG_TYPE "/thing/service/property/get"
#define KK_GET_PROPERTY_REPLY_METHOD "thing.service.property.get"
#define KK_REPORT_ALARM_METHOD "thing.event.alarm.post"
#define KK_REPORT_ALARM_METHOD "thing.event.alarm.post"
#define KK_REPORT_ATTRIBUTE_METHOD "thing.event.property.post"
#define KK_REPORT_ATTRIBUTE_METHOD "thing.event.property.post"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
#define KK_REPORT_DEVICE_BATCH_JOINED_TYPE "/thing/topo/batch_add"
#define KK_REPORT_DEVICE_BATCH_JOINED_TYPE "/thing/topo/batch_add"
#define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add"
#define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_DEVICE_BATCH_LEFT_TYPE "/thing/topo/batch_delete"
#define KK_REPORT_DEVICE_BATCH_LEFT_TYPE "/thing/topo/batch_delete"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define KK_REPORT_ADDWHITELIST_NOTIFY_TYPE "/thing/event/whiteListAddedNotification/post"
#define KK_REPORT_ADDWHITELIST_NOTIFY_TYPE "/thing/event/whiteListAddedNotification/post"
#define KK_REPORT_DELWHITELIST_NOTIFY_TYPE "/thing/event/whiteListDeletedNotification/post"
#define KK_REPORT_DELWHITELIST_NOTIFY_TYPE "/thing/event/whiteListDeletedNotification/post"
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.c
View file @
e3402700
...
@@ -3,26 +3,32 @@
...
@@ -3,26 +3,32 @@
static
ncp_queue_s
g_ncp_queue
;
static
ncp_queue_s
*
_ncp_queue_get_ctx
(
void
)
#define NCP_QUEUE1_SIZE 50
#define NCP_QUEUE2_SIZE 20
#define NCP_QUEUE_SIZE(x) NCP_QUEUE##x##_SIZE
static
ncp_queue_s
g_ncp_queue
[
GET_PROPERTY
];
static
ncp_queue_s
*
_ncp_queue_get_ctx
(
NCP_QUEUE_ENUM
ix
)
{
{
return
&
g_ncp_queue
;
return
&
g_ncp_queue
[
ix
]
;
}
}
static
void
_ncp_queue_lock
(
void
)
static
void
_ncp_queue_lock
(
NCP_QUEUE_ENUM
ix
)
{
{
int
err_num
;
int
err_num
;
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
();
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
if
(
0
!=
(
err_num
=
pthread_mutex_lock
((
pthread_mutex_t
*
)
ctx
->
mutex
)))
{
if
(
0
!=
(
err_num
=
pthread_mutex_lock
((
pthread_mutex_t
*
)
ctx
->
mutex
)))
{
printf
(
"lock mutex failed: - '%s' (%d)"
,
strerror
(
err_num
),
err_num
);
printf
(
"lock mutex failed: - '%s' (%d)"
,
strerror
(
err_num
),
err_num
);
}
}
}
}
static
void
_ncp_queue_unlock
(
void
)
static
void
_ncp_queue_unlock
(
NCP_QUEUE_ENUM
ix
)
{
{
int
err_num
;
int
err_num
;
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
();
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
if
(
0
!=
(
err_num
=
pthread_mutex_unlock
((
pthread_mutex_t
*
)
ctx
->
mutex
)))
{
if
(
0
!=
(
err_num
=
pthread_mutex_unlock
((
pthread_mutex_t
*
)
ctx
->
mutex
)))
{
printf
(
"unlock mutex failed - '%s' (%d)"
,
strerror
(
err_num
),
err_num
);
printf
(
"unlock mutex failed - '%s' (%d)"
,
strerror
(
err_num
),
err_num
);
...
@@ -30,10 +36,10 @@ static void _ncp_queue_unlock(void)
...
@@ -30,10 +36,10 @@ static void _ncp_queue_unlock(void)
}
}
int
ncp_queue_init
(
int
max_size
)
static
int
_ncp_queue_init
(
NCP_QUEUE_ENUM
ix
,
int
max_size
)
{
{
int
err_num
;
int
err_num
;
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
();
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
memset
(
ctx
,
0
,
sizeof
(
ncp_queue_s
));
memset
(
ctx
,
0
,
sizeof
(
ncp_queue_s
));
...
@@ -49,6 +55,7 @@ int ncp_queue_init(int max_size)
...
@@ -49,6 +55,7 @@ int ncp_queue_init(int max_size)
}
}
ctx
->
magic
=
KK_NCP_QUEUE_MAGIC
;
ctx
->
max_size
=
max_size
;
ctx
->
max_size
=
max_size
;
INIT_LIST_HEAD
(
&
ctx
->
list
);
INIT_LIST_HEAD
(
&
ctx
->
list
);
...
@@ -56,69 +63,92 @@ int ncp_queue_init(int max_size)
...
@@ -56,69 +63,92 @@ int ncp_queue_init(int max_size)
}
}
int
ncp_queue_init
(
void
)
{
_ncp_queue_init
(
REV_MSG
,
NCP_QUEUE_SIZE
(
1
));
_ncp_queue_init
(
GET_PROPERTY
,
NCP_QUEUE_SIZE
(
2
));
}
void
ncp_queue_deinit
(
void
)
void
ncp_queue_deinit
(
void
)
{
{
}
}
int
ncp_queue_enqueue
(
void
*
data
)
int
ncp_queue_enqueue
(
NCP_QUEUE_ENUM
ix
,
void
*
data
)
{
{
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
();
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
ncp_queue_msg_s
*
node
=
NULL
;
ncp_queue_msg_s
*
node
=
NULL
;
if
(
ctx
->
magic
!=
KK_NCP_QUEUE_MAGIC
){
return
-
1
;
}
if
(
data
==
NULL
)
{
if
(
data
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
_ncp_queue_lock
();
_ncp_queue_lock
(
ix
);
printf
(
"list size: %d, max size: %d
\n
"
,
ctx
->
size
,
ctx
->
max_size
);
printf
(
"list size: %d, max size: %d
\n
"
,
ctx
->
size
,
ctx
->
max_size
);
if
(
ctx
->
size
>=
ctx
->
max_size
)
{
if
(
ctx
->
size
>=
ctx
->
max_size
)
{
printf
(
"ncp queue list full"
);
printf
(
"ncp queue list full"
);
_ncp_queue_unlock
();
_ncp_queue_unlock
(
ix
);
return
-
2
;
return
-
2
;
}
}
node
=
malloc
(
sizeof
(
ncp_queue_msg_s
));
node
=
malloc
(
sizeof
(
ncp_queue_msg_s
));
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
_ncp_queue_unlock
();
_ncp_queue_unlock
(
ix
);
return
-
3
;
return
-
3
;
}
}
memset
(
node
,
0
,
sizeof
(
ncp_queue_msg_s
));
memset
(
node
,
0
,
sizeof
(
ncp_queue_msg_s
));
node
->
data
=
data
;
node
->
data
=
data
;
INIT_LIST_HEAD
(
&
node
->
list
);
INIT_LIST_HEAD
(
&
node
->
list
);
ctx
->
size
++
;
ctx
->
size
++
;
list_add_tail
(
&
node
->
list
,
&
ctx
->
list
);
list_add_tail
(
&
node
->
list
,
&
ctx
->
list
);
_ncp_queue_unlock
();
_ncp_queue_unlock
(
ix
);
printf
(
"add queue
\n
"
);
return
0
;
return
0
;
}
}
int
ncp_queue_dequeue
(
void
**
data
)
int
ncp_queue_dequeue
(
NCP_QUEUE_ENUM
ix
,
void
**
data
)
{
{
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
();
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
ncp_queue_msg_s
*
node
=
NULL
;
ncp_queue_msg_s
*
node
=
NULL
;
if
(
ctx
->
magic
!=
KK_NCP_QUEUE_MAGIC
){
return
-
1
;
}
if
(
data
==
NULL
)
{
if
(
data
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
_ncp_queue_lock
();
_ncp_queue_lock
(
ix
);
if
(
list_empty
(
&
ctx
->
list
))
{
if
(
list_empty
(
&
ctx
->
list
))
{
_ncp_queue_unlock
();
_ncp_queue_unlock
(
ix
);
return
-
2
;
return
-
2
;
}
}
node
=
list_first_entry
(
&
ctx
->
list
,
ncp_queue_msg_s
,
list
);
node
=
list_first_entry
(
&
ctx
->
list
,
ncp_queue_msg_s
,
list
);
list_del
(
&
node
->
list
);
list_del
(
&
node
->
list
);
ctx
->
size
--
;
ctx
->
size
--
;
*
data
=
node
->
data
;
*
data
=
node
->
data
;
free
(
node
);
free
(
node
);
_ncp_queue_unlock
();
_ncp_queue_unlock
(
ix
);
printf
(
"de queue
\n
"
);
return
0
;
return
0
;
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.h
View file @
e3402700
#include "klist.h"
#include "klist.h"
#define KK_NCP_QUEUE_MAGIC 712341940
typedef
struct
{
typedef
struct
{
void
*
data
;
void
*
data
;
struct
list_head
list
;
struct
list_head
list
;
}
ncp_queue_msg_s
;
}
ncp_queue_msg_s
;
typedef
struct
{
typedef
struct
{
int
magic
;
void
*
mutex
;
void
*
mutex
;
int
max_size
;
int
max_size
;
int
size
;
int
size
;
...
@@ -13,7 +16,13 @@ typedef struct {
...
@@ -13,7 +16,13 @@ typedef struct {
}
ncp_queue_s
;
}
ncp_queue_s
;
int
ncp_queue_init
(
int
max_size
);
typedef
enum
{
int
ncp_queue_dequeue
(
void
**
data
);
REV_MSG
=
0
,
int
ncp_queue_enqueue
(
void
*
data
);
GET_PROPERTY
,
NCP_QUEUE_ENUM_END
}
NCP_QUEUE_ENUM
;
int
ncp_queue_init
(
void
);
int
ncp_queue_dequeue
(
NCP_QUEUE_ENUM
ix
,
void
**
data
);
int
ncp_queue_enqueue
(
NCP_QUEUE_ENUM
ix
,
void
*
data
);
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.c
0 → 100644
View file @
e3402700
#include "kk_test.h"
#include "kk_tsl_property_get.h"
#include "kk_ncp_queue.h"
#define MAX_ATTRIBUTE_SIZE 10
#define MAX_CLUSTER_SIZE 10
typedef
struct
{
uint8_t
ep
;
uint16_t
clu
;
uint8_t
len
;
uint16_t
attr
[
MAX_ATTRIBUTE_SIZE
];
}
property_s
;
typedef
struct
{
uint16_t
node
;
property_s
property
[
MAX_CLUSTER_SIZE
];
}
get_property_s
;
static
get_property_s
g_property
;
static
get_property_s
*
_get_g_property
(
void
)
{
return
&
g_property
;
}
void
kk_tsl_get_property_s
(
uint16_t
node
)
{
uint8_t
i
,
j
;
get_property_s
*
pery
=
_get_g_property
();
property_s
*
property
=
pery
->
property
;
memset
(
pery
,
0
,
sizeof
(
get_property_s
));
pery
->
node
=
node
;
}
void
kk_tsl_get_property_print
(
void
)
{
uint8_t
i
,
j
;
get_property_s
*
pery
=
_get_g_property
();
property_s
*
property
=
pery
->
property
;
for
(
i
=
0
;
i
<
MAX_CLUSTER_SIZE
;
i
++
){
if
(
property
[
i
].
ep
!=
0
){
for
(
j
=
0
;
j
<
property
[
i
].
len
;
j
++
){
printf
(
"i=%d,j=%d,ep=%d,clu=0x%04X,attr=0x%04X
\n
"
,
i
,
j
,
property
[
i
].
ep
,
property
[
i
].
clu
,
property
[
i
].
attr
[
j
]);
}
}
}
return
false
;
}
/*
void kk_tsl_get_property(uint16_t node)
{
status = zclGRead(ptr->nodeId,
1,
1,
false,
ZCL_BASIC_CLUSTER_ID,
ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID,
true);
}
*/
void
kk_tsl_get_property_e
(
uint16_t
node
)
{
uint8_t
i
,
j
;
get_property_s
*
pery
=
_get_g_property
();
property_s
*
property
=
pery
->
property
;
get_property_data_s
*
data
;
kk_tsl_get_property_print
();
for
(
i
=
0
;
i
<
MAX_CLUSTER_SIZE
;
i
++
){
if
(
property
[
i
].
ep
!=
0
&&
property
[
i
].
len
!=
0
){
data
=
(
get_property_data_s
*
)
malloc
(
sizeof
(
get_property_data_s
));
data
->
node
=
pery
->
node
;
data
->
ep
=
property
[
i
].
ep
;
data
->
clu
=
property
[
i
].
clu
;
data
->
len
=
property
[
i
].
len
;
data
->
attr
=
(
get_property_data_s
*
)
malloc
(
sizeof
(
uint16_t
)
*
data
->
len
);
for
(
j
=
0
;
j
<
data
->
len
;
j
++
){
data
->
attr
[
j
]
=
property
[
i
].
attr
[
j
];
printf
(
"ep=%d,clu=0x%04X,attr=0x%04X
\n
"
,
data
->
ep
,
data
->
clu
,
data
->
attr
[
j
]);
ncp_queue_enqueue
(
GET_PROPERTY
,
data
);
}
}
}
}
uint8_t
kk_tsl_get_pery_ix
(
uint8_t
ep
,
uint16_t
clu
)
{
uint8_t
i
=
0
;
get_property_s
*
pery
=
_get_g_property
();
for
(;
i
<
MAX_CLUSTER_SIZE
;
i
++
)
{
if
(
pery
->
property
[
i
].
ep
==
0
){
return
i
;
}
if
(
pery
->
property
[
i
].
ep
==
ep
&&
pery
->
property
[
i
].
clu
==
clu
)
break
;
}
return
i
;
}
bool
kk_tsl_get_pery_isExist
(
uint8_t
ep
,
uint16_t
clu
,
uint16_t
attr
)
{
uint8_t
i
,
j
;
get_property_s
*
pery
=
_get_g_property
();
property_s
*
property
=
pery
->
property
;
for
(
i
=
0
;
i
<
MAX_CLUSTER_SIZE
;
i
++
){
if
(
property
[
i
].
ep
==
ep
&&
property
[
i
].
clu
==
clu
){
for
(
j
=
0
;
j
<
MAX_ATTRIBUTE_SIZE
;
j
++
){
if
(
property
[
i
].
attr
[
j
]
==
attr
)
return
true
;
}
}
}
return
false
;
}
bool
kk_tsl_get_pery_attr_isExist
(
uint16_t
*
pAttr
,
uint16_t
attr
)
{
uint8_t
i
=
0
;
for
(;
i
<
MAX_ATTRIBUTE_SIZE
;
i
++
,
pAttr
++
){
if
(
pAttr
==
attr
&&
pAttr
!=
0xffff
){
return
true
;
}
}
return
false
;
}
uint8_t
kk_tsl_get_pery_add
(
uint8_t
ep
,
uint16_t
clu
,
uint16_t
attr
)
{
uint8_t
ix
;
get_property_s
*
pery
;
property_s
*
property
;
uint16_t
*
pAttr
;
if
(
kk_tsl_get_pery_isExist
(
ep
,
clu
,
attr
)
==
true
){
printf
(
"property already add in array!!!
\n
"
);
return
0
;
}
pery
=
_get_g_property
();
ix
=
kk_tsl_get_pery_ix
(
ep
,
clu
);
if
(
ix
>=
MAX_CLUSTER_SIZE
){
printf
(
"not find ix
\n
"
);
return
-
1
;
}
property
=
&
pery
->
property
[
ix
];
property
->
ep
=
ep
;
property
->
clu
=
clu
;
pAttr
=
property
->
attr
;
if
(
kk_tsl_get_pery_attr_isExist
(
pAttr
,
attr
)
==
true
){
printf
(
"attr already add in array!!!
\n
"
);
return
0
;
}
if
(
property
->
len
>=
MAX_ATTRIBUTE_SIZE
){
printf
(
"full!!!,len=%d,max attr array size = %d!!!
\n
"
,
MAX_ATTRIBUTE_SIZE
,
property
->
len
);
return
-
2
;
}
property
->
attr
[
property
->
len
++
]
=
attr
;
printf
(
"[add]ep=%d,clu=0x%04X,attr=0x%04X
\n
"
,
property
->
ep
,
property
->
clu
,
attr
);
return
0
;
}
void
kk_tsl_get_property
(
uint8_t
ep
,
uint16_t
clu
,
uint16_t
attr
)
{
kk_tsl_get_pery_add
(
ep
,
clu
,
attr
);
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.h
0 → 100644
View file @
e3402700
#ifndef __KK_TSL_PROPERTY_GET_H
#define __KK_TSL_PROPERTY_GET_H
typedef
struct
{
uint16_t
node
;
uint8_t
ep
;
uint16_t
clu
;
uint8_t
len
;
uint16_t
*
attr
;
}
get_property_data_s
;
void
kk_tsl_get_property_s
(
uint16_t
node
);
void
kk_tsl_get_property_e
(
uint16_t
node
);
uint8_t
kk_tsl_get_pery_add
(
uint8_t
ep
,
uint16_t
clu
,
uint16_t
attr
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
e3402700
#include "kk_tsl_property_set.h"
#include "kk_tsl_property_set.h"
#include "kk_rgb_hsl_convert.h"
#include "kk_rgb_hsl_convert.h"
#include "kk_tsl_property_get.h"
static
uint8_t
kk_global_buffer
[
256
];
static
uint8_t
kk_global_buffer
[
256
];
static
uint8_t
kk_global_len
;
static
uint8_t
kk_global_len
;
//
emberAfAppPrintln("[tsl report:Gloabl] OnOff~~~~~~~~~");
//
"identifier":["PowerSwitch_1","PowerSwitch_2","PowerSwitch_3"]
//cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
cJSON
*
kk_tsl_get_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
kk_device_table_s
*
dev
;
kk_dev_config_map
*
ptr
;
kk_dev_config_map
*
dev_info
=
NULL
;
kk_dev_config_item
*
item
=
NULL
;
cJSON
*
array
;
cJSON
*
identifier
=
NULL
;
int
num
;
uint8_t
eui64
[
EUI64_SIZE
];
EmberNodeId
nodeId
=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
;
UTIL_LOG_INFO
(
"
\n
********************kk tsl get property operation********************
\n
"
);
if
(
params
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
rpc_get_mac
(
mac
->
valuestring
,
eui64
);
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfAppFlush
();
dev
=
kk_device_find_by_mac
(
eui64
);
if
(
dev
==
NULL
){
goto
error_return
;
}
dev_info
=
kk_device_config_find
(
dev
->
productCode
);
if
(
dev_info
==
NULL
){
goto
error_return
;
}
array
=
rpc_cJSON_GetObjectItem
(
params
,
"identifier"
);
if
(
array
==
NULL
){
goto
error_return
;
}
num
=
rpc_cJSON_GetArraySize
(
array
);
kk_tsl_get_property_s
(
nodeId
);
for
(
int
i
=
0
;
i
<
num
;
i
++
){
identifier
=
rpc_cJSON_GetArrayItem
(
array
,
i
);
ptr
=
dev_info
;
item
=
&
ptr
->
item
;
while
(
item
!=
NULL
){
if
(
item
==
NULL
)
continue
;
if
(
strcmp
(
item
->
identity
,
identifier
->
valuestring
)
==
0
){
printf
(
"
\n
================================
\n
"
);
printf
(
"ep=%d,cluster=0x%04X,attribute=0x%04X
\n
"
,
item
->
endpoint
,
item
->
cluster
,
item
->
attribute
);
printf
(
"
\n
================================
\n
"
);
kk_tsl_get_pery_add
(
item
->
endpoint
,
item
->
cluster
,
item
->
attribute
);
break
;
}
item
=
item
->
next
;
}
}
kk_tsl_get_property_e
(
nodeId
);
return
rpc_cJSON_CreateNumber
(
0
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
kk_topo_change_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
cJSON
*
kk_topo_change_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
e3402700
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
View file @
e3402700
...
@@ -40,9 +40,11 @@
...
@@ -40,9 +40,11 @@
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
);
extern
cJSON
*
kk_tsl_get_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
#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"
},
\
{(
rpc_function
*
)
kk_tsl_get_property_operation
,
KK_GET_PROPERTY_MSG_TYPE
},
\
{(
rpc_function
*
)
kk_tsl_property_operation
,
KK_READ_ATTRIBUTE_METHOD
},
\
{(
rpc_function
*
)
kk_tsl_property_operation
,
KK_READ_ATTRIBUTE_METHOD
},
\
{(
rpc_function
*
)
kk_topo_change_operation
,
KK_DEVICE_TOPO_CHANGE_TYPE
}
{(
rpc_function
*
)
kk_topo_change_operation
,
KK_DEVICE_TOPO_CHANGE_TYPE
}
...
@@ -66,6 +68,7 @@ int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* d
...
@@ -66,6 +68,7 @@ int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* d
#endif
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_interface_parse.h
View file @
e3402700
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
#define PORT 5555
#define PORT 5555
void
rpcInterfaceParse
(
void
);
void
ipcHandle
(
void
);
void
ipcHandle
(
void
);
void
get_prey_handle
(
void
);
void
rpc_reportDevices
(
void
);
void
rpc_reportDevices
(
void
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
e3402700
...
@@ -22,13 +22,42 @@
...
@@ -22,13 +22,42 @@
#include "rpc_onoff.h"
#include "rpc_onoff.h"
#include "kk_test.h"
#include "kk_test.h"
#include "kk_ncp_queue.h"
#include "kk_tsl_property_get.h"
//#include "kk_log.h"
//#include "kk_log.h"
static
struct
jrpc_server
my_server
;
static
struct
jrpc_server
my_server
;
void
aaaBBB
()
cJSON
*
test_func
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
{
char
*
ptr
;
const
char
*
strings
[
3
]
=
{
"PowerSwitch_1"
,
"PowerSwitch_2"
,
"PowerSwitch_3"
};
cJSON
*
params
=
rpc_cJSON_CreateObject
();
cJSON
*
id
=
rpc_cJSON_CreateObject
();
cJSON
*
mac
=
rpc_cJSON_CreateObject
();
cJSON
*
array
=
rpc_cJSON_CreateArray
();
rpc_cJSON_AddItemToArray
(
array
,
rpc_cJSON_CreateString
(
"PowerSwitch_1"
));
rpc_cJSON_AddItemToArray
(
array
,
rpc_cJSON_CreateString
(
"PowerSwitch_2"
));
rpc_cJSON_AddItemToArray
(
array
,
rpc_cJSON_CreateString
(
"PowerSwitch_3"
));
rpc_cJSON_AddItemToObject
(
params
,
"identifier"
,
array
);
rpc_cJSON_AddStringToObject
(
id
,
"msgId"
,
"123"
);
rpc_cJSON_AddStringToObject
(
mac
,
"mac"
,
"1122334455667788"
);
ptr
=
rpc_cJSON_Print
(
params
);
printf
(
"params--->%s
\n
"
,
ptr
);
free
(
ptr
);
ptr
=
rpc_cJSON_Print
(
id
);
printf
(
"id--->%s
\n
"
,
ptr
);
free
(
ptr
);
ptr
=
rpc_cJSON_Print
(
mac
);
mac
=
cJSON_GetObjectItem
(
mac
,
"mac"
);
printf
(
"mac--->%s,%s
\n
"
,
ptr
,
mac
->
valuestring
);
free
(
ptr
);
kk_tsl_get_property_operation
(
&
my_server
,
params
,
id
,
mac
);
}
typedef
cJSON
(
*
rpc_function
)(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
typedef
cJSON
(
*
rpc_function
)(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
typedef
struct
{
typedef
struct
{
...
@@ -37,54 +66,14 @@ typedef struct{
...
@@ -37,54 +66,14 @@ typedef struct{
}
rpc_table_s
;
}
rpc_table_s
;
rpc_table_s
rpc_table
[]
=
{
rpc_table_s
rpc_table
[]
=
{
{
test_func
,
"test_func"
},
RPC_KK_TEST_FUNCTION_TABLE
,
RPC_KK_TEST_FUNCTION_TABLE
,
RPC_NETWORK_FUNCTION_TABLE
,
RPC_COMMON_FUNCTION_TABLE
,
RPC_GLOBAL_COMMAND_FUNCTION_TABLE
,
RPC_COLOR_CONTROL_COMMAND_FUNCTION_TABLE
,
RPC_OnOff_COMMAND_FUNCTION_TABLE
,
};
};
void
rpcInterfaceParse
(
void
)
{
emberAfAppPrint
(
"Thread rpc Interface Parse create
\n
"
);
jrpc_server_init
(
&
my_server
,
PORT
);
emberAfAppPrint
(
"sizeof(rpc_table)=%d,sizeof(rpc_table_s)=%d,%d
\n
"
,
sizeof
(
rpc_table
),
sizeof
(
rpc_table_s
),
sizeof
(
rpc_table
)
/
sizeof
(
rpc_table_s
));
for
(
int
i
=
0
;
i
<
sizeof
(
rpc_table
)
/
sizeof
(
rpc_table_s
);
i
++
){
emberAfAppPrint
(
"i=%d,%s
\r\n
"
,
i
,
rpc_table
[
i
].
name
);
jrpc_register_procedure
(
&
my_server
,
rpc_table
[
i
].
func
,
rpc_table
[
i
].
name
,
NULL
);
}
jrpc_server_run
(
&
my_server
);
jrpc_server_destroy
(
&
my_server
);
}
cJSON
*
test_func
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item1
=
rpc_cJSON_CreateObject
();
cJSON
*
item2
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddNullToObject
(
item1
,
"Null"
);
rpc_cJSON_AddTrueToObject
(
item1
,
"True"
);
rpc_cJSON_AddFalseToObject
(
item1
,
"False"
);
rpc_cJSON_AddNumberToObject
(
item1
,
"Number"
,
12345
);
rpc_cJSON_AddStringToObject
(
item1
,
"String"
,
"hello world!"
);
rpc_cJSON_AddNullToObject
(
item2
,
"1"
);
rpc_cJSON_AddTrueToObject
(
item2
,
"2"
);
rpc_cJSON_AddFalseToObject
(
item2
,
"3"
);
rpc_cJSON_AddNumberToObject
(
item2
,
"4"
,
12345
);
rpc_cJSON_AddStringToObject
(
item2
,
"5"
,
"hello world!"
);
rpc_cJSON_AddItemToObject
(
item1
,
"hhhhhh"
,
item2
);
return
item1
;
}
static
int
send_result_resp
(
cJSON
*
result
,
static
int
send_result_resp
(
cJSON
*
result
,
cJSON
*
id
)
{
cJSON
*
id
)
{
...
@@ -229,10 +218,10 @@ void ncp_queue_tick(void)
...
@@ -229,10 +218,10 @@ void ncp_queue_tick(void)
{
{
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
char
*
str
;
char
*
str
;
if
(
ncp_queue_dequeue
(
&
root
)
==
0
){
if
(
ncp_queue_dequeue
(
REV_MSG
,
&
root
)
==
0
){
str
=
rpc_cJSON_Print
(
root
);
str
=
rpc_cJSON_Print
(
root
);
printf
(
"
d
equeue cJson = %s
\n
"
,
str
);
printf
(
"
D
equeue cJson = %s
\n
"
,
str
);
free
(
str
);
free
(
str
);
eval_request
(
&
my_server
,
root
);
eval_request
(
&
my_server
,
root
);
rpc_cJSON_Delete
(
root
);
rpc_cJSON_Delete
(
root
);
...
@@ -253,7 +242,7 @@ void _cb(void* data, int len, char* chlmark){
...
@@ -253,7 +242,7 @@ void _cb(void* data, int len, char* chlmark){
kk_ota_process
(
root
);
kk_ota_process
(
root
);
}
else
{
}
else
{
ncp_queue_enqueue
((
void
*
)
root
);
ncp_queue_enqueue
(
REV_MSG
,
(
void
*
)
root
);
//eval_request(&my_server, root);
//eval_request(&my_server, root);
}
}
}
}
...
@@ -549,6 +538,28 @@ int kk_connect_check(){
...
@@ -549,6 +538,28 @@ int kk_connect_check(){
}
}
}
}
void
get_prey_handle
(
void
)
{
get_property_data_s
*
data
;
EmberStatus
status
;
while
(
1
){
if
(
ncp_queue_dequeue
(
GET_PROPERTY
,
&
data
)
==
0
){
printf
(
"
\n
================dequeue==================
\n
"
);
printf
(
"node = 0x%04X,ep=%d,clu=0x%04X,len=%d
\n
"
,
data
->
node
,
data
->
ep
,
data
->
clu
,
data
->
len
);
for
(
int
i
=
0
;
i
<
data
->
len
;
i
++
){
printf
(
"attr=0x%04X
\n
"
,
data
->
attr
[
i
]);
}
status
=
zclGReadAttrs
(
data
->
node
,
1
,
data
->
ep
,
false
,
data
->
clu
,
data
->
len
,
data
->
attr
,
true
);
free
(
data
->
attr
);
free
(
data
);
}
}
}
void
ipcHandle
(
void
)
void
ipcHandle
(
void
)
{
{
#ifdef GATEWAY_TYPE_NCP
#ifdef GATEWAY_TYPE_NCP
...
...
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
View file @
e3402700
...
@@ -94,7 +94,7 @@ extern void kk_print_network_info(void);
...
@@ -94,7 +94,7 @@ extern void kk_print_network_info(void);
extern
void
test_123
(
int
val
);
extern
void
test_123
(
int
val
);
extern
void
kk_ota_test111
();
extern
void
kk_ota_test111
();
extern
void
kk_ota_test123123123
();
extern
void
kk_ota_test123123123
();
extern
int
ncp_queue_enqueue
(
void
*
data
);
extern
void
aaaBBB
(
);
void
kk_message_process
(
char
*
messageString
)
void
kk_message_process
(
char
*
messageString
)
{
{
...
@@ -120,6 +120,7 @@ void kk_message_process(char *messageString)
...
@@ -120,6 +120,7 @@ void kk_message_process(char *messageString)
kk_ota_test123123123
();
kk_ota_test123123123
();
}
}
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST
\r\n
"
,
len
)
==
0
){
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST
\r\n
"
,
len
)
==
0
){
aaaBBB
();
}
}
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
View file @
e3402700
...
@@ -81,8 +81,7 @@ extern void ColorCtrEmovehueCMD( unsigned short node,
...
@@ -81,8 +81,7 @@ extern void ColorCtrEmovehueCMD( unsigned short node,
//
extern
void
rpcInterfaceParse
(
void
);
#endif
#endif
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
View file @
e3402700
...
@@ -596,9 +596,10 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
...
@@ -596,9 +596,10 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
kk_device_gateway_add
(
eui64
);
kk_device_gateway_add
(
eui64
);
pthread_t
tid
;
pthread_t
tid
;
pthread_t
prey_tid
;
//pthread_create(&tid, NULL, rpcInterfaceParse, NULL);
//pthread_create(&tid, NULL, rpcInterfaceParse, NULL);
pthread_create
(
&
tid
,
NULL
,
ipcHandle
,
NULL
);
pthread_create
(
&
tid
,
NULL
,
ipcHandle
,
NULL
);
pthread_create
(
&
prey_tid
,
NULL
,
get_prey_handle
,
NULL
);
// initialize the ZCL framework ,(plug in) ,mqtt init is here
// initialize the ZCL framework ,(plug in) ,mqtt init is here
emAfInit
();
emAfInit
();
...
...
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