Commit a84179ef authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

【修改内容】修改根据配置文件来实现面板的控制和属性上报

See merge request chenweican/k-sdk!7
parents 1df76f11 2c711cbb
...@@ -3,18 +3,11 @@ ...@@ -3,18 +3,11 @@
"config":[ "config":[
{ {
"identity":"PowerSwitch_1", "identity":"PowerSwitch_1",
"endpoint":18, "endpoint":1,
"cluster":"0x0011", "cluster":"0x0006",
"attribute":"0x0022", "attribute":"0x0000",
"reportFunc":"A", "reportFunc":"kk_tsl_report_global_onoff",
"controlFunc":"B" "controlFunc":"zclOnOff"
},{
"identity":"PowerSwitch_2",
"endpoint":19,
"cluster":"0x0033",
"attribute":"0x0044",
"reportFunc":"C",
"controlFunc":"D"
} }
] ]
} }
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
"productCode":"3002", "productCode":"3002",
"config":[ "config":[
{ {
"identity":"AAA", "identity":"PowerSwitch_1",
"endpoint":11, "endpoint":1,
"cluster":"0x1111", "cluster":"0x0006",
"attribute":"0x2222", "attribute":"0x0000",
"reportFunc":"zclOnOff_On", "reportFunc":"kk_tsl_report_global_onoff",
"controlFunc":"zclOnOff_On" "controlFunc":"zclOnOff"
},{ },{
"identity":"BBB", "identity":"PowerSwitch_2",
"endpoint":22, "endpoint":2,
"cluster":"0x3333", "cluster":"0x0006",
"attribute":"0x4444", "attribute":"0x0000",
"reportFunc":"zclOnOff_Off", "reportFunc":"kk_tsl_report_global_onoff",
"controlFunc":"zclOnOff_Off" "controlFunc":"zclOnOff"
} }
] ]
} }
...@@ -2,26 +2,26 @@ ...@@ -2,26 +2,26 @@
"productCode":"3003", "productCode":"3003",
"config":[ "config":[
{ {
"identity":"AAA", "identity":"PowerSwitch_1",
"endpoint":11, "endpoint":1,
"cluster":"0x1111", "cluster":"0x0006",
"attribute":"0x2222", "attribute":"0x0000",
"reportFunc":"zclOnOff_On", "reportFunc":"kk_tsl_report_global_onoff",
"controlFunc":"zclOnOff_On" "controlFunc":"zclOnOff"
},{ },{
"identity":"BBB", "identity":"PowerSwitch_2",
"endpoint":22, "endpoint":2,
"cluster":"0x3333", "cluster":"0x0006",
"attribute":"0x4444", "attribute":"0x0000",
"reportFunc":"zclOnOff_Off", "reportFunc":"kk_tsl_report_global_onoff",
"controlFunc":"zclOnOff_Off" "controlFunc":"zclOnOff"
},{ },{
"identity":"CCCC", "identity":"PowerSwitch_3",
"endpoint":33, "endpoint":3,
"cluster":"0x5555", "cluster":"0x0006",
"attribute":"0x6666", "attribute":"0x0000",
"reportFunc":"zclOnOff_Off", "reportFunc":"kk_tsl_report_global_onoff",
"controlFunc":"zclOnOff_Off" "controlFunc":"zclOnOff"
} }
] ]
} }
#include "kk_device_manager.h" #include "kk_device_manager.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -417,24 +415,7 @@ char *kk_match_productCode(const char* modelId) ...@@ -417,24 +415,7 @@ char *kk_match_productCode(const char* modelId)
return NULL; return NULL;
} }
typedef struct kk_dev_config_item{
char * identity;
char * reportFuncName;
char * controlFuncName;
kk_rpc_report * reportFunc;
kk_rpc_set * controlFunc;
uint8_t endpoint;
uint16_t cluster;
uint16_t attribute;
struct kk_dev_config_item * next;
}kk_dev_config_item;
typedef struct kk_dev_config_map{
char * productCode;
kk_dev_config_item item;
struct kk_dev_config_map *next;
}kk_dev_config_map;
static kk_dev_config_map *dev_config_map = NULL; static kk_dev_config_map *dev_config_map = NULL;
#define KK_DEVICE_CONFIG_MAP_TABLE_FILE_PREFIX "./ZB/dev_config_table/device_%s.json" #define KK_DEVICE_CONFIG_MAP_TABLE_FILE_PREFIX "./ZB/dev_config_table/device_%s.json"
...@@ -449,6 +430,7 @@ kk_dev_config_item *kk_device_config_item_find_by_identity(kk_dev_config_map * m ...@@ -449,6 +430,7 @@ kk_dev_config_item *kk_device_config_item_find_by_identity(kk_dev_config_map * m
if(!strcmp(item->identity,identity)){ if(!strcmp(item->identity,identity)){
return item; return item;
} }
item = item->next;
} }
return NULL; return NULL;
} }
......
...@@ -42,9 +42,29 @@ char *kk_match_productCode(const char* modelId); ...@@ -42,9 +42,29 @@ char *kk_match_productCode(const char* modelId);
bool kk_device_config_map_add(const char *productCode); bool kk_device_config_map_add(const char *productCode);
typedef int (*kk_rpc_set)(jrpc_context * ctx,EmberNodeId node,unsigned char ep,void* data);
typedef int(*kk_rpc_report)(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
typedef struct kk_dev_config_item{
char * identity;
char * reportFuncName;
char * controlFuncName;
kk_rpc_report * reportFunc;
kk_rpc_set * controlFunc;
uint8_t endpoint;
uint16_t cluster;
uint16_t attribute;
struct kk_dev_config_item * next;
}kk_dev_config_item;
typedef struct kk_dev_config_map{
char * productCode;
kk_dev_config_item item;
struct kk_dev_config_map *next;
}kk_dev_config_map;
......
#include "kk_tsl_property_report.h" #include "kk_tsl_property_report.h"
#include "kk_tsl_zigbee_map.h" #include "kk_tsl_zigbee_map.h"
#include "kk_device_manager.h"
const char *kk_tsl_rpt_status_string[] = { const char *kk_tsl_rpt_status_string[] = {
"Success", "Success",
...@@ -16,28 +17,35 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId ...@@ -16,28 +17,35 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
char *Identify; char *Identify;
sub_dev_node_t *node = NULL; sub_dev_node_t *node = NULL;
kk_device_table_s *dev; kk_device_table_s *dev;
kk_dev_config_map *dev_info = NULL;
kk_dev_config_item *item = NULL;
char macString[RPC_EUI64_STRING_LENGTH]; char macString[RPC_EUI64_STRING_LENGTH];
rpc_eui64ToString(mac,macString); rpc_eui64ToString(mac,macString);
root = rpc_cJSON_CreateObject(); root = rpc_cJSON_CreateObject();
index = kk_get_tsl_index(EP,clusterId,attributeId); dev = kk_device_find_by_mac(mac);
if(dev == NULL){
return tsl_rpt_err;
}
printf("[%s][%d]dev->productCode:%s\n",__FUNCTION__,__LINE__,dev->productCode);
dev_info = kk_device_config_find(dev->productCode);
if(dev_info == NULL){
return tsl_rpt_err;
}
if(index < 0){ item = &dev_info->item;
dev = kk_device_find_by_mac(mac); while(item!=NULL){
if(dev!=NULL){ if(EP == item->endpoint &&
index = kk_get_tsl_glb_index(dev->productCode,EP,clusterId,attributeId); clusterId == item->cluster&&
} attributeId == item->attribute){
Identify = item->identity;
if(index < 0){
return tsl_rpt_err; break;
}else{
Identify = g_tsl_zigbee_map_glb[index].map.Identity;
} }
}else{ item = item->next;
Identify = g_tsl_zigbee_map[index].Identity;
} }
rpc_cJSON_AddNumberToObject(root, Identify,status); rpc_cJSON_AddNumberToObject(root, Identify,status);
kk_msg_report_property(root,mac); kk_msg_report_property(root,mac);
return tsl_rpt_success; return tsl_rpt_success;
......
...@@ -19,7 +19,7 @@ typedef struct{ ...@@ -19,7 +19,7 @@ typedef struct{
void kk_rpc_test(void); void kk_rpc_test(void);
#define KK_RPC_SET_FUNCTION_TABLE {\ #define KK_RPC_SET_FUNCTION_TABLE {\
{"zclOnOff_On",zclOnOff_On},\ {"zclOnOff",kk_tsl_set_gloabl_OnOff},\
{"zclOnOff_Off",zclOnOff_Off}\ {"zclOnOff_Off",zclOnOff_Off}\
} }
......
...@@ -31,7 +31,7 @@ void emAfTick(void) ...@@ -31,7 +31,7 @@ void emAfTick(void)
{ {
emberAfMainTickCallback(); emberAfMainTickCallback();
emberAfOtaServerTick(); emberAfOtaServerTick();
emberAfPluginGatewayTickCallback(); //emberAfPluginGatewayTickCallback();
emberAfPluginHeartbeatTickCallback(); emberAfPluginHeartbeatTickCallback();
emberAfTick(); emberAfTick();
} }
......
...@@ -205,8 +205,8 @@ error_return: ...@@ -205,8 +205,8 @@ error_return:
void emberAfMainTickCallback(void) void emberAfMainTickCallback(void)
{ {
static int last_time; static unsigned int last_time;
int time = halCommonGetInt32uMillisecondTick(); unsigned int time = halCommonGetInt32uMillisecondTick();
if((time-last_time)>=1000){ if((time-last_time)>=1000){
last_time = time; last_time = time;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "kk_device_table_db.h" #include "kk_device_table_db.h"
#define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add" #define KK_REPORT_DEVICE_JOINED_TYPE "/thing/topo/add"
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete" #define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post" #define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
......
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