Commit 2f74adb5 authored by 陈伟灿's avatar 陈伟灿

Merge branch 'yjq' into 'master'

Yjq

See merge request chenweican/k-sdk!32
parents c1141a95 2a4c6f81
{
"mapTable": [
{
"modleId": "00068611",
"productCode": "3001",
"productName": "星辰系列.白色零火线单路灯控面板Z3S(KONKE)"
},{
"modleId": "00068612",
"productCode": "3002",
"productName": "星辰系列.白色零火线双路灯控面板Z3S(KONKE)"
},{
"modleId": "00068613",
"productCode": "3003",
"productName": "星辰系列.白色零火线三路灯控面板Z3S(KONKE)"
},{
"modleId": "00048611",
"productCode": "3004",
"productName": "星辰系列.白色零火线情景面板Z3S(KONKE)"
},{
"modleId": "00038611",
"productCode": "3005",
"productName": "星辰系列.白色零火线单路窗帘面板Z3S(KONKE)"
},{
"modleId": "00038612",
"productCode": "3006",
"productName": "星辰系列.白色零火线双路窗帘面板Z3S(KONKE)"
},{
"modleId": "00038613",
"productCode": "3007",
"productName": "星辰系列·白色干触点单路窗帘面板Z3S(KONKE)"
},{
"modleId": "00038614",
"productCode": "3008",
"productName": "星辰系列·白色干触点双路窗帘面板Z3S(KONKE)"
},{
"modleId": "00068601",
"productCode": "3009",
"productName": "铂金系列.白色零火线单路灯控面板Z3S(KONKE)"
},{
"modleId": "00068602",
"productCode": "3010",
"productName": "铂金系列.白色零火线双路灯控面板Z3S(KONKE)"
},{
"modleId": "00068603",
"productCode": "3011",
"productName": "铂金系列.白色零火线三路灯控面板Z3S(KONKE)"
},{
"modleId": "00038601",
"productCode": "3012",
"productName": "铂金系列.白色零火线窗帘面板Z3S(KONKE)"
},{
"modleId": "00048601",
"productCode": "3013",
"productName": "铂金系列.白色零火线情景面板Z3S(KONKE)"
},{
"modleId": "00048602",
"productCode": "3014",
"productName": "铂金系列.白色快捷面板Z3S(KONKE)"
},{
"modleId": "0402812C",
"productCode": "3016",
"productName": "铂金系列.白色紧急呼叫按钮Z3S(KONKE)"
},{
"modleId": "0402802C",
"productCode": "3015",
"productName": "铂金系列.白色零火线SOS紧急呼叫面板Z3S(KONKE)"
},{
"modleId": "00038603",
"productCode": "3017",
"productName": "铂金系列.白色零火线推窗器面板Z3S(KONKE)"
},{
"modleId": "01018601",
"productCode": "3018",
"productName": "铂金系列.白色零火线调光面板Z3S(KONKE)"
},{
"modleId": "3019",
"productCode": "00518610",
"productName": "铂金系列.白色10A智能插座Z3S(KONKE)"
},{
"modleId": "00518616",
"productCode": "3020",
"productName": "铂金系列.白色16A智能插座Z3S(KONKE)"
},{
"modleId": "00038602",
"productCode": "3021",
"productName": "铂金系列·白色干触点窗帘面板Z3S(安心加)"
},{
"modleId": "00068621",
"productCode": "3022",
"productName": "肖邦系列.白色零火线单路灯控面板Z3S(KONKE)"
},{
"modleId": "00068622",
"productCode": "3023",
"productName": "肖邦系列.白色零火线双路灯控面板Z3S(KONKE)"
},{
"modleId": "00068623",
"productCode": "3024",
"productName": "肖邦系列.白色零火线三路灯控面板Z3S(KONKE)"
},{
"modleId": "00048621",
"productCode": "3025",
"productName": "肖邦系列.白色零火线情景面板Z3S(KONKE)"
},{
"modleId": "00038621",
"productCode": "3026",
"productName": "肖邦系列.白色零火线单路窗帘面板Z3S(KONKE)"
},{
"modleId": "00038622",
"productCode": "3027",
"productName": "肖邦系列.白色零火线双路窗帘面板Z3S(KONKE)"
},{
"modleId": "00518620",
"productCode": "3037",
"productName": "肖邦系列.白色10A智能插座Z3S(KONKE)"
},{
"modleId": "00518626",
"productCode": "3038",
"productName": "肖邦系列.白色16A智能插座Z3S(KONKE)"
},{
"modleId": "0402002A",
"productCode": "3039",
"productName": "水浸传感器-HZB30S版(KONKE)"
},{
"modleId": "0402002B",
"productCode": "3040",
"productName": "燃气报警器-HZ3S版(KONKE)"
},{
"modleId": "04020028",
"productCode": "3041",
"productName": "烟雾报警器-HZ3S版(KONKE)"
},{
"modleId": "3041",
"productCode": "3080",
"productName": "燃气报警器-豪恩版(iHORN)"
},{
"modleId": "3050",
"productCode": "3081",
"productName": "烟雾报警器-豪恩版(iHORN)"
},{
"modleId": "3043",
"productCode": "0402010D",
"productName": "红外幕帘探测器HZ3S版(KONKE)"
},{
"modleId": "03020001",
"productCode": "3076",
"productName": "环境传感器KZ3S(KONKE)"
},{
"modleId": "00510001",
"productCode": "3046",
"productName": "KIT系列.白色快捷情景按钮"
},{
"modleId": "03020000",
"productCode": "3048",
"productName": "KIT系列.白色温湿度传感器"
},{
"modleId": "0402000D",
"productCode": "1035",
"productName": "KIT系列.白色人体传感器"
},{
"modleId": "04020015",
"productCode": "3050",
"productName": "KIT系列.白色门窗传感器"
},{
"modleId": "04021015",
"productCode": "3051",
"productName": "邦德系列.白色门窗传感器(KONKE)"
},{
"modleId": "0402102C",
"productCode": "3054",
"productName": "邦德系列.白色SOS按钮(KONKE)"
},{
"modleId": "0402102A",
"productCode": "3055",
"productName": "邦德系列.白色水浸传感器(KONKE)"
},{
"modleId": "00040002",
"productCode": "3056",
"productName": "邦德系列.白色快捷按键(KONKE)"
},{
"modleId": "04031225",
"productCode": "3057",
"productName": "邦德系列.白色声光传感器(KONKE)"
},{
"modleId": "02020000",
"productCode": "3067",
"productName": "智能窗帘电机Z3S(KONKE)(说明:杜亚款)"
},{
"modleId": "02020001",
"productCode": "3068",
"productName": "威刚系列.智能窗帘电机Z3S(KONKE)(说明:威士达款)"
},{
"modleId": "01000002",
"productCode": "3069",
"productName": "双路智能灯控模块Z3S(KONKE)"
},{
"modleId": "04028301",
"productCode": "3070",
"productName": "传感器模块Z3S(KONKE)"
},{
"modleId": "03300001",
"productCode": "3071",
"productName": "智能水阀控制器Z3S(KONKE)"
},{
"modleId": "03310001",
"productCode": "3072",
"productName": "智能燃气机械臂控制器Z3S(KONKE)"
},{
"modleId": "01020001",
"productCode": "3073",
"productName": "幻彩灯带控制器Z3S(KONKE)"
},{
"modleId": "00648631",
"productCode": "3077",
"productName": "多功能面板(亚运村临时项目)"
}
]
}
{
"productCode":"1008",
"config":[
{
"identity":"SosState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"sosAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"1012",
"config":[
{
"identity":"SosState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"sosAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"1015",
"config":[
{
"identity":"GasSensorState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"gasAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"1008",
"config":[
{
"identity":"SosState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"sosAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"1023",
"config":[
{
"identity":"ContactState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"contactAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"1024",
"config":[
{
"identity":"WaterSensorState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"waterAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"1035",
"config":[
{
"identity":"MotionAlarmState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"motionAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"135",
"config":[
{
"identity":"ContactState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"contactAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"140",
"config":[
{
"identity":"SmokeSensorState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"smokeAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"141",
"config":[
{
"identity":"GasSensorState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"gasAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"26",
"config":[
{
"identity":"MotionAlarmState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"motionAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
{
"productCode":"27",
"config":[
{
"identity":"SmokeSensorState",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"kk_tsl_report_iasZoneStatus",
"controlFunc":""
},{
"identity":"Battery",
"endpoint":1,
"cluster":"0x0001",
"attribute":"0x0021",
"iasStatusMask":"0x0008",
"reportFunc":"kk_tsl_report_battery",
"controlFunc":""
},{
"identity":"smokeAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0001",
"reportFunc":"",
"controlFunc":""
},{
"identity":"batteryAlarm",
"endpoint":1,
"cluster":"0x0500",
"attribute":"0x0002",
"iasStatusMask":"0x0008",
"reportFunc":"",
"controlFunc":""
}
]
}
\ No newline at end of file
......@@ -154,7 +154,7 @@
"productName": "KIT系列.白色温湿度传感器"
},{
"modleId": "0402000D",
"productCode": "3049",
"productCode": "1035",
"productName": "KIT系列.白色人体传感器"
},{
"modleId": "04020015",
......
......@@ -156,6 +156,9 @@ void emberAfPluginDeviceTableDeviceLeftCallback(EmberEUI64 nodeEui64)
rpc_printfJSON("left",nodeJson);
kk_msg_report_dev_leave(deviceTable[deviceTableIndex].eui64);
kk_device_table_delete(deviceTable[deviceTableIndex].eui64);
kk_device_db_delete(deviceTable[deviceTableIndex].eui64);
}
......@@ -331,20 +334,24 @@ void kk_load_dev_map_table(void)
{
int len;
int bufferSize;
int fd = open(KK_DEVICE_MAP_TABLE_FILE,O_RDONLY);
if(fd<0){
UTIL_LOG_ERR("can not open %s,fd=%d!!!\n",KK_DEVICE_MAP_TABLE_FILE,fd);
return ;
}
struct stat statbuff;
stat(KK_DEVICE_MAP_TABLE_FILE, &statbuff);
bufferSize = statbuff.st_size + 128;
uint8_t *buffer = (uint8_t *)malloc(bufferSize);
memset(buffer,0,bufferSize);
;
UTIL_LOG_INFO("\n***************load device map table***************\n");
if(fd<0){
free(buffer);
UTIL_LOG_ERR("can not open %s,fd=%d!!!\n",KK_DEVICE_MAP_TABLE_FILE,fd);
return ;
}
len = read(fd,buffer ,bufferSize);
if(len<0){
free(buffer);
......@@ -524,7 +531,7 @@ bool kk_device_config_exist_check(const char *productCode)
return false;
}
bool kk_device_config_add(const char *productCode,const char *identity,uint8_t ep,uint16_t clu,uint16_t attr,const char *reportFuncName,const char *controlFuncName)
bool kk_device_config_add(const char *productCode,const char *identity,uint8_t ep,uint16_t clu,uint16_t attr,uint16_t mask,const char *reportFuncName,const char *controlFuncName)
{
int len;
kk_dev_config_map *ptr,*pre,*pTemp;
......@@ -552,6 +559,7 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
ptr->item.endpoint = ep;
ptr->item.cluster = clu;
ptr->item.attribute = attr;
ptr->item.iasZoneStatusMask = mask;
len = strlen(reportFuncName);
ptr->item.reportFuncName = (char *)malloc(len+1);
......@@ -601,6 +609,7 @@ bool kk_device_config_add(const char *productCode,const char *identity,uint8_t e
newItem->endpoint = ep;
newItem->cluster = clu;
newItem->attribute = attr;
newItem->iasZoneStatusMask = mask;
len = strlen(reportFuncName);
newItem->reportFuncName = (char *)malloc(len+1);
......@@ -705,13 +714,15 @@ kk_dev_config_item_extra_data * kk_find_extra_data(EmberNodeId node,const char *
}
void kk_add_dev_config_map_table_to_list(cJSON * root,const char *productCode)
{
uint8_t ep;
uint16_t clu;
uint16_t attr;
uint8_t ep = 0;
uint16_t clu = 0;
uint16_t attr = 0;
uint16_t mask = 0;
int i,j,len,size,extraSize;
cJSON *item,*identity;
cJSON *endpoint,*cluster,*attribute,*reportFuncName,*controlFuncName;
cJSON *extraRoot,*extraData,*extraDataItem;
cJSON *iasZoneStatusMask;
cJSON * table = rpc_cJSON_GetObjectItem(root,KK_DEVICE_CONFIG_MAP_TABLE_ARRAY_IDENTIFY);
kk_dev_config_item_extra_data *pData = NULL,*ptr = NULL;
......@@ -730,7 +741,7 @@ void kk_add_dev_config_map_table_to_list(cJSON * root,const char *productCode)
attribute = cJSON_GetObjectItem(item, "attribute");
reportFuncName = cJSON_GetObjectItem(item, "reportFunc");
controlFuncName = cJSON_GetObjectItem(item, "controlFunc");
iasZoneStatusMask = cJSON_GetObjectItem(item, "iasStatusMask");
extraRoot = cJSON_GetObjectItem(item, KK_DEVICE_CONFIG_MAP_TABLE_EXTRA_DATA_IDENTIFY);
if(extraRoot!=NULL){
extraSize = rpc_cJSON_GetArraySize(extraRoot);
......@@ -771,20 +782,30 @@ void kk_add_dev_config_map_table_to_list(cJSON * root,const char *productCode)
ep = endpoint->valueint;
if(cluster!=NULL){
len = strlen(cluster->valuestring);
if(len >=4){
clu = rpc_get_u16(&cluster->valuestring[len-4]);
}else{
continue ;
}
}
if(attribute!=NULL){
len = strlen(attribute->valuestring);
if(len >=4){
attr = rpc_get_u16(&attribute->valuestring[len-4]);
}else{
continue ;
}
}
kk_device_config_add(productCode,identity->valuestring,ep,clu,attr,reportFuncName->valuestring,controlFuncName->valuestring);
if(clu==ZCL_IAS_ZONE_CLUSTER_ID && attr== ZCL_ZONE_STATUS_ATTRIBUTE_ID){
if(iasZoneStatusMask!=NULL){
len = strlen(iasZoneStatusMask->valuestring);
mask = rpc_get_u16(&iasZoneStatusMask->valuestring[len-4]);
}
}
kk_device_config_add(productCode,identity->valuestring,ep,clu,attr,mask,reportFuncName->valuestring,controlFuncName->valuestring);
kk_append_extra_data_to_list(productCode,pData);
......@@ -878,6 +899,7 @@ void kk_device_config_map_print(void)
emberAfCorePrintln("endpoint:%d\n",item->endpoint);
emberAfCorePrintln("cluster:0x%04X\n",item->cluster);
emberAfCorePrintln("attribute:0x%04X\n",item->attribute);
emberAfCorePrintln("iasZoneStatusMask:0x%04X\n",item->iasZoneStatusMask);
emberAfCorePrintln("reportFunc:%s\n",item->reportFuncName);
emberAfCorePrintln("controlFunc:%s\n",item->controlFuncName);
extra = item->data;
......
......@@ -14,7 +14,7 @@
#define KK_MAX_READ_MODLE_ID_COUNT 30
#define KK_NETWORK_PARAMETER_TX_POWER 10
#define KK_NETWORK_PARAMETER_CHANNEL 0x0B
#define KK_NETWORK_PARAMETER_CHANNEL 15
#define KK_EP(x) (x)
#define KK_DUMMY_EP KK_EP(0)
......@@ -61,6 +61,7 @@ typedef struct kk_dev_config_item{
kk_rpc_set * controlFunc;
uint8_t endpoint;
uint16_t cluster;
uint16_t iasZoneStatusMask;
uint16_t attribute;
kk_dev_config_item_extra_data *data;
struct kk_dev_config_item * next;
......
......@@ -52,7 +52,6 @@ void kk_print_device_table(void)
ptr = ptr->next;
}
}
static kk_device_table_s *kk_device_table_create()
{
......@@ -532,6 +531,7 @@ void emberAfPluginDeviceTableInitialized(void)
{
kk_device_db_load();
kk_print_device_table();
kk_load_dev_map_table();
kk_device_map_print();
kk_device_config_load_from_db();
......
......@@ -64,6 +64,12 @@ void kk_msg_report_property(cJSON *data,EmberEUI64 mac)
{
kk_msg_report(data,KK_REPORT_ATTRIBUTE_TYPE,KK_REPORT_ATTRIBUTE_METHOD,mac);
}
void kk_msg_report_alarm(cJSON *data,EmberEUI64 mac)
{
kk_msg_report(data,KK_REPORT_ALARM_TYPE,KK_REPORT_ALARM_METHOD,mac);
}
void kk_msg_report_dev_joined(EmberEUI64 mac,const char* productCode)
{
......
......@@ -15,6 +15,11 @@
#define KK_REPORT_DEVICE_LEAVE_METHOD "thing.topo.delete"
#define KK_REPORT_DEVICE_BATCH_LEAVE_METHOD "thing.topo.batchDelete"
#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"
......@@ -23,6 +28,7 @@
#define KK_REPORT_DEVICE_LEFT_TYPE "/thing/topo/delete"
#define KK_REPORT_DEVICE_BATCH_LEFT_TYPE "/thing/topo/batch_delete"
#define KK_REPORT_ATTRIBUTE_TYPE "/thing/event/property/post"
#define KK_REPORT_ALARM_TYPE "/thing/event/alarm/post"
#define GW2CCU_PROTOCOL "tcp"
......@@ -35,6 +41,7 @@ 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_property(cJSON *data,EmberEUI64 mac);
void kk_msg_report_alarm(cJSON *data,EmberEUI64 mac);
......
......@@ -75,14 +75,34 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
if(dev_info == NULL){
return tsl_rpt_err;
}
item = &dev_info->item;
if(clusterId==ZCL_IAS_ZONE_CLUSTER_ID && attributeId== ZCL_ZONE_STATUS_ATTRIBUTE_ID){
while(item!=NULL){
if(EP == item->endpoint &&
clusterId == item->cluster&&
attributeId == item->attribute){
{
if(item->iasZoneStatusMask!=0){
root_tmp = kk_check_identify(Identify,root,index,status);
if(root_tmp != NULL){
kk_rpc_report_status(root_tmp,mac);
}
else{
status = ((status&0xffff)&item->iasZoneStatusMask) ? 1 : 0;
rpc_cJSON_AddNumberToObject(root, Identify,status);
kk_msg_report_property(root,mac);
}
}
}
}
item = item->next;
}
}else{
while(item!=NULL){
if(EP == item->endpoint &&
clusterId == item->cluster&&
attributeId == item->attribute){
Identify = item->identity;
break;
}
item = item->next;
......@@ -92,15 +112,65 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
kk_rpc_report_status(root_tmp,mac);
}
else{
if(clusterId==ZCL_BASIC_CLUSTER_ID && attributeId== ZCL_BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE_ID){
double battery = (double)status * 0.5;
char batteryStr[32];
sprintf(batteryStr,"f",battery);
rpc_cJSON_AddStringToObject(root, Identify,batteryStr);
}else{
rpc_cJSON_AddNumberToObject(root, Identify,status);
kk_msg_report_property(root,mac);
}
kk_msg_report_property(root,mac);
}
}
return tsl_rpt_success;
}
//typedef int(*kk_rpc_report)(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
void kk_tsl_report_alarm(EmberEUI64 eui64,
uint16_t zoneStatus,
uint8_t extendedStatus,
uint8_t zoneId,
uint16_t delay)
{
cJSON* root;
kk_device_table_s *dev = NULL;
kk_dev_config_map *dev_info = NULL;
kk_dev_config_item *item = NULL;
kk_rpc_report func;
UTIL_LOG_INFO("\n********************kk_tsl_report_alarm********************\n");
dev = kk_device_find_by_mac(eui64);
if(dev == NULL){
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
return;
}
dev_info = kk_device_config_find(dev->productCode);
if(dev_info == NULL){
printf("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,%s\n",dev->productCode);
return;
}
item = &dev_info->item;
while(item!=NULL){
printf("&&&&&&&&&&&&&&&&&&&&&&\n");
if(item->cluster== ZCL_IAS_ZONE_CLUSTER_ID
&& item->attribute ==ZCL_ZONE_STATUS_ATTRIBUTE_ID &&
item->iasZoneStatusMask!=0 && item->reportFunc==NULL){
printf("!!!!!!!!!!!!\n");
root = rpc_cJSON_CreateObject();
rpc_cJSON_AddNumberToObject(root, item->identity,(zoneStatus & item->iasZoneStatusMask) ? 1 : 0);
kk_msg_report_alarm(root,eui64);
}
item = item->next;
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
}
}
void kk_tsl_report_attribute(EmberEUI64 eui64,
uint8_t EP,
......@@ -439,3 +509,51 @@ int kk_tsl_report_colorControl_RGB(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId
int kk_tsl_report_iasZoneStatus(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data)
{
uint16_t value;
kk_device_table_s *dev;
UTIL_LOG_INFO("[tsl report:kk_tsl_report_iasZoneStatus] value:%d\n",value);
dev = kk_device_find_by_mac(eui64);
if(dev == NULL){
return tsl_rpt_err;
}
if(dataType == ZCL_BITMAP16_ATTRIBUTE_TYPE){
if(len==2){
value = KK_GET_U16(data);
kk_tsl_report(eui64,EP,value,clusterId,attributeId);
return tsl_rpt_success;
}
}
return tsl_rpt_err;
}
int kk_tsl_report_battery(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data)
{
uint8_t value = data[0];
kk_device_table_s *dev;
UTIL_LOG_INFO("[tsl report:kk_tsl_report_battery] value:%d\n",value);
dev = kk_device_find_by_mac(eui64);
if(dev == NULL){
return tsl_rpt_err;
}
if(dataType == ZCL_INT8U_ATTRIBUTE_TYPE){
if(len==1){
kk_tsl_report(eui64,EP,value,clusterId,attributeId);
return tsl_rpt_success;
}
}
return tsl_rpt_err;
}
......@@ -19,6 +19,11 @@ void kk_tsl_report_attribute(EmberEUI64 eui64,
uint8_t dataType,
uint8_t len,
uint8_t *data);
void kk_tsl_report_alarm(EmberEUI64 eui64,
uint16_t zoneStatus,
uint8_t extendedStatus,
uint8_t zoneId,
uint16_t delay);
int kk_tsl_report_global_onoff(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
......@@ -45,6 +50,8 @@ int kk_tsl_report_colorControl_RGB(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId
int kk_tsl_report_iasZoneStatus(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
int kk_tsl_report_battery(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId clusterId,EmberAfAttributeId attributeId,uint8_t dataType,uint8_t len,uint8_t *data);
......
......@@ -34,6 +34,8 @@ void kk_rpc_test(void);
{"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[];
......
......@@ -266,7 +266,7 @@ int _init_param(struct jrpc_server *server) {
//kk_zlog_init("paltform");
printf("getenv\r\n");
char * debug_level_env = getenv("HOME");
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;
......
......@@ -89,6 +89,8 @@ void kk_read_ncp_configuration_without_memory_allocation(void)
extern void kk_print_network_info(void);
extern void test_123(int val);
extern void kk_ota_test111();
extern void kk_ota_test123123123();
void kk_message_process(char *messageString)
{
......@@ -111,30 +113,10 @@ void kk_message_process(char *messageString)
}
if(MEMCOMPARE(messageString,"AT+TEST1\r\n",len)==0){
uint16_t h;
unsigned char s,l;
RGB_to_HSL(100, 150, 200,&h,&s,&l);
emberAfAppPrintln("%d,%d,%d",h,s,l);
emberAfAppPrintln("%d,%d,%d",h*254/360,s*254/100,l);
kk_device_table_s* dev = kk_device_find_by_node(0x5996);
dev->manage.dev.ColorLighting.color.HSL.L = l;
zclLevel_MoveToLevel(0x5996,1,l,0,NULL,NULL);
zclColorControlMovetohueandsat(0x5996,1,h*254/360,s*254/100,0,0,0,0);
emberAfAppPrint("AT+TEST1\r\n" );
kk_ota_test123123123();
}
if(MEMCOMPARE(messageString,"AT+TEST2\r\n",len)==0){
uint16_t h;
unsigned char s,l;
RGB_to_HSL(20, 24, 22,&h,&s,&l);
emberAfAppPrintln("%d,%d,%d",h,s,l);
emberAfAppPrintln("%d,%d,%d",h*254/360,s*254/100,l);
kk_device_table_s* dev = kk_device_find_by_node(0x5996);
dev->manage.dev.ColorLighting.color.HSL.L = l;
zclLevel_MoveToLevel(0x5996,1,l,0,NULL,NULL);
zclColorControlMovetohueandsat(0x5996,1,h*254/360,s*254/100,0,0,0,0);
emberAfAppPrint("AT+TEST2\r\n" );
if(MEMCOMPARE(messageString,"AT+TEST\r\n",len)==0){
kk_ota_test111();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -36,6 +36,7 @@
static const char options[] = "b:f:hv::i:n:o:p:r:s:t:x:";
bool checkSerialPort(const char* portString);
bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr)
{
int c;
......@@ -137,7 +138,7 @@ bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr)
devport[5] = '\0';
if ( strncmp(devport, port, 5) == 0) {
strncat(devport, port + 5, ASH_PORT_LEN - 5 - 1);
#ifdef __CYGWIN__
#ifdef __CYGWIN__
} else if ( ((strncmp("COM", port, 3) == 0)
|| (strncmp("com", port, 3) == 0) )
&& (sscanf(port + 3, "%hhu", &portnum) == 1)
......@@ -145,10 +146,10 @@ bool ezspInternalProcessCommandOptions(int argc, char *argv[], char *errStr)
snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum - 1);
} else if ( (sscanf(port, "%hhu", &portnum) == 1) && portnum ) {
snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum - 1);
#else
#else
} else if (sscanf(port, "%hhu", &portnum) == 1) {
snprintf(devport, ASH_PORT_LEN, "/dev/ttyS%hhu", portnum);
#endif
#endif
} else {
strncat(devport, port, ASH_PORT_LEN - 1);
}
......
......@@ -559,6 +559,7 @@ bool ezspSerialPortRegisterCallback(EzspSerialPortCallbackFunction callback)
void ezspSerialWriteByte(uint8_t byte)
{
BUMP_HOST_COUNTER(txBytes);
#ifdef IO_LOG
{
......
......@@ -226,11 +226,13 @@ uint8_t emberAfOtaServerQueryCallback(const EmberAfOtaImageId* currentImageId,
// We only perform a check if both the query and the
// file have hardware version(s). If one or the other doesn't
// have them, we assume a match is still possible.
otaPrintln("[OTA]2222,hardwareVersion=%d",hardwareVersion);
if (hardwareVersion) {
EmberAfOtaHeader header;
emberAfOtaStorageGetFullHeaderCallback(nextUpgradeImageId,
&header);
if (header.fieldControl & HARDWARE_VERSIONS_PRESENT_MASK) {
otaPrintln("[OTA]3333");
if (*hardwareVersion < header.minimumHardwareVersion
|| header.maximumHardwareVersion < *hardwareVersion) {
otaPrintln("Hardware version 0x%02X does not fall within the min (0x%02X) and max (0x%02X) hardware versions in the file.",
......@@ -246,16 +248,19 @@ uint8_t emberAfOtaServerQueryCallback(const EmberAfOtaImageId* currentImageId,
// as a potential upgrade candidate because the hardware is out
// of range.
if (!hardwareVersionMismatch) {
otaPrintln("[OTA]4444,%x,%x",nextUpgradeImageId->firmwareVersion,currentImageId->firmwareVersion);
status = (determineNextSoftwareVersion(nextUpgradeImageId->firmwareVersion,
currentImageId->firmwareVersion)
? EMBER_ZCL_STATUS_SUCCESS
: EMBER_ZCL_STATUS_NO_IMAGE_AVAILABLE);
otaPrintln("[OTA]555,status=%x",status);
if (status == EMBER_ZCL_STATUS_SUCCESS) {
otaPrintln("Next fw version is: 0x%4X",
nextUpgradeImageId->firmwareVersion);
}
}
}
otaPrintln("[OTA]11111");
return status;
}
......
......@@ -571,6 +571,54 @@ void emberAfOtaServerSendUpgradeCommandCallback(EmberNodeId dest,
}
}
void kk_ota_test123123123()
{
EmberAfOtaImageId id;
id.manufacturerId = 0x1268;
id.imageTypeId = 0x2904;
id.firmwareVersion = 15;
emberAfOtaServerSendImageNotifyCallback(0xffff,
1,
0x03,
0,
&id);
}
void kk_ota_test111()
{
/*zclBufferSetup(ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT|ZCL_DISABLE_DEFAULT_RESPONSE_MASK, \
(ZCL_OTA_BOOTLOAD_CLUSTER_ID), \
(ZCL_IMAGE_NOTIFY_COMMAND_ID));
zclBufferAddByte(0x03);
zclBufferAddByte(0x00);
zclBufferAddWord(0x1234);
zclBufferAddWord(0x5678);
zclBufferAddInt32(0x11223344);
rpcSendCommand(0xffff,1,1,false);
emberAfCorePrintln("[kk_ota_test111] \r\n");*/
emberAfCorePrintln("[kk_ota_test111] \r\n");
static int cnt;
EmberAfOtaImageId id = emberAfOtaStorageIteratorFirstCallback();
cnt = 0;
do {
emberAfCorePrintln("**********%d********\r\n",++cnt);
emberAfCorePrintln("manufacturerId=0x%4X \r\n",id.manufacturerId);
emberAfCorePrintln("imageTypeId=0x%4X \r\n",id.imageTypeId);
emberAfCorePrintln("firmwareVersion=0x%8X \r\n",id.firmwareVersion);
id = emberAfOtaStorageIteratorNextCallback();
} while (emberAfIsOtaImageIdValid(&id));
}
static int s_ota_server_init = 0;
EmberAfOtaImageId kk_get_imageId(char* filename){
......@@ -589,7 +637,6 @@ EmberAfOtaImageId kk_get_imageId(char* filename){
return emberAfInvalidImageId;
}
void kk_ota_notify(char* filepath){
if (s_ota_server_init == 0){
s_ota_server_init = 1;
......
......@@ -63,11 +63,11 @@
#define INVALID_EUI64 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
#define INVALID_OTA_IMAGE_ID \
{ INVALID_MANUFACTURER_ID, \
{ INVALID_MANUFACTURER_ID, \
INVALID_DEVICE_ID, \
INVALID_FIRMWARE_VERSION, \
INVALID_EUI64, \
}
}
#define INVALID_SLOT (uint32_t)-1
......
......@@ -170,9 +170,9 @@ static OtaImage* iterator = NULL;
#endif
static EmAfOtaStorageLinuxConfig config = {
false, // memoryDebug
false, // fileDebug
false, // fieldDebug
true, // memoryDebug
true, // fileDebug
true, // fieldDebug
true, // ignoreFilesWithUnderscorePrefix
true, // printFileDiscoveryOrRemoval
NULL, // fileAddedHandler
......@@ -863,13 +863,6 @@ static void printHeaderInfo(const EmberAfOtaHeader* header)
if (!config.printFileDiscoveryOrRemoval) {
return;
}
// printf(" Header Version: 0x%04X\n",
// header->headerVersion);
// printf(" Header Length: 0x%04X\n",
// header->headerLength);
// printf(" Field Control: 0x%04X\n",
// header->fieldControl);
note(" Manufacturer ID: 0x%04X\n",
header->manufacturerId);
note(" Image Type ID: 0x%04X\n",
......@@ -878,7 +871,6 @@ static void printHeaderInfo(const EmberAfOtaHeader* header)
header->firmwareVersion);
note(" Header String: %s\n",
header->headerString);
// printf("\n");
}
static OtaImage* addImageFileToList(const char* filename,
......
......@@ -545,16 +545,12 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
halInit();
INTERRUPTS_ON(); // Safe to enable interrupts at this point
{
int returnCode;
if (emberAfMainStartCallback(&returnCode,
APP_FRAMEWORK_MAIN_ARGUMENTS)) { //get serial port info
return returnCode;
}
}
kk_print("*******************123****************\r\n");
kk_print_info("\r\n-----hello world![%s:%s]-----\r\n",__DATE__,__TIME__);
kk_print_version();
emberSerialInit(APP_SERIAL, BAUD_RATE, PARITY_NONE, 1); //fock child process
......
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