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

Merge branch 'cwc' into 'master'

【修改内容】增加主动上报topo delete功能

See merge request chenweican/k-sdk!124
parents 254c2dc9 30506952
......@@ -593,18 +593,14 @@ int kk_sync_devices_status_to_sdk(cJSON *root)
kk_map_dev_node_t *n = NULL;
cJSON *devStatusAry = cJSON_CreateArray();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_map_dev_mutex_lock();
list_for_each_entry_safe(node,n, &ctx->dev_list, linked_list, kk_map_dev_node_t){
if(node->syn_type==1){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_sync_devices_status_arg_obj(node,devStatusAry,&idx);
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_sync_devices_status_arg_str(node,devStatusAry,&idx);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//_kk_sync_devicestatus(node,devStatusAry);
}
......@@ -1288,12 +1284,7 @@ int kk_create_syncinfo_to_sdk(cJSON *payload)
#endif
char *out=cJSON_Print(root);
printf("out:%s\n",out);
cJSON *msg = old_ccu_msg_build_json("*","SYNC_INFO",NULL,root);
send_msg_to_module(msg);
cJSON_Delete(msg);
......
......@@ -555,6 +555,24 @@ int dm_mgr_get_devId_by_devicecode(_IN_ char deviceCode[DEVICE_CODE_MAXLEN],_OU_
return SUCCESS_RETURN;
}
int dm_mgr_get_gw_deviceCode(_OU_ dm_mgr_dev_node_t **node)
{
dm_mgr_ctx *ctx = _dm_mgr_get_ctx();
dm_mgr_dev_node_t *search_node = NULL;
list_for_each_entry(search_node, &ctx->dev_list, linked_list, dm_mgr_dev_node_t) {
if (memcmp(search_node->productCode, "gateway_2", strlen("gateway_2")) == 0) {
/* dm_log_debug("Device Found, Product Key: %s, Device Name: %s", product_key, device_name); */
if (node) {
*node = search_node;
}
return SUCCESS_RETURN;
}
}
ERROR_PRINT("gw Not Found\n");
return FAIL_RETURN;
}
static void _dm_mgr_destroy_devlist(void)
{
dm_mgr_ctx *ctx = _dm_mgr_get_ctx();
......
......@@ -120,5 +120,6 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version);
int dm_mgr_subdev_create(int devtype,_IN_ char productCode[PRODUCT_CODE_MAXLEN], _IN_ char deviceCode[DEVICE_CODE_MAXLEN],
_IN_ char mac[DEVICE_MAC_MAXLEN],_IN_ char fatherDeviceCode[DEVICE_CODE_MAXLEN],_IN_ int isOffline, _OU_ int *devid,_OU_ int *heartbeat);
int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN]);
int dm_msg_thing_property_post_all(char *deviceCode);
int dm_msg_thing_property_post_all(char *deviceCode);
int dm_mgr_get_gw_deviceCode(_OU_ dm_mgr_dev_node_t **node);
#endif
......@@ -305,6 +305,58 @@ int kk_get_cloud_recv_status(void){
return s_CloudStatusRecv;
}
static int kk_topo_delete_report(cJSON *paramStr)
{
int res = 0;
char *deviceCode = NULL;
char *productCode = NULL;
char msgId[MSG_MAX_LEN] = {0};
char curTime[32] = {0};
if(paramStr == NULL){
return -1;
}
dm_mgr_dev_node_t *node = NULL;
res = dm_mgr_get_gw_deviceCode(&node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
cJSON *deviceArray = cJSON_GetObjectItem(paramStr, MSG_TOPO_CHANGE_DEVICES_STR);
if(deviceArray == NULL){
return FAIL_RETURN;
}
cJSON * item = deviceArray->child;
while(item != NULL){
deviceCode = cJSON_GetObjectItem(item,MSG_DEVICE_CODE_STR)->valuestring;
productCode = cJSON_GetObjectItem(item,MSG_PRODUCT_CODE_STR)->valuestring;
break;
}
if(deviceCode == NULL || productCode == NULL){
return FAIL_RETURN;
}
cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, KK_THING_TOPO_DELETE_MSG);
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, node->deviceCode);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, node->productCode);
char *infff=cJSON_Print(info);
iotx_report_id(msgId);
HAL_GetTime_s(curTime);
cJSON *payload = cJSON_CreateObject();
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "msgId", msgId);
cJSON *paramsInfo = cJSON_CreateObject();
cJSON_AddStringToObject(paramsInfo, "deviceCode", deviceCode);
cJSON_AddStringToObject(paramsInfo, "productCode", productCode);
cJSON_AddItemToObject(payload, "params", paramsInfo);
cJSON_AddStringToObject(payload, "time", curTime);
cJSON_AddStringToObject(payload, "method", "thing.topo.delete");
char *payload11=cJSON_Print(payload);
kk_sendData2app(infff,payload11,0);
free(payload11);
free(infff);
cJSON_Delete(payload);
cJSON_Delete(info);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述:手机端主动删除设备处理函数
*输入参数:payload:云端传下来数据
......@@ -320,9 +372,9 @@ int kk_topo_delete_handle(cJSON *payload,cJSON *buf)
if(payload == NULL || buf == NULL){
return FAIL_RETURN;
}
cJSON *paramStr = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
cJSON *state = cJSON_GetObjectItem(paramStr, MSG_TOPO_CHANGE_TYPE_STR);
kk_topo_delete_report(paramStr);//主动报topo delete
if(state != NULL && state->valueint == 1){
cJSON *deviceArray = cJSON_GetObjectItem(paramStr, MSG_TOPO_CHANGE_DEVICES_STR);
if(deviceArray == NULL){
......@@ -334,11 +386,13 @@ int kk_topo_delete_handle(cJSON *payload,cJSON *buf)
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
if (res < SUCCESS_RETURN) {
ERROR_PRINT("dm_mgr_search_device_by_pkdn failed");
//kk_topo_delete_report(paramStr);//补报topo delete
return res;
}
res = dm_mgr_get_device_by_devicecode(node->fatherDeviceCode, &gwnode);
if (res < SUCCESS_RETURN) {
ERROR_PRINT("dm_mgr_search_device_by_pkdn failed");
//kk_topo_delete_report(paramStr);
return res;
}
cJSON* rootData=cJSON_CreateObject();
......
......@@ -1694,6 +1694,90 @@
}
]
},
{
"pid": "01018631",
"name": "HD Dimmable Light Panel 1G",
"type": "ZR",
"ota": true,
"b_pid": 3091,
"eps": [
{
"ep": "1:21",
"zid": "0101",
"zname": "Dimmable Light",
"b_oid": 0,
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0B05"
}
}
]
},
{
"pid": "01018632",
"name": "HD Dimmable Light Panel 2G",
"type": "ZR",
"ota": true,
"b_pid": 3092,
"eps": [
{
"ep": "1:2:21:22",
"zid": "0101",
"zname": "Dimmable Light",
"b_oid": 0,
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0B05"
}
}
]
},
{
"pid": "01018633",
"name": "HD Dimmable Light Panel 3G",
"type": "ZR",
"ota": true,
"b_pid": 3093,
"eps": [
{
"ep": "1:2:3:21:22:23",
"zid": "0101",
"zname": "Dimmable Light",
"b_oid": 0,
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0B05"
}
}
]
},
{
"pid": "03008611",
"name": "HD HVAC Air condition All in one",
"type": "ZR",
"ota": true,
"b_pid": 3095,
"eps": [
{
"ep": "1:2:3",
"zid": "0300",
"zname": "Heating Cooling Unit",
"b_oid": 0,
"cluster": {
"client": "0003:0006",
"server": "0000:0003:0004:0005:0006:0201:0202"
}
}
]
},
{
"pid": "03008603",
"name": "HD HVAC Floor Heating All in one",
......@@ -1716,37 +1800,47 @@
]
},
{
"pid": "01018631",
"name": "HD Dimmable Light Panel 1G",
"pid": "03008601",
"name": "HD HVAC Fan coil All in one",
"type": "ZR",
"ota": true,
"b_pid": 3091,
"b_pid": 3098,
"eps": [
{
"ep": "1",
"zid": "0101",
"zname": "Dimmable Light",
"ep": "1:2:3",
"zid": "0300",
"zname": "Heating Cooling Unit",
"b_oid": 0,
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0006:0008:0B05"
"client": "0003:0006",
"server": "0000:0003:0004:0005:0006:0201:0202"
}
},
}
]
},
{
"pid": "03008604",
"name": "HD HVAC Fresh Air All in one",
"type": "ZR",
"ota": true,
"b_pid": 3099,
"eps": [
{
"ep": "21",
"zid": "0003",
"zname": "Level Controllable Output",
"ep": "1:2:3",
"zid": "0300",
"zname": "Heating Cooling Unit",
"b_oid": 0,
"cluster": {
"client": "0003:0019",
"server": "0000:0003:0004:0005:0008:0B05"
"client": "0003:0006",
"server": "0000:0003:0004:0005:0006:0201:0202"
}
}
]
},
},
{
"pid": "01018630",
"name": "HD SCR Dimmable Light Panel",
......
......@@ -39,12 +39,12 @@ if [ ! -d "$run_Dir" ]; then
mkdir ${run_Dir}
fi
if [ ! -d "$tsl_Dir" ]; then
cp -rf $filepath/tsl ${run_Dir}/
fi
if [ ! -d "$map_Dir" ]; then
cp -rf $filepath/map ${run_Dir}/
fi
#if [ ! -d "$tsl_Dir" ]; then
cp -rf $filepath/tsl ${run_Dir}/
#fi
#if [ ! -d "$map_Dir" ]; then
cp -rf $filepath/map ${run_Dir}/
#fi
cd $filepath/lib
if [ ! -f "$nanomsg_File" ]; then
......@@ -62,14 +62,17 @@ fi
export LD_LIBRARY_PATH=$filepath/lib
$filepath/bin/kk_midware &
sleep 3
sleep 1
$filepath/bin/kk_lan --uart=/dev/ttyS3&
sleep 2
$filepath/bin/kk_cloud &
sleep 5
#/home/kk/process_check.sh >/dev/null 2>&1 &
$filepath/bin/smarthome_z3gw_nx5 -r0 -l3 --device-def=$filepath/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1&
sleep 2
$filepath/bin/kk_lan --uart=/dev/ttyS3&
sleep 1
#echo "*/1 * * * * /app/ccuApps/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;}
if [ ! -f /etc/cron.d/ccu ]; then
echo "*/1 * * * * /app/ccuApps/process_check.sh" > /etc/cron.d/ccu || { echo "ERROR:add ccu crontab rule failed."; exit 1;}
fi
ntpd -n -q -d -p stdtime.gov.hk &
exit 0
\ No newline at end of file
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