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
33a3264b
Commit
33a3264b
authored
Oct 23, 2020
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
Yjq See merge request chenweican/k-sdk!58
parents
d61a4575
79494974
Changes
49
Show whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
1546 additions
and
3670 deletions
+1546
-3670
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+4
-6
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
+8
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
+25
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.h
.../zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.h
+13
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.c
+26
-44
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.h
+6
-74
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_common.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_common.c
+624
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_common.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_common.h
+34
-43
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_msg.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_msg.c
+129
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_msg.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_msg.h
+90
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.c
+20
-21
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.h
+3
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_rpc.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_rpc.c
+126
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_rpc.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_rpc.h
+21
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_thread.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_thread.c
+188
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_thread.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_thread.h
+28
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_topo_batch_handle.c
...igbee/app/builder/Z3GatewayHost/ZB/kk_topo_batch_handle.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
+2
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
...bee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
+0
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
+19
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
...zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
+3
-7
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_wlist_mng.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_wlist_mng.c
+1
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_wlist_mng.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_wlist_mng.h
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
+39
-0
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
+9
-21
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.c
...m/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.c
+4
-2
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.h
...m/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.h
+3
-1
platform/zigbee/app/builder/Z3GatewayHost/afv2-bookkeeping.c
platform/zigbee/app/builder/Z3GatewayHost/afv2-bookkeeping.c
+4
-6
platform/zigbee/app/builder/Z3GatewayHost/call-command-handler.c
...m/zigbee/app/builder/Z3GatewayHost/call-command-handler.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/call-command-handler.h
...m/zigbee/app/builder/Z3GatewayHost/call-command-handler.h
+4
-0
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+0
-218
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
+0
-74
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/RPC_API.h
...rm/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/RPC_API.h
+2
-6
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_colorControl.h
.../app/builder/Z3GatewayHost/rpc_api/inc/rpc_colorControl.h
+0
-86
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_global_cmd.h
...ee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_global_cmd.h
+0
-23
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_interface_parse.h
...p/builder/Z3GatewayHost/rpc_api/inc/rpc_interface_parse.h
+0
-41
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_network_operate.h
...p/builder/Z3GatewayHost/rpc_api/inc/rpc_network_operate.h
+0
-69
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_onoff.h
.../zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_onoff.h
+0
-42
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/color_control/rpc_colorControl.c
...3GatewayHost/rpc_api/src/color_control/rpc_colorControl.c
+0
-1859
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_common.c
...zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_common.c
+1
-1
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_global_cmd.c
...ee/app/builder/Z3GatewayHost/rpc_api/src/rpc_global_cmd.c
+0
-178
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_network_operate.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_network_operate.c
+0
-487
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_onoff.c
.../zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_onoff.c
+0
-332
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
+99
-1
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
+1
-1
platform/zigbee/protocol/zigbee/app/framework/plugin/device-table/device-table.c
...l/zigbee/app/framework/plugin/device-table/device-table.c
+1
-1
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
.../zigbee/protocol/zigbee/app/framework/util/af-main-host.c
+4
-14
No files found.
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
33a3264b
...
@@ -294,15 +294,13 @@ APPLICATION_FILES= \
...
@@ -294,15 +294,13 @@ APPLICATION_FILES= \
./ZB/kk_color_space.c
\
./ZB/kk_color_space.c
\
./ZB/sub_device_manage.c
\
./ZB/sub_device_manage.c
\
./ZB/kk_ncp_queue.c
\
./ZB/kk_ncp_queue.c
\
./ZB/kk_ncp_common.c
\
./ZB/kk_ncp_rpc.c
\
./ZB/kk_ncp_msg.c
\
./ZB/kk_ncp_thread.c
\
./ZB/kk_topo_batch_handle.c
\
./ZB/kk_topo_batch_handle.c
\
./ZB/kk_wlist_mng.c
\
./ZB/kk_wlist_mng.c
\
./kk_test.c
\
./rpc_api/src/rpc_common.c
\
./rpc_api/src/rpc_common.c
\
./rpc_api/src/rpc_onoff.c
\
./rpc_api/src/rpc_global_cmd.c
\
./rpc_api/src/rpc_interface_parse.c
\
./rpc_api/src/color_control/rpc_colorControl.c
\
./rpc_api/src/rpc_network_operate.c
\
LIBRARIES
=
\
LIBRARIES
=
\
\
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.c
View file @
33a3264b
...
@@ -3,7 +3,13 @@
...
@@ -3,7 +3,13 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <fcntl.h>
#include "kk_product_code.h"
#include "kk_product_code.h"
#include "kk_zb_com.h"
#include "kk_device_table_db.h"
#include "kk_ncp_msg.h"
#include "kk_zigbee_api.h"
#include "zb_device_id.h"
//#include "sub_device_manage.h"
...
@@ -515,6 +521,7 @@ void kk_device_config_item_report(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId c
...
@@ -515,6 +521,7 @@ void kk_device_config_item_report(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId c
break
;
break
;
}
}
}
}
item
=
item
->
next
;
}
}
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_manager.h
View file @
33a3264b
#ifndef __KK_DEVICE_MANAGER_H
#ifndef __KK_DEVICE_MANAGER_H
#define __KK_DEVICE_MANAGER_H
#define __KK_DEVICE_MANAGER_H
#include "kk_
test
.h"
#include "kk_
ncp_common
.h"
/****************** ******************************************************************
/****************** ******************************************************************
...
@@ -74,6 +74,30 @@ typedef struct kk_dev_config_map{
...
@@ -74,6 +74,30 @@ typedef struct kk_dev_config_map{
struct
kk_dev_config_map
*
next
;
struct
kk_dev_config_map
*
next
;
}
kk_dev_config_map
;
}
kk_dev_config_map
;
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
;
kk_dev_config_item_extra_data
*
kk_find_extra_data
(
EmberNodeId
node
,
const
char
*
tag
);
kk_dev_config_item_extra_data
*
kk_find_extra_data
(
EmberNodeId
node
,
const
char
*
tag
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.c
View file @
33a3264b
#include "kk_device_table_db.h"
#include "kk_device_table_db.h"
#include "sqlite3.h"
#include "sqlite3.h"
#include "kk_ncp_queue.h"
#include "kk_ncp_queue.h"
#include "kk_device_manager.h"
void
kk_mac_conver
(
EmberEUI64
mac
,
char
*
macString
)
void
kk_mac_conver
(
EmberEUI64
mac
,
char
*
macString
)
{
{
sprintf
(
macString
,
"%02X%02X%02X%02X%02X%02X%02X%02X"
,
sprintf
(
macString
,
"%02X%02X%02X%02X%02X%02X%02X%02X"
,
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_device_table_db.h
View file @
33a3264b
#ifndef __KK_DEVICE_TABLE_DB_H
#ifndef __KK_DEVICE_TABLE_DB_H
#define __KK_DEVICE_TABLE_DB_H
#define __KK_DEVICE_TABLE_DB_H
#include "kk_zb_com.h"
#include "kk_ncp_common.h"
#include "kk_test.h"
#include "kk_device_manager.h"
#include "../device-table/device-table.h"
typedef
struct
kk_device_table_s
{
EmberEUI64
mac
;
EmberNodeId
nodeId
;
uint16_t
deviceId
;
uint16_t
identifyCnt
;
char
productCode
[
33
];
SubDevManage_s
manage
;
struct
kk_device_table_s
*
next
;
}
kk_device_table_s
;
#define KK_MAX_PRODUCT_CODE_SIZE 33
#define KK_MAX_PRODUCT_CODE_SIZE 33
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.c
View file @
33a3264b
#include "kk_msg_report.h"
#include "kk_msg_report.h"
#include "kk_ncp_common.h"
#include "kk_device_manager.h"
#include "kk_device_table_db.h"
static
void
kk_msg_report
(
cJSON
*
data
,
char
*
msgtype
,
char
*
method
,
EmberEUI64
mac
)
static
void
kk_msg_report
(
cJSON
*
data
,
char
*
msgtype
,
char
*
method
,
EmberEUI64
mac
)
{
{
cJSON
*
root
;
cJSON
*
info
,
*
payload
;
static
uint16_t
msgid
;
static
uint16_t
msgid
;
char
msgIdString
[
10
]
=
{
0
};
char
msgIdString
[
10
]
=
{
0
};
char
macString
[
19
]
=
{
0
};
char
macString
[
19
]
=
{
0
};
int
res
=
0
;
kk_device_table_s
*
dev
=
NULL
;
kk_device_table_s
*
dev
=
NULL
;
rpc_eui64ToString
(
mac
,
macString
);
rpc_eui64ToString
(
mac
,
macString
);
dev
=
kk_device_find_by_mac
(
mac
);
dev
=
kk_device_find_by_mac
(
mac
);
if
(
dev
==
NULL
)
{
if
(
dev
==
NULL
)
{
printf
(
"[%s][%d]kk_msg_report error!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
emberAfDebugPrintln
(
"[%s][%d]kk_msg_report error!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
;
return
;
}
}
cJSON
*
info
=
rpc_cJSON_CreateObject
();
info
=
rpc_cJSON_CreateObject
();
if
(
info
!=
NULL
){
if
(
info
!=
NULL
){
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
msgtype
);
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
msgtype
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
dev
->
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
dev
->
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
macString
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
macString
);
}
}
cJSON
*
payload
=
rpc_cJSON_CreateObject
();
payload
=
rpc_cJSON_CreateObject
();
if
(
payload
!=
NULL
){
if
(
payload
!=
NULL
){
sprintf
(
msgIdString
,
"%d"
,
++
msgid
);
sprintf
(
msgIdString
,
"%d"
,
++
msgid
);
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgIdString
);
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgIdString
);
...
@@ -29,18 +33,23 @@ static void kk_msg_report(cJSON *data,char *msgtype,char *method,EmberEUI64 mac)
...
@@ -29,18 +33,23 @@ static void kk_msg_report(cJSON *data,char *msgtype,char *method,EmberEUI64 mac)
rpc_cJSON_AddStringToObject
(
payload
,
"method"
,
method
);
rpc_cJSON_AddStringToObject
(
payload
,
"method"
,
method
);
rpc_cJSON_AddItemToObject
(
payload
,
"params"
,
data
);
rpc_cJSON_AddItemToObject
(
payload
,
"params"
,
data
);
}
}
cJSON
*
root
=
rpc_cJSON_CreateObject
();
root
=
rpc_cJSON_CreateObject
();
if
(
root
!=
NULL
){
if
(
root
!=
NULL
){
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
}
}
char
*
p
=
rpc_cJSON_Print
(
root
);
kk_tsl_send_msg
(
root
);
emberAfAppPrintln
(
"send json:
\n
%s
\n
"
,
p
);
free
(
p
);
jrpc_send_msg
(
root
);
rpc_cJSON_Delete
(
root
);
rpc_cJSON_Delete
(
root
);
}
}
static
void
kk_msg_report_joined
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_msg_report
(
data
,
KK_REPORT_DEVICE_JOINED_TYPE
,
KK_REPORT_DEVICE_JOINED_METHOD
,
mac
);
}
static
void
kk_msg_report_leave
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_msg_report
(
data
,
KK_REPORT_DEVICE_LEFT_TYPE
,
KK_REPORT_DEVICE_LEAVE_METHOD
,
mac
);
}
void
kk_msg_report_batch_joined
(
cJSON
*
data
,
EmberEUI64
mac
)
void
kk_msg_report_batch_joined
(
cJSON
*
data
,
EmberEUI64
mac
)
{
{
...
@@ -51,42 +60,23 @@ void kk_msg_report_batch_leave(cJSON *data,EmberEUI64 mac)
...
@@ -51,42 +60,23 @@ void kk_msg_report_batch_leave(cJSON *data,EmberEUI64 mac)
kk_msg_report
(
data
,
KK_REPORT_DEVICE_BATCH_LEFT_TYPE
,
KK_REPORT_DEVICE_BATCH_LEAVE_METHOD
,
mac
);
kk_msg_report
(
data
,
KK_REPORT_DEVICE_BATCH_LEFT_TYPE
,
KK_REPORT_DEVICE_BATCH_LEAVE_METHOD
,
mac
);
}
}
static
void
kk_msg_report_joined
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_msg_report
(
data
,
KK_REPORT_DEVICE_JOINED_TYPE
,
KK_REPORT_DEVICE_JOINED_METHOD
,
mac
);
}
static
void
kk_msg_report_leave
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_msg_report
(
data
,
KK_REPORT_DEVICE_LEFT_TYPE
,
KK_REPORT_DEVICE_LEAVE_METHOD
,
mac
);
}
void
kk_msg_report_property
(
cJSON
*
data
,
EmberEUI64
mac
)
void
kk_msg_report_property
(
cJSON
*
data
,
EmberEUI64
mac
)
{
{
kk_msg_report
(
data
,
KK_REPORT_ATTRIBUTE_TYPE
,
KK_REPORT_ATTRIBUTE_METHOD
,
mac
);
kk_msg_report
(
data
,
KK_REPORT_ATTRIBUTE_TYPE
,
KK_REPORT_ATTRIBUTE_METHOD
,
mac
);
}
}
void
kk_msg_report_whiteListAddedNotification
(
cJSON
*
data
,
EmberEUI64
mac
)
void
kk_msg_report_whiteListAddedNotification
(
cJSON
*
data
,
EmberEUI64
mac
)
{
{
kk_msg_report
(
data
,
KK_REPORT_ADDWHITELIST_NOTIFY_METHOD
,
KK_REPORT_ADDWHITELIST_NOTIFY_TYPE
,
mac
);
kk_msg_report
(
data
,
KK_REPORT_ADDWHITELIST_NOTIFY_METHOD
,
KK_REPORT_ADDWHITELIST_NOTIFY_TYPE
,
mac
);
}
}
void
kk_msg_report_whiteListDelNotification
(
cJSON
*
data
,
EmberEUI64
mac
)
void
kk_msg_report_whiteListDelNotification
(
cJSON
*
data
,
EmberEUI64
mac
)
{
{
kk_msg_report
(
data
,
KK_REPORT_DELWHITELIST_NOTIFY_METHOD
,
KK_REPORT_DELWHITELIST_NOTIFY_TYPE
,
mac
);
kk_msg_report
(
data
,
KK_REPORT_DELWHITELIST_NOTIFY_METHOD
,
KK_REPORT_DELWHITELIST_NOTIFY_TYPE
,
mac
);
}
}
void
kk_msg_report_alarm
(
cJSON
*
data
,
EmberEUI64
mac
)
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
)
{
{
cJSON
*
devicesJson
;
cJSON
*
devicesJson
;
...
@@ -110,7 +100,6 @@ void kk_msg_report_dev_joined(EmberEUI64 mac,const char* productCode)
...
@@ -110,7 +100,6 @@ void kk_msg_report_dev_joined(EmberEUI64 mac,const char* productCode)
void
kk_msg_report_dev_leave
(
EmberEUI64
mac
)
void
kk_msg_report_dev_leave
(
EmberEUI64
mac
)
{
{
int
res
=
0
;
cJSON
*
devicesJson
;
cJSON
*
devicesJson
;
EmberEUI64
localEui64
=
{
0
};
EmberEUI64
localEui64
=
{
0
};
char
macString
[
KK_EUI64_STRING_LENGTH
];
char
macString
[
KK_EUI64_STRING_LENGTH
];
...
@@ -131,12 +120,5 @@ void kk_msg_report_dev_leave(EmberEUI64 mac)
...
@@ -131,12 +120,5 @@ void kk_msg_report_dev_leave(EmberEUI64 mac)
}
}
int
kk_sendData2CCU
(
char
*
data
,
int
len
)
{
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_send
(
data
,
len
);
}
else
{
kk_ipc_send
(
IPC_PLAT2MID
,
data
,
len
+
1
);
}
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_msg_report.h
View file @
33a3264b
#ifndef __KK_MSG_REPORT_H
#ifndef __KK_MSG_REPORT_H
#define __KK_MSG_REPORT_H
#define __KK_MSG_REPORT_H
#include <stdio.h>
#include "kk_ncp_msg.h"
#include "app/framework/include/af.h"
#include ".././jsonrpc/jsonrpc-c.h"
#include ".././jsonrpc/rpccJSON.h"
#include "com_api.h"
#include "kk_zb_com.h"
#define KK_IPC_VERSION "1.0"
#define KK_REPORT_DEVICE_BATCH_JOINED_METHOD "thing.topo.batchAdd"
#define KK_REPORT_DEVICE_JOINED_METHOD "thing.topo.add"
#define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.delete"
#define KK_REPORT_DEVICE_BATCH_LEAVE_METHOD "thing.topo.batchDelete"
#define KK_REPORT_ADDWHITELIST_NOTIFY_METHOD "thing.event.whiteListAddedNotification.post"
#define KK_REPORT_DELWHITELIST_NOTIFY_METHOD "thing.event.whiteListDeletedNotification.post"
#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_ATTRIBUTE_METHOD "thing.event.property.post"
#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_JOINED_TYPE "/thing/topo/add"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_DEVICE_BATCH_LEFT_TYPE "/thing/topo/batch_delete"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define KK_REPORT_ADDWHITELIST_NOTIFY_TYPE "/thing/event/whiteListAddedNotification/post"
#define KK_REPORT_DELWHITELIST_NOTIFY_TYPE "/thing/event/whiteListDeletedNotification/post"
#define GW2CCU_PROTOCOL "tcp"
//#define GATEWAY_TYPE_NCP
#ifdef GATEWAY_TYPE_NCP
#undef GW2CCU_PROTOCOL
#define GW2CCU_PROTOCOL "nanomsg"
#endif
int
kk_sendData2CCU
(
char
*
data
,
int
len
);
void
kk_msg_report_dev_leave
(
EmberEUI64
mac
);
void
kk_msg_report_dev_joined
(
EmberEUI64
mac
,
const
char
*
productCode
);
void
kk_msg_report_dev_joined
(
EmberEUI64
mac
,
const
char
*
productCode
);
void
kk_msg_report_dev_leave
(
EmberEUI64
mac
);
void
kk_msg_report_batch_joined
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_batch_leave
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_property
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_property
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_whiteListAddedNotification
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_whiteListDelNotification
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_alarm
(
cJSON
*
data
,
EmberEUI64
mac
);
void
kk_msg_report_alarm
(
cJSON
*
data
,
EmberEUI64
mac
);
#endif
#endif
platform/zigbee/app/builder/Z3GatewayHost/
rpc_api/src/rpc_interface_parse
.c
→
platform/zigbee/app/builder/Z3GatewayHost/
ZB/kk_ncp_common
.c
View file @
33a3264b
#include <stdio.h>
//#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
//#include <netinet/in.h>
#include <netdb.h>
//#include <netdb.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <sys/wait.h>
//#include <sys/wait.h>
#include <signal.h>
//#include <signal.h>
#include <time.h>
//#include <time.h>
#include <fcntl.h>
#include <fcntl.h>
#include "RPC_API.h"
#include "./rpc_api/inc/rpc_interface_parse.h"
#include "rpc_network_operate.h"
#include "rpc_global_cmd.h"
#include "rpc_colorControl.h"
#include "rpc_onoff.h"
#include "kk_test.h"
#include "kk_ncp_queue.h"
#include "kk_tsl_property_get.h"
//#include "kk_log.h"
static
struct
jrpc_server
my_server
;
void
aaaBBB
()
{
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
struct
{
rpc_function
func
;
char
*
name
;
}
rpc_table_s
;
rpc_table_s
rpc_table
[]
=
{
RPC_KK_TEST_FUNCTION_TABLE
,
};
void
kk_tsl_msg_ack
(
const
char
*
id
,
const
char
*
ackMsgType
,
const
char
*
productCode
,
const
char
*
deviceCode
)
{
cJSON
*
root
=
rpc_cJSON_CreateObject
();
cJSON
*
info
=
rpc_cJSON_CreateObject
();
cJSON
*
payload
=
rpc_cJSON_CreateObject
();
cJSON
*
data
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
ackMsgType
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
deviceCode
);
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
id
);
rpc_cJSON_AddNullToObject
(
payload
,
"code"
);
rpc_cJSON_AddItemToObject
(
payload
,
"data"
,
data
);
jrpc_send_msg
(
root
);
rpc_cJSON_Delete
(
root
);
}
static
int
kk_tsl_send_msg_ack
(
const
char
*
msgType
,
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
id
)
{
cJSON
*
root
=
rpc_cJSON_CreateObject
();
cJSON
*
info
=
rpc_cJSON_CreateObject
();
cJSON
*
payload
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
"/thing/service/property/get_reply"
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
deviceCode
);
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
"*******"
);
return
0
;
}
static
int
send_result_resp
(
int
code
,
char
*
message
,
cJSON
*
id
)
{
}
static
int
send_error_resp
(
int
code
,
char
*
message
,
cJSON
*
id
)
{
#if 0
int return_value = 0;
cJSON *edata;
cJSON *info_root = rpc_cJSON_CreateObject();
if(info_root){
rpc_cJSON_AddStringToObject(info_root, "msgType", "");
rpc_cJSON_AddStringToObject(info_root, "productType", "");
rpc_cJSON_AddStringToObject(info_root, "productCode", "");
rpc_cJSON_AddStringToObject(info_root, "deviceCode", "");
}
cJSON *payload_root = rpc_cJSON_CreateObject();
if(payload_root){
rpc_cJSON_AddItemToObject(payload_root, "msgId", id);
rpc_cJSON_AddNumberToObject(payload_root, "code", code);
edata = rpc_cJSON_CreateObject();
if(edata){
rpc_cJSON_AddStringToObject(edata, "message", message);
}
rpc_cJSON_AddItemToObject(payload_root, "data", edata);
}
#include "kk_ncp_common.h"
cJSON *result_root = rpc_cJSON_CreateObject();
if(result_root){
rpc_cJSON_AddItemToObject(result_root, "info", info_root);
rpc_cJSON_AddItemToObject(result_root, "payload", payload_root);
}
char * str_result = rpc_cJSON_Print(result_root);
//printf("alla=========== :%d\n", strlen(str_result)+1);
return_value = kk_sendData2CCU(str_result, strlen(str_result));
printf("send_error_resp:\n%s\n", str_result);
free(str_result);
rpc_cJSON_Delete(result_root);
free(message);
return return_value;
#else
return
0
;
#endif
}
static
int
invoke_procedure
(
struct
jrpc_server
*
server
,
char
*
name
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
cJSON
*
returned
=
NULL
;
int
procedure_found
=
0
;
jrpc_context
ctx
;
ctx
.
error_code
=
0
;
ctx
.
error_message
=
NULL
;
int
i
=
server
->
procedure_count
;
while
(
i
--
)
{
if
(
!
strcmp
(
server
->
procedures
[
i
].
name
,
name
))
{
procedure_found
=
1
;
ctx
.
data
=
server
->
procedures
[
i
].
data
;
returned
=
server
->
procedures
[
i
].
function
(
&
ctx
,
params
,
id
,
mac
);
break
;
}
}
if
(
!
procedure_found
)
return
send_error_resp
(
JRPC_METHOD_NOT_FOUND
,
strdup
(
"Method not found."
),
id
);
else
{
if
(
ctx
.
error_code
)
return
send_error_resp
(
ctx
.
error_code
,
ctx
.
error_message
,
id
);
else
return
0
;
//send_result_resp(returned, id);
}
}
static
int
eval_request
(
struct
jrpc_server
*
server
,
cJSON
*
root
)
{
cJSON
*
params
,
*
id
,
*
deviceCode
,
*
productCode
,
*
info
,
*
msgType
,
*
payload
;
info
=
rpc_cJSON_GetObjectItem
(
root
,
"info"
);
if
(
info
!=
NULL
){
msgType
=
rpc_cJSON_GetObjectItem
(
info
,
"msgType"
);
deviceCode
=
rpc_cJSON_GetObjectItem
(
info
,
"deviceCode"
);
productCode
=
rpc_cJSON_GetObjectItem
(
info
,
"productCode"
);
}
payload
=
rpc_cJSON_GetObjectItem
(
root
,
"payload"
);
if
(
payload
!=
NULL
){
params
=
rpc_cJSON_GetObjectItem
(
payload
,
"params"
);
id
=
rpc_cJSON_GetObjectItem
(
payload
,
"msgId"
);
}
if
(
id
!=
NULL
&&
params
!=
NULL
&&
msgType
!=
NULL
&&
deviceCode
!=
NULL
){
cJSON
*
id_copy
=
NULL
;
#include "kk_wlist_mng.h"
id_copy
=
(
id
->
type
==
cJSON_String
)
?
rpc_cJSON_CreateString
(
id
->
valuestring
)
:
\
#include "com_api.h"
rpc_cJSON_CreateNumber
(
id
->
valueint
);
#include "kk_ncp_queue.h"
#include "kk_ncp_msg.h"
#include "kk_device_manager.h"
#include "kk_device_table_db.h"
if
(
strcmp
(
msgType
->
valuestring
,
"/thing/service/property/get"
)
==
0
)
kk_tsl_msg_ack
(
id
,
msgType
->
valuestring
,
productCode
->
valuestring
,
deviceCode
->
valuestring
);
return
invoke_procedure
(
server
,
msgType
->
valuestring
,
params
,
id_copy
,
deviceCode
);
}
#include "kk_tsl_property_report.h"
send_error_resp
(
JRPC_INVALID_REQUEST
,
strdup
(
"The JSON sent is not a valid Request object."
),
NULL
);
return
-
1
;
}
#define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade"
void
_cb
(
void
*
data
,
int
len
,
char
*
chlmark
){
if
(
data
!=
NULL
){
printf
(
"plat_cb: %s [%d]RECEIVED
\r\n
"
,
data
,
len
);
cJSON
*
root
;
char
*
end_ptr
=
NULL
;
if
((
root
=
rpc_cJSON_Parse_Stream
(
data
,
&
end_ptr
))
!=
NULL
)
{
if
(
root
->
type
==
cJSON_Object
)
{
cJSON
*
info
=
rpc_cJSON_GetObjectItem
(
root
,
"info"
);
if
(
info
!=
NULL
&&
strstr
(
rpc_cJSON_GetObjectItem
(
info
,
"msgType"
)
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)
!=
NULL
){
/**************************************************************/
kk_ota_process
(
root
);
}
else
{
ncp_queue_enqueue
(
REV_MSG
,(
void
*
)
root
);
//eval_request(&my_server, root);
}
}
//shift processed request, discarding it
//rpc_cJSON_Delete(root);
}
else
{
if
(
1
)
{
printf
(
"INVALID JSON Received:
\n
---
\n
%s
\n
---
\n
"
,
data
);
}
send_error_resp
(
JRPC_PARSE_ERROR
,
strdup
(
"Parse error. Invalid JSON was received by the server."
),
NULL
);
}
}
}
int
_init_param
(
struct
jrpc_server
*
server
)
{
//*************************************************************
memset
(
server
,
0
,
sizeof
(
struct
jrpc_server
));
//kk_zlog_init("paltform");
printf
(
"getenv
\r\n
"
);
char
*
debug_level_env
=
getenv
(
"JRPC_DEBUG"
);
printf
(
"getenv(JRPC_DEBUG):%s
\n
"
,
server
->
debug_level
);
if
(
debug_level_env
==
NULL
)
server
->
debug_level
=
0
;
else
{
server
->
debug_level
=
strtol
(
debug_level_env
,
NULL
,
10
);
printf
(
"JSONRPC-C Debug level %d
\n
"
,
server
->
debug_level
);
}
server
->
debug_level
=
1
;
return
0
;
}
char
g_mac
[
19
]
=
{
0
};
static
char
g_mac
[
19
]
=
{
0
};
char
*
kk_get_gw_mac
(){
char
*
kk_get_gw_mac
(
void
)
{
int
cnt
=
0
;
int
cnt
=
0
;
EmberEUI64
eui64
;
EmberEUI64
eui64
;
emberAfGetEui64
(
eui64
);
emberAfGetEui64
(
eui64
);
...
@@ -295,6 +59,17 @@ char* kk_get_gw_mac(){
...
@@ -295,6 +59,17 @@ char* kk_get_gw_mac(){
}
}
int
kk_connect_check
(){
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
return
kk_get_retry_num
()
>
20
;
}
else
{
if
(
kk_ipc_get_senderrcnt
(
IPC_PLAT2MID
)
>
0
){
return
kk_ipc_isconnect
(
IPC_PLAT2MID
)
==
0
?
1
:
0
;
}
return
0
;
}
}
int
search_ccu
(
char
devcode
[
33
],
char
ip
[
16
],
int
*
port
){
int
search_ccu
(
char
devcode
[
33
],
char
ip
[
16
],
int
*
port
){
char
sendCmdFmt
[]
=
"search_kk_ccu|deviceCode=%s;protocol=%s"
;
char
sendCmdFmt
[]
=
"search_kk_ccu|deviceCode=%s;protocol=%s"
;
...
@@ -467,324 +242,168 @@ int search_ccu(char devcode[33], char ip[16], int* port){
...
@@ -467,324 +242,168 @@ int search_ccu(char devcode[33], char ip[16], int* port){
}
}
#define GW_PRODUCT_CODE "2"
void
_cb
(
void
*
data
,
int
len
,
char
*
chlmark
){
if
(
data
!=
NULL
){
void
*
_msg_topo_add
(){
printf
(
"plat_cb: %s [%d]RECEIVED
\r\n
"
,
data
,
len
);
char
msgFmt
[]
=
"{
\"
info
\"
:{
\"
msgtype
\"
:
\"
/thing/topo/add
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
},\
cJSON
*
root
;
\"
payload
\"
:{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
deviceCode
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
mac
\"
:
\"
%s
\"
}}}"
;
char
*
end_ptr
=
NULL
;
//char msg[520] = {0};
char
*
msg
=
NULL
;
char
*
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
printf
(
"[%s] get mac fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
msg
=
malloc
(
520
);
if
(
msg
==
NULL
){
printf
(
"[%s] msg malloc fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
sprintf
(
msg
,
msgFmt
,
GW_PRODUCT_CODE
,
macString
,
1
,
macString
,
GW_PRODUCT_CODE
,
macString
);
//cJSON* msgObj = cJSON_Parse(msg);
//char* outbuf = cJSON_Print(msgObj);
//cJSON_Delete(msgObj);
//return outbuf;
return
msg
;
}
void
*
_msg_event_property_post
(
char
ip
[
16
],
int
port
){
char
msgFmt
[]
=
"{
\"
info
\"
:{
\"
msgtype
\"
:
\"
/thing/event/property/post
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
},\
\"
payload
\"
:{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
NetChannelState
\"
:%d,
\"
WhiteListState
\"
:%d,\
\"
OnlineDetectionState
\"
:%d,
\"
SN
\"
:
\"
%s
\"
,
\"
IPAddress
\"
:
\"
%s
\"
,
\"
MACAddress
\"
:
\"
%s
\"
,
\"
Port
\"
:%d},\
\"
time
\"
:1524448722000,
\"
method
\"
:
\"
thing.event.property.post
\"
}\
}"
;
//char msg[620] = {0};
char
*
msg
=
NULL
;
char
*
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
printf
(
"[%s] get mac fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
msg
=
malloc
(
620
);
if
((
root
=
rpc_cJSON_Parse_Stream
(
data
,
&
end_ptr
))
!=
NULL
)
{
if
(
msg
==
NULL
){
printf
(
"[%s] msg malloc fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
sprintf
(
msg
,
msgFmt
,
GW_PRODUCT_CODE
,
macString
,
if
(
root
->
type
==
cJSON_Object
)
{
1
,
0
,
0
,
0
,
"12345"
,
ip
,
macString
,
port
);
cJSON
*
info
=
rpc_cJSON_GetObjectItem
(
root
,
"info"
);
//cJSON* msgObj = cJSON_Parse(msg);
//char* outbuf = cJSON_Print(msgObj);
//cJSON_Delete(msgObj);
//return outbuf;
return
msg
;
}
if
(
info
!=
NULL
&&
strstr
(
rpc_cJSON_GetObjectItem
(
info
,
"msgType"
)
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)
!=
NULL
){
int
kk_connect_check
(){
kk_ota_process
(
root
);
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
return
kk_get_retry_num
()
>
20
;
}
else
{
}
else
{
if
(
kk_ipc_get_senderrcnt
(
IPC_PLAT2MID
)
>
0
){
ncp_queue_enqueue
(
REV_MSG
,(
void
*
)
root
);
return
kk_ipc_isconnect
(
IPC_PLAT2MID
)
==
0
?
1
:
0
;
//eval_request(&my_server, root);
}
}
return
0
;
}
}
}
//shift processed request, discarding it
static
void
_msg_deal_from_mid
(
void
)
//rpc_cJSON_Delete(root);
{
}
else
{
cJSON
*
root
=
NULL
;
if
(
1
)
{
char
*
str
;
printf
(
"INVALID JSON Received:
\n
---
\n
%s
\n
---
\n
"
,
if
(
ncp_queue_dequeue
(
REV_MSG
,
&
root
)
==
0
){
data
);
str
=
rpc_cJSON_Print
(
root
);
printf
(
"Dequeue cJson = %s
\n
"
,
str
);
free
(
str
);
eval_request
(
&
my_server
,
root
);
rpc_cJSON_Delete
(
root
);
}
}
}
/*
send_error_resp(JRPC_PARSE_ERROR,
strdup(
"Parse error. Invalid JSON was received by the server."),
NULL);*/
static
void
_get_prey_from_dev
(
void
)
{
get_property_data_s
*
data
;
EmberStatus
status
;
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
ncp_queue_handle
(
void
)
{
UTIL_LOG_INFO
(
"
\n
ncp_queue_handle start~~~~~~~~~~~~~~~~~~~~
\n
"
);
while
(
1
){
_msg_deal_from_mid
();
_get_prey_from_dev
();
usleep
(
100000
);
}
UTIL_LOG_WARNING
(
"
\n
ncp_queue_handle end!!!!!!!!!!!!!!!!!!!
\n
"
);
}
void
ipcHandle
(
void
)
{
#ifdef GATEWAY_TYPE_NCP
kk_print_info
(
"Thread rpc Interface Parse create
\n
"
);
_init_param
(
&
my_server
);
char
*
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
kk_print_error
(
"[%s] get mac fail, exit pthread !!!!!!!!!!!!!!!!!
\n
"
,
__FUNCTION__
);
return
;
}
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
,
"127.0.0.1"
);
kk_print_info
(
"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
++
){
kk_print_debug
(
"i=%d,%s
\r\n
"
,
i
,
rpc_table
[
i
].
name
);
jrpc_register_procedure
(
&
my_server
,
rpc_table
[
i
].
func
,
rpc_table
[
i
].
name
,
NULL
);
}
//send add gw to ccu
char
*
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
kk_print_error
(
"[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
return
;
}
kk_print_info
(
"check nanomsg is connect(%d)
\n
"
,
kk_ipc_isconnect
(
IPC_PLAT2MID
));
kk_ipc_send
(
IPC_PLAT2MID
,
outbuf
,
strlen
(
outbuf
)
+
1
);
free
(
outbuf
);
char
*
postmsg
=
_msg_event_property_post
(
"127.0.0.1"
,
0
);
if
(
postmsg
==
NULL
){
kk_print_error
(
"[%s] property_post msg failed
\n
"
,
__FUNCTION__
);
return
;
}
kk_ipc_send
(
IPC_PLAT2MID
,
postmsg
,
strlen
(
postmsg
)
+
1
);
free
(
postmsg
);
//handle procidure
while
(
1
){
//
usleep
(
20000
);
}
#else
char
deviceCode
[
33
]
=
{
0
};
char
ip
[
16
]
=
{
0
};
int
port
=
0
;
kk_print_info
(
"Thread rpc Interface Parse create
\n
"
);
search_ccu
(
deviceCode
,
ip
,
&
port
);
_init_param
(
&
my_server
);
char
*
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
kk_print_error
(
"[%s] get mac fail, exit pthread !!!!!!!!!!!!!!!!!
\n
"
,
__FUNCTION__
);
return
;
}
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_init
(
ip
,
port
,
_cb
);
}
else
{
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
,
ip
);
}
kk_print_info
(
"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
++
){
kk_print_info
(
"i=%d,%s
\r\n
"
,
i
,
rpc_table
[
i
].
name
);
jrpc_register_procedure
(
&
my_server
,
rpc_table
[
i
].
func
,
rpc_table
[
i
].
name
,
NULL
);
}
//send add gw to ccu
char
*
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
kk_print_error
(
"[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
static
void
kk_rpc_send_message
(
cJSON
*
data
,
char
*
msgtype
,
char
*
method
,
EmberEUI64
mac
)
{
static
uint16_t
msgid
;
char
msgIdString
[
10
]
=
{
0
};
char
macString
[
19
]
=
{
0
};
int
res
=
0
;
kk_device_table_s
*
dev
=
NULL
;
rpc_eui64ToString
(
mac
,
macString
);
dev
=
kk_device_find_by_mac
(
mac
);
if
(
dev
==
NULL
)
{
printf
(
"[%s][%d]kk_rpc_send_message error!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
;
return
;
}
}
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
!=
0
){
kk_print_info
(
"check nanomsg is connect(%d)
\n
"
,
kk_ipc_isconnect
(
IPC_PLAT2MID
));
}
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
free
(
outbuf
);
int
cnt
=
0
;
//handle procidure
while
(
1
){
//
usleep
(
20000
);
cnt
++
;
if
(
cnt
==
2
){
sleep
(
1
);
char
gwIp
[
17
]
=
{
0
};
HAL_Get_IP
(
gwIp
,
NULL
);
char
*
postmsg
=
_msg_event_property_post
(
gwIp
,
port
);
if
(
postmsg
==
NULL
){
kk_print_error
(
"[%s] property_post msg failed
\n
"
,
__FUNCTION__
);
continue
;
}
kk_sendData2CCU
(
postmsg
,
strlen
(
postmsg
));
free
(
postmsg
);
}
if
(
kk_connect_check
()){
//discover ccu
search_ccu
(
deviceCode
,
ip
,
&
port
);
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_init
(
ip
,
port
,
_cb
);
}
else
{
kk_ipc_deinit
(
IPC_PLAT2MID
);
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
/*GW_DEVICE_CODE*/
,
ip
);
}
//send add gw to ccu
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
kk_print_error
(
"[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
cJSON
*
info
=
rpc_cJSON_CreateObject
();
return
;
if
(
info
!=
NULL
){
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
msgtype
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
dev
->
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
macString
);
}
}
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
cJSON
*
payload
=
rpc_cJSON_CreateObject
();
free
(
outbuf
);
if
(
payload
!=
NULL
){
cnt
=
0
;
sprintf
(
msgIdString
,
"%d"
,
++
msgid
);
kk_reset_retry_num
();
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgIdString
);
rpc_cJSON_AddStringToObject
(
payload
,
"version"
,
KK_IPC_VERSION
);
rpc_cJSON_AddStringToObject
(
payload
,
"method"
,
method
);
rpc_cJSON_AddItemToObject
(
payload
,
"params"
,
data
);
}
}
cJSON
*
root
=
rpc_cJSON_CreateObject
();
if
(
root
!=
NULL
){
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
}
}
#endif
char
*
p
=
rpc_cJSON_Print
(
root
);
emberAfAppPrintln
(
"send json:
\n
%s
\n
"
,
p
);
free
(
p
);
kk_tsl_send_msg
(
root
);
rpc_cJSON_Delete
(
root
);
}
void
kk_rpc_report_devices
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_DEVICE_JOINED_TYPE
,
KK_REPORT_DEVICE_JOINED_METHOD
,
mac
);
}
void
kk_rpc_report_left_devices
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_DEVICE_LEFT_TYPE
,
KK_REPORT_DEVICE_LEAVE_METHOD
,
mac
);
}
}
void
kk_rpc_report_status
(
cJSON
*
data
,
EmberEUI64
mac
)
{
int
jrpc_send_msg
(
cJSON
*
msgJson
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_ATTRIBUTE_TYPE
,
KK_REPORT_ATTRIBUTE_METHOD
,
mac
);
int
return_value
=
0
;
}
char
*
str_result
=
rpc_cJSON_Print
(
msgJson
);
emberAfAppPrintln
(
"send json:
\n
%s
\n
"
,
str_result
);
cJSON
*
rpc_reportDeviceState
(
char
*
state
,
EmberEUI64
eui64
)
{
char
euiString
[
RPC_EUI64_STRING_LENGTH
]
=
{
0
};
cJSON
*
stateJSON
;
rpc_eui64ToString
(
eui64
,
euiString
);
return_value
=
kk_sendData2CCU
(
str_result
,
strlen
(
str_result
));
stateJSON
=
rpc_cJSON_CreateObject
();
free
(
str_result
);
rpc_cJSON_AddStringToObject
(
stateJSON
,
"mac"
,
euiString
);
return
return_value
;
rpc_cJSON_AddStringToObject
(
stateJSON
,
"status"
,
state
);
return
stateJSON
;
}
}
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_ID 1
static
void
kk_reportDeviceStateChange
(
EmberEUI64
eui64
,
uint8_t
state
)
#define ATTRIBUTE_BUFFER_REPORT_DATA_TYPE 2
#define ATTRIBUTE_BUFFER_REPORT_DATA_VALUE 3
// Attribute reading buffer location definitions
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS 0
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_HIGH_BITS 1
#define ATTRIBUTE_BUFFER_SUCCESS_CODE 2
#define ATTRIBUTE_BUFFER_DATA_TYPE 3
#define ATTRIBUTE_BUFFER_DATA_START 4
static
void
rpc_send_message
(
cJSON
*
data
,
char
*
method
)
{
{
cJSON
*
item
=
rpc_cJSON_CreateObject
();
char
euiString
[
RPC_EUI64_STRING_LENGTH
]
=
{
0
};
rpc_cJSON_AddStringToObject
(
item
,
"jsonrpc"
,
"2.0"
);
cJSON
*
stateChangeJson
;
rpc_cJSON_AddStringToObject
(
item
,
"method"
,
method
);
rpc_cJSON_AddItemToObject
(
item
,
"params"
,
data
);
char
*
p
=
rpc_cJSON_Print
(
item
);
emberAfAppPrintln
(
"send send json:
\n
%s
\n
"
,
p
);
free
(
p
);
jrpc_send_msg
(
item
);
rpc_eui64ToString
(
eui64
,
euiString
);
stateChangeJson
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddStringToObject
(
stateChangeJson
,
"mac"
,
euiString
);
rpc_cJSON_AddNumberToObject
(
stateChangeJson
,
"deviceState"
,
state
);
rpc_printfJSON
(
"devicestatechange"
,
stateChangeJson
);
}
}
void
emberAfPluginDeviceTableStateChangeCallback
(
EmberNodeId
nodeId
,
void
rpc_report_attribute
(
cJSON
*
data
)
uint8_t
state
)
{
rpc_send_message
(
data
,
"report_attribute"
);
}
void
rpc_report_devices
(
cJSON
*
data
)
{
rpc_send_message
(
data
,
"report_devices"
);
}
void
rpc_control_devices
(
cJSON
*
data
,
char
*
method
)
{
{
rpc_send_message
(
data
,
method
);
EmberEUI64
nodeEui64
;
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
);
kk_reportDeviceStateChange
(
nodeEui64
,
state
);
}
}
bool
rpc_IasZoneClusterZoneStatusChangeNotificationCallback
(
uint16_t
zoneStatus
,
void
kk_IasZoneClusterZoneStatusChangeNotificationCallback
(
uint16_t
zoneStatus
,
uint8_t
extendedStatus
,
uint8_t
extendedStatus
,
uint8_t
zoneId
,
uint8_t
zoneId
,
uint16_t
delay
)
uint16_t
delay
)
{
{
EmberEUI64
nodeEui64
;
EmberEUI64
nodeEui64
;
EmberNodeId
nodeId
=
emberAfCurrentCommand
()
->
source
;
EmberNodeId
nodeId
=
emberAfCurrentCommand
()
->
source
;
kk_print_debug
(
"
\n
********************ChangeNotificationCallback**********************
\n
"
);
UTIL_LOG_INFO
(
"
\n
======================NotificationCallback======================
\n
"
);
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
);
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
);
kk_tsl_report_alarm
(
nodeEui64
,
zoneStatus
,
extendedStatus
,
zoneId
,
delay
);
kk_tsl_report_alarm
(
nodeEui64
,
zoneStatus
,
extendedStatus
,
zoneId
,
delay
);
}
}
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_ID 1
#define ATTRIBUTE_BUFFER_REPORT_DATA_TYPE 2
#define ATTRIBUTE_BUFFER_REPORT_DATA_VALUE 3
// Attribute reading buffer location definitions
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_LOW_BITS 0
#define ATTRIBUTE_BUFFER_ATTRIBUTEID_HIGH_BITS 1
#define ATTRIBUTE_BUFFER_SUCCESS_CODE 2
#define ATTRIBUTE_BUFFER_DATA_TYPE 3
#define ATTRIBUTE_BUFFER_DATA_START 4
bool
rpc_ReportAttributesCallback
(
EmberAfClusterId
clusterId
,
bool
kk_ReportAttributesCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint8_t
*
buffer
,
uint16_t
bufLen
)
uint16_t
bufLen
)
{
{
...
@@ -800,7 +419,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
...
@@ -800,7 +419,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
uint8_t
dataLen
,
dataType
;
uint8_t
dataLen
,
dataType
;
uint8_t
*
dataPtr
;
uint8_t
*
dataPtr
;
kk_print_debug
(
"
\n
********************report callback**********************
\n
"
);
printf
(
"
\n
********************report callback**********************
\n
"
);
emberAfAppPrint
(
"[ "
);
emberAfAppPrint
(
"[ "
);
emberAfAppPrintBuffer
(
buffer
,
bufLen
,
true
);
emberAfAppPrintBuffer
(
buffer
,
bufLen
,
true
);
emberAfAppPrint
(
"]
\n
"
);
emberAfAppPrint
(
"]
\n
"
);
...
@@ -810,7 +429,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
...
@@ -810,7 +429,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
return
false
;
return
false
;
}
}
kk_print_debug
(
"
\n
mac:"
);
printf
(
"
\n
mac:"
);
emberAfPrintBigEndianEui64
(
nodeEui64
);
emberAfPrintBigEndianEui64
(
nodeEui64
);
emberAfAppPrintln
(
",EP=%d,cluster=0x%04X
\n
"
,
ep
,
clusterId
);
emberAfAppPrintln
(
",EP=%d,cluster=0x%04X
\n
"
,
ep
,
clusterId
);
...
@@ -861,7 +480,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
...
@@ -861,7 +480,7 @@ bool rpc_ReportAttributesCallback(EmberAfClusterId clusterId,
return
false
;
return
false
;
}
}
bool
rpc_ReadAttributesResponseCallback
(
EmberAfClusterId
clusterId
,
bool
kk_ReadAttributesResponseCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint8_t
*
buffer
,
uint16_t
bufLen
)
uint16_t
bufLen
)
{
{
...
@@ -876,7 +495,7 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
...
@@ -876,7 +495,7 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
EmberAfAttributeId
attributeId
;
EmberAfAttributeId
attributeId
;
uint8_t
cnt
=
1
;
uint8_t
cnt
=
1
;
uint8_t
Status
;
uint8_t
Status
;
kk_print_debug
(
"
\n
********************read attributes response callback**********************
\n
"
);
printf
(
"
\n
********************read attributes response callback**********************
\n
"
);
emberAfAppPrint
(
"[ "
);
emberAfAppPrint
(
"[ "
);
emberAfAppPrintBuffer
(
buffer
,
bufLen
,
true
);
emberAfAppPrintBuffer
(
buffer
,
bufLen
,
true
);
emberAfAppPrint
(
"]
\n
"
);
emberAfAppPrint
(
"]
\n
"
);
...
@@ -886,7 +505,7 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
...
@@ -886,7 +505,7 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
return
false
;
return
false
;
}
}
kk_print_debug
(
"
\n
mac:"
);
printf
(
"
\n
mac:"
);
emberAfPrintBigEndianEui64
(
nodeEui64
);
emberAfPrintBigEndianEui64
(
nodeEui64
);
emberAfAppPrintln
(
",EP=%d,cluster=0x%04X
\n
"
,
ep
,
clusterId
);
emberAfAppPrintln
(
",EP=%d,cluster=0x%04X
\n
"
,
ep
,
clusterId
);
...
@@ -983,146 +602,23 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
...
@@ -983,146 +602,23 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
cJSON
*
rpc_reportDeviceState
(
char
*
state
,
EmberEUI64
eui64
)
{
char
euiString
[
RPC_EUI64_STRING_LENGTH
]
=
{
0
};
cJSON
*
stateJSON
;
rpc_eui64ToString
(
eui64
,
euiString
);
stateJSON
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddStringToObject
(
stateJSON
,
"mac"
,
euiString
);
rpc_cJSON_AddStringToObject
(
stateJSON
,
"status"
,
state
);
return
stateJSON
;
}
void
rpc_reportDeviceStateChange
(
EmberEUI64
eui64
,
uint8_t
state
)
{
char
euiString
[
RPC_EUI64_STRING_LENGTH
]
=
{
0
};
cJSON
*
stateChangeJson
;
rpc_eui64ToString
(
eui64
,
euiString
);
stateChangeJson
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddStringToObject
(
stateChangeJson
,
"mac"
,
euiString
);
rpc_cJSON_AddNumberToObject
(
stateChangeJson
,
"deviceState"
,
state
);
rpc_printfJSON
(
"devicestatechange"
,
stateChangeJson
);
}
void
emberAfPluginDeviceTableStateChangeCallback
(
EmberNodeId
nodeId
,
void
emberAfMainTickCallback
(
void
)
uint8_t
state
)
{
{
EmberEUI64
nodeEui64
;
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
);
rpc_reportDeviceStateChange
(
nodeEui64
,
state
);
}
static
unsigned
int
last_time
;
unsigned
int
time
=
halCommonGetInt32uMillisecondTick
();
kk_sub_dev_manage
();
if
((
time
-
last_time
)
>=
3000
){
last_time
=
time
;
static
cJSON
*
rpc_buildDeviceEndpoint
(
EmberEUI64
eui64
,
uint8_t
endpoint
)
kk_productCode_tick
();
{
//printf("kk_productCode_tick!\n");
cJSON
*
deviceEndpointObj
;
char
euiString
[
RPC_EUI64_STRING_LENGTH
]
=
{
0
};
deviceEndpointObj
=
rpc_cJSON_CreateObject
();
rpc_eui64ToString
(
eui64
,
euiString
);
rpc_cJSON_AddStringToObject
(
deviceEndpointObj
,
"mac"
,
euiString
);
rpc_cJSON_AddNumberToObject
(
deviceEndpointObj
,
"ep"
,
endpoint
);
return
deviceEndpointObj
;
}
static
cJSON
*
rpc_buildDeviceEndpointWithClusterInfo
(
EmberEUI64
eui64
,
uint8_t
endpoint
,
uint16_t
*
clusterIds
,
uint8_t
clusterOutStartPosition
)
{
cJSON
*
deviceEndpointObj
;
cJSON
*
clusterInfoArray
;
cJSON
*
clusterInfoItem
;
uint16_t
clusterIdIndex
;
char
clusterIdString
[
RPC_CLUSTERID_STRING_LENGTH
]
=
{
0
};
clusterInfoArray
=
rpc_cJSON_CreateArray
();
deviceEndpointObj
=
rpc_buildDeviceEndpoint
(
eui64
,
endpoint
);
for
(
clusterIdIndex
=
0
;
clusterIdIndex
<
EMBER_AF_PLUGIN_DEVICE_TABLE_CLUSTER_SIZE
;
clusterIdIndex
++
)
{
clusterInfoItem
=
rpc_cJSON_CreateObject
();
if
(
clusterIds
[
clusterIdIndex
]
!=
ZCL_NULL_CLUSTER_ID
)
{
sprintf
(
clusterIdString
,
"0x%04X"
,
clusterIds
[
clusterIdIndex
]);
rpc_cJSON_AddStringToObject
(
clusterInfoItem
,
"clusterId"
,
clusterIdString
);
if
(
clusterIdIndex
<
clusterOutStartPosition
)
{
rpc_cJSON_AddStringToObject
(
clusterInfoItem
,
"clusterType"
,
"In"
);
}
else
{
rpc_cJSON_AddStringToObject
(
clusterInfoItem
,
"clusterType"
,
"Out"
);
}
}
rpc_cJSON_AddItemToArray
(
clusterInfoArray
,
clusterInfoItem
);
clusterInfoItem
=
NULL
;
}
else
{
rpc_cJSON_Delete
(
clusterInfoItem
);
clusterInfoItem
=
NULL
;
break
;
}
}
rpc_cJSON_AddItemToObject
(
deviceEndpointObj
,
"clusterInfo"
,
clusterInfoArray
);
return
deviceEndpointObj
;
}
}
static
cJSON
*
buildNodeJson
(
uint16_t
nodeIndex
)
{
cJSON
*
nodeJson
;
cJSON
*
deviceEndpoint
;
char
nodeIdString
[
RPC_NODEID_STRING_LENGTH
]
=
{
0
};
char
*
deviceTypeString
;
EmberAfPluginDeviceTableEntry
*
deviceTable
=
emberAfDeviceTablePointer
();
nodeJson
=
rpc_cJSON_CreateObject
();
rpc_nodeIdToString
(
deviceTable
[
nodeIndex
].
nodeId
,
nodeIdString
);
rpc_cJSON_AddStringToObject
(
nodeJson
,
"nodeId"
,
nodeIdString
);
rpc_cJSON_AddNumberToObject
(
nodeJson
,
"deviceState"
,
deviceTable
[
nodeIndex
].
state
);
deviceTypeString
=
rpc_createTwoByteHexString
(
deviceTable
[
nodeIndex
].
deviceId
);
rpc_cJSON_AddStringToObject
(
nodeJson
,
"deviceType"
,
deviceTypeString
);
free
(
deviceTypeString
);
deviceEndpoint
=
rpc_buildDeviceEndpointWithClusterInfo
(
deviceTable
[
nodeIndex
].
eui64
,
deviceTable
[
nodeIndex
].
endpoint
,
deviceTable
[
nodeIndex
].
clusterIds
,
deviceTable
[
nodeIndex
].
clusterOutStartPosition
);
rpc_cJSON_AddItemToObject
(
nodeJson
,
"deviceEndpoint"
,
deviceEndpoint
);
return
nodeJson
;
}
void
rpc_reportDevices
(
void
)
{
uint16_t
nodeIndex
;
cJSON
*
nodeJson
;
cJSON
*
devicesJson
;
cJSON
*
devicesJsonNodeArray
;
devicesJson
=
rpc_cJSON_CreateObject
();
devicesJsonNodeArray
=
rpc_cJSON_CreateArray
();
rpc_cJSON_AddItemToObject
(
devicesJson
,
"devices"
,
devicesJsonNodeArray
);
for
(
nodeIndex
=
0
;
nodeIndex
<
EMBER_AF_PLUGIN_DEVICE_TABLE_DEVICE_TABLE_SIZE
;
nodeIndex
++
)
{
if
(
emberAfDeviceTableGetNodeIdFromIndex
(
nodeIndex
)
!=
EMBER_AF_PLUGIN_DEVICE_TABLE_NULL_NODE_ID
)
{
nodeJson
=
buildNodeJson
(
nodeIndex
);
rpc_cJSON_AddItemToArray
(
devicesJsonNodeArray
,
nodeJson
);
break
;
}
}
rpc_report_devices
(
devicesJson
);
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_
zb_com
.h
→
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_
ncp_common
.h
View file @
33a3264b
#ifndef __KK_
ZB_COM
_H
#ifndef __KK_
NCP_COMMON
_H
#define __KK_
ZB_COM
_H
#define __KK_
NCP_COMMON
_H
#include "app/framework/include/af.h"
#include "app/framework/include/af.h"
#include "zb_device_id.h"
typedef
struct
#include "./jsonrpc/rpccJSON.h"
{
#include "./jsonrpc/jsonrpc-c.h"
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
;
#define GW2CCU_PROTOCOL "tcp"
unsigned
char
S
;
#define GW_PRODUCT_CODE "2"
unsigned
char
L
;
}
HSL
;
//#define GATEWAY_TYPE_NCP
}
color
;
}
ColorLighting_s
;
#ifdef GATEWAY_TYPE_NCP
#undef GW2CCU_PROTOCOL
#define GW2CCU_PROTOCOL "nanomsg"
typedef
struct
{
#endif
union
{
ColorLighting_s
ColorLighting
;
void
_cb
(
void
*
data
,
int
len
,
char
*
chlmark
);
}
dev
;
}
SubDevManage_s
;
char
*
kk_get_gw_mac
(
void
);
typedef
struct
kk_device_table_s
{
cJSON
*
rpc_reportDeviceState
(
char
*
state
,
EmberEUI64
eui64
);
EmberEUI64
mac
;
EmberNodeId
nodeId
;
uint16_t
deviceId
;
uint16_t
identifyCnt
;
char
productCode
[
33
];
SubDevManage_s
manage
;
struct
kk_device_table_s
*
next
;
}
kk_device_table_s
;
#define RPC_APPVERSION_STRING_LENGTH 3 //
#define RPC_APPVERSION_STRING_LENGTH 3 //
...
@@ -49,11 +41,7 @@ typedef struct kk_device_table_s{
...
@@ -49,11 +41,7 @@ typedef struct kk_device_table_s{
#define RPC_LENGTH_STRING_LENGTH 4 //0-255 + NULL
#define RPC_LENGTH_STRING_LENGTH 4 //0-255 + NULL
#define RPC_STATUS_STRING_LENGTH 4 //0-255 + NULL
#define RPC_STATUS_STRING_LENGTH 4 //0-255 + NULL
enum
{
WC_normal_dir
=
0
,
//"正转"
WC_reversed_dir
=
1
,
//"反转"
WC_calibration_mode
=
2
,
//"校验"
}
windowCoveringMode
;
#define KK_EUI64_STRING_LENGTH 17 //16 characters + NULL
#define KK_EUI64_STRING_LENGTH 17 //16 characters + NULL
...
@@ -69,7 +57,6 @@ enum {
...
@@ -69,7 +57,6 @@ enum {
#endif
...
@@ -78,3 +65,7 @@ enum {
...
@@ -78,3 +65,7 @@ enum {
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_msg.c
0 → 100644
View file @
33a3264b
#include <stdio.h>
#include "kk_ncp_common.h"
#include "kk_ncp_msg.h"
#include "com_api.h"
void
*
_msg_event_property_post
(
char
ip
[
16
],
int
port
)
{
char
msgFmt
[]
=
"{
\"
info
\"
:{
\"
msgtype
\"
:
\"
/thing/event/property/post
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
},\
\"
payload
\"
:{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
NetChannelState
\"
:%d,
\"
WhiteListState
\"
:%d,\
\"
OnlineDetectionState
\"
:%d,
\"
SN
\"
:
\"
%s
\"
,
\"
IPAddress
\"
:
\"
%s
\"
,
\"
MACAddress
\"
:
\"
%s
\"
,
\"
Port
\"
:%d},\
\"
time
\"
:1524448722000,
\"
method
\"
:
\"
thing.event.property.post
\"
}\
}"
;
char
*
msg
=
NULL
;
char
*
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
emberAfDebugPrintln
(
"[%s] get mac fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
msg
=
malloc
(
620
);
if
(
msg
==
NULL
){
emberAfDebugPrintln
(
"[%s] msg malloc fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
sprintf
(
msg
,
msgFmt
,
GW_PRODUCT_CODE
,
macString
,
1
,
0
,
0
,
0
,
"12345"
,
ip
,
macString
,
port
);
return
msg
;
}
void
*
_msg_topo_add
(
void
)
{
char
msgFmt
[]
=
"{
\"
info
\"
:{
\"
msgtype
\"
:
\"
/thing/topo/add
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
},\
\"
payload
\"
:{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
1.0
\"
,
\"
params
\"
:{
\"
deviceCode
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
mac
\"
:
\"
%s
\"
}}}"
;
char
*
msg
=
NULL
;
char
*
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
emberAfDebugPrintln
(
"[%s] get mac fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
msg
=
malloc
(
520
);
if
(
msg
==
NULL
){
emberAfDebugPrintln
(
"[%s] msg malloc fail
\n
"
,
__FUNCTION__
);
return
NULL
;
}
sprintf
(
msg
,
msgFmt
,
GW_PRODUCT_CODE
,
macString
,
1
,
macString
,
GW_PRODUCT_CODE
,
macString
);
return
msg
;
}
int
kk_sendData2CCU
(
char
*
data
,
int
len
)
{
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_send
(
data
,
len
);
}
else
{
kk_ipc_send
(
IPC_PLAT2MID
,
data
,
len
+
1
);
}
}
int
kk_tsl_send_msg
(
cJSON
*
msgJson
)
{
int
return_value
=
0
;
char
*
str_result
=
rpc_cJSON_Print
(
msgJson
);
emberAfAppPrintln
(
"send tsl msg:
\n
%s
\n
"
,
str_result
);
return_value
=
kk_sendData2CCU
(
str_result
,
strlen
(
str_result
));
free
(
str_result
);
return
return_value
;
}
void
kk_tsl_msg_ack
(
const
char
*
id
,
const
char
*
ackMsgType
,
const
char
*
productCode
,
const
char
*
deviceCode
)
{
char
*
p_msgType
;
cJSON
*
root
=
rpc_cJSON_CreateObject
();
cJSON
*
info
=
rpc_cJSON_CreateObject
();
cJSON
*
payload
=
rpc_cJSON_CreateObject
();
cJSON
*
data
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
int
len
=
strlen
(
ackMsgType
)
+
"_reply"
+
1
;
p_msgType
=
(
char
*
)
malloc
(
len
);
memset
(
p_msgType
,
0
,
len
);
strcpy
(
p_msgType
,
ackMsgType
);
strcat
(
p_msgType
,
"_reply"
);
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
p_msgType
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
deviceCode
);
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
id
);
rpc_cJSON_AddNullToObject
(
payload
,
"code"
);
rpc_cJSON_AddItemToObject
(
payload
,
"data"
,
data
);
free
(
p_msgType
);
kk_tsl_send_msg
(
root
);
rpc_cJSON_Delete
(
root
);
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_msg.h
0 → 100644
View file @
33a3264b
#ifndef __KK_NCP_MSG_H
#define __KK_NCP_MSG_H
#include "kk_ncp_common.h"
#define MSG_PARSE_ERROR "Parse error"
#define MSG_INVALID_REQUEST "Invalid Request"
#define MSG_METHOD_NOT_FOUND "Method not found"
#define MSG_INVALID_PARAMS "Invalid params"
#define MSG_INTERNAL_ERROR "Internal error"
#define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade"
#define KK_GET_PROPERTY_MSG_TYPE "/thing/service/property/get"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define KK_DEVICE_TOPO_CHANGE_TYPE "/thing/topo/change"
#define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define KK_IPC_VERSION "1.0"
#define KK_REPORT_DEVICE_JOINED_METHOD "thing.topo.add"
#define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.delete"
#define KK_REPORT_ATTRIBUTE_METHOD "thing.event.property.post"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
#define MSG_TOPO_CHANGE_DEVICES_STR "devices"
/////////////
#define KK_IPC_VERSION "1.0"
#define KK_REPORT_DEVICE_BATCH_JOINED_METHOD "thing.topo.batchAdd"
#define KK_REPORT_DEVICE_JOINED_METHOD "thing.topo.add"
#define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.delete"
#define KK_REPORT_DEVICE_BATCH_LEAVE_METHOD "thing.topo.batchDelete"
#define KK_REPORT_ADDWHITELIST_NOTIFY_METHOD "thing.event.whiteListAddedNotification.post"
#define KK_REPORT_DELWHITELIST_NOTIFY_METHOD "thing.event.whiteListDeletedNotification.post"
#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_REPLY_METHOD "thing.service.property.get"
#define KK_REPORT_ALARM_METHOD "thing.event.alarm.post"
#define KK_REPORT_ATTRIBUTE_METHOD "thing.event.property.post"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
#define KK_REPORT_DEVICE_BATCH_JOINED_TYPE "/thing/topo/batch_add"
#define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_DEVICE_BATCH_LEFT_TYPE "/thing/topo/batch_delete"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define KK_REPORT_ADDWHITELIST_NOTIFY_TYPE "/thing/event/whiteListAddedNotification/post"
#define KK_REPORT_DELWHITELIST_NOTIFY_TYPE "/thing/event/whiteListDeletedNotification/post"
void
*
_msg_event_property_post
(
char
ip
[
16
],
int
port
);
void
*
_msg_topo_add
(
void
);
int
kk_sendData2CCU
(
char
*
data
,
int
len
);
int
kk_tsl_send_msg
(
cJSON
*
msgJson
);
void
kk_tsl_msg_ack
(
const
char
*
id
,
const
char
*
ackMsgType
,
const
char
*
productCode
,
const
char
*
deviceCode
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.c
View file @
33a3264b
#include "kk_ncp_queue.h"
#include <pthread.h>
#include <pthread.h>
#include "kk_ncp_queue.h"
#include "app/framework/include/af.h"
#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
g_ncp_queue
[
GET_PROPERTY
];
static
ncp_queue_s
*
_ncp_queue_get_ctx
(
NCP_QUEUE_ENUM
ix
)
static
ncp_queue_s
*
_ncp_queue_get_ctx
(
NCP_QUEUE_ENUM
ix
)
...
@@ -22,7 +17,7 @@ static void _ncp_queue_lock(NCP_QUEUE_ENUM ix)
...
@@ -22,7 +17,7 @@ static void _ncp_queue_lock(NCP_QUEUE_ENUM ix)
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
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
);
UTIL_LOG_WARNING
(
"
\n
lock queue mutex[%d] failed: - '%s' (%d)
\n
"
,
ix
,
strerror
(
err_num
),
err_num
);
}
}
}
}
static
void
_ncp_queue_unlock
(
NCP_QUEUE_ENUM
ix
)
static
void
_ncp_queue_unlock
(
NCP_QUEUE_ENUM
ix
)
...
@@ -31,7 +26,7 @@ static void _ncp_queue_unlock(NCP_QUEUE_ENUM ix)
...
@@ -31,7 +26,7 @@ static void _ncp_queue_unlock(NCP_QUEUE_ENUM ix)
ncp_queue_s
*
ctx
=
_ncp_queue_get_ctx
(
ix
);
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
);
UTIL_LOG_WARNING
(
"unlock queue mutex[%d] failed - '%s' (%d)
\n
"
,
ix
,
strerror
(
err_num
),
err_num
);
}
}
}
}
...
@@ -45,19 +40,20 @@ static int _ncp_queue_init(NCP_QUEUE_ENUM ix,int max_size)
...
@@ -45,19 +40,20 @@ static int _ncp_queue_init(NCP_QUEUE_ENUM ix,int max_size)
ctx
->
mutex
=
(
pthread_mutex_t
*
)
malloc
(
sizeof
(
pthread_mutex_t
));
ctx
->
mutex
=
(
pthread_mutex_t
*
)
malloc
(
sizeof
(
pthread_mutex_t
));
if
(
ctx
->
mutex
==
NULL
)
{
if
(
ctx
->
mutex
==
NULL
)
{
UTIL_LOG_WARNING
(
"
\n
malloc queue mutex[%d] failed: - '%s' (%d)
\n
"
,
ix
,
strerror
(
err_num
),
err_num
);
return
-
1
;
return
-
1
;
}
}
if
(
0
!=
(
err_num
=
pthread_mutex_init
(
ctx
->
mutex
,
NULL
)))
{
if
(
0
!=
(
err_num
=
pthread_mutex_init
(
ctx
->
mutex
,
NULL
)))
{
printf
(
"create mutex failed"
);
UTIL_LOG_WARNING
(
"
\n
init queue mutex[%d] failed
\n
"
,
ix
);
free
(
ctx
->
mutex
);
free
(
ctx
->
mutex
);
return
-
2
;
return
-
2
;
}
}
ctx
->
magic
=
KK_NCP_QUEUE_MAGIC
;
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
);
UTIL_LOG_INFO
(
"
\n
ncp queue[%d] init success~~~
\n
"
,
ix
);
return
0
;
return
0
;
}
}
...
@@ -71,7 +67,7 @@ int ncp_queue_init(void)
...
@@ -71,7 +67,7 @@ int ncp_queue_init(void)
}
}
void
ncp_queue_deinit
(
void
)
void
ncp_queue_deinit
(
void
)
{
{
//do it;
}
}
...
@@ -81,26 +77,29 @@ int ncp_queue_enqueue(NCP_QUEUE_ENUM ix,void *data)
...
@@ -81,26 +77,29 @@ int ncp_queue_enqueue(NCP_QUEUE_ENUM ix,void *data)
ncp_queue_msg_s
*
node
=
NULL
;
ncp_queue_msg_s
*
node
=
NULL
;
if
(
ctx
->
magic
!=
KK_NCP_QUEUE_MAGIC
){
if
(
ctx
->
magic
!=
KK_NCP_QUEUE_MAGIC
){
UTIL_LOG_WARNING
(
"
\n
enqueue-[%d] fail,queue-[%d] not init!!!
\n
"
,
ix
);
return
-
1
;
return
-
1
;
}
}
if
(
data
==
NULL
)
{
if
(
data
==
NULL
)
{
return
-
1
;
UTIL_LOG_DBG
(
"
\n
enqueue-[%d] fail,data is NULL!!!
\n
"
,
ix
);
return
-
2
;
}
}
_ncp_queue_lock
(
ix
);
_ncp_queue_lock
(
ix
);
printf
(
"
list size: %d, max size: %d
\n
"
,
ctx
->
size
,
ctx
->
max_size
);
UTIL_LOG_DBG
(
"
\n
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"
);
UTIL_LOG_DBG
(
"
\n
enqueue-[%d] fail,queue full!!!
\n
"
,
ix
);
_ncp_queue_unlock
(
ix
);
_ncp_queue_unlock
(
ix
);
return
-
2
;
return
-
3
;
}
}
node
=
malloc
(
sizeof
(
ncp_queue_msg_s
));
node
=
malloc
(
sizeof
(
ncp_queue_msg_s
));
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
UTIL_LOG_DBG
(
"
\n
enqueue-[%d] fail,node is NULL!!!
\n
"
,
ix
);
_ncp_queue_unlock
(
ix
);
_ncp_queue_unlock
(
ix
);
return
-
3
;
return
-
4
;
}
}
memset
(
node
,
0
,
sizeof
(
ncp_queue_msg_s
));
memset
(
node
,
0
,
sizeof
(
ncp_queue_msg_s
));
...
@@ -113,7 +112,7 @@ int ncp_queue_enqueue(NCP_QUEUE_ENUM ix,void *data)
...
@@ -113,7 +112,7 @@ int ncp_queue_enqueue(NCP_QUEUE_ENUM ix,void *data)
_ncp_queue_unlock
(
ix
);
_ncp_queue_unlock
(
ix
);
printf
(
"add queue
\n
"
);
UTIL_LOG_INFO
(
"
\n
enqueue-[%d] success~~~
\n
"
,
ix
);
return
0
;
return
0
;
}
}
...
@@ -128,14 +127,14 @@ int ncp_queue_dequeue(NCP_QUEUE_ENUM ix,void **data)
...
@@ -128,14 +127,14 @@ int ncp_queue_dequeue(NCP_QUEUE_ENUM ix,void **data)
}
}
if
(
data
==
NULL
)
{
if
(
data
==
NULL
)
{
return
-
1
;
return
-
2
;
}
}
_ncp_queue_lock
(
ix
);
_ncp_queue_lock
(
ix
);
if
(
list_empty
(
&
ctx
->
list
))
{
if
(
list_empty
(
&
ctx
->
list
))
{
_ncp_queue_unlock
(
ix
);
_ncp_queue_unlock
(
ix
);
return
-
2
;
return
-
3
;
}
}
node
=
list_first_entry
(
&
ctx
->
list
,
ncp_queue_msg_s
,
list
);
node
=
list_first_entry
(
&
ctx
->
list
,
ncp_queue_msg_s
,
list
);
...
@@ -148,7 +147,7 @@ int ncp_queue_dequeue(NCP_QUEUE_ENUM ix,void **data)
...
@@ -148,7 +147,7 @@ int ncp_queue_dequeue(NCP_QUEUE_ENUM ix,void **data)
_ncp_queue_unlock
(
ix
);
_ncp_queue_unlock
(
ix
);
printf
(
"de queue
\n
"
);
UTIL_LOG_INFO
(
"
\n
dequeue queue[%d] success~~~
\n
"
,
ix
);
return
0
;
return
0
;
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_queue.h
View file @
33a3264b
...
@@ -15,12 +15,14 @@ typedef struct {
...
@@ -15,12 +15,14 @@ typedef struct {
struct
list_head
list
;
struct
list_head
list
;
}
ncp_queue_s
;
}
ncp_queue_s
;
typedef
enum
{
typedef
enum
{
REV_MSG
=
0
,
REV_MSG
=
0
,
GET_PROPERTY
,
GET_PROPERTY
,
NCP_QUEUE_ENUM_END
NCP_QUEUE_ENUM_END
}
NCP_QUEUE_ENUM
;
}
NCP_QUEUE_ENUM
;
#define NCP_QUEUE1_SIZE 50
#define NCP_QUEUE2_SIZE 20
#define NCP_QUEUE_SIZE(x) NCP_QUEUE##x##_SIZE
int
ncp_queue_init
(
void
);
int
ncp_queue_init
(
void
);
int
ncp_queue_dequeue
(
NCP_QUEUE_ENUM
ix
,
void
**
data
);
int
ncp_queue_dequeue
(
NCP_QUEUE_ENUM
ix
,
void
**
data
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_rpc.c
0 → 100644
View file @
33a3264b
#include "kk_ncp_common.h"
#include "kk_ncp_msg.h"
#include "kk_ncp_rpc.h"
static
struct
jrpc_server
my_server
;
typedef
cJSON
(
*
rpc_function
)(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
typedef
struct
{
rpc_function
func
;
char
*
name
;
}
rpc_table_s
;
extern
cJSON
*
kk_tsl_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
extern
cJSON
*
kk_topo_change_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
extern
cJSON
*
kk_tsl_get_property_operation
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
extern
cJSON
*
kk_wlist_add
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
extern
cJSON
*
kk_wlist_delete
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
);
static
rpc_table_s
rpc_table
[]
=
{
{(
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_topo_change_operation
,
KK_DEVICE_TOPO_CHANGE_TYPE
},
\
{(
rpc_function
*
)
kk_wlist_add
,
"/thing/service/addWhiteList"
},
\
{(
rpc_function
*
)
kk_wlist_delete
,
"/thing/service/deleteWhiteList"
},
\
};
struct
jrpc_server
*
kk_get_jrpc_server
(
void
)
{
return
&
my_server
;
}
void
kk_jrpc_init
(
void
)
{
my_server
.
debug_level
=
1
;
emberAfDebugPrintln
(
"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
++
){
emberAfDebugPrintln
(
"i=%d,%s
\r\n
"
,
i
,
rpc_table
[
i
].
name
);
jrpc_register_procedure
(
&
my_server
,
rpc_table
[
i
].
func
,
rpc_table
[
i
].
name
,
NULL
);
}
}
static
int
invoke_procedure
(
struct
jrpc_server
*
server
,
char
*
name
,
cJSON
*
params
,
cJSON
*
id
,
cJSON
*
mac
)
{
cJSON
*
returned
=
NULL
;
int
procedure_found
=
0
;
jrpc_context
ctx
;
int
i
=
server
->
procedure_count
;
while
(
i
--
)
{
if
(
!
strcmp
(
server
->
procedures
[
i
].
name
,
name
))
{
procedure_found
=
1
;
ctx
.
data
=
server
->
procedures
[
i
].
data
;
returned
=
server
->
procedures
[
i
].
function
(
&
ctx
,
params
,
id
,
mac
);
break
;
}
}
if
(
!
procedure_found
){
emberAfDebugPrintln
(
"[rpc invoke] Method not found...
\n
"
);
return
-
1
;
}
else
{
return
0
;
}
}
int
kk_jrpc_eval_request
(
cJSON
*
root
)
{
cJSON
*
info
,
*
payload
;
cJSON
*
msgType
,
*
deviceCode
,
*
productCode
;
cJSON
*
params
,
*
id
;
info
=
rpc_cJSON_GetObjectItem
(
root
,
"info"
);
payload
=
rpc_cJSON_GetObjectItem
(
root
,
"payload"
);
if
(
info
!=
NULL
){
msgType
=
rpc_cJSON_GetObjectItem
(
info
,
"msgType"
);
deviceCode
=
rpc_cJSON_GetObjectItem
(
info
,
"deviceCode"
);
productCode
=
rpc_cJSON_GetObjectItem
(
info
,
"productCode"
);
}
if
(
payload
!=
NULL
){
params
=
rpc_cJSON_GetObjectItem
(
payload
,
"params"
);
id
=
rpc_cJSON_GetObjectItem
(
payload
,
"msgId"
);
}
if
(
id
!=
NULL
&&
params
!=
NULL
&&
msgType
!=
NULL
&&
deviceCode
!=
NULL
&&
deviceCode
!=
NULL
){
if
(
strcmp
(
msgType
->
valuestring
,
KK_GET_PROPERTY_MSG_TYPE
)
==
0
)
kk_tsl_msg_ack
(
id
->
valuestring
,
msgType
->
valuestring
,
productCode
->
valuestring
,
deviceCode
->
valuestring
);
return
invoke_procedure
(
&
my_server
,
msgType
->
valuestring
,
params
,
id
,
deviceCode
);
}
return
-
1
;
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_rpc.h
0 → 100644
View file @
33a3264b
#ifndef __KK_NCP_RPC_H
#define __KK_NCP_RPC_H
#include <stdio.h>
#include "./jsonrpc/rpccJSON.h"
#include "./jsonrpc/jsonrpc-c.h"
void
kk_jrpc_init
(
void
);
int
kk_jrpc_eval_request
(
cJSON
*
root
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_thread.c
0 → 100644
View file @
33a3264b
#include <stdio.h>
#include "kk_ncp_common.h"
#include "kk_ncp_thread.h"
#include "kk_ncp_rpc.h"
#include "kk_ncp_queue.h"
#include "kk_zigbee_api.h"
#include "com_api.h"
#include "kk_tsl_property_get.h"
static
void
_msg_deal_from_mid
(
void
)
{
cJSON
*
root
=
NULL
;
char
*
cJsonStr
;
if
(
ncp_queue_dequeue
(
REV_MSG
,
&
root
)
==
0
){
cJsonStr
=
rpc_cJSON_Print
(
root
);
emberAfDebugPrintln
(
"[dequeue-msgRev] cJson:
\n
%s
\n
"
,
cJsonStr
);
free
(
cJsonStr
);
kk_jrpc_eval_request
(
root
);
rpc_cJSON_Delete
(
root
);
}
}
static
void
_get_prey_from_dev
(
void
)
{
int
i
;
EmberStatus
status
;
get_property_data_s
*
data
;
if
(
ncp_queue_dequeue
(
GET_PROPERTY
,
&
data
)
==
0
){
emberAfDebugPrintln
(
"[dequeue-getPrey] data:"
);
emberAfDebugPrintln
(
"node = 0x%04X,ep=%d,clu=0x%04X,attr len=%d"
,
data
->
node
,
data
->
ep
,
data
->
clu
,
data
->
len
);
for
(
int
i
=
0
;
i
<
data
->
len
;
i
++
){
emberAfDebugPrintln
(
"attr[%d]:0x%04X
\n
"
,
i
,
data
->
attr
[
i
]);
}
status
=
zclGReadAttrs
(
data
->
node
,
1
,
data
->
ep
,
false
,
data
->
clu
,
data
->
len
,
data
->
attr
,
true
);
emberAfDebugPrintln
(
"func call status:0x%02X"
,
status
);
free
(
data
->
attr
);
free
(
data
);
}
}
static
void
ncp_queue_handle
(
void
)
{
UTIL_LOG_INFO
(
"
\n
ncp_queue_handle start~~~~~~~~~~~~~~~~~~~~
\n
"
);
while
(
1
){
_msg_deal_from_mid
();
_get_prey_from_dev
();
usleep
(
100000
);
}
UTIL_LOG_ERR
(
"
\n
ncp_queue_handle end!!!!!!!!!!!!!!!!!!!
\n
"
);
}
void
ipc_handle
(
void
)
{
char
*
outbuf
;
char
*
postmsg
;
char
*
macString
;
UTIL_LOG_INFO
(
"
\n
ipc_handle start~~~~~~~~~~~~~~~~~~~~
\n
"
);
#ifdef GATEWAY_TYPE_NCP
kk_jrpc_init
();
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] get mac fail, exit pthread !!!
\n
"
,
__FUNCTION__
);
return
;
}
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
,
"127.0.0.1"
);
//send add gw to ccu
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
return
;
}
emberAfDebugPrintln
(
"check nanomsg is connect(%d)"
,
kk_ipc_isconnect
(
IPC_PLAT2MID
));
kk_ipc_send
(
IPC_PLAT2MID
,
outbuf
,
strlen
(
outbuf
)
+
1
);
free
(
outbuf
);
postmsg
=
_msg_event_property_post
(
"127.0.0.1"
,
0
);
if
(
postmsg
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] property_post msg failed
\n
"
,
__FUNCTION__
);
return
;
}
kk_ipc_send
(
IPC_PLAT2MID
,
postmsg
,
strlen
(
postmsg
)
+
1
);
free
(
postmsg
);
//handle procidure
while
(
1
){
usleep
(
20000
);
}
#else
char
deviceCode
[
33
]
=
{
0
};
char
ip
[
16
]
=
{
0
};
int
port
=
0
;
int
cnt
=
0
;
search_ccu
(
deviceCode
,
ip
,
&
port
);
kk_jrpc_init
();
macString
=
kk_get_gw_mac
();
if
(
macString
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] get mac fail, exit pthread !!!
\n
"
,
__FUNCTION__
);
return
;
}
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_init
(
ip
,
port
,
_cb
);
}
else
{
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
,
ip
);
}
//send add gw to ccu
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
return
;
}
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
!=
0
){
emberAfDebugPrintln
(
"check nanomsg is connect(%d)"
,
kk_ipc_isconnect
(
IPC_PLAT2MID
));
}
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
free
(
outbuf
);
//handle procidure
while
(
1
){
usleep
(
20000
);
if
(
++
cnt
==
2
){
sleep
(
1
);
char
gwIp
[
17
]
=
{
0
};
HAL_Get_IP
(
gwIp
,
NULL
);
postmsg
=
_msg_event_property_post
(
gwIp
,
port
);
if
(
postmsg
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] property_post msg failed
\n
"
,
__FUNCTION__
);
continue
;
}
kk_sendData2CCU
(
postmsg
,
strlen
(
postmsg
));
free
(
postmsg
);
}
if
(
kk_connect_check
()){
//discover ccu
search_ccu
(
deviceCode
,
ip
,
&
port
);
if
(
strcmp
(
GW2CCU_PROTOCOL
,
"tcp"
)
==
0
){
kk_tcp_client_init
(
ip
,
port
,
_cb
);
}
else
{
kk_ipc_deinit
(
IPC_PLAT2MID
);
kk_ipc_init
(
IPC_PLAT2MID
,
_cb
,
macString
/*GW_DEVICE_CODE*/
,
ip
);
}
//send add gw to ccu
outbuf
=
_msg_topo_add
();
if
(
outbuf
==
NULL
){
UTIL_LOG_ERR
(
"
\n
[%s] topo add msg failed, exit
\n
"
,
__FUNCTION__
);
return
;
}
kk_sendData2CCU
(
outbuf
,
strlen
(
outbuf
));
free
(
outbuf
);
cnt
=
0
;
kk_reset_retry_num
();
}
}
#endif
UTIL_LOG_ERR
(
"
\n
ipc_handle end!!!!!!!!!!!!!!!!!!!
\n
"
);
}
void
kk_thread_init
(
void
)
{
pthread_t
ipc_tid
;
pthread_t
prey_tid
;
pthread_create
(
&
ipc_tid
,
NULL
,
ipc_handle
,
NULL
);
pthread_create
(
&
prey_tid
,
NULL
,
ncp_queue_handle
,
NULL
);
}
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_ncp_thread.h
0 → 100644
View file @
33a3264b
#ifndef __KK_NCP_THREAD_H
#define __KK_NCP_THREAD_H
#include <pthread.h>
void
kk_thread_init
(
void
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_topo_batch_handle.c
View file @
33a3264b
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include "kk_tsl_common.h"
#include "kk_tsl_common.h"
#include ".././jsonrpc/jsonrpc-c.h"
#include ".././jsonrpc/jsonrpc-c.h"
#include ".././jsonrpc/rpccJSON.h"
#include ".././jsonrpc/rpccJSON.h"
#include "kk_
zb_com
.h"
#include "kk_
ncp_common
.h"
typedef
struct
{
typedef
struct
{
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_get.c
View file @
33a3264b
#include "kk_
test
.h"
#include "kk_
ncp_common
.h"
#include "kk_tsl_property_get.h"
#include "kk_tsl_property_get.h"
#include "kk_ncp_queue.h"
#include "kk_ncp_queue.h"
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.c
View file @
33a3264b
#include "kk_tsl_property_report.h"
#include "kk_tsl_property_report.h"
#include "kk_device_manager.h"
#include "kk_device_manager.h"
#include "kk_rgb_hsl_convert.h"
#include "kk_rgb_hsl_convert.h"
#include "kk_device_table_db.h"
#include "kk_zigbee_api.h"
const
char
*
kk_tsl_rpt_status_string
[]
=
{
const
char
*
kk_tsl_rpt_status_string
[]
=
{
"Success"
,
"Success"
,
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_report.h
View file @
33a3264b
#ifndef __KK_TSL_PROPERTY_REPORT_H
#ifndef __KK_TSL_PROPERTY_REPORT_H
#define __KK_TSL_PROPERTY_REPORT_H
#define __KK_TSL_PROPERTY_REPORT_H
#include "kk_zb_com.h"
#include "kk_msg_report.h"
#include "kk_msg_report.h"
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.c
View file @
33a3264b
#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"
#include "kk_tsl_property_get.h"
#include "kk_ncp_msg.h"
#include "kk_color_space.h"
#include "kk_device_table_db.h"
#include "com_api.h"
#include "kk_device_manager.h"
#include "kk_zigbee_api.h"
#include "../device-table/device-table.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
;
...
@@ -16,7 +23,8 @@ cJSON *kk_tsl_get_property_operation(jrpc_context * ctx, cJSON *params, cJSON *i
...
@@ -16,7 +23,8 @@ cJSON *kk_tsl_get_property_operation(jrpc_context * ctx, cJSON *params, cJSON *i
kk_dev_config_map
*
ptr
;
kk_dev_config_map
*
ptr
;
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
;
EmberEUI64
localEui64
;
char
localEui64Str
[
17
];
cJSON
*
array
;
cJSON
*
array
;
cJSON
*
identifier
=
NULL
;
cJSON
*
identifier
=
NULL
;
int
num
;
int
num
;
...
@@ -30,7 +38,17 @@ cJSON *kk_tsl_get_property_operation(jrpc_context * ctx, cJSON *params, cJSON *i
...
@@ -30,7 +38,17 @@ cJSON *kk_tsl_get_property_operation(jrpc_context * ctx, cJSON *params, cJSON *i
goto
error_return
;
goto
error_return
;
}
}
rpc_get_mac
(
mac
->
valuestring
,
eui64
);
rpc_get_mac
(
mac
->
valuestring
,
eui64
);
emberAfGetEui64
(
localEui64
);
rpc_eui64ToString
(
localEui64
,
localEui64Str
);
if
(
strcmp
(
localEui64Str
,
mac
->
valuestring
)
==
0
){
printf
(
"&&&&&&&&&&&&&&&& ignore
\n
"
);
goto
error_return
;
}
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
nodeId
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
emberAfPrintBigEndianEui64
(
eui64
);
emberAfPrintBigEndianEui64
(
eui64
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_tsl_property_set.h
View file @
33a3264b
#ifndef __KK_TSL_PROPERTY_SET_H
#ifndef __KK_TSL_PROPERTY_SET_H
#define __KK_TSL_PROPERTY_SET_H
#define __KK_TSL_PROPERTY_SET_H
#include "kk_
test
.h"
#include "kk_
ncp_common
.h"
#include "kk_color_space.h"
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
);
...
@@ -22,11 +22,7 @@ int kk_tsl_set_colorlight_RGB_blue(jrpc_context * ctx,EmberNodeId node,unsigned
...
@@ -22,11 +22,7 @@ int kk_tsl_set_colorlight_RGB_blue(jrpc_context * ctx,EmberNodeId node,unsigned
int
kk_tsl_set_colorlight_Brightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_Brightness
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
int
kk_tsl_set_colorlight_mode
(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
#define RPC_KK_TEST_FUNCTION_TABLE \
{(
rpc_function
*
)
kk_tsl_property_operation
,
"/thing/service/property/set"
},
\
{(
rpc_function
*
)
kk_wlist_add
,
"/thing/service/addWhiteList"
},
\
{(
rpc_function
*
)
kk_wlist_delete
,
"/thing/service/deleteWhiteList"
},
\
{(
rpc_function
*
)
kk_topo_change_operation
,
"/thing/topo/change"
},
\
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_wlist_mng.c
View file @
33a3264b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdio.h>
#include ".././jsonrpc/jsonrpc-c.h"
#include ".././jsonrpc/jsonrpc-c.h"
#include ".././jsonrpc/rpccJSON.h"
#include ".././jsonrpc/rpccJSON.h"
#include "kk_ncp_common.h"
#include "kk_wlist_mng.h"
#include "kk_wlist_mng.h"
#include "sqlite3.h"
#include "sqlite3.h"
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_wlist_mng.h
View file @
33a3264b
#ifndef __KK_WHITELIST_MNG_H__
#ifndef __KK_WHITELIST_MNG_H__
#define __KK_WHITELIST_MNG_H__
#define __KK_WHITELIST_MNG_H__
#include "kk_tsl_common.h"
#include "kk_tsl_common.h"
#include "kk_zb_com.h"
int
kk_wlist_init
(
void
);
int
kk_wlist_init
(
void
);
int
kk_wlist_status_open
(
int
isOpen
);
int
kk_wlist_status_open
(
int
isOpen
);
int
kk_delete_wlist_byMac
(
const
char
*
device_mac
);
int
kk_delete_wlist_byMac
(
const
char
*
device_mac
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.c
View file @
33a3264b
#include "kk_zigbee_api.h"
#include "kk_zigbee_api.h"
#include "kk_device_manager.h"
#include "kk_tsl_property_set.h"
#include "kk_tsl_property_report.h"
#include "RPC_API.h"
#define KK_RPC_SET_FUNCTION_TABLE {\
{
"kk_permit_join"
,
kk_permit_join
},
\
{
"kk_wlist_ctrl"
,
kk_wlist_ctrl
},
\
{
"zclOnOff"
,
kk_tsl_set_gloabl_OnOff
},
\
{
"zclOnOff_Off"
,
zclOnOff_Off
},
\
{
"kk_tsl_set_colorlight_RGB_red"
,
kk_tsl_set_colorlight_RGB_red
},
\
{
"kk_tsl_set_colorlight_RGB_green"
,
kk_tsl_set_colorlight_RGB_green
},
\
{
"kk_tsl_set_colorlight_RGB_blue"
,
kk_tsl_set_colorlight_RGB_blue
},
\
{
"kk_tsl_set_colorlight_Brightness"
,
kk_tsl_set_colorlight_Brightness
},
\
{
"kk_tsl_set_colorlight_mode"
,
kk_tsl_set_colorlight_mode
},
\
}
#define KK_RPC_REPORT_FUNCTION_TABLE {\
{
"kk_tsl_report_global_onoff"
,
kk_tsl_report_global_onoff
},
\
{
"kk_tsl_report_colorControl_Brightness"
,
kk_tsl_report_colorControl_Brightness
},
\
{
"kk_tsl_report_colorControl_RGB"
,
kk_tsl_report_colorControl_RGB
},
\
{
"kk_tsl_report_iasZoneStatus"
,
kk_tsl_report_iasZoneStatus
},
\
{
"kk_tsl_report_battery"
,
kk_tsl_report_battery
},
\
}
kk_rpc_set_api_s
kk_rpc_set_api
[]
=
KK_RPC_SET_FUNCTION_TABLE
;
kk_rpc_set_api_s
kk_rpc_set_api
[]
=
KK_RPC_SET_FUNCTION_TABLE
;
kk_rpc_report_api_s
kk_rpc_report_api
[]
=
KK_RPC_REPORT_FUNCTION_TABLE
;
kk_rpc_report_api_s
kk_rpc_report_api
[]
=
KK_RPC_REPORT_FUNCTION_TABLE
;
...
@@ -30,6 +56,19 @@ EmberAfStatus kk_private_protocol(uint16_t node,uint8_t dataLen,uint8_t *data)
...
@@ -30,6 +56,19 @@ EmberAfStatus kk_private_protocol(uint16_t node,uint8_t dataLen,uint8_t *data)
EmberStatus
nwkPermitJoinCMD
(
bool
open
)
{
EmberStatus
status
;
status
=
(
open
?
emberAfPluginNetworkCreatorSecurityOpenNetwork
()
:
emberAfPluginNetworkCreatorSecurityCloseNetwork
());
emberAfCorePrintln
(
"%p: %p network: 0x%X"
,
"NWK Creator Security"
,
(
open
?
"Open"
:
"Close"
),
status
);
return
status
;
}
// network leave
// network leave
EmberStatus
kk_network_leave
(
void
)
EmberStatus
kk_network_leave
(
void
)
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/kk_zigbee_api.h
View file @
33a3264b
#ifndef __KK_ZIGBEE_API_H
#ifndef __KK_ZIGBEE_API_H
#define __KK_ZIGBEE_API_H
#define __KK_ZIGBEE_API_H
#include "kk_
test
.h"
#include "kk_
ncp_common
.h"
typedef
int
(
*
kk_rpc_set
)(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
typedef
int
(
*
kk_rpc_set
)(
jrpc_context
*
ctx
,
EmberNodeId
node
,
unsigned
char
ep
,
void
*
data
);
...
@@ -18,26 +18,7 @@ typedef struct{
...
@@ -18,26 +18,7 @@ typedef struct{
void
kk_rpc_test
(
void
);
void
kk_rpc_test
(
void
);
#define KK_RPC_SET_FUNCTION_TABLE {\
{
"kk_permit_join"
,
kk_permit_join
},
\
{
"kk_wlist_ctrl"
,
kk_wlist_ctrl
},
\
{
"zclOnOff"
,
kk_tsl_set_gloabl_OnOff
},
\
{
"zclOnOff_Off"
,
zclOnOff_Off
},
\
{
"kk_tsl_set_colorlight_RGB_red"
,
kk_tsl_set_colorlight_RGB_red
},
\
{
"kk_tsl_set_colorlight_RGB_green"
,
kk_tsl_set_colorlight_RGB_green
},
\
{
"kk_tsl_set_colorlight_RGB_blue"
,
kk_tsl_set_colorlight_RGB_blue
},
\
{
"kk_tsl_set_colorlight_Brightness"
,
kk_tsl_set_colorlight_Brightness
},
\
{
"kk_tsl_set_colorlight_mode"
,
kk_tsl_set_colorlight_mode
},
\
}
#define KK_RPC_REPORT_FUNCTION_TABLE {\
{
"kk_tsl_report_global_onoff"
,
kk_tsl_report_global_onoff
},
\
{
"kk_tsl_report_colorControl_Brightness"
,
kk_tsl_report_colorControl_Brightness
},
\
{
"kk_tsl_report_colorControl_RGB"
,
kk_tsl_report_colorControl_RGB
},
\
{
"kk_tsl_report_iasZoneStatus"
,
kk_tsl_report_iasZoneStatus
},
\
{
"kk_tsl_report_battery"
,
kk_tsl_report_battery
},
\
}
kk_rpc_set_api_s
kk_rpc_set_api
[];
kk_rpc_set_api_s
kk_rpc_set_api
[];
kk_rpc_report_api_s
kk_rpc_report_api
[];
kk_rpc_report_api_s
kk_rpc_report_api
[];
...
@@ -46,6 +27,12 @@ kk_rpc_report_api_s kk_rpc_report_api[];
...
@@ -46,6 +27,12 @@ kk_rpc_report_api_s kk_rpc_report_api[];
uint8_t
kk_get_rpc_set_api_size
(
void
);
uint8_t
kk_get_rpc_set_api_size
(
void
);
uint8_t
kk_get_rpc_report_api_size
(
void
);
uint8_t
kk_get_rpc_report_api_size
(
void
);
enum
{
WC_normal_dir
=
0
,
//"正转"
WC_reversed_dir
=
1
,
//"反转"
WC_calibration_mode
=
2
,
//"校验"
}
windowCoveringMode
;
typedef
enum
{
typedef
enum
{
EnrollResponseCode_Success
=
0x00
,
EnrollResponseCode_Success
=
0x00
,
EnrollResponseCode_NoSupported
=
0x01
,
EnrollResponseCode_NoSupported
=
0x01
,
...
@@ -144,6 +131,7 @@ typedef enum{
...
@@ -144,6 +131,7 @@ typedef enum{
EmberAfStatus
kk_private_protocol
(
uint16_t
node
,
uint8_t
dataLen
,
uint8_t
*
data
);
EmberAfStatus
kk_private_protocol
(
uint16_t
node
,
uint8_t
dataLen
,
uint8_t
*
data
);
EmberStatus
nwkPermitJoinCMD
(
bool
open
);
EmberStatus
kk_network_leave
(
void
);
EmberStatus
kk_network_leave
(
void
);
EmberStatus
kk_network_form
(
bool
centralized
,
EmberPanId
panId
,
int8_t
radioTxPower
,
uint8_t
channel
);
EmberStatus
kk_network_form
(
bool
centralized
,
EmberPanId
panId
,
int8_t
radioTxPower
,
uint8_t
channel
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.c
View file @
33a3264b
#include "sub_device_manage.h"
#include "sub_device_manage.h"
#include "kk_device_manager.h"
#include "zb_device_id.h"
#include "kk_zb_com.h"
#include "kk_tsl_property_report.h"
typedef
void
(
*
subDevManageFunc
)(
kk_device_table_s
*
dev
);
typedef
void
(
*
subDevManageFunc
)(
kk_device_table_s
*
dev
);
typedef
struct
{
typedef
struct
{
...
...
platform/zigbee/app/builder/Z3GatewayHost/ZB/sub_device_manage.h
View file @
33a3264b
#ifndef __SUB_DEVICE_MANAGE_H
#ifndef __SUB_DEVICE_MANAGE_H
#define __SUB_DEVICE_MANAGE_H
#define __SUB_DEVICE_MANAGE_H
#include "kk_zb_com.h"
#include "kk_device_manager.h"
#include "kk_device_table_db.h"
...
...
platform/zigbee/app/builder/Z3GatewayHost/afv2-bookkeeping.c
View file @
33a3264b
...
@@ -91,20 +91,18 @@ void emAfZigbeeKeyEstablishment(EmberEUI64 partner, EmberKeyStatus status)
...
@@ -91,20 +91,18 @@ void emAfZigbeeKeyEstablishment(EmberEUI64 partner, EmberKeyStatus status)
// ReportAttributes function declarations.
// ReportAttributes function declarations.
bool
emberAfReportAttributesCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
);
bool
emberAfReportAttributesCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
);
bool
rpc
_ReportAttributesCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
);
bool
kk
_ReportAttributesCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
);
bool
rpc
_ReadAttributesResponseCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
);
bool
kk
_ReadAttributesResponseCallback
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
);
bool
emAfReportAttributes
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
)
bool
emAfReportAttributes
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
)
{
{
return
rpc_ReportAttributesCallback
(
clusterId
,
buffer
,
bufLen
);
return
kk_ReportAttributesCallback
(
clusterId
,
buffer
,
bufLen
);
//return emberAfReportAttributesCallback(clusterId, buffer, bufLen);
}
}
bool
emAfReadAttributesResponse
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
)
bool
emAfReadAttributesResponse
(
EmberAfClusterId
clusterId
,
uint8_t
*
buffer
,
uint16_t
bufLen
)
{
{
return
rpc_ReadAttributesResponseCallback
(
clusterId
,
buffer
,
bufLen
);
return
kk_ReadAttributesResponseCallback
(
clusterId
,
buffer
,
bufLen
);
//return emberAfReadAttributesResponseCallback(clusterId, buffer, bufLen);
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/call-command-handler.c
View file @
33a3264b
...
@@ -1482,7 +1482,7 @@ EmberAfStatus emberAfIasZoneClusterClientCommandParse(EmberAfClusterCommand *cmd
...
@@ -1482,7 +1482,7 @@ EmberAfStatus emberAfIasZoneClusterClientCommandParse(EmberAfClusterCommand *cmd
extendedStatus
,
extendedStatus
,
zoneId
,
zoneId
,
delay
);
delay
);
rpc
_IasZoneClusterZoneStatusChangeNotificationCallback
(
zoneStatus
,
kk
_IasZoneClusterZoneStatusChangeNotificationCallback
(
zoneStatus
,
extendedStatus
,
extendedStatus
,
zoneId
,
zoneId
,
delay
);
delay
);
...
...
platform/zigbee/app/builder/Z3GatewayHost/call-command-handler.h
View file @
33a3264b
...
@@ -40,4 +40,8 @@ EmberAfStatus emberAfIasZoneClusterClientCommandParse(EmberAfClusterCommand *cmd
...
@@ -40,4 +40,8 @@ EmberAfStatus emberAfIasZoneClusterClientCommandParse(EmberAfClusterCommand *cmd
// Cluster: Simple Metering, client
// Cluster: Simple Metering, client
EmberAfStatus
emberAfSimpleMeteringClusterClientCommandParse
(
EmberAfClusterCommand
*
cmd
);
EmberAfStatus
emberAfSimpleMeteringClusterClientCommandParse
(
EmberAfClusterCommand
*
cmd
);
void
kk_IasZoneClusterZoneStatusChangeNotificationCallback
(
uint16_t
zoneStatus
,
uint8_t
extendedStatus
,
uint8_t
zoneId
,
uint16_t
delay
);
#endif // SILABS_EMBER_AF_COMMAND_PARSE_HEADER
#endif // SILABS_EMBER_AF_COMMAND_PARSE_HEADER
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
deleted
100644 → 0
View file @
d61a4575
#include "kk_test.h"
#include "kk_ncp_queue.h"
static
void
kk_rpc_send_message
(
cJSON
*
data
,
char
*
msgtype
,
char
*
method
,
EmberEUI64
mac
)
{
static
uint16_t
msgid
;
char
msgIdString
[
10
]
=
{
0
};
char
macString
[
19
]
=
{
0
};
int
res
=
0
;
kk_device_table_s
*
dev
=
NULL
;
rpc_eui64ToString
(
mac
,
macString
);
dev
=
kk_device_find_by_mac
(
mac
);
if
(
dev
==
NULL
)
{
printf
(
"[%s][%d]kk_rpc_send_message error!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
;
}
cJSON
*
info
=
rpc_cJSON_CreateObject
();
if
(
info
!=
NULL
){
rpc_cJSON_AddStringToObject
(
info
,
"msgType"
,
msgtype
);
rpc_cJSON_AddStringToObject
(
info
,
"productCode"
,
dev
->
productCode
);
rpc_cJSON_AddStringToObject
(
info
,
"deviceCode"
,
macString
);
}
cJSON
*
payload
=
rpc_cJSON_CreateObject
();
if
(
payload
!=
NULL
){
sprintf
(
msgIdString
,
"%d"
,
++
msgid
);
rpc_cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgIdString
);
rpc_cJSON_AddStringToObject
(
payload
,
"version"
,
KK_IPC_VERSION
);
rpc_cJSON_AddStringToObject
(
payload
,
"method"
,
method
);
rpc_cJSON_AddItemToObject
(
payload
,
"params"
,
data
);
}
cJSON
*
root
=
rpc_cJSON_CreateObject
();
if
(
root
!=
NULL
){
rpc_cJSON_AddItemToObject
(
root
,
"info"
,
info
);
rpc_cJSON_AddItemToObject
(
root
,
"payload"
,
payload
);
}
char
*
p
=
rpc_cJSON_Print
(
root
);
emberAfAppPrintln
(
"send json:
\n
%s
\n
"
,
p
);
free
(
p
);
jrpc_send_msg
(
root
);
rpc_cJSON_Delete
(
root
);
}
void
kk_rpc_report_devices
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_DEVICE_JOINED_TYPE
,
KK_REPORT_DEVICE_JOINED_METHOD
,
mac
);
}
void
kk_rpc_report_left_devices
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_DEVICE_LEFT_TYPE
,
KK_REPORT_DEVICE_LEAVE_METHOD
,
mac
);
}
void
kk_rpc_report_status
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_ATTRIBUTE_TYPE
,
KK_REPORT_ATTRIBUTE_METHOD
,
mac
);
}
typedef
struct
{
EmberEUI64
mac
;
uint8_t
AppVersion
;
uint8_t
deviceType
;
uint8_t
deviceCode
;
uint8_t
productType
;
uint8_t
productCode
;
}
kk_report_device_s
;
void
kk_rpc_reportLeftDevices
(
EmberEUI64
mac
)
{
cJSON
*
devicesJson
;
char
macString
[
RPC_EUI64_STRING_LENGTH
];
int
res
=
0
;
EmberEUI64
gw_eui64
=
{
0
};
kk_device_table_s
*
dev
=
NULL
;
rpc_eui64ToString
(
mac
,
macString
);
dev
=
kk_device_find_by_mac
(
mac
);
if
(
dev
==
NULL
)
{
printf
(
"[%s][%d]kk_rpc_reportLeftDevices error!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
;
}
devicesJson
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddStringToObject
(
devicesJson
,
"productCode"
,
dev
->
productCode
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"deviceCode"
,
macString
);
emberAfGetEui64
(
gw_eui64
);
kk_rpc_report_left_devices
(
devicesJson
,
gw_eui64
);
kk_device_table_delete
(
mac
);
}
void
kk_rpc_reportDevices
(
EmberEUI64
mac
,
const
char
*
productCode
)
{
cJSON
*
devicesJson
;
char
macString
[
19
]
=
{
0
};
EmberEUI64
eui64
=
{
0
};
UTIL_LOG_WARNING
(
"report tsl product code:%s
\n
"
,
productCode
);
emberAfPrintBigEndianEui64
(
mac
);
emberAfDebugPrintln
(
""
);
devicesJson
=
rpc_cJSON_CreateObject
();
rpc_eui64ToString
(
mac
,
macString
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"productCode"
,
productCode
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"deviceCode"
,
macString
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"mac"
,
macString
);
//
emberAfGetEui64
(
eui64
);
kk_rpc_report_devices
(
devicesJson
,
eui64
);
}
int
kk_zcl_onoff_set
(
jrpc_context
*
ctx
,
const
char
*
mac
,
unsigned
char
ep
,
void
*
data
)
{
uint8_t
eui64
[
EUI64_SIZE
];
uint8_t
OnOffStatus
=
0
;
EmberStatus
status
=
0
;
EmberNodeId
node
=
0xffff
;
OnOffStatus
=
*
(
uint8_t
*
)
data
;
bool
macMatch
=
rpc_get_mac
(
mac
,
eui64
);
emberAfCorePrintBuffer
(
eui64
,
EUI64_SIZE
,
true
);
for
(
int
i
=
0
;
i
<
EUI64_SIZE
;
i
++
){
emberAfCorePrintln
(
"i=%d,val=%02x"
,
i
,
eui64
[
i
]);
}
if
(
macMatch
){
node
=
emberAfDeviceTableGetNodeIdFromEui64
(
eui64
);
if
(
node
==
0xffff
){
emberAfCorePrintln
(
"
\r\n
not find device by node!
\r\n
"
);
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
emberAfCorePrintln
(
"
\r\n
node=0x%02X,ep=%d,OnOffStatus=%d
\r\n
"
,
node
,
ep
,
OnOffStatus
);
if
(
OnOffStatus
==
1
){
status
=
zclOnOff_On
(
node
,
ep
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_On,status=0x%x
\r\n
"
,
status
);
}
else
if
(
OnOffStatus
==
0
){
status
=
zclOnOff_Off
(
node
,
ep
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_Off,status=0x%x
\r\n
"
,
status
);
}
else
{
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
}
else
{
emberAfCorePrintln
(
"
\r\n
not find device by mac!
\r\n
"
);
if
(
ctx
)
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
return
status
;
error_return:
return
-
1
;
}
//EmberStatus WindowCover_UpOpen(uint16_t node,uint8_t ep);
//EmberStatus WindowCover_DownClose(uint16_t node,uint8_t ep);
//EmberStatus WindowCover_Stop(uint16_t node,uint8_t ep);
extern
void
ncp_queue_tick
(
void
);
void
emberAfMainTickCallback
(
void
)
{
static
unsigned
int
last_time
;
unsigned
int
time
=
halCommonGetInt32uMillisecondTick
();
kk_sub_dev_manage
();
if
((
time
-
last_time
)
>=
3000
){
last_time
=
time
;
kk_productCode_tick
();
//printf("kk_productCode_tick!\n");
}
}
platform/zigbee/app/builder/Z3GatewayHost/kk_test.h
deleted
100644 → 0
View file @
d61a4575
#ifndef _KK_TEST_H
#define _KK_TEST_H
#include "rpc_network_operate.h"
#include "network-creator.h"
#include "network-creator-security.h"
#include "RPC_API.h"
#include "com_api.h"
#include "zb_device_id.h"
#include "kk_device_manager.h"
#include "kk_zigbee_api.h"
#include "kk_tsl_property_report.h"
#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"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define KK_DEVICE_TOPO_CHANGE_TYPE "/thing/topo/change"
#define KK_IPC_VERSION "1.0"
#define KK_REPORT_DEVICE_JOINED_METHOD "thing.topo.add"
#define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.delete"
#define KK_REPORT_ATTRIBUTE_METHOD "thing.event.property.post"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
#define ZIGBEE_COO_PRODUCT_CODE "2"
#define TEST_PRODUCT_CODE "24"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
#define MSG_TOPO_CHANGE_DEVICES_STR "devices"
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 \
{(
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_topo_change_operation
,
KK_DEVICE_TOPO_CHANGE_TYPE
}
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/RPC_API.h
View file @
33a3264b
...
@@ -4,17 +4,13 @@
...
@@ -4,17 +4,13 @@
#include <stdio.h>
#include <stdio.h>
#include <pthread.h>
#include <pthread.h>
#include "../device-table/device-table.h"
#include "./jsonrpc/jsonrpc-c.h"
#include "./jsonrpc/jsonrpc-c.h"
#include "./jsonrpc/rpccJSON.h"
#include "./jsonrpc/rpccJSON.h"
#define MSG_PARSE_ERROR "Parse error"
#define MSG_INVALID_REQUEST "Invalid Request"
#define MSG_METHOD_NOT_FOUND "Method not found"
#define MSG_INVALID_PARAMS "Invalid params"
#define MSG_INTERNAL_ERROR "Internal error"
extern
pthread_mutex_t
g_mutex_lock
;
extern
pthread_mutex_t
g_mutex_lock
;
extern
pthread_mutex_t
report_mutex_lock
;
extern
pthread_mutex_t
report_mutex_lock
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_colorControl.h
deleted
100644 → 0
View file @
d61a4575
#ifndef __RPC_COLOR_CONTROL_H
#define __RPC_COLOR_CONTROL_H
#include "RPC_API.h"
cJSON
*
rpc_zclColorControlMovetohue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovehue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlStephue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovetosat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovesat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlStepsat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovetohueandsat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovetocolor
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovecolor
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlStepcolor
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovetocolortemp
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlEmovetohue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlEmovehue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlEstephue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlEmovetohueandsat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlLoopSet
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlStopmovestep
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlMovecolortemp
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclColorControlStepcolortemp
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
#define RPC_COLOR_CONTROL_COMMAND_FUNCTION_TABLE \
{rpc_zclColorControlMovetohue,"zclColorControlMovetohue"},\
{rpc_zclColorControlMovehue,"zclColorControlMovehue"},\
{rpc_zclColorControlStephue,"zclColorControlStephue"},\
{rpc_zclColorControlMovetosat,"zclColorControlMovetosat"},\
{rpc_zclColorControlMovesat,"zclColorControlMovesat"},\
{rpc_zclColorControlStepsat,"zclColorControlStepsat"},\
{rpc_zclColorControlMovetohueandsat,"zclColorControlMovetohueandsat"},\
{rpc_zclColorControlMovetocolor,"zclColorControlMovetocolor"},\
{rpc_zclColorControlMovecolor,"zclColorControlMovecolor"},\
{rpc_zclColorControlStepcolor,"zclColorControlStepcolor"},\
{rpc_zclColorControlMovetocolortemp,"zclColorControlMovetocolortemp"},\
{rpc_zclColorControlEmovetohue,"zclColorControlEmovetohue"},\
{rpc_zclColorControlEmovehue,"zclColorControlEmovehue"},\
{rpc_zclColorControlEstephue,"zclColorControlEstephue"},\
{rpc_zclColorControlEmovetohueandsat,"zclColorControlEmovetohueandsat"},\
{rpc_zclColorControlLoopSet,"zclColorControlLoopSet"},\
{rpc_zclColorControlStopmovestep,"zclColorControlStopmovestep"},\
{rpc_zclColorControlMovecolortemp,"zclColorControlMovecolortemp"},\
{rpc_zclColorControlStepcolortemp,"zclColorControlStepcolortemp"}\
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_global_cmd.h
deleted
100644 → 0
View file @
d61a4575
#ifndef __ZCL_GLOBAL_CMD_H
#define __ZCL_GLOBAL_CMD_H
#include "RPC_API.h"
cJSON
*
rpc_zclGRead
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
#define RPC_GLOBAL_COMMAND_FUNCTION_TABLE \
{rpc_zclGRead,"zclGRead"}\
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_interface_parse.h
deleted
100644 → 0
View file @
d61a4575
#ifndef __PRC_INTERFACE_PARSE_H
#define __PRC_INTERFACE_PARSE_H
#include "Z3GatewayHost.h"
#include "yjq_ezsp.h"
#include "./jsonrpc/rpccJSON.h"
#define PORT 5555
void
ipcHandle
(
void
);
void
ncp_queue_handle
(
void
);
void
rpc_reportDevices
(
void
);
void
rpc_control_devices
(
cJSON
*
data
,
char
*
method
);
cJSON
*
rpc_reportDeviceState
(
char
*
state
,
EmberEUI64
eui64
);
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_network_operate.h
deleted
100644 → 0
View file @
d61a4575
#ifndef __NETWORK_OPERATE_H
#define __NETWORK_OPERATE_H
#include "RPC_API.h"
typedef
struct
{
EmberNetworkStatus
status
;
EmberEUI64
eui64
;
EmberNodeId
nodeid
;
EmberPanId
panid
;
uint8_t
ch
;
EmberKeyStruct
nwkKey
;
}
rpc_nwk_info_s
;
EmberStatus
nwkLeave
(
void
);
EmberStatus
nwkLeaveRequest
(
EmberNodeId
target
,
bool
removeChildren
,
bool
rejoin
);
void
nwkGetInfo
(
rpc_nwk_info_s
*
info
);
EmberStatus
nwkFormCMD
(
bool
centralized
,
uint16_t
panId
,
int8_t
txPower
,
uint8_t
channel
);
void
nwkStartCMD
(
bool
centralized
);
void
nwkaddChMaskCMD
(
bool
channelMaskIsPrimary
,
uint32_t
channelOrNewMask
);
void
nwksubChMaskCMD
(
bool
channelMaskIsPrimary
,
uint32_t
channelOrNewMask
);
void
nwksetChMaskCMD
(
bool
channelMaskIsPrimary
,
uint32_t
channelOrNewMask
);
void
nwkgetChMaskCMD
(
void
);
EmberStatus
nwkPermitJoinCMD
(
bool
open
);
void
nwkPermitJoinWithKeyCMD
(
EmberEUI64
eui64
,
EmberKeyData
keyData
);
void
nwkSetJoiningLinkKeyCMD
(
EmberEUI64
eui64
,
EmberKeyData
keyData
);
void
nwkClearJoiningLinkKeyCMD
(
void
);
cJSON
*
rpc_nwkGetInfo
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkFormCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkStar
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkLeave
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_nwkLeaveRequest
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
#define RPC_NETWORK_FUNCTION_TABLE \
{(rpc_function*)rpc_nwkLeave,"nwkLeave"},\
{(rpc_function*)rpc_nwkLeaveRequest,"nwkLeaveRequest"},\
{(rpc_function*)rpc_nwkGetInfo,"nwkGetInfo"},\
{(rpc_function*)rpc_nwkFormCMD,"thing.topo.property.set"},\
{(rpc_function*)rpc_nwkStar,"nwkStar"}\
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/inc/rpc_onoff.h
deleted
100644 → 0
View file @
d61a4575
#ifndef __RPC_ONOFF_H
#define __RPC_ONOFF_H
#include "RPC_API.h"
EmberStatus
WindowCover_UpOpen
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
WindowCover_DownClose
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
WindowCover_Stop
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
WindowCover_GotoLiftPercentage
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
position
);
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
);
EmberStatus
zclOnOff_OffWithEffect
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
id
,
uint8_t
var
);
EmberStatus
zclOnOff_OnWithRecallGlobalScene
(
uint16_t
node
,
uint8_t
ep
);
EmberStatus
zclOnOff_OnWithTimedOff
(
uint16_t
node
,
uint8_t
ep
,
uint8_t
Control
,
uint16_t
OnTime
,
uint16_t
OffWaitTime
);
cJSON
*
rpc_zclOnOff_On
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclOnOff_Off
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclOnOff_Toggle
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclOnOff_OffWithEffect
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclOnOff_OnWithRecallGlobalScene
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
cJSON
*
rpc_zclOnOff_OnWithTimedOff
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
);
#define RPC_OnOff_COMMAND_FUNCTION_TABLE \
{rpc_zclOnOff_On,"zclOnOff_On"},\
{rpc_zclOnOff_Off,"zclOnOff_Off"},\
{rpc_zclOnOff_Toggle,"zclOnOff_Toggle"},\
{rpc_zclOnOff_OffWithEffect,"zclOnOff_OffWithEffect"},\
{rpc_zclOnOff_OnWithRecallGlobalScene,"zclOnOff_OnWithRecallGlobalScene"},\
{rpc_zclOnOff_OnWithTimedOff,"zclOnOff_OnWithTimedOff"}\
#endif
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/color_control/rpc_colorControl.c
deleted
100644 → 0
View file @
d61a4575
#include "RPC_API.h"
#include "rpc_colorControl.h"
cJSON
*
rpc_zclColorControlMovetohue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_hue
;
cJSON
*
item_dir
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_hue
=
cJSON_GetObjectItem
(
params
,
"hue"
);
item_dir
=
cJSON_GetObjectItem
(
params
,
"dir"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_hue
==
NULL
||
item_dir
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_hue
->
type
!=
cJSON_String
||
item_dir
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"hue=%s
\n
"
,(
item_hue
->
type
==
cJSON_True
)
?
""
:
"not "
);
kk_print_debug
(
"dir=%s
\n
"
,
item_dir
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
hue
=
rpc_get_u8
(
item_hue
->
valuestring
);
uint8_t
dir
=
rpc_get_u8
(
item_dir
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_override
->
valuestring
);
}
status
=
zclColorControlMovetohue
(
node
,
ep
,
hue
,
dir
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovehue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_rate
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_rate
=
cJSON_GetObjectItem
(
params
,
"rate"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_mode
==
NULL
||
item_rate
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_rate
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"rate=%s
\n
"
,
item_rate
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint8_t
rate
=
rpc_get_u8
(
item_rate
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovehue
(
node
,
ep
,
mode
,
rate
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlStephue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_size
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_size
=
cJSON_GetObjectItem
(
params
,
"size"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_mode
==
NULL
||
item_size
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_size
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"size=%s
\n
"
,
item_size
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint8_t
size
=
rpc_get_u8
(
item_size
->
valuestring
);
uint8_t
trsTime
=
rpc_get_u8
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlStephue
(
node
,
ep
,
mode
,
size
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovetosat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_saturation
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_saturation
=
cJSON_GetObjectItem
(
params
,
"saturation"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_saturation
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_saturation
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"saturation=%s
\n
"
,
item_saturation
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
saturation
=
rpc_get_u8
(
item_saturation
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovetosat
(
node
,
ep
,
saturation
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovesat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_rate
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_rate
=
cJSON_GetObjectItem
(
params
,
"rate"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_mode
==
NULL
||
item_rate
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_rate
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"rate=%s
\n
"
,
item_rate
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint8_t
rate
=
rpc_get_u8
(
item_rate
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovesat
(
node
,
ep
,
mode
,
rate
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlStepsat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_size
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_size
=
cJSON_GetObjectItem
(
params
,
"size"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_mode
==
NULL
||
item_size
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_size
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"rate=%s
\n
"
,
item_size
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint8_t
size
=
rpc_get_u8
(
item_size
->
valuestring
);
uint8_t
trsTime
=
rpc_get_u8
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlStepsat
(
node
,
ep
,
mode
,
size
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovetohueandsat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_hue
;
cJSON
*
item_saturation
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_hue
=
cJSON_GetObjectItem
(
params
,
"hue"
);
item_saturation
=
cJSON_GetObjectItem
(
params
,
"saturation"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_hue
==
NULL
||
item_saturation
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_hue
->
type
!=
cJSON_String
||
item_saturation
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_hue
->
valuestring
);
kk_print_debug
(
"rate=%s
\n
"
,
item_saturation
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
hue
=
rpc_get_u8
(
item_hue
->
valuestring
);
uint8_t
saturation
=
rpc_get_u8
(
item_saturation
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovetohueandsat
(
node
,
ep
,
hue
,
saturation
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovetocolor
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_colorX
;
cJSON
*
item_colorY
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_colorX
=
cJSON_GetObjectItem
(
params
,
"colorX"
);
item_colorY
=
cJSON_GetObjectItem
(
params
,
"colorY"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_colorX
==
NULL
||
item_colorY
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_colorX
->
type
!=
cJSON_String
||
item_colorY
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"colorX=%s
\n
"
,
item_colorX
->
valuestring
);
kk_print_debug
(
"colorY=%s
\n
"
,
item_colorY
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint16_t
colorX
=
rpc_get_u16
(
item_colorX
->
valuestring
);
uint16_t
colorY
=
rpc_get_u16
(
item_colorY
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovetocolor
(
node
,
ep
,
colorX
,
colorY
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovecolor
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_rateX
;
cJSON
*
item_rateY
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_rateX
=
cJSON_GetObjectItem
(
params
,
"rateX"
);
item_rateY
=
cJSON_GetObjectItem
(
params
,
"rateY"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_rateX
==
NULL
||
item_rateY
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_rateX
->
type
!=
cJSON_String
||
item_rateY
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"rateX=%s
\n
"
,
item_rateX
->
valuestring
);
kk_print_debug
(
"rateY=%s
\n
"
,
item_rateY
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint16_t
rateX
=
rpc_get_u16
(
item_rateX
->
valuestring
);
uint16_t
rateY
=
rpc_get_u16
(
item_rateY
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovecolor
(
node
,
ep
,
rateX
,
rateY
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlStepcolor
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_stepX
;
cJSON
*
item_stepY
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_stepX
=
cJSON_GetObjectItem
(
params
,
"stepX"
);
item_stepY
=
cJSON_GetObjectItem
(
params
,
"stepY"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_stepX
==
NULL
||
item_stepY
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_stepX
->
type
!=
cJSON_String
||
item_stepY
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"stepX=%s
\n
"
,
item_stepX
->
valuestring
);
kk_print_debug
(
"stepY=%s
\n
"
,
item_stepY
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint16_t
stepX
=
rpc_get_u16
(
item_stepX
->
valuestring
);
uint16_t
stepY
=
rpc_get_u16
(
item_stepY
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlStepcolor
(
node
,
ep
,
stepX
,
stepY
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovetocolortemp
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_colorTemp
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_colorTemp
=
cJSON_GetObjectItem
(
params
,
"colorTemp"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_colorTemp
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_colorTemp
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"colorTemp=%s
\n
"
,
item_colorTemp
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint16_t
colorTemp
=
rpc_get_u16
(
item_colorTemp
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovetocolortemp
(
node
,
ep
,
colorTemp
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlEmovetohue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_hue
;
cJSON
*
item_dir
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_hue
=
cJSON_GetObjectItem
(
params
,
"hue"
);
item_dir
=
cJSON_GetObjectItem
(
params
,
"dir"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_hue
==
NULL
||
item_dir
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_hue
->
type
!=
cJSON_String
||
item_dir
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"hue=%s
\n
"
,
item_hue
->
valuestring
);
kk_print_debug
(
"dir=%s
\n
"
,
item_dir
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint16_t
hue
=
rpc_get_u16
(
item_hue
->
valuestring
);
uint8_t
dir
=
rpc_get_u8
(
item_dir
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlEmovetohue
(
node
,
ep
,
hue
,
dir
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlEmovehue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_rate
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_rate
=
cJSON_GetObjectItem
(
params
,
"rate"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_mode
==
NULL
||
item_rate
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_rate
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"rate=%s
\n
"
,
item_rate
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint16_t
rate
=
rpc_get_u16
(
item_rate
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlEmovehue
(
node
,
ep
,
mode
,
rate
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlEstephue
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_size
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_size
=
cJSON_GetObjectItem
(
params
,
"size"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_mode
==
NULL
||
item_size
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_size
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"size=%s
\n
"
,
item_size
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint16_t
size
=
rpc_get_u16
(
item_size
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlEstephue
(
node
,
ep
,
mode
,
size
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlEmovetohueandsat
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_hue
;
cJSON
*
item_saturation
;
cJSON
*
item_trsTime
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_hue
=
cJSON_GetObjectItem
(
params
,
"hue"
);
item_saturation
=
cJSON_GetObjectItem
(
params
,
"saturation"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_hue
==
NULL
||
item_saturation
==
NULL
||
item_trsTime
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_hue
->
type
!=
cJSON_String
||
item_saturation
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"hue=%s
\n
"
,
item_hue
->
valuestring
);
kk_print_debug
(
"saturation=%s
\n
"
,
item_saturation
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint16_t
hue
=
rpc_get_u16
(
item_hue
->
valuestring
);
uint8_t
saturation
=
rpc_get_u8
(
item_saturation
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlEmovetohueandsat
(
node
,
ep
,
hue
,
saturation
,
trsTime
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlLoopSet
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_flags
;
cJSON
*
item_action
;
cJSON
*
item_dir
;
cJSON
*
item_time
;
cJSON
*
item_sHue
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_flags
=
cJSON_GetObjectItem
(
params
,
"flags"
);
item_action
=
cJSON_GetObjectItem
(
params
,
"action"
);
item_dir
=
cJSON_GetObjectItem
(
params
,
"dir"
);
item_time
=
cJSON_GetObjectItem
(
params
,
"time"
);
item_sHue
=
cJSON_GetObjectItem
(
params
,
"sHue"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_flags
==
NULL
||
item_action
==
NULL
||
item_dir
==
NULL
||
item_time
==
NULL
||
item_sHue
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_flags
->
type
!=
cJSON_String
||
item_action
->
type
!=
cJSON_String
||
item_dir
->
type
!=
cJSON_String
||
item_time
->
type
!=
cJSON_String
||
item_sHue
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"flags=%s
\n
"
,
item_flags
->
valuestring
);
kk_print_debug
(
"action=%s
\n
"
,
item_action
->
valuestring
);
kk_print_debug
(
"dir=%s
\n
"
,
item_dir
->
valuestring
);
kk_print_debug
(
"time=%s
\n
"
,
item_time
->
valuestring
);
kk_print_debug
(
"sHue=%s
\n
"
,
item_sHue
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
flags
=
rpc_get_u8
(
item_flags
->
valuestring
);
uint8_t
action
=
rpc_get_u8
(
item_action
->
valuestring
);
uint8_t
dir
=
rpc_get_u8
(
item_dir
->
valuestring
);
uint16_t
Time
=
rpc_get_u16
(
item_time
->
valuestring
);
uint16_t
sHue
=
rpc_get_u16
(
item_sHue
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlLoopSet
(
node
,
ep
,
flags
,
action
,
dir
,
Time
,
sHue
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlStopmovestep
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlStopmovestep
(
node
,
ep
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlMovecolortemp
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_rate
;
cJSON
*
item_min
;
cJSON
*
item_max
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_rate
=
cJSON_GetObjectItem
(
params
,
"rate"
);
item_min
=
cJSON_GetObjectItem
(
params
,
"minMireds"
);
item_max
=
cJSON_GetObjectItem
(
params
,
"maxMireds"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_rate
->
type
!=
cJSON_String
||
item_max
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"rate=%s
\n
"
,
item_rate
->
valuestring
);
kk_print_debug
(
"minMireds=%s
\n
"
,
item_min
->
valuestring
);
kk_print_debug
(
"maxMireds=%s
\n
"
,
item_max
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint16_t
rate
=
rpc_get_u16
(
item_rate
->
valuestring
);
uint16_t
min
=
rpc_get_u16
(
item_min
->
valuestring
);
uint16_t
max
=
rpc_get_u16
(
item_max
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlMovecolortemp
(
node
,
ep
,
mode
,
rate
,
min
,
max
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclColorControlStepcolortemp
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_mode
;
cJSON
*
item_size
;
cJSON
*
item_trsTime
;
cJSON
*
item_minimum
;
cJSON
*
item_maximum
;
cJSON
*
item_options
;
cJSON
*
item_mask
;
cJSON
*
item_Override
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_mode
=
cJSON_GetObjectItem
(
params
,
"mode"
);
item_size
=
cJSON_GetObjectItem
(
params
,
"size"
);
item_trsTime
=
cJSON_GetObjectItem
(
params
,
"trsTime"
);
item_minimum
=
cJSON_GetObjectItem
(
params
,
"minMireds"
);
item_maximum
=
cJSON_GetObjectItem
(
params
,
"maxMireds"
);
item_options
=
cJSON_GetObjectItem
(
params
,
"options"
);
item_mask
=
cJSON_GetObjectItem
(
params
,
"mask"
);
item_Override
=
cJSON_GetObjectItem
(
params
,
"override"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_options
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_mode
->
type
!=
cJSON_String
||
item_size
->
type
!=
cJSON_String
||
item_trsTime
->
type
!=
cJSON_String
||
item_minimum
->
type
!=
cJSON_String
||
item_maximum
->
type
!=
cJSON_String
||
(
item_options
->
type
!=
cJSON_True
&&
item_options
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
item_options
->
type
==
cJSON_True
){
if
(
item_mask
==
NULL
||
item_Override
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".3....
\n
"
);
goto
error_return
;
}
if
(
item_mask
->
type
!=
cJSON_String
||
item_Override
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".4....
\n
"
);
goto
error_return
;
}
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"mode=%s
\n
"
,
item_mode
->
valuestring
);
kk_print_debug
(
"size=%s
\n
"
,
item_size
->
valuestring
);
kk_print_debug
(
"trsTime=%s
\n
"
,
item_trsTime
->
valuestring
);
kk_print_debug
(
"minMireds=%s
\n
"
,
item_minimum
->
valuestring
);
kk_print_debug
(
"maxMireds=%s
\n
"
,
item_maximum
->
valuestring
);
kk_print_debug
(
"%s options
\n
"
,(
item_options
->
type
==
cJSON_True
)
?
"has"
:
"no"
);
if
(
item_options
->
type
==
cJSON_True
){
kk_print_debug
(
"mask=%s
\n
"
,
item_mask
->
valuestring
);
kk_print_debug
(
"override=%s
\n
"
,
item_Override
->
valuestring
);
}
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
mode
=
rpc_get_u8
(
item_mode
->
valuestring
);
uint16_t
size
=
rpc_get_u16
(
item_size
->
valuestring
);
uint16_t
trsTime
=
rpc_get_u16
(
item_trsTime
->
valuestring
);
uint16_t
minimum
=
rpc_get_u16
(
item_minimum
->
valuestring
);
uint16_t
maximum
=
rpc_get_u16
(
item_maximum
->
valuestring
);
bool
options
=
(
item_options
->
type
==
cJSON_True
)
?
true
:
false
;
uint8_t
mask
=
0
;
uint8_t
Override
=
0
;
if
(
options
==
true
){
mask
=
rpc_get_u8
(
item_mask
->
valuestring
);
Override
=
rpc_get_u8
(
item_Override
->
valuestring
);
}
status
=
zclColorControlStepcolortemp
(
node
,
ep
,
mode
,
size
,
trsTime
,
minimum
,
maximum
,
options
,
mask
,
Override
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_common.c
View file @
33a3264b
#include "RPC_API.h"
#include "RPC_API.h"
#include <pthread.h>
#include <pthread.h>
#include "kk_ncp_msg.h"
pthread_mutex_t
report_mutex_lock
;
pthread_mutex_t
report_mutex_lock
;
...
...
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_global_cmd.c
deleted
100644 → 0
View file @
d61a4575
#include "rpc_global_cmd.h"
#include <stdio.h>
/*
void emAfCliSendCommand(uint16_t destination,uint8_t srcEndpoint,uint8_t dstEndpoint)
{
EmberStatus status;
// check that cmd is built
if (zclCmdIsBuilt == false) {
emberAfCorePrintln("no cmd");
return;
}
emAfApsFrameEndpointSetup(srcEndpoint, dstEndpoint);
status = emberAfSendUnicast(EMBER_OUTGOING_DIRECT,
destination,
&globalApsFrame,
appZclBufferLen,
appZclBuffer);
if (status != EMBER_SUCCESS) {
emberAfCorePrintln("Error: CLI Send failed, status: 0x%X", status);
}
emberAfDebugPrintln("T%4x:TX (%p) %ccast 0x%x%p",
emberAfGetCurrentTime(),
"CLI",
label,
status,
((globalApsFrame.options & EMBER_APS_OPTION_ENCRYPTION)
? " w/ link key" : ""));
emberAfDebugPrint("TX buffer: [");
emberAfDebugFlush();
emberAfDebugPrintBuffer(appZclBuffer, appZclBufferLen, true);
emberAfDebugPrintln("]");
emberAfDebugFlush();
zclCmdIsBuilt = false;
mfgSpecificId = EMBER_AF_NULL_MANUFACTURER_CODE;
disableDefaultResponse = 0;
useNextSequence = false;
}*/
cJSON
*
rpc_zclGRead
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_srcEP
;
cJSON
*
item_dstEP
;
cJSON
*
item_multicast
;
cJSON
*
item_clu
;
cJSON
*
item_attr
;
cJSON
*
item_svr
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_srcEP
=
cJSON_GetObjectItem
(
params
,
"srcEP"
);
item_dstEP
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_multicast
=
cJSON_GetObjectItem
(
params
,
"multicast"
);
item_clu
=
cJSON_GetObjectItem
(
params
,
"clu"
);
item_attr
=
cJSON_GetObjectItem
(
params
,
"attr"
);
item_svr
=
cJSON_GetObjectItem
(
params
,
"svr"
);
}
if
(
item_node
==
NULL
||
item_srcEP
==
NULL
||
item_dstEP
==
NULL
||
item_multicast
==
NULL
||
item_clu
==
NULL
||
item_attr
==
NULL
||
item_svr
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_srcEP
->
type
!=
cJSON_String
||
item_dstEP
->
type
!=
cJSON_String
||
item_clu
->
type
!=
cJSON_String
||
item_attr
->
type
!=
cJSON_String
||
(
item_multicast
->
type
!=
cJSON_True
&&
item_multicast
->
type
!=
cJSON_False
)
||
(
item_svr
->
type
!=
cJSON_True
&&
item_svr
->
type
!=
cJSON_False
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
if
(
strlen
(
item_node
->
valuestring
)
!=
4
||
strlen
(
item_srcEP
->
valuestring
)
!=
2
||
strlen
(
item_dstEP
->
valuestring
)
!=
2
||
strlen
(
item_clu
->
valuestring
)
!=
4
||
strlen
(
item_attr
->
valuestring
)
!=
4
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"3[%d,%d,%d,%d,%d]
\n
"
,
strlen
(
item_node
->
valuestring
),
strlen
(
item_srcEP
->
valuestring
),
strlen
(
item_dstEP
->
valuestring
),
strlen
(
item_clu
->
valuestring
),
strlen
(
item_attr
->
valuestring
));
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"srcEP=%s
\n
"
,
item_srcEP
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_dstEP
->
valuestring
);
kk_print_debug
(
"%s multicast
\n
"
,(
item_multicast
->
type
==
cJSON_True
)
?
""
:
"not "
);
kk_print_debug
(
"clu=%s
\n
"
,
item_clu
->
valuestring
);
kk_print_debug
(
"attr=%s
\n
"
,
item_attr
->
valuestring
);
kk_print_debug
(
"dir:%s
\n
"
,(
item_svr
->
type
==
cJSON_True
)
?
"client->server"
:
"server->client"
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
srcEP
=
rpc_get_u8
(
item_srcEP
->
valuestring
);
uint8_t
dstEP
=
rpc_get_u8
(
item_dstEP
->
valuestring
);
bool
multicast
=
(
item_multicast
->
type
==
cJSON_True
)
?
true
:
false
;
uint16_t
clu
=
rpc_get_u16
(
item_clu
->
valuestring
);
uint16_t
attr
=
rpc_get_u16
(
item_attr
->
valuestring
);
bool
svr
=
(
item_svr
->
type
==
cJSON_True
)
?
true
:
false
;
kk_print_debug
(
"read clu:0x%04X,attr:0x%04X,type:%s
\n
"
,
clu
,
attr
,(
svr
==
true
)
?
"client->server"
:
"server->client"
);
kk_print_debug
(
"target:0x%04X,srcEP=%d,dstEP=%d,type:%s
\n
"
,
node
,
srcEP
,
dstEP
,(
multicast
==
true
)
?
"multicast"
:
"not multicast"
);
status
=
zclGRead
(
node
,
srcEP
,
dstEP
,
multicast
,
clu
,
attr
,
svr
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send read command suc."
);
}
else
{
kk_print_debug
(
"send read command fail!status=0x%02X
\r\n
"
,
status
);
}
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_network_operate.c
deleted
100644 → 0
View file @
d61a4575
#include "rpc_network_operate.h"
#include "network-creator.h"
#include "network-creator-security.h"
void
nwkGetInfo
(
rpc_nwk_info_s
*
info
)
{
emberAfGetEui64
(
info
->
eui64
);
emberAfPrintBigEndianEui64
(
info
->
eui64
);
info
->
status
=
ezspNetworkState
();
if
(
info
->
status
==
EMBER_JOINED_NETWORK
){
info
->
nodeid
=
emberAfGetNodeId
();
info
->
panid
=
emberAfGetPanId
();
info
->
ch
=
emberAfGetRadioChannel
();
if
(
emberGetKey
(
EMBER_CURRENT_NETWORK_KEY
,
&
info
->
nwkKey
)
==
EMBER_SUCCESS
)
{
emberAfAppPrintln
(
"
\r\n
Network Key = "
);
emberAfPrintZigbeeKey
(
emberKeyContents
(
&
info
->
nwkKey
.
key
));
emberAfAppFlush
();
}
}
}
EmberStatus
nwkFormCMD
(
bool
centralized
,
uint16_t
panId
,
int8_t
txPower
,
uint8_t
channel
)
{
EmberStatus
status
=
emberAfPluginNetworkCreatorNetworkForm
(
centralized
,
panId
,
txPower
,
channel
);
emberAfCorePrintln
(
"%p: %p: 0x%X"
,
"NWK Creator"
,
"Form"
,
status
);
return
status
;
}
void
nwkStartCMD
(
bool
centralized
)
{
EmberStatus
status
=
emberAfPluginNetworkCreatorStart
(
centralized
);
emberAfCorePrintln
(
"%p: %p: 0x%X"
,
"NWK Creator"
,
"Form"
,
status
);
}
void
nwkaddChMaskCMD
(
bool
channelMaskIsPrimary
,
uint32_t
channelOrNewMask
)
{
uint32_t
*
channelMask
=
(
channelMaskIsPrimary
?
&
emAfPluginNetworkCreatorPrimaryChannelMask
:
&
emAfPluginNetworkCreatorSecondaryChannelMask
);
if
(
channelOrNewMask
<
EMBER_MIN_802_15_4_CHANNEL_NUMBER
||
channelOrNewMask
>
EMBER_MAX_802_15_4_CHANNEL_NUMBER
)
{
emberAfCorePrintln
(
"%p: %p: 0x%X"
,
"NWK Creator"
,
"Illegal 802.15.4 channel"
,
channelOrNewMask
);
}
else
{
*
channelMask
|=
(
1
<<
channelOrNewMask
);
}
emberAfCorePrint
(
"%p channel mask now: 0x%4X ["
,
(
channelMaskIsPrimary
?
"Primary"
:
"Secondary"
),
*
channelMask
);
emberAfPrintChannelListFromMask
(
*
channelMask
);
emberAfCorePrintln
(
"]"
);
}
void
nwksubChMaskCMD
(
bool
channelMaskIsPrimary
,
uint32_t
channelOrNewMask
)
{
uint32_t
*
channelMask
=
(
channelMaskIsPrimary
?
&
emAfPluginNetworkCreatorPrimaryChannelMask
:
&
emAfPluginNetworkCreatorSecondaryChannelMask
);
if
(
channelOrNewMask
<
EMBER_MIN_802_15_4_CHANNEL_NUMBER
||
channelOrNewMask
>
EMBER_MAX_802_15_4_CHANNEL_NUMBER
)
{
emberAfCorePrintln
(
"%p: %p: 0x%X"
,
"NWK Creator"
,
"Illegal 802.15.4 channel"
,
channelOrNewMask
);
}
else
{
*
channelMask
&=
~
(
1
<<
channelOrNewMask
);
}
emberAfCorePrint
(
"%p channel mask now: 0x%4X ["
,
(
channelMaskIsPrimary
?
"Primary"
:
"Secondary"
),
*
channelMask
);
emberAfPrintChannelListFromMask
(
*
channelMask
);
emberAfCorePrintln
(
"]"
);
}
void
nwksetChMaskCMD
(
bool
channelMaskIsPrimary
,
uint32_t
channelOrNewMask
)
{
uint32_t
*
channelMask
=
(
channelMaskIsPrimary
?
&
emAfPluginNetworkCreatorPrimaryChannelMask
:
&
emAfPluginNetworkCreatorSecondaryChannelMask
);
*
channelMask
=
channelOrNewMask
;
emberAfCorePrint
(
"%p channel mask now: 0x%4X ["
,
(
channelMaskIsPrimary
?
"Primary"
:
"Secondary"
),
*
channelMask
);
emberAfPrintChannelListFromMask
(
*
channelMask
);
emberAfCorePrintln
(
"]"
);
}
void
nwkgetChMaskCMD
(
void
)
{
uint8_t
i
;
uint32_t
masks
[]
=
{
0
,
emAfPluginNetworkCreatorPrimaryChannelMask
,
emAfPluginNetworkCreatorSecondaryChannelMask
};
emberAfCorePrintln
(
"%p: %p:"
,
"NWK Creator"
,
"Channel mask"
);
for
(
i
=
1
;
i
<=
2
;
i
++
)
{
emberAfCorePrint
(
" (%d) 0x%4X ["
,
i
,
masks
[
i
]);
emberAfPrintChannelListFromMask
(
masks
[
i
]);
emberAfCorePrintln
(
"]"
);
}
}
EmberStatus
nwkPermitJoinCMD
(
bool
open
)
{
EmberStatus
status
;
status
=
(
open
?
emberAfPluginNetworkCreatorSecurityOpenNetwork
()
:
emberAfPluginNetworkCreatorSecurityCloseNetwork
());
emberAfCorePrintln
(
"%p: %p network: 0x%X"
,
"NWK Creator Security"
,
(
open
?
"Open"
:
"Close"
),
status
);
return
status
;
}
void
nwkPermitJoinWithKeyCMD
(
EmberEUI64
eui64
,
EmberKeyData
keyData
)
{
EmberStatus
status
;
status
=
emberAfPluginNetworkCreatorSecurityOpenNetworkWithKeyPair
(
eui64
,
keyData
);
emberAfCorePrintln
(
"%p: Open network: 0x%X"
,
"NWK Creator Security"
,
status
);
}
void
nwkSetJoiningLinkKeyCMD
(
EmberEUI64
eui64
,
EmberKeyData
keyData
)
{
EmberStatus
status
;
status
=
ezspAddTransientLinkKey
(
eui64
,
&
keyData
);
emberAfCorePrintln
(
"%p: %p: 0x%X"
,
"NWK Creator Security"
,
"Set joining link key"
,
status
);
}
void
nwkClearJoiningLinkKeyCMD
(
void
)
{
ezspClearTransientLinkKeys
();
emberAfCorePrintln
(
"%p: %p: 0x%X"
,
"NWK Creator Security"
,
"Clear joining link keys"
,
EMBER_SUCCESS
);
}
// network leave
EmberStatus
nwkLeave
(
void
)
{
EmberStatus
status
;
status
=
emberLeaveNetwork
();
emberAfAppPrintln
(
"%p 0x%x"
,
"leave"
,
status
);
return
status
;
}
EmberStatus
nwkLeaveRequest
(
EmberNodeId
target
,
bool
removeChildren
,
bool
rejoin
)
{
EmberEUI64
nullEui64
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
EmberStatus
status
;
uint8_t
options
=
0
;
if
(
rejoin
)
{
options
|=
EMBER_ZIGBEE_LEAVE_AND_REJOIN
;
}
if
(
removeChildren
)
{
options
|=
EMBER_ZIGBEE_LEAVE_AND_REMOVE_CHILDREN
;
}
status
=
emberLeaveRequest
(
target
,
nullEui64
,
options
,
EMBER_APS_OPTION_RETRY
);
emberAfAppPrintln
(
"Leave %p0x%X"
,
"Request: "
,
status
);
return
status
;
}
/**************************************************************************************************/
/*
void nwkStartCMD(bool centralized);
void nwkaddChMaskCMD(bool channelMaskIsPrimary,uint32_t channelOrNewMask);
void nwksubChMaskCMD(bool channelMaskIsPrimary,uint32_t channelOrNewMask);
void nwksetChMaskCMD(bool channelMaskIsPrimary,uint32_t channelOrNewMask);
void nwkgetChMaskCMD(void);
void nwkPermitJoinCMD(bool open);
void nwkPermitJoinWithKeyCMD(EmberEUI64 eui64,EmberKeyData keyData);
void nwkSetJoiningLinkKeyCMD(EmberEUI64 eui64,EmberKeyData keyData);
void nwkClearJoiningLinkKeyCMD(void);
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;
}*/
cJSON
*
rpc_nwkLeaveRequest
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_target
,
*
item_rm
,
*
item_rejoin
;
EmberNodeId
target
;
bool
removeChildren
;
bool
rejoin
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
if
(
params
->
type
==
cJSON_Object
){
item_target
=
rpc_cJSON_GetObjectItem
(
params
,
"target"
);
item_rm
=
rpc_cJSON_GetObjectItem
(
params
,
"removeChildren"
);
item_rejoin
=
rpc_cJSON_GetObjectItem
(
params
,
"rejoin"
);
}
else
if
(
params
->
type
==
cJSON_Array
){
//
}
if
(
item_target
==
NULL
||
item_rm
==
NULL
||
item_rejoin
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1....
\n
"
);
goto
error_return
;
}
if
(
item_target
->
type
!=
cJSON_String
||
(
item_rm
->
type
!=
cJSON_False
&&
item_rm
->
type
!=
cJSON_True
)
||
(
item_rejoin
->
type
!=
cJSON_False
&&
item_rejoin
->
type
!=
cJSON_True
)){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
target
=
rpc_get_u16
(
item_target
->
valuestring
);
removeChildren
=
(
item_rm
->
type
==
cJSON_True
)
?
true
:
false
;
rejoin
=
(
item_rejoin
->
type
==
cJSON_True
)
?
true
:
false
;
status
=
nwkLeaveRequest
(
target
,
removeChildren
,
rejoin
);
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkLeave
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
return
rpc_cJSON_CreateNull
();
}
else
{
status
=
nwkLeave
();
return
rpc_cJSON_CreateNumber
(
status
);
}
}
cJSON
*
rpc_nwkGetInfo
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
rpc_nwk_info_s
info
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
return
rpc_cJSON_CreateNull
();
}
else
{
nwkGetInfo
(
&
info
);
cJSON
*
item
=
rpc_cJSON_CreateObject
();
char
buffer
[
100
];
sprintf
(
buffer
,
"%02X %02X %02X %02X %02X %02X %02X %02X"
,
info
.
eui64
[
7
],
info
.
eui64
[
6
],
info
.
eui64
[
5
],
info
.
eui64
[
4
],
info
.
eui64
[
3
],
info
.
eui64
[
2
],
info
.
eui64
[
1
],
info
.
eui64
[
0
]);
rpc_cJSON_AddStringToObject
(
item
,
"MAC"
,
buffer
);
info
.
status
=
ezspNetworkState
();
switch
(
info
.
status
){
case
EMBER_NO_NETWORK
:
rpc_cJSON_AddStringToObject
(
item
,
"network"
,
"no network"
);
break
;
case
EMBER_JOINING_NETWORK
:
rpc_cJSON_AddStringToObject
(
item
,
"network"
,
"joining"
);
break
;
case
EMBER_JOINED_NETWORK
:
rpc_cJSON_AddStringToObject
(
item
,
"network"
,
"joined"
);
break
;
case
EMBER_JOINED_NETWORK_NO_PARENT
:
rpc_cJSON_AddStringToObject
(
item
,
"network"
,
"no parent"
);
break
;
case
EMBER_LEAVING_NETWORK
:
rpc_cJSON_AddStringToObject
(
item
,
"network"
,
"leaving"
);
break
;
default:
rpc_cJSON_AddStringToObject
(
item
,
"network"
,
"unkown"
);
break
;
}
if
(
info
.
status
==
EMBER_JOINED_NETWORK
){
rpc_cJSON_AddNumberToObject
(
item
,
"channel"
,
info
.
ch
);
sprintf
(
buffer
,
"0x%04X"
,
info
.
nodeid
);
rpc_cJSON_AddStringToObject
(
item
,
"node id"
,
buffer
);
sprintf
(
buffer
,
"0x%04X"
,
info
.
panid
);
rpc_cJSON_AddStringToObject
(
item
,
"pan id"
,
buffer
);
for
(
int
i
=
0
;
i
<
EMBER_ENCRYPTION_KEY_SIZE
;
i
++
){
sprintf
(
&
buffer
[
i
*
3
],
"%02X "
,
info
.
nwkKey
.
key
.
contents
[
EMBER_ENCRYPTION_KEY_SIZE
-
1
-
i
]);
}
rpc_cJSON_AddStringToObject
(
item
,
"network key"
,
buffer
);
}
return
item
;
}
}
cJSON
*
rpc_nwkFormCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_centralized
;
cJSON
*
item_panId
;
cJSON
*
item_txPower
;
cJSON
*
item_channel
;
EmberStatus
status
;
if
(
params
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
if
(
params
->
type
==
cJSON_Object
){
item_centralized
=
rpc_cJSON_GetObjectItem
(
params
,
"centralized"
);
item_txPower
=
rpc_cJSON_GetObjectItem
(
params
,
"txPower"
);
item_channel
=
rpc_cJSON_GetObjectItem
(
params
,
"channel"
);
item_panId
=
rpc_cJSON_GetObjectItem
(
params
,
"panId"
);
}
else
if
(
params
->
type
==
cJSON_Array
){
item_centralized
=
rpc_cJSON_GetArrayItem
(
params
,
0
);
item_panId
=
rpc_cJSON_GetArrayItem
(
params
,
1
);
item_txPower
=
rpc_cJSON_GetArrayItem
(
params
,
2
);
item_channel
=
rpc_cJSON_GetArrayItem
(
params
,
3
);
}
else
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
if
(
item_centralized
==
NULL
||
item_panId
==
NULL
||
item_txPower
==
NULL
||
item_channel
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
if
(
item_centralized
->
type
!=
cJSON_Number
||
item_panId
->
type
!=
cJSON_Number
||
item_txPower
->
type
!=
cJSON_Number
||
item_channel
->
type
!=
cJSON_Number
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
status
=
nwkFormCMD
(
item_centralized
->
valueint
,
item_panId
->
valueint
,
item_txPower
->
valueint
,
item_channel
->
valueint
);
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkStar
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkaddChMaskCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"1
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwksubChMaskCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwksetChMaskCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkgetChMaskCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkPermitJoinWithKeyCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"1
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkSetJoiningLinkKeyCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"1
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkClearJoiningLinkKeyCMD
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
kk_print_debug
(
"2
\r\n
"
);
return
rpc_cJSON_CreateNull
();
}
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_onoff.c
deleted
100644 → 0
View file @
d61a4575
#include "RPC_API.h"
#include "rpc_onoff.h"
cJSON
*
rpc_zclOnOff_On
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
status
=
zclOnOff_On
(
node
,
ep
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclOnOff_Off
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
status
=
zclOnOff_Off
(
node
,
ep
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclOnOff_Toggle
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
status
=
zclOnOff_Toggle
(
node
,
ep
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclOnOff_OffWithEffect
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_id
;
cJSON
*
item_var
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_id
=
cJSON_GetObjectItem
(
params
,
"identifier"
);
item_var
=
cJSON_GetObjectItem
(
params
,
"variant"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_id
==
NULL
||
item_var
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_id
->
type
!=
cJSON_String
||
item_var
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"identifier=%s
\n
"
,
item_id
->
valuestring
);
kk_print_debug
(
"variant=%s
\n
"
,
item_var
->
valuestring
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
identifier
=
rpc_get_u8
(
item_id
->
valuestring
);
uint8_t
var
=
rpc_get_u8
(
item_var
->
valuestring
);
status
=
zclOnOff_OffWithEffect
(
node
,
ep
,
identifier
,
var
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclOnOff_OnWithRecallGlobalScene
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
status
=
zclOnOff_OnWithRecallGlobalScene
(
node
,
ep
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_zclOnOff_OnWithTimedOff
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
item_node
;
cJSON
*
item_ep
;
cJSON
*
item_control
;
cJSON
*
item_OnTime
;
cJSON
*
item_OffWaitTime
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
item_node
=
cJSON_GetObjectItem
(
params
,
"node"
);
item_ep
=
cJSON_GetObjectItem
(
params
,
"dstEP"
);
item_control
=
cJSON_GetObjectItem
(
params
,
"control"
);
item_OnTime
=
cJSON_GetObjectItem
(
params
,
"OnTime"
);
item_OffWaitTime
=
cJSON_GetObjectItem
(
params
,
"OffWaitTime"
);
}
if
(
item_node
==
NULL
||
item_ep
==
NULL
||
item_control
==
NULL
||
item_OnTime
==
NULL
||
item_OffWaitTime
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
"1.....
\n
"
);
goto
error_return
;
}
if
(
item_node
->
type
!=
cJSON_String
||
item_ep
->
type
!=
cJSON_String
||
item_control
->
type
!=
cJSON_String
||
item_OnTime
->
type
!=
cJSON_String
||
item_OffWaitTime
->
type
!=
cJSON_String
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
kk_print_debug
(
".2....
\n
"
);
goto
error_return
;
}
kk_print_debug
(
"node=%s
\n
"
,
item_node
->
valuestring
);
kk_print_debug
(
"dstEP=%s
\n
"
,
item_ep
->
valuestring
);
kk_print_debug
(
"control=%s
\n
"
,
item_control
->
valuestring
);
kk_print_debug
(
"OnTime=%s
\n
"
,
item_OnTime
->
valuestring
);
kk_print_debug
(
"OffWaitTime=%s
\n
"
,
item_OffWaitTime
->
valuestring
);
uint16_t
node
=
rpc_get_u16
(
item_node
->
valuestring
);
uint8_t
ep
=
rpc_get_u8
(
item_ep
->
valuestring
);
uint8_t
control
=
rpc_get_u8
(
item_control
->
valuestring
);
uint16_t
OnTime
=
rpc_get_u16
(
item_OnTime
->
valuestring
);
uint16_t
OffWaitTime
=
rpc_get_u16
(
item_OffWaitTime
->
valuestring
);
status
=
zclOnOff_OnWithTimedOff
(
node
,
ep
,
control
,
OnTime
,
OffWaitTime
);
if
(
status
==
EMBER_ZCL_STATUS_SUCCESS
){
kk_print_debug
(
"send suc."
);
}
else
{
kk_print_debug
(
"send fail!status=0x%02X
\r\n
"
,
status
);
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.c
View file @
33a3264b
...
@@ -96,6 +96,104 @@ extern void kk_ota_test111();
...
@@ -96,6 +96,104 @@ extern void kk_ota_test111();
extern
void
kk_ota_test123123123
();
extern
void
kk_ota_test123123123
();
extern
void
aaaBBB
();
extern
void
aaaBBB
();
extern
void
kk_tsl_msg_ack
(
const
char
*
id
,
const
char
*
ackMsgType
,
const
char
*
productCode
,
const
char
*
deviceCode
);
extern
void
kk_tsl_msg_ack
(
const
char
*
id
,
const
char
*
ackMsgType
,
const
char
*
productCode
,
const
char
*
deviceCode
);
extern
void
TEST2
(
void
);
char
aaaaaaaaaa
[]
=
"{\
\"
info
\"
: {\
\"
msgtype
\"
:
\"
/thing/service/property/get
\"
,\
\"
productCode
\"
:
\"
3003
\"
,\
\"
deviceCode
\"
:
\"
1122334455667788
\"
\
\},\
\"
payload
\"
: {\
\"
msgId
\"
:
\"
11
\"
,\
\"
version
\"
:
\"
1.0
\"
,\
\"
params
\"
: {\
\"
identifier
\"
: [
\"
PowerSwitch_1
\"
,
\"
PowerSwitch_2
\"
,
\"
PowerSwitch_3
\"
]\
},\
\"
time
\"
:
\"
1603359090
\"
,\
\"
method
\"
:
\"
thing.service.property.get
\"
\
}\
}"
;
void
TEST2
(
void
)
{
_cb
(
aaaaaaaaaa
,
strlen
(
aaaaaaaaaa
),
NULL
);
/*
char *ptr;
cJSON *root = rpc_cJSON_CreateObject();
cJSON *info = rpc_cJSON_CreateObject();
cJSON *payload = rpc_cJSON_CreateObject();
cJSON *params = rpc_cJSON_CreateObject();
cJSON *array = rpc_cJSON_CreateArray();
rpc_cJSON_AddItemToObject(root, "info", info);
rpc_cJSON_AddItemToObject(root, "payload", payload);
rpc_cJSON_AddStringToObject(info, "msgtype","/thing/service/property/get");
rpc_cJSON_AddStringToObject(info, "productCode","83");
rpc_cJSON_AddStringToObject(info, "deviceCode","1023");
rpc_cJSON_AddStringToObject(payload, "msgId","123");
rpc_cJSON_AddStringToObject(payload, "version","1.0");
rpc_cJSON_AddItemToObject(payload, "params", params);
rpc_cJSON_AddItemToObject(params, "identifier", array);
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_AddStringToObject(root, "method","thing.service.property.get");
ptr = rpc_cJSON_Print(root);
printf("--->%s\n",ptr);
free(ptr);
ncp_queue_enqueue(REV_MSG,(void *)root);
*/
}
extern
struct
jrpc_server
*
kk_get_jrpc_server
(
void
);
void
aaaBBB
()
{
struct
jrpc_server
*
server
=
kk_get_jrpc_server
();
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
(
server
,
params
,
id
,
mac
);
}
void
kk_message_process
(
char
*
messageString
)
void
kk_message_process
(
char
*
messageString
)
{
{
...
@@ -118,7 +216,7 @@ void kk_message_process(char *messageString)
...
@@ -118,7 +216,7 @@ void kk_message_process(char *messageString)
}
}
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST1
\r\n
"
,
len
)
==
0
){
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST1
\r\n
"
,
len
)
==
0
){
kk_ota_test123123123
();
TEST2
();
}
}
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST
\r\n
"
,
len
)
==
0
){
if
(
MEMCOMPARE
(
messageString
,
"AT+TEST
\r\n
"
,
len
)
==
0
){
aaaBBB
();
aaaBBB
();
...
...
platform/zigbee/app/builder/Z3GatewayHost/yjq_ezsp.h
View file @
33a3264b
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "app/util/serial/command-interpreter2.h"
#include "app/util/serial/command-interpreter2.h"
#include "app/util/zigbee-framework/zigbee-device-common.h"
#include "app/util/zigbee-framework/zigbee-device-common.h"
#include "network-cli.h"
#include "network-cli.h"
#include "kk_
zb_com
.h"
#include "kk_
ncp_common
.h"
#define emberAfAppPrint(...) emberAfPrint(EMBER_AF_PRINT_APP, __VA_ARGS__)
#define emberAfAppPrint(...) emberAfPrint(EMBER_AF_PRINT_APP, __VA_ARGS__)
...
...
platform/zigbee/protocol/zigbee/app/framework/plugin/device-table/device-table.c
View file @
33a3264b
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include "app/framework/plugin/device-table/device-table-internal.h"
#include "app/framework/plugin/device-table/device-table-internal.h"
#include "app/framework/util/util.h"
#include "app/framework/util/util.h"
#include <stdlib.h>
#include <stdlib.h>
#include <kk_test.h>
void
emAfDeviceTableSave
(
void
);
void
emAfDeviceTableSave
(
void
);
...
...
platform/zigbee/protocol/zigbee/app/framework/util/af-main-host.c
View file @
33a3264b
...
@@ -46,11 +46,10 @@
...
@@ -46,11 +46,10 @@
#include "afv2-bookkeeping.h"
#include "afv2-bookkeeping.h"
#include "yjq_ezsp.h"
#include "yjq_ezsp.h"
#include "./rpc_api/inc/rpc_interface_parse.h"
#include <pthread.h>
#include <pthread.h>
#include <fcntl.h>
#include <fcntl.h>
#include "kk_ncp_common.h"
pthread_mutex_t
g_mutex_lock
;
pthread_mutex_t
g_mutex_lock
;
...
@@ -564,13 +563,6 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
...
@@ -564,13 +563,6 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
return
-
1
;
return
-
1
;
}
}
/*int pid=fork();
if(pid==0){
rpcInterfaceParse();
}*/
emberAfCoreFlush
();
emberAfCoreFlush
();
...
@@ -595,11 +587,9 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
...
@@ -595,11 +587,9 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
kk_topo_batch_handle_init
();
kk_topo_batch_handle_init
();
kk_device_gateway_add
(
eui64
);
kk_device_gateway_add
(
eui64
);
pthread_t
tid
;
pthread_t
prey_tid
;
//pthread_create(&tid, NULL, rpcInterfaceParse, NULL);
kk_thread_init
();
pthread_create
(
&
tid
,
NULL
,
ipcHandle
,
NULL
);
pthread_create
(
&
prey_tid
,
NULL
,
ncp_queue_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