Commit 8d64d301 authored by 尹佳钦's avatar 尹佳钦

2020/8/11 提交

parent 6e247767
...@@ -71,6 +71,56 @@ bool kk_rpc_report_LightStatus(EmberEUI64 mac,bool LightStatus) ...@@ -71,6 +71,56 @@ bool kk_rpc_report_LightStatus(EmberEUI64 mac,bool LightStatus)
kk_rpc_report_status(root,mac); kk_rpc_report_status(root,mac);
} }
cJSON *rpc_read_attribue(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
{
rpc_nwk_info_s info;
EmberStatus status;
if(params == NULL){
emberAfCorePrintln("\r\nparams == NULL\r\n" );
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
}else{
cJSON *LightStatus_item = rpc_cJSON_GetObjectItem(params, "LightStatus");
uint8_t LightStatus = rpc_get_u8(LightStatus_item->valuestring);
uint8_t eui64[EUI64_SIZE];
bool flag= rpc_get_mac(mac->valuestring,eui64);
emberAfCorePrintBuffer(eui64,EUI64_SIZE,true);
for(int i=0;i<EUI64_SIZE;i++){
emberAfCorePrintln("i=%d,val=%02x",i,eui64[i]);
}
EmberNodeId node = emberAfDeviceTableGetNodeIdFromEui64(eui64);
if(node==0xffff){
emberAfCorePrintln("\r\n not find device!\r\n" );
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
}
emberAfCorePrintln("\r\nnode=0x%02X,LightStatus=%d\r\n",node,LightStatus);
if(flag){
EmberStatus status;
if(LightStatus==1){
status = zclOnOff_On(node,1);
emberAfCorePrintln("\r\nzclOnOff_On\r\n" );
}else if(LightStatus==0){
status = zclOnOff_Off(node,1);
emberAfCorePrintln("\r\nzclOnOff_Off\r\n" );
}else{
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
}
}else{
emberAfCorePrintln("\r\n22222\r\n" );
set_json_error_type(ctx,JRPC_INVALID_PARAMS,MSG_INVALID_PARAMS);
goto error_return;
}
return rpc_cJSON_CreateNumber(status);
}
error_return:
return rpc_cJSON_CreateNull();
}
cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac) cJSON *rpc_Control(jrpc_context * ctx, cJSON *params, cJSON *id,cJSON *mac)
......
...@@ -9,14 +9,16 @@ ...@@ -9,14 +9,16 @@
#define KK_REPORT_DEVICE_JOINED_METHOD "thing.topo.add" #define KK_REPORT_DEVICE_JOINED_METHOD "thing.topo.add"
#define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.leave" #define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.leave"
#define KK_REPORT_ATTRIBUTE_METHOD "thing.service.property.report" #define KK_REPORT_ATTRIBUTE_METHOD "thing.service.property.report"
#define KK_READ_ATTRIBUTE_METHOD "thing.service.property.get"
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);
#define RPC_KK_TEST_FUNCTION_TABLE \ #define RPC_KK_TEST_FUNCTION_TABLE \
{(rpc_function*)rpc_Control,"thing.service.property.set"},\ {(rpc_function*)rpc_Control,"thing.service.property.set"},\
{(rpc_function*)rpc_Control,KK_READ_ATTRIBUTE_METHOD},\
{(rpc_function*)rpc_nwkPermitJoin,"thing.service.NetChannelState.set"} {(rpc_function*)rpc_nwkPermitJoin,"thing.service.NetChannelState.set"}
...@@ -37,4 +39,5 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac); ...@@ -37,4 +39,5 @@ cJSON *rpc_Control(jrpc_context * ctx, cJSON * params, cJSON *id,cJSON *mac);
#endif #endif
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