Commit ebff3b9d authored by 黄振令's avatar 黄振令
parents 7eae9e10 f379631d
...@@ -195,6 +195,59 @@ int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* d ...@@ -195,6 +195,59 @@ int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* d
error_return: error_return:
return -1; 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);
int kk_zcl_windowCovering_OperationMode_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data)
{
uint8_t eui64[EUI64_SIZE];
uint8_t Operation = 0;
EmberStatus status = 0;
EmberNodeId node = 0xffff;
Operation = *(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\nnode=0x%02X,ep=%d,OnOffStatus=%d\r\n",node,ep,Operation);
if(Operation==0){
status = WindowCover_UpOpen(node,ep);
emberAfCorePrintln("\r\nUp/Open,status=0x%x\r\n",status);
}else if(Operation==1){
status = WindowCover_DownClose(node,ep);
emberAfCorePrintln("\r\nDown/Close,status=0x%x\r\n",status);
}else if(Operation==2){
status = WindowCover_Stop(node,ep);
emberAfCorePrintln("\r\nStop,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;
}
int kk_zcl_windowCovering_mode_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data) int kk_zcl_windowCovering_mode_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data)
{ {
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
cJSON *rpc_Control(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac); cJSON *rpc_Control(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac);
cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac); cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac);
int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data); int kk_zcl_onoff_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data);
int kk_zcl_windowCovering_OperationMode_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data);
int kk_zcl_windowCovering_mode_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data); int kk_zcl_windowCovering_mode_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data);
int kk_zcl_windowCovering_position_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data); int kk_zcl_windowCovering_position_set(jrpc_context * ctx,const char *mac,unsigned char ep,void* data);
......
...@@ -16,7 +16,7 @@ kk_tsl_zigbee_map_t g_tsl_zigbee_map [] = { ...@@ -16,7 +16,7 @@ kk_tsl_zigbee_map_t g_tsl_zigbee_map [] = {
TEST_PRODUCT_CODE, TEST_PRODUCT_CODE,
3, 3,
{ {
{KK_TSL_DATA_TYPE_TEXT,"OperationMode",KK_PRIMARY_EP,kk_zcl_onoff_set,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID},//开 {KK_TSL_DATA_TYPE_TEXT,"OperationMode",KK_PRIMARY_EP,kk_zcl_windowCovering_OperationMode_set,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID},//开
{KK_TSL_DATA_TYPE_TEXT,"WorkMode",KK_PRIMARY_EP,kk_zcl_windowCovering_mode_set,ZCL_WINDOW_COVERING_CLUSTER_ID,ZCL_MODE_ATTRIBUTE_ID}, {KK_TSL_DATA_TYPE_TEXT,"WorkMode",KK_PRIMARY_EP,kk_zcl_windowCovering_mode_set,ZCL_WINDOW_COVERING_CLUSTER_ID,ZCL_MODE_ATTRIBUTE_ID},
{KK_TSL_DATA_TYPE_TEXT,"Position",KK_PRIMARY_EP,kk_zcl_windowCovering_position_set,ZCL_WINDOW_COVERING_CLUSTER_ID,ZCL_CURRENT_LIFT_ATTRIBUTE_ID}, {KK_TSL_DATA_TYPE_TEXT,"Position",KK_PRIMARY_EP,kk_zcl_windowCovering_position_set,ZCL_WINDOW_COVERING_CLUSTER_ID,ZCL_CURRENT_LIFT_ATTRIBUTE_ID},
} }
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
#include "RPC_API.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 WindowCover_GotoLiftPercentage(uint16_t node,uint8_t ep,uint8_t position);
EmberStatus zclOnOff_On(uint16_t node,uint8_t ep); EmberStatus zclOnOff_On(uint16_t node,uint8_t ep);
......
...@@ -73,6 +73,32 @@ EmberStatus zclGRead(uint16_t node, ...@@ -73,6 +73,32 @@ EmberStatus zclGRead(uint16_t node,
return status; return status;
} }
EmberStatus zclGWrite(uint16_t node,
uint8_t srcEP,
uint8_t dstEP,
bool multicast,
uint16_t clusterId,
uint16_t attrId,
uint8_t dataType,
uint8_t dataLen,
uint8_t *data,
bool svr)
{
EmberStatus status;
zclBufferSetup(ZCL_GLOBAL_COMMAND | ((svr==true)?
ZCL_FRAME_CONTROL_CLIENT_TO_SERVER
:ZCL_FRAME_CONTROL_SERVER_TO_CLIENT),
clusterId,
ZCL_WRITE_ATTRIBUTES_COMMAND_ID);
zclBufferAddByte(LOW_BYTE(attrId));
zclBufferAddByte(HIGH_BYTE(attrId));
rpcBufferPrint();
status = rpcSendCommand(node,srcEP,dstEP,multicast);
return status;
}
......
...@@ -2,6 +2,36 @@ ...@@ -2,6 +2,36 @@
#include "rpc_onoff.h" #include "rpc_onoff.h"
EmberStatus WindowCover_UpOpen(uint16_t node,uint8_t ep)
{
EmberStatus status;
zcl_clu_client_cmd_buffer_setup( ZCL_WINDOW_COVERING_CLUSTER_ID,
ZCL_WINDOW_COVERING_UP_OPEN_COMMAND_ID);
status = rpcSendCommand(node,1,ep,false);
kk_print_debug("[Up/Open]node=0x%02X,ep=%d,status=0x%02X\n",node,ep,status);
return status;
}
EmberStatus WindowCover_DownClose(uint16_t node,uint8_t ep)
{
EmberStatus status;
zcl_clu_client_cmd_buffer_setup( ZCL_WINDOW_COVERING_CLUSTER_ID,
ZCL_WINDOW_COVERING_DOWN_CLOSE_COMMAND_ID);
status = rpcSendCommand(node,1,ep,false);
kk_print_debug("[Down/Close]node=0x%02X,ep=%d,status=0x%02X\n",node,ep,status);
return status;
}
EmberStatus WindowCover_Stop(uint16_t node,uint8_t ep)
{
EmberStatus status;
zcl_clu_client_cmd_buffer_setup( ZCL_WINDOW_COVERING_CLUSTER_ID,
ZCL_WINDOW_COVERING_STOP_COMMAND_ID);
status = rpcSendCommand(node,1,ep,false);
kk_print_debug("[Stop]node=0x%02X,ep=%d,status=0x%02X\n",node,ep,status);
return status;
}
EmberStatus WindowCover_GotoLiftPercentage(uint16_t node,uint8_t ep,uint8_t position) EmberStatus WindowCover_GotoLiftPercentage(uint16_t node,uint8_t ep,uint8_t position)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment