Commit c3c39a1f authored by chen.weican's avatar chen.weican

【修改内容】增加拓清空气盒子的支持

【提交人】陈伟灿
parent 4359d78c
......@@ -1091,7 +1091,6 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
if(params == NULL || deviceCode == NULL){
return INVALID_PARAMETER;
}
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
......@@ -1141,27 +1140,28 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
if(property->data_value.type == KK_TSL_DATA_TYPE_INT ||
property->data_value.type == KK_TSL_DATA_TYPE_ENUM||
property->data_value.type == KK_TSL_DATA_TYPE_BOOL){
sprintf(tmpValue,"%d",property->data_value.value_int);
//printf("property->identifier:%s,property->data_value.value:%d\n",property->identifier,property->data_value.value_int);
sprintf(tmpValue,"%d",propertyItem->valueint);
kk_property_db_update_value(deviceCode,property->identifier,tmpValue);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,&property->data_value.value_int);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,&propertyItem->valueint);
}
else if(property->data_value.type == KK_TSL_DATA_TYPE_FLOAT){
sprintf(tmpValue,"%f",property->data_value.value_float);
sprintf(tmpValue,"%f",propertyItem->valuedouble);
kk_property_db_update_value(deviceCode,property->identifier,tmpValue);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,&property->data_value.value_float);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,&propertyItem->valuedouble);
}
else if(property->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
sprintf(tmpValue,"%f",property->data_value.value_double);
sprintf(tmpValue,"%f",propertyItem->valuedouble);
kk_property_db_update_value(deviceCode,property->identifier,tmpValue);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,&property->data_value.value_double);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,&propertyItem->valuedouble);
}
else if(property->data_value.type == KK_TSL_DATA_TYPE_TEXT||
property->data_value.type == KK_TSL_DATA_TYPE_DATE){
kk_property_db_update_value(deviceCode,property->identifier,property->data_value.value);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,property->data_value.value);
kk_property_db_update_value(deviceCode,property->identifier,propertyItem->valuestring);
_kk_property_handle(&propertyInfoBuf[epNumInt-1],property->data_value.type,pFinal,propertyItem->valuestring);
}
else if(property->data_value.type == KK_TSL_DATA_TYPE_STRUCT){
......@@ -1181,26 +1181,26 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
if(current_data->data_value.type == KK_TSL_DATA_TYPE_INT ||
current_data->data_value.type == KK_TSL_DATA_TYPE_ENUM||
current_data->data_value.type == KK_TSL_DATA_TYPE_BOOL){
sprintf(tmpValue,"%d",current_data->data_value.value_int);
sprintf(tmpValue,"%d",propertyItem_1->valueint);
kk_property_db_update_value(deviceCode,tmp_identifiers,tmpValue);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&current_data->data_value.value_int);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&propertyItem_1->valueint);
}
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_FLOAT){
sprintf(tmpValue,"%f",current_data->data_value.value_float);
sprintf(tmpValue,"%f",propertyItem_1->valuedouble);
kk_property_db_update_value(deviceCode,tmp_identifiers,tmpValue);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&current_data->data_value.value_float);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&propertyItem_1->valuedouble);
}
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
sprintf(tmpValue,"%f",current_data->data_value.value_double);
sprintf(tmpValue,"%f",propertyItem_1->valuedouble);
kk_property_db_update_value(deviceCode,tmp_identifiers,tmpValue);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&current_data->data_value.value_double);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&propertyItem_1->valuedouble);
}
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_TEXT||
current_data->data_value.type == KK_TSL_DATA_TYPE_DATE){
kk_property_db_update_value(deviceCode,tmp_identifiers,current_data->data_value.value);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,current_data->data_value.value);
kk_property_db_update_value(deviceCode,tmp_identifiers,propertyItem_1->valuestring);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,propertyItem_1->valuestring);
}
else{
......
......@@ -205,7 +205,7 @@ static int _kk_msg_set_numberOrStr(kk_msg_set_type_t type, kk_tsl_t *dev_shadow,
dm_set_shadow_data set_shadow_data_func = (type == KK_MSG_PROPERTY_SET) ? (_kk_msg_set_property_value) :
(_kk_msg_set_service_input_value);
/* dm_log_debug("Current Key: %s", key); */
//printf("_kk_msg_set_numberOrStr Current Key: %s\n", key);
res = get_shadow_data_func(dev_shadow, key, strlen(key), &data);
if (res != SUCCESS_RETURN) {
......@@ -216,8 +216,7 @@ static int _kk_msg_set_numberOrStr(kk_msg_set_type_t type, kk_tsl_t *dev_shadow,
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
/* dm_log_debug("Current Type: %d", data_type); */
//printf("_kk_msg_set_numberOrStr Current Type: %d\n", data_type);
switch (data_type) {
case KK_TSL_DATA_TYPE_INT:
case KK_TSL_DATA_TYPE_ENUM:
......@@ -225,6 +224,7 @@ static int _kk_msg_set_numberOrStr(kk_msg_set_type_t type, kk_tsl_t *dev_shadow,
if (root->type == cJSON_String && root->value_length > 0){
root->value_int = atoi(root->value);
}
//printf("root->value_int:%d\n ",root->value_int);
res = set_shadow_data_func(dev_shadow, key, strlen(key), &root->value_int, 0);
}
break;
......@@ -327,7 +327,7 @@ static int _kk_msg_set_object(kk_msg_set_type_t type, kk_tsl_t *dev_shadow, char
continue;
}
//printf("Current Key: %s, Value: %s,type:%d", lite_item_key.value,lite_item_value.value,lite_item_value.type);
//printf("Current Key: %s, Value: %s,type:%d\n", lite_item_key.value,lite_item_value.value,lite_item_value.type);
//new_key_len = lite_item_key.value_length + 1;
new_key_len = ((key == NULL) ? (0) : (strlen(key) + 1)) + lite_item_key.value_length + 1;
/* dm_log_debug("new_key_len: %d", new_key_len); */
......@@ -341,7 +341,7 @@ static int _kk_msg_set_object(kk_msg_set_type_t type, kk_tsl_t *dev_shadow, char
new_key[strlen(new_key)] = KK_MSG_KEY_DELIMITER;
}
memcpy(new_key + strlen(new_key), lite_item_key.value, lite_item_key.value_length);
/* dm_log_debug("New Key: %s", new_key); */
//printf("New Key: %s\n", new_key);
if (lite_cjson_is_object(&lite_item_value)) {
res = _kk_msg_set_object(type, dev_shadow, new_key, &lite_item_value);
......
......@@ -1138,10 +1138,15 @@ int kk_tsl_data_search(_IN_ kk_tsl_data_t *input, _IN_ char *key,
if (input == NULL || key == NULL || key_len <= 0) {
return INVALID_PARAMETER;
}
if(strcmp(key,"PM2.5") == 0){
deli_offset = key_len;
}
else{
res = kk_utils_memtok(key, key_len, KK_MSG_KEY_DELIMITER, 1, &deli_offset);
if (res != SUCCESS_RETURN) {
deli_offset = key_len;
}
}
partial_offset = deli_offset;
res = kk_utils_strarr_index(key, deli_offset, &partial_input_len, &array_input_len, &array_index);
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3119.json",
"productType": "sensor",
"version": "1.0",
"profile": {
"heartbeat": "300",
"productCode": "3119",
"productName": "拓清系列.白色空气质量检测仪HTPC(KONKE)"
},
"services": [
{
"outputData": [
{
"identifier": "Temperature",
"name": "当前温度",
"dataType": {
"type": "double",
"specs": {
"min": "-10",
"max": "60",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.01"
}
}
},
{
"identifier": "Humidity",
"name": "当前湿度",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
},
{
"identifier": "Carbondioxide",
"name": "CO2检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "5000",
"unit": "ppm",
"unitName": "百万分之一",
"step": "1"
}
}
},
{
"identifier": "PM2.5",
"name": "PM2.5检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "999",
"unit": "ug/m3",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "Formaldehyde",
"name": "当前甲醛检测值",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "1",
"unit": "mg/m3",
"unitName": "毫克每立方米",
"step": "0.01"
}
}
}
],
"identifier": "get",
"inputData": [
"Temperature",
"Humidity",
"Carbondioxide",
"PM2.5",
"Formaldehyde"
],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}
],
"properties": [
{
"identifier": "Temperature",
"name": "当前温度",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "-40",
"max": "100",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.01"
}
}
},
{
"identifier": "Humidity",
"name": "当前湿度",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
},
{
"identifier": "Carbondioxide",
"name": "CO2检测值",
"accessMode": "r",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "5000",
"unit": "ppm",
"unitName": "百万分之一",
"step": "1"
}
}
},
{
"identifier": "PM2.5",
"name": "PM2.5检测值",
"accessMode": "r",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "999",
"unit": "ug/m3",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "Formaldehyde",
"name": "当前甲醛检测值",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "1",
"unit": "mg/m3",
"unitName": "毫克每立方米",
"step": "0.01"
}
}
}
],
"events": [
{
"outputData": [
{
"identifier": "Temperature",
"name": "当前温度",
"dataType": {
"type": "double",
"specs": {
"min": "-40",
"max": "100",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.01"
}
}
},
{
"identifier": "Humidity",
"name": "当前湿度",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
},
{
"identifier": "Carbondioxide",
"name": "CO2检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "5000",
"unit": "ppm",
"unitName": "百万分之一",
"step": "1"
}
}
},
{
"identifier": "PM2.5",
"name": "PM2.5检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "999",
"unit": "ug/m3",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "Formaldehyde",
"name": "当前甲醛检测值",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "1",
"unit": "mg/m3",
"unitName": "毫克每立方米",
"step": "0.01"
}
}
}
],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}
]
}
\ No newline at end of file
{
"schema": "https://iot-ap.ikonke.com/model/product_3132.json",
"productType": "sensor",
"version": "1.0",
"profile": {
"heartbeat": "300",
"productCode": "3132",
"productName": "拓清系列.白色零火线环境检测面板C5HPC(KONKE)"
},
"services": [
{
"outputData": [
{
"identifier": "Temperature",
"name": "当前温度",
"dataType": {
"type": "double",
"specs": {
"min": "-10",
"max": "60",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.01"
}
}
},
{
"identifier": "Humidity",
"name": "当前湿度",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
},
{
"identifier": "Carbondioxide",
"name": "CO2检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "5000",
"unit": "ppm",
"unitName": "百万分之一",
"step": "1"
}
}
},
{
"identifier": "PM2.5",
"name": "PM2.5检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "999",
"unit": "ug/m3",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "Formaldehyde",
"name": "当前甲醛检测值",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "1",
"unit": "mg/m3",
"unitName": "毫克每立方米",
"step": "0.01"
}
}
}
],
"identifier": "get",
"inputData": [
"Temperature",
"Humidity",
"Carbondioxide",
"PM2.5",
"Formaldehyde"
],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}
],
"properties": [
{
"identifier": "Temperature",
"name": "当前温度",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "-40",
"max": "100",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.01"
}
}
},
{
"identifier": "Humidity",
"name": "当前湿度",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
},
{
"identifier": "Carbondioxide",
"name": "CO2检测值",
"accessMode": "r",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "5000",
"unit": "ppm",
"unitName": "百万分之一",
"step": "1"
}
}
},
{
"identifier": "PM2.5",
"name": "PM2.5检测值",
"accessMode": "r",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "999",
"unit": "ug/m3",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "Formaldehyde",
"name": "当前甲醛检测值",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "1",
"unit": "mg/m3",
"unitName": "毫克每立方米",
"step": "0.01"
}
}
}
],
"events": [
{
"outputData": [
{
"identifier": "Temperature",
"name": "当前温度",
"dataType": {
"type": "double",
"specs": {
"min": "-40",
"max": "100",
"unit": "°C",
"unitName": "摄氏度",
"step": "0.01"
}
}
},
{
"identifier": "Humidity",
"name": "当前湿度",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
},
{
"identifier": "Carbondioxide",
"name": "CO2检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "5000",
"unit": "ppm",
"unitName": "百万分之一",
"step": "1"
}
}
},
{
"identifier": "PM2.5",
"name": "PM2.5检测值",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "999",
"unit": "ug/m3",
"unitName": "微克每立方米",
"step": "1"
}
}
},
{
"identifier": "Formaldehyde",
"name": "当前甲醛检测值",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "1",
"unit": "mg/m3",
"unitName": "毫克每立方米",
"step": "0.01"
}
}
}
],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}
]
}
\ No newline at end of file
1.3.2
\ No newline at end of file
1.3.4
\ 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