Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
96034b95
Commit
96034b95
authored
Sep 22, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cwc' into 'master'
【修改内容】修改空调内机场景的设置 See merge request chenweican/k-sdk!142
parents
4f605363
75a5620f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
96 additions
and
16 deletions
+96
-16
application/kcloud/kcloud_config.h
application/kcloud/kcloud_config.h
+1
-1
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+4
-3
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+1
-0
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+1
-1
application/kcloud/mqtt_api.h
application/kcloud/mqtt_api.h
+1
-0
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+19
-5
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+1
-0
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+64
-5
midware/midware/midware.c
midware/midware/midware.c
+3
-0
midware/tsl/tsl_handle/kk_tsl_api.c
midware/tsl/tsl_handle/kk_tsl_api.c
+1
-1
No files found.
application/kcloud/kcloud_config.h
View file @
96034b95
...
...
@@ -22,6 +22,6 @@ typedef enum {
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#define HOST_NAME "dev.nj-ikonke.site"
int
KK_Get_ccuid
(
char
*
device_code
);
#endif
application/kcloud/kcloud_main.c
View file @
96034b95
...
...
@@ -26,9 +26,10 @@
#include "mqtt_api.h"
#include "com_api.h"
#include "kk_product.h"
#include "kk_hal.h"
//#include "kcloud_log.h"
static
char
s_ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
int
KK_Get_ccuid
(
_OU_
char
*
device_code
)
int
KK_Get_ccuid
(
char
*
device_code
)
{
strncpy
(
device_code
,
s_ccuid
,
strlen
(
s_ccuid
));
printf
(
"HAL_Get_ccuid:%s
\n
"
,
s_ccuid
);
...
...
@@ -43,8 +44,8 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
}
static
int
KK_Ccuid_init
(
void
)
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
char
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
char
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
...
...
application/kcloud/kk_register.c
View file @
96034b95
...
...
@@ -332,6 +332,7 @@ int kk_start_ccu_register(void)
if
(
NULL
==
host
)
{
INFO_PRINT
(
"gethostbyname h_errno
\n
"
);
close
(
sockfd
);
return
-
1
;
}
memcpy
(
s_ServerIp
,
inet_ntoa
(
*
(
struct
in_addr
*
)(
host
->
h_addr_list
[
0
])),
strlen
(
inet_ntoa
(
*
(
struct
in_addr
*
)(
host
->
h_addr_list
[
0
]))));
...
...
application/kcloud/mqtt_api.c
View file @
96034b95
...
...
@@ -217,7 +217,7 @@ extern char s_ServerIp[16];
MQTTAsync
KK_MQTT_Connect
(
void
)
{
int
rc
=
0
;
int
temp_address
[
128
]
=
{
0
};
char
temp_address
[
128
]
=
{
0
};
FILE
*
fp
;
MQTTAsync_createOptions
opts
=
MQTTAsync_createOptions_initializer
;
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
...
...
application/kcloud/mqtt_api.h
View file @
96034b95
...
...
@@ -16,5 +16,6 @@ extern int KK_MQTT_UnsubTopic(const char *topicName);
extern
MQTTAsync
KK_MQTT_Connect
(
void
);
int
kk_get_cloud_status
(
void
);
void
kk_write_disconnect_flag
(
void
);
#endif
application/klansdk/kk_lan_sync.c
View file @
96034b95
...
...
@@ -461,7 +461,8 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
{
int
i
,
num
=
0
,
n_num
=
0
,
o_num
=
0
;
cJSON
*
newccu
,
*
oldccu
;
cJSON
*
arg
=
cJSON_CreateObject
();
cJSON
*
arg
=
NULL
;
int
flag
=
0
;
if
(
node
==
NULL
||
node
->
syn_type
!=
1
||
node
->
syn_opcode
==
NULL
){
...
...
@@ -481,7 +482,7 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
num
=
(
n_num
>
o_num
)
?
o_num
:
n_num
;
//channelNum
arg
=
cJSON_CreateObject
();
for
(
i
=
0
;
i
<
num
;
i
++
){
cJSON
*
newccuItem
=
cJSON_GetArrayItem
(
newccu
,
i
);
cJSON
*
oldccuItem
=
cJSON_GetArrayItem
(
oldccu
,
i
);
...
...
@@ -516,19 +517,24 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node,int ch)
cJSON_AddBoolToObject
(
syn_obj
,
"enable"
,
0
);
cJSON_AddNullToObject
(
syn_obj
,
"time"
);
}
flag
=
1
;
cJSON_AddItemToObject
(
arg
,
synKey
->
valuestring
,
syn_obj
);
}
else
{
if
(
atoi
(
newccuItemCh
->
valuestring
)
==
atoi
(
oldccuItemCh
->
valuestring
)
&&
atoi
(
newccuItemCh
->
valuestring
)
==
ch
){
if
((
val
=
val_conver_new2old
(
newccuItem
,
oldccuItem
,
1
))
!=
NULL
){
flag
=
1
;
kk_lan_add_val_to_obj
(
arg
,
val
,
synKey
->
valuestring
);
}
}
}
}
}
if
(
flag
==
0
){
cJSON_Delete
(
arg
);
return
NULL
;
}
return
arg
;
}
...
...
@@ -967,9 +973,12 @@ int kk_send_indoorAir_status(cJSON *info,const char *deviceCode)
return
-
1
;
}
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
epNum
=
cJSON_GetObjectItem
(
info
,
"epNum"
);
if
(
epNum
==
NULL
){
return
-
1
;
}
cJSON
*
root
=
cJSON_CreateObject
();
node
=
kk_lan_db_node_get
(
deviceCode
,
atoi
(
epNum
->
valuestring
));
snprintf
(
nodeStr
,
sizeof
(
nodeStr
),
"%d"
,
node
);
...
...
@@ -979,14 +988,19 @@ int kk_send_indoorAir_status(cJSON *info,const char *deviceCode)
cJSON
*
arg
=
cJSON_CreateObject
();
cJSON_AddBoolToObject
(
arg
,
"online"
,
1
);
cJSON
*
PowerSwitch
=
cJSON_GetObjectItem
(
info
,
"PowerSwitch"
);
if
(
PowerSwitch
==
NULL
)
{
cJSON_Delete
(
root
);
return
-
1
;}
cJSON_AddBoolToObject
(
arg
,
"on"
,
PowerSwitch
->
valueint
);
cJSON
*
Temperature
=
cJSON_GetObjectItem
(
info
,
"Temperature"
);
if
(
Temperature
==
NULL
)
{
cJSON_Delete
(
root
);
return
-
1
;}
cJSON_AddNumberToObject
(
arg
,
"settingTemperature"
,
Temperature
->
valuedouble
);
cJSON
*
CurrentTemperature
=
cJSON_GetObjectItem
(
info
,
"CurrentTemperature"
);
if
(
CurrentTemperature
==
NULL
)
{
cJSON_Delete
(
root
);
return
-
1
;}
cJSON_AddNumberToObject
(
arg
,
"roomTemperature"
,
CurrentTemperature
->
valuedouble
);
cJSON
*
WindSpeed
=
cJSON_GetObjectItem
(
info
,
"WindSpeed"
);
if
(
WindSpeed
==
NULL
)
{
cJSON_Delete
(
root
);
return
-
1
;}
cJSON_AddStringToObject
(
arg
,
"fanSpeed"
,
speedMap
[
WindSpeed
->
valueint
]);
cJSON
*
WorkMode
=
cJSON_GetObjectItem
(
info
,
"WorkMode"
);
if
(
WorkMode
==
NULL
)
{
cJSON_Delete
(
root
);
return
-
1
;}
cJSON_AddStringToObject
(
arg
,
"runModel"
,
modeMap
[
WorkMode
->
valueint
]);
cJSON_AddItemToObject
(
root
,
"arg"
,
arg
);
...
...
midware/midware/dm/kk_dm_msg.h
View file @
96034b95
...
...
@@ -153,6 +153,7 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
int
dm_msg_thing_syncinfo_reply
(
void
);
int
dm_msg_thing_syncinfopush_reply
(
void
);
void
kk_split
(
char
*
src
,
const
char
*
separator
,
char
**
dest
,
int
*
num
);
int
kk_msg_cloud_status_notify
(
const
char
*
deviceCode
,
const
char
*
productCode
);
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
...
...
midware/midware/dm/kk_sub_db.c
View file @
96034b95
...
...
@@ -590,7 +590,7 @@ static productype_map_s producTypeMap[] = {
{
"LIGHT_STRIP"
,
"colorDimmableLight"
},
{
"LIGHT_DIMMER"
,
"lightPanel"
},
{
"SOCKET"
,
"outlet"
},
{
"AC_IndoorUnit"
,
"air
Conditioning
"
},
{
"AC_IndoorUnit"
,
"air
conditioning gateway
"
},
{
"FLOOR_HEATING"
,
"floorHeating"
},
{
"FRESH_AIR"
,
"freshAir"
},
{
"AIR_SWITCH"
,
"airSwitch"
},
...
...
@@ -599,6 +599,59 @@ int kk_get_product_type_table_size(void)
{
return
sizeof
(
producTypeMap
)
/
sizeof
(
productype_map_s
);
}
static
int
_kk_indoor_air_info_handle
(
char
*
deviceCode
,
char
*
propertyName
,
char
*
propertyValue
,
int
ep
,
int
delay
,
char
*
gwDeviceCode
,
char
*
sceneId
,
char
*
type
)
{
int
res
=
0
;
kk_scene_action_detail_t
info
=
{
0
};
memcpy
(
info
.
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
memcpy
(
info
.
propertyName
,
propertyName
,
strlen
(
propertyName
));
memcpy
(
info
.
propertyValue
,
propertyValue
,
strlen
(
propertyValue
));
info
.
epNum
=
ep
;
info
.
delay
=
delay
;
kk_scene_action_add
(
gwDeviceCode
,
sceneId
,
info
);
res
=
kk_scene_insert_scene_action
(
type
,
deviceCode
,
info
.
epNum
,
propertyName
,
propertyValue
,
info
.
delay
,
sceneId
,
gwDeviceCode
);
if
(
res
!=
SUCCESS_RETURN
){
INFO_PRINT
(
"kk_subDev_set_action_by_productType fail!!!
\n
"
);
}
return
res
;
}
static
int
_kk_indoor_air_handle
(
char
*
deviceCode
,
char
*
sceneId
,
char
*
propertyName
,
char
*
propertyValue
,
char
*
type
,
int
delay
,
char
*
gwDeviceCode
)
{
int
eplist
[
64
]
=
{
0
};
char
data
[
32
]
=
{
0
};
int
res
=
0
;
int
i
=
0
;
int
count
=
kk_indoorAir_query_epnums
(
deviceCode
,
eplist
);
for
(
i
=
0
;
i
<
count
;
i
++
){
if
(
strcmp
(
propertyName
,
"CustomAction"
)
==
0
){
cJSON
*
json
=
cJSON_Parse
(
propertyValue
);
if
(
json
==
NULL
)
{
return
-
1
;
}
cJSON
*
Temperature
=
cJSON_GetObjectItem
(
json
,
"Temperature"
);
if
(
Temperature
==
NULL
)
{
cJSON_Delete
(
json
);
return
-
1
;}
memset
(
data
,
0x0
,
sizeof
(
data
));
sprintf
(
data
,
"%f"
,
Temperature
->
valuedouble
);
_kk_indoor_air_info_handle
(
deviceCode
,
"Temperature"
,
data
,
eplist
[
i
],
delay
,
gwDeviceCode
,
sceneId
,
type
);
cJSON
*
WindSpeed
=
cJSON_GetObjectItem
(
json
,
"WindSpeed"
);
if
(
WindSpeed
==
NULL
)
{
cJSON_Delete
(
json
);
return
-
1
;}
memset
(
data
,
0x0
,
sizeof
(
data
));
sprintf
(
data
,
"%d"
,
WindSpeed
->
valueint
);
_kk_indoor_air_info_handle
(
deviceCode
,
"WindSpeed"
,
data
,
eplist
[
i
],
delay
,
gwDeviceCode
,
sceneId
,
type
);
cJSON
*
WorkMode
=
cJSON_GetObjectItem
(
json
,
"WorkMode"
);
if
(
WorkMode
==
NULL
){
cJSON_Delete
(
json
);
return
-
1
;}
memset
(
data
,
0x0
,
sizeof
(
data
));
sprintf
(
data
,
"%d"
,
WorkMode
->
valueint
);
_kk_indoor_air_info_handle
(
deviceCode
,
"WorkMode"
,
data
,
eplist
[
i
],
delay
,
gwDeviceCode
,
sceneId
,
type
);
cJSON_Delete
(
json
);
}
else
{
_kk_indoor_air_info_handle
(
deviceCode
,
propertyName
,
propertyValue
,
eplist
[
i
],
delay
,
gwDeviceCode
,
sceneId
,
type
);
}
}
return
0
;
}
int
kk_subDev_set_action_by_productType
(
const
char
*
productType
,
const
char
*
sceneId
,
const
char
*
propertyName
,
const
char
*
propertyValue
,
const
char
*
type
,
int
delay
)
{
int
res
=
0
;
...
...
@@ -609,7 +662,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
const
char
*
searchCmd
=
"select * from SubDeviceInfo WHERE productType= '%s'"
;
int
idx
=
0
;
int
gw_support_scene
=
0
;
//
int gw_support_scene = 0;
kk_tsl_data_t
*
property
=
NULL
;
int
k
=
0
,
count
=
0
;
char
typeArray
[
10
][
32
]
=
{
0
};
...
...
@@ -635,7 +688,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
}
}
for
(
k
=
0
;
k
<
count
;
k
++
){
//printf("---------------------------->
typeArray[k]:%s\n",typeArray[k]);
INFO_PRINT
(
"
typeArray[k]:%s
\n
"
,
typeArray
[
k
]);
sqlCmd
=
sqlite3_mprintf
(
searchCmd
,
typeArray
[
k
]);
//curtain type
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
...
...
@@ -645,12 +698,18 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
if
(
res
!=
SUCCESS_RETURN
)
{
continue
;
}
if
(
strcmp
(
typeArray
[
k
],
"air conditioning gateway"
)
==
0
){
_kk_indoor_air_handle
(
pDeviceCode
,
sceneId
,
propertyName
,
propertyValue
,
type
,
delay
,
node
->
fatherDeviceCode
);
continue
;
}
#if 0
if(kk_subDev_check_scene_support(node->fatherDeviceCode) == 1){
gw_support_scene = 1;
}
else{
gw_support_scene = 0;
}
#endif
//if(!strcmp(typeArray[k],"switch")){
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
...
...
@@ -659,7 +718,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
}
char
*
ptr
=
strstr
(
property
->
identifier
,
propertyName
);
if
(
ptr
!=
NULL
&&
(
ptr
-
property
->
identifier
==
0
)
){
if
(
gw_support_scene
){
//
if(gw_support_scene){
kk_scene_action_detail_t
info
=
{
0
};
memcpy
(
info
.
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
memcpy
(
info
.
propertyName
,
property
->
identifier
,
strlen
(
property
->
identifier
));
...
...
@@ -681,7 +740,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
//return res;
continue
;
}
}
//
}
}
}
...
...
midware/midware/midware.c
View file @
96034b95
...
...
@@ -666,6 +666,8 @@ static int kk_indoorAir_property_save(cJSON *payload,char *deviceCode)
while
(
client_list
!=
NULL
){
cJSON
*
epNum
=
cJSON_GetObjectItem
(
client_list
,
"epNum"
);
if
(
epNum
==
NULL
){
client_list
=
client_list
->
next
;
// printf("-----------------------------------------------------------------------222\n");
continue
;
}
if
(
epNum
->
type
==
cJSON_Number
){
...
...
@@ -676,6 +678,7 @@ static int kk_indoorAir_property_save(cJSON *payload,char *deviceCode)
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
client_list
=
client_list
->
next
;
continue
;
}
propertyItem
=
cJSON_GetObjectItem
(
client_list
,
property
->
identifier
);
...
...
midware/tsl/tsl_handle/kk_tsl_api.c
View file @
96034b95
...
...
@@ -809,7 +809,7 @@ static int _kk_tsl_get_service_input_value(_IN_ kk_tsl_t * dev_shadow, _IN_ char
return
FAIL_RETURN
;
}
res
=
(
data
,
&
type
);
res
=
kk_tsl_get_data_type
(
data
,
&
type
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment