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
db4d645b
Commit
db4d645b
authored
Dec 10, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改floor id 相关
【提交人】陈伟灿
parent
fa827093
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
434 additions
and
165 deletions
+434
-165
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+4
-35
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+6
-0
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+24
-25
common/api/ccu_ver.h
common/api/ccu_ver.h
+4
-1
common/curl/libcurl_a133.so
common/curl/libcurl_a133.so
+0
-0
common/hal/kk_product.h
common/hal/kk_product.h
+2
-1
midware/midware/area/kk_area_handle.c
midware/midware/area/kk_area_handle.c
+21
-16
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+5
-31
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+5
-2
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+93
-48
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+53
-4
midware/midware/midware.c
midware/midware/midware.c
+175
-2
nx5_soc_gw/kk_device_def.json
nx5_soc_gw/kk_device_def.json
+19
-0
nx5_soc_gw/smarthome_z3gw_nx5
nx5_soc_gw/smarthome_z3gw_nx5
+0
-0
tools/build-rules/_rules-top.mk
tools/build-rules/_rules-top.mk
+23
-0
No files found.
application/kcloud/kcloud_main.c
View file @
db4d645b
...
...
@@ -88,31 +88,6 @@ static int KK_Ccuid_init(void)
char
s_pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
static
int
kk_cloud_pid_init
(
void
)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t
data
[
128
]
=
{
0
};
int
data_len
=
0
;
char
*
pstart
=
NULL
;
char
*
pEnd
=
NULL
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
data
,
sizeof
(
data
),
&
data_len
);
printf
(
"---GET_CCUID_CMD:%s
\n
"
,
data
);
if
(
data_len
>
0
&&
data_len
<=
128
){
pstart
=
data
;
pEnd
=
strstr
(
data
,
"pid_"
);
if
(
pstart
!=
NULL
&&
pEnd
!=
NULL
){
memcpy
(
s_pid
,
pEnd
+
4
,
data_len
-
1
-
(
pEnd
-
pstart
+
4
));
INFO_PRINT
(
"kk_cloud_pid_init s_pid:%s
\n
"
,
s_pid
);
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT
(
"KK_Ccuid_init get ccuid error
\n
"
);
return
-
1
;
}
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT
(
"KK_Ccuid_init get ccuid error
\n
"
);
return
-
1
;
}
#else
char
pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
int
pid_len
=
0
;
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
pid
,
sizeof
(
pid
),
&
pid_len
);
...
...
@@ -122,7 +97,6 @@ static int kk_cloud_pid_init(void)
}
else
{
return
-
1
;
}
#endif
return
0
;
}
int
kk_cloud_get_pid
(
char
*
productId
)
...
...
@@ -142,10 +116,10 @@ static int kk_cloud_key_init(void)
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
key
,
sizeof
(
key
),
&
key_len
);
printf
(
"---productSecret:%s
\n
"
,
key
);
if
(
key_len
>
0
&&
key_len
<=
128
){
pstart
=
strstr
(
key
,
"key_"
);
;
pEnd
=
strstr
(
key
,
"
-pid
_"
);
if
(
p
start
!=
NULL
&&
p
End
!=
NULL
){
memcpy
(
s_key
,
p
start
+
4
,
pEnd
-
pstart
+
4
);
pstart
=
key
;
pEnd
=
strstr
(
key
,
"
key
_"
);
if
(
pEnd
!=
NULL
){
memcpy
(
s_key
,
p
End
+
4
,
key_len
-
1
-
(
pEnd
-
pstart
+
4
)
);
INFO_PRINT
(
"kk_cloud_key_init s_key:%s
\n
"
,
s_key
);
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
...
...
@@ -273,11 +247,6 @@ int main(int argc, char* argv[])
kk_cloud_pid_init
();
kk_cloud_key_init
();
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
//kk_info_report_start();
//
#ifdef CONFIG_NX5_PLATFORM
//adlakdlkf
#endif
#if 1
kk_dl_config
();
again:
...
...
application/kcloud/kk_topic_mng.c
View file @
db4d645b
...
...
@@ -10,6 +10,7 @@
#include "mqtt_api.h"
const
char
KK_URI_SYS_PREFIX
[]
=
"biz/newkk/%s/%s/thing/service/property/set"
;
const
char
KK_URI_SYS_PREFIX_GET
[]
=
"biz/newkk/%s/%s/thing/service/property/get"
;
const
char
KK_URI_SYS_PREFIX_SERVICE
[]
=
"biz/newkk/%s/%s/thing/service/+"
;
const
char
KK_URI_SYS_PREFIX_TOPO_CHANGE
[]
=
"biz/newkk/%s/%s/thing/topo/change"
;
const
char
KK_URI_SYS_PREFIX_EX
[]
=
"biz/newkk/%s/%s"
;
...
...
@@ -59,6 +60,11 @@ int KK_Subdev_Subscribe(const cJSON *root)
INFO_PRINT
(
"ota [%s][%d] URL:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
url
);
res
=
KK_MQTT_SubTopic
(
url
);
memset
(
url
,
0
,
url_len
);
snprintf
(
url
,
url_len
,
KK_URI_SYS_PREFIX_GET
,
productCode
->
valuestring
,
deviceCode
->
valuestring
);
INFO_PRINT
(
"sys [%s][%d] URL:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
url
);
res
=
KK_MQTT_SubTopic
(
url
);
memset
(
url
,
0
,
url_len
);
snprintf
(
url
,
url_len
,
KK_URI_SYS_PREFIX
,
productCode
->
valuestring
,
deviceCode
->
valuestring
);
INFO_PRINT
(
"sys [%s][%d] URL:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
url
);
...
...
application/klansdk/kk_lan_main.c
View file @
db4d645b
...
...
@@ -54,28 +54,6 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
char
s_pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
static
int
kk_lan_pid_init
(
void
)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t
data
[
128
]
=
{
0
};
int
data_len
=
0
;
uint8_t
uuid
[
32
]
=
{
0
};
char
*
pstart
=
NULL
;
char
*
pEnd
=
NULL
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
data
,
sizeof
(
data
),
&
data_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
data
);
if
(
data_len
>
0
&&
data_len
<=
128
){
pstart
=
data
;
pEnd
=
strstr
(
data
,
"pid_"
);
if
(
pstart
!=
NULL
&&
pEnd
!=
NULL
){
memcpy
(
s_pid
,
pEnd
+
4
,
data_len
-
1
-
(
pEnd
-
pstart
+
4
));
INFO_PRINT
(
"s_pid:%s
\n
"
,
s_pid
);
}
else
{
return
-
1
;
}
}
else
{
return
-
1
;
}
#else
char
pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
int
pid_len
=
0
;
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
pid
,
sizeof
(
pid
),
&
pid_len
);
...
...
@@ -85,7 +63,6 @@ static int kk_lan_pid_init(void)
}
else
{
return
-
1
;
}
#endif
return
0
;
}
int
kk_lan_get_pid
(
_OU_
char
*
productId
)
...
...
@@ -97,6 +74,27 @@ int kk_lan_get_pid(_OU_ char *productId)
static
void
kk_lan_ccuid_init
(
void
)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t
data
[
128
]
=
{
0
};
int
data_len
=
0
;
uint8_t
uuid
[
32
]
=
{
0
};
char
*
pstart
=
NULL
;
char
*
pEnd
=
NULL
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
data
,
sizeof
(
data
),
&
data_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
data
);
if
(
data_len
>
0
&&
data_len
<=
128
){
pstart
=
data
;
pEnd
=
strstr
(
data
,
"-"
);
if
(
pstart
!=
NULL
&&
pEnd
!=
NULL
){
memcpy
(
uuid
,
pstart
,
pEnd
-
pstart
);
_setDevice_Code
(
uuid
,
pEnd
-
pstart
);
}
else
{
return
;
}
}
else
{
return
;
}
#else
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
...
...
@@ -108,6 +106,7 @@ static void kk_lan_ccuid_init(void)
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
}
#endif
}
int
prg_run_singleton
(
const
char
*
prg
)
...
...
@@ -211,11 +210,11 @@ int main(int argc, char* argv[])
struct
sigaction
sa
;
/* setup alarm signal handler */
#ifdef CONFIG_NX5_PLATFORM
//
#ifdef CONFIG_NX5_PLATFORM
for
(
int
i
=
1
;
i
<
32
;
i
++
){
signal
(
i
,
handler
);
}
#endif
//
#endif
//signal(SIGPIPE, SIG_IGN);
...
...
common/api/ccu_ver.h
View file @
db4d645b
...
...
@@ -3,7 +3,10 @@
#define KK_CCU_VERSION "1.3.0"
#ifdef CONFIG_A133_PLATFORM
#define KK_VERSION_FILE_PATH "/data/local/kk/etc/VERSION"
#else
#define KK_VERSION_FILE_PATH "/app/ccuApps/VERSION"
#endif
#endif
common/curl/libcurl_a133.so
View file @
db4d645b
No preview for this file type
common/hal/kk_product.h
View file @
db4d645b
...
...
@@ -40,6 +40,7 @@
#define KK_DEVICE_MAP_FILE_PATH "/data/local/kk/map/device_%s.json"
#define GET_CCUID_CMD "getprop ro.ccuinfo"
#define GET_KEY_CMD "getprop ro.ccuinfo"
#define GET_PRODUCTID_CMD "getprop ro.product.ccu.pid"
#define KK_DB_FILE "/data/local/kk/etc/kk_database.db"
#define TSL_SUBDEVICE_PATH_FILE "/data/local/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/data/local/kk/tsl/gateway_%s.json"
...
...
@@ -49,7 +50,7 @@
#define OTA_IMG_FILE "/data/local/OTA/app_squashfs.img"
#define OTA_IMG_FILE_MD5 "/data/local/OTA/app_squashfs.img.md5"
#define KK_CONFIG_FILE_PATH "/data/local/kk/kk_cloud_conf.json"
#define KK_DEFAULT_CONFIG_FILE_PATH "/data/local/kk/cloud_default_config.json"
#define KK_DEFAULT_CONFIG_FILE_PATH "/data/local/kk/
etc/
cloud_default_config.json"
#define KK_AUTH_CONFIG_FILE_PATH "/data/local/kk/auth_conf.json"
#else
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
...
...
midware/midware/area/kk_area_handle.c
View file @
db4d645b
...
...
@@ -115,7 +115,7 @@ int kk_area_init(void)
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
"[%s][%d]kk_area_init FAIL!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
}
//kk_floor_add("默认","1
");//创建默认楼层
kk_floor_add
(
"默认"
,
"0
"
);
//创建默认楼层
return
SUCCESS_RETURN
;
}
static
int
kk_check_room_exist
(
const
char
*
roomId
)
...
...
@@ -157,7 +157,7 @@ static int _kk_room_add(const char *name,const char *roomId)
_kk_area_lock
();
ctx
->
roomNum
++
;
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
name
,
roomId
,
-
1
,
"
1
"
,
"默认"
);
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
name
,
roomId
,
-
1
,
"
0
"
,
"默认"
);
res
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
res
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
@@ -226,29 +226,29 @@ int kk_room_add(const char *name,const char *roomId)
}
}
int
kk_get_
roomname_by_id
(
const
char
*
roomid
,
char
*
room
name
,
int
len
)
int
kk_get_
floorname_by_id
(
const
char
*
floorid
,
char
*
floor
name
,
int
len
)
{
int
isExist
=
0
;
sqlite3_stmt
*
stmt
;
char
*
p
Room
name
=
NULL
;
char
*
p
Floor
name
=
NULL
;
kk_area_ctx_t
*
ctx
=
_kk_area_get_ctx
();
char
*
sqlCmd
=
NULL
;
int
tlen
=
0
;
if
(
roomname
==
NULL
){
if
(
floorid
==
NULL
){
return
-
1
;
}
_kk_area_lock
();
sqlCmd
=
sqlite3_mprintf
(
"select * from
AreaInfo WHERE roomId= '%s'"
,
room
id
);
sqlCmd
=
sqlite3_mprintf
(
"select * from
floorInfo WHERE floorId= '%s'"
,
floor
id
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
p
Roomname
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_ROOM
_NAME
);
p
Floorname
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_FLOOR
_NAME
);
}
if
(
p
Roomname
!=
NULL
&&
strlen
(
pRoom
name
)
>
0
){
tlen
=
strlen
(
p
Roomname
)
>
len
?
len
:
strlen
(
pRoom
name
);
strncpy
(
roomname
,
pRoom
name
,
tlen
);
if
(
p
Floorname
!=
NULL
&&
strlen
(
pFloor
name
)
>
0
){
tlen
=
strlen
(
p
Floorname
)
>
len
?
len
:
strlen
(
pFloor
name
);
strncpy
(
floorname
,
pFloor
name
,
tlen
);
}
else
{
strcpy
(
room
name
,
""
);
strcpy
(
floor
name
,
""
);
}
sqlite3_finalize
(
stmt
);
sqlite3_free
(
sqlCmd
);
...
...
@@ -330,10 +330,15 @@ int kk_room_set_floor_info(const char*floorId,const char* floorName,const char *
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_area_ctx_t
*
ctx
=
_kk_area_get_ctx
();
_kk_area_lock
();
printf
(
"----------------------floorId:%s,floorName:%s,roomid:%s
\n
"
,
floorId
,
floorName
,
roomid
);
sqlCmd
=
sqlite3_mprintf
(
"UPDATE AreaInfo SET floorId='%s',floorName='%s' WHERE roomId= '%s'"
,
floorId
,
floorName
,
roomid
);
_kk_area_lock
();
if
(
strcmp
(
floorName
,
""
)
==
0
){
char
floorNameBuf
[
128
]
=
{
0
};
kk_get_floorname_by_id
(
floorId
,
floorNameBuf
,
sizeof
(
floorNameBuf
));
sqlCmd
=
sqlite3_mprintf
(
"UPDATE AreaInfo SET floorId='%s',floorName='%s' WHERE roomId= '%s'"
,
floorId
,
floorNameBuf
,
roomid
);
}
else
{
sqlCmd
=
sqlite3_mprintf
(
"UPDATE AreaInfo SET floorId='%s',floorName='%s' WHERE roomId= '%s'"
,
floorId
,
floorName
,
roomid
);
}
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
@@ -353,7 +358,7 @@ int kk_set_floor_to_default(const char*floorId)
kk_area_ctx_t
*
ctx
=
_kk_area_get_ctx
();
_kk_area_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE AreaInfo SET floorId='%s',floorName='%s' WHERE floorId= '%s'"
,
"
1
"
,
"默认"
,
floorId
);
sqlCmd
=
sqlite3_mprintf
(
"UPDATE AreaInfo SET floorId='%s',floorName='%s' WHERE floorId= '%s'"
,
"
0
"
,
"默认"
,
floorId
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
midware/midware/dm/kk_dm_mng.c
View file @
db4d645b
...
...
@@ -597,30 +597,6 @@ static void _dm_mgr_destroy_devlist(void)
char
s_pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
static
int
kk_pid_init
(
void
)
{
#ifdef CONFIG_A133_PLATFORM
uint8_t
data
[
128
]
=
{
0
};
int
data_len
=
0
;
char
*
pstart
=
NULL
;
char
*
pEnd
=
NULL
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
data
,
sizeof
(
data
),
&
data_len
);
printf
(
"---GET_CCUID_CMD:%s
\n
"
,
data
);
if
(
data_len
>
0
&&
data_len
<=
128
){
pstart
=
data
;
pEnd
=
strstr
(
data
,
"pid_"
);
if
(
pstart
!=
NULL
&&
pEnd
!=
NULL
){
memcpy
(
s_pid
,
pEnd
+
4
,
data_len
-
1
-
(
pEnd
-
pstart
+
4
));
INFO_PRINT
(
"kk_cloud_pid_init s_pid:%s
\n
"
,
s_pid
);
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT
(
"KK_Ccuid_init get ccuid error
\n
"
);
return
-
1
;
}
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
INFO_PRINT
(
"KK_Ccuid_init get ccuid error
\n
"
);
return
-
1
;
}
#else
char
pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
int
pid_len
=
0
;
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
pid
,
sizeof
(
pid
),
&
pid_len
);
...
...
@@ -630,13 +606,12 @@ static int kk_pid_init(void)
}
else
{
return
-
1
;
}
#endif
return
0
;
}
int
kk_get_pid
(
char
*
productId
)
{
strncpy
(
productId
,
s_pid
,
strlen
(
s_pid
));
printf
(
"kk_
lan_get_ccu
id:%s
\n
"
,
s_pid
);
printf
(
"kk_
get_p
id:%s
\n
"
,
s_pid
);
return
strlen
(
s_pid
);
}
extern
char
*
kk_sync_get_info
();
...
...
@@ -646,7 +621,7 @@ int dm_mgr_init(void)
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
char
mac
[
DEVICE_MAC_MAXLEN
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
pid
[
32
]
=
{
0
};
int
devId
=
0
,
heartbeat
=
0
;
memset
(
ctx
,
0
,
sizeof
(
dm_mgr_ctx
));
...
...
@@ -658,21 +633,20 @@ int dm_mgr_init(void)
/* Init Device Id*/
ctx
->
global_devid
=
1
;
kk_property_db_init
();
HAL_Get_ccuid
(
ccuid
);
HAL_Get_ccuid
(
ccuid
);
kk_pid_init
();
kk_get_pid
(
pid
);
/* Init Device List */
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
HAL_Get_mac
(
mac
);
kk_sync_init
();
//kk_sync_get_info();
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
s_
pid
,
ccuid
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
pid
,
ccuid
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
}
else
{
kk_property_db_update
(
ccuid
);
}
return
SUCCESS_RETURN
;
...
...
midware/midware/dm/kk_dm_msg.h
View file @
db4d645b
...
...
@@ -49,6 +49,7 @@ typedef struct {
#define KK_ONLINE_TOPIC_REPLY "/thing/status/online_reply"
#define KK_THING_SERVICE_PROPERTY_SET "/thing/service/property/set"
#define KK_THING_SERVICE_PROPERTY_GET "/thing/service/property/get"
#define KK_THING_SERVICE_PROPERTY_GET_REPLY "/thing/service/property/get_reply"
#define KK_THING_OTA_DEVICE_UPGRADE "/thing/service/upgrade"
#define KK_THING_CLOUDSTATE_MSG "/thing/ccu/cloudstate_reply"
#define KK_THING_TOPO_ADD_MSG "/thing/topo/add"
...
...
@@ -60,8 +61,10 @@ typedef struct {
#define KK_THING_SERVICE_REBOOT "/thing/service/reboot"
#define KK_THING_SERVICE_ADDROOM "/thing/service/addRoom"
#define KK_THING_SERVICE_ADDROOM_REPLY "/thing/service/addRoom_reply"
#define KK_THING_SERVICE_UPDATEROOM "/thing/service/updateRoomName"
#define KK_THING_SERVICE_UPDATEROOM_REPLY "/thing/service/updateRoomName_reply"
#define KK_THING_SERVICE_UPDATEROOM "/thing/service/updateRoom"
#define KK_THING_SERVICE_UPDATEROOM_REPLY "/thing/service/updateRoom_reply"
#define KK_THING_SERVICE_UPDATEROOMNAME "/thing/service/updateRoomName"
#define KK_THING_SERVICE_UPDATEROOMNAME_REPLY "/thing/service/updateRoomName_reply"
#define KK_THING_SERVICE_DELETEROOM "/thing/service/deleteRoom"
#define KK_THING_SERVICE_DELETEROOM_REPLY "/thing/service/deleteRoom_reply"
#define KK_THING_SERVICE_ADDDEVICETOROOM "/thing/service/addDeviceToRoom"
...
...
midware/midware/dm/kk_linkkit.c
View file @
db4d645b
...
...
@@ -433,7 +433,7 @@ static int kk_service_addRoom_reply(cJSON *param,cJSON *msgId,char *roomid,int t
if
(
type
==
0
){
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_ADDROOM_REPLY
);
}
else
{
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_UPDATEROOM_REPLY
);
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_UPDATEROOM
NAME
_REPLY
);
}
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
...
...
@@ -484,13 +484,58 @@ static int kk_service_addRoom_handle(const char *deviceCode, cJSON *params,cJSON
if
(
roomInfoStr
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
floorId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
){
//return FAIL_RETURN;
}
//memcpy(roomId,roomIdStr->valuestring,strlen(roomIdStr->valuestring));
HAL_GetTime_s
((
char
*
)
roomId
);
kk_room_add
(
roomInfoStr
->
valuestring
,
roomId
);
kk_service_addRoom_reply
(
inforoot
,
msgid
,
roomId
,
0
);
kk_tsl_set_value
(
kk_tsl_set_event_output_value
,
node
->
dev_shadow
,
MSG_AREA_ADDROOM_NOTIFICATION_ROOMID
,
NULL
,
roomId
);
if
(
floorId
!=
NULL
){
kk_room_set_floor_info
(
floorId
->
valuestring
,
""
,
roomId
);
}
return
SUCCESS_RETURN
;
}
static
int
kk_service_common_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
)
{
int
res
=
0
;
int
i
=
0
,
num
=
0
;
SensorType_t
*
pList
=
NULL
;
char
version
[
VERSION_MAXLEN
]
=
{
0
};
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
param
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
msgType
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
cJSON
*
Item
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
payload
,
"params"
,
Item
);
char
*
payload11
=
cJSON_Print
(
payload
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
res
;
}
/************************************************************
*功能描述:更新房间处理函数
*输入参数:params:云端传下来JSON数据,主要包含房间名称
...
...
@@ -514,8 +559,15 @@ static int kk_service_updateRoom_handle(const char *deviceCode, cJSON *params,cJ
//memcpy(roomId,roomIdStr->valuestring,strlen(roomIdStr->valuestring));
//INFO_PRINT(" update room 111!!! %s.%s\n",roomInfoStr->valuestring,roomIdStr->valuestring);
kk_room_add
(
roomInfoStr
->
valuestring
,
roomIdStr
->
valuestring
);
cJSON
*
floorId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
){
kk_service_addRoom_reply
(
inforoot
,
msgid
,
roomIdStr
->
valuestring
,
1
);
}
else
{
kk_room_set_floor_info
(
floorId
->
valuestring
,
roomIdStr
->
valuestring
,
roomIdStr
->
valuestring
);
kk_service_common_reply
(
inforoot
,
msgid
,
KK_THING_SERVICE_UPDATEROOM_REPLY
);
}
//INFO_PRINT(" update room 111!!!\n");
kk_service_addRoom_reply
(
inforoot
,
msgid
,
roomIdStr
->
valuestring
,
1
);
//INFO_PRINT(" update room 111!!!\n");
return
SUCCESS_RETURN
;
}
...
...
@@ -1076,13 +1128,29 @@ static int kk_service_client_online_push(cJSON *param,cJSON *msgId,char *serialI
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
void
kk_strdel
(
char
*
s
,
char
del_x
)
{
char
*
p
;
char
*
q
;
for
(
p
=
s
,
q
=
s
;
*
p
!=
'\0'
;
p
++
)
if
(
*
p
!=
del_x
)
*
q
++=*
p
;
*
q
=*
p
;
}
static
int
kk_service_addScreen_handle
(
cJSON
*
info
,
cJSON
*
msgId
,
cJSON
*
params
)
{
char
str_mac
[
32
]
=
{
0
};
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
mac
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_MAC
);
if
(
mac
==
NULL
)
return
INVALID_PARAMETER
;
strcpy
(
str_mac
,
mac
->
valuestring
);
kk_strdel
(
str_mac
,
':'
);
cJSON
*
ip
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_IP
);
if
(
ip
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
version
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_VERSION
);
...
...
@@ -1090,11 +1158,13 @@ static int kk_service_addScreen_handle(cJSON *info,cJSON *msgId,cJSON *params)
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_SERIALID
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
devtype
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_TYPE
);
if
(
devtype
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
expand
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_EXPAND
);
if
(
expand
==
NULL
)
return
INVALID_PARAMETER
;
kk_service_addScreen_handle_reply
(
info
,
msgId
,
serialid
->
valuestring
);
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
mac
->
valuestring
,
version
->
valuestring
,
expand
->
valuestring
);
if
(
devtype
==
NULL
)
return
INVALID_PARAMETER
;
kk_service_addScreen_handle_reply
(
info
,
msgId
,
serialid
->
valuestring
);
#ifdef CONFIG_A133_PLATFORM
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
str_mac
,
version
->
valuestring
,
""
);
#else
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
&
str_mac
[
4
],
version
->
valuestring
,
""
);
#endif
kk_service_client_online_push
(
info
,
msgId
,
serialid
->
valuestring
);
return
SUCCESS_RETURN
;
}
...
...
@@ -1108,18 +1178,23 @@ static int kk_service_addScreen_handle(cJSON *info,cJSON *msgId,cJSON *params)
*************************************************************/
static
int
kk_service_addScreenToRoom_handle
(
cJSON
*
params
)
{
char
str_mac
[
32
]
=
{
0
};
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
mac
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
mac
==
NULL
)
return
INVALID_PARAMETER
;
strcpy
(
str_mac
,
mac
->
valuestring
);
cJSON
*
roomname
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
if
(
roomname
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
roomId
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETER
;
kk_screenDev_update_room
(
serialid
->
valuestring
,
roomId
->
valuestring
,
roomname
->
valuestring
,
name
->
valuestring
);
if
(
name
==
NULL
)
return
INVALID_PARAMETER
;
#ifdef CONFIG_A133_PLATFORM
#else
kk_screenDev_update_room
(
str_mac
,
roomId
->
valuestring
,
roomname
->
valuestring
,
name
->
valuestring
);
#endif
return
SUCCESS_RETURN
;
}
/************************************************************
...
...
@@ -1522,44 +1597,7 @@ static int kk_service_getCCUVersion_handle(cJSON *param,cJSON *msgId)
cJSON_Delete
(
info
);
return
res
;
}
static
int
kk_service_common_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
msgType
)
{
int
res
=
0
;
int
i
=
0
,
num
=
0
;
SensorType_t
*
pList
=
NULL
;
char
version
[
VERSION_MAXLEN
]
=
{
0
};
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
param
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
msgType
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
cJSON
*
Item
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
payload
,
"params"
,
Item
);
char
*
payload11
=
cJSON_Print
(
payload
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
res
;
}
/************************************************************
*功能描述:获取主机版本信息
*输入参数:params:云端下发数据,包含场景Id等
...
...
@@ -1944,6 +1982,13 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
kk_service_updateRoom_handle
(
deviceCode
->
valuestring
,
paramStr
,
info_root
,
msgId
);
//dm_msg_thing_event_post(deviceCode->valuestring,MSG_AREA_ADDROOM_NOTIFICATION,msgId->valuestring);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_UPDATEROOMNAME
)
==
0
){
INFO_PRINT
(
" update roomname!!!
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_updateRoom_handle
(
deviceCode
->
valuestring
,
paramStr
,
info_root
,
msgId
);
//dm_msg_thing_event_post(deviceCode->valuestring,MSG_AREA_ADDROOM_NOTIFICATION,msgId->valuestring);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_DELETEROOM
)
==
0
){
INFO_PRINT
(
" delete room
\n
"
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
...
...
midware/midware/dm/kk_sub_db.c
View file @
db4d645b
...
...
@@ -859,6 +859,40 @@ static int _kk_check_screenDev_exist(const char* sId)
}
/************************************************************
*功能描述:更新设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_screenDev_update
(
int
devType
,
char
*
serialId
,
\
char
*
ip
,
char
*
mac
,
char
*
version
)
{
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE ScreenDeviceInfo SET deviceIp= '%s',mac ='%s',version = '%s' WHERE serialId= '%s'"
,
ip
,
mac
,
version
,
serialId
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
INFO_PRINT
(
"Table updata data successfully
\n
"
);
}
sqlite3_free
(
sqlCmd
);
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:保存设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
...
...
@@ -884,11 +918,15 @@ int kk_screenDev_insert_db(int devType,char *serialId, \
if
(
_kk_check_screenDev_exist
((
const
char
*
)
serialId
)
==
1
)
{
WARNING_PRINT
(
"[%s][%d] DATA ALREADY EXIST!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
kk_screenDev_update
(
devType
,
serialId
,
ip
,
mac
,
version
);
return
SUCCESS_RETURN
;
}
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
"MOOR4C"
,
mac
,
version
,
""
,
""
,
expand
);
#ifdef CONFIG_A133_PLATFORM
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
"MOOR4S"
,
mac
,
version
,
""
,
""
,
expand
);
#else
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
"MOOR4C"
,
mac
,
version
,
""
,
""
,
expand
);
#endif
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
...
...
@@ -914,15 +952,26 @@ int kk_screenDev_insert_db(int devType,char *serialId, \
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_screenDev_update_room
(
char
*
serialId
,
char
*
roomid
,
char
*
roomname
,
char
*
name
)
void
str_trans
(
char
c
[])
{
int
i
;
for
(
i
=
0
;
c
[
i
];
i
++
)
if
(
c
[
i
]
>=
'A'
&&
c
[
i
]
<=
'Z'
)
c
[
i
]
=
(
c
[
i
]
-
'A'
)
+
'a'
;
/*以下注释内容为小写转大写,如不需要可删除*/
/*else if(c[i]<='z' && c[i]>='a')
c[i]=(c[i]-'a')+'A';*/
}
int
kk_screenDev_update_room
(
char
*
mac
,
char
*
roomid
,
char
*
roomname
,
char
*
name
)
{
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
str_trans
(
mac
);
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE ScreenDeviceInfo SET roomId= '%s',roomName ='%s',deviceName = '%s' WHERE
serialId= '%s'"
,
roomid
,
roomname
,
name
,
serialId
);
sqlCmd
=
sqlite3_mprintf
(
"UPDATE ScreenDeviceInfo SET roomId= '%s',roomName ='%s',deviceName = '%s' WHERE
mac= '%s'"
,
roomid
,
roomname
,
name
,
mac
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
...
...
midware/midware/midware.c
View file @
db4d645b
...
...
@@ -414,7 +414,174 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
return
SUCCESS_RETURN
;
}
static
int
kk_service_get_reply
(
char
*
deviceCode
,
char
*
productCode
,
char
*
msgId
,
int
param1
,
int
param2
,
int
param3
,
int
epNum
,
char
*
type
)
{
if
(
deviceCode
==
NULL
||
productCode
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_PROPERTY_GET_REPLY
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
);
cJSON
*
paramInfo
=
cJSON_CreateObject
();
if
(
strcmp
(
type
,
"ColorTempSwitch"
)
==
0
){
cJSON_AddNumberToObject
(
paramInfo
,
"ColorTempSwitch"
,
param1
);
}
else
if
(
strcmp
(
type
,
"FadeTime"
)
==
0
){
cJSON_AddNumberToObject
(
paramInfo
,
"FadeTime"
,
param1
);
cJSON_AddNumberToObject
(
paramInfo
,
"LowBrightness"
,
param2
);
cJSON_AddNumberToObject
(
paramInfo
,
"HighBrightness"
,
param3
);
}
cJSON_AddNumberToObject
(
paramInfo
,
"epNum"
,
epNum
);
cJSON_AddItemToObject
(
payload
,
"params"
,
paramInfo
);
char
*
payload11
=
cJSON_Print
(
payload
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
SUCCESS_RETURN
;
}
static
int
kk_property_FadeAndRange_handle
(
char
*
deviceCode
,
int
epNum
,
char
*
msgid
)
{
int
res
=
0
;
int
idx
=
0
;
int
num
=
0
;
int
mutiDev
=
0
;
int
FadeTime
=
0
;
int
LowBrightness
=
0
;
int
HighBrightness
=
0
;
kk_tsl_data_t
*
property
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
char
*
propertiesbuf
[
64
]
=
{
0
};
char
propertiesTmp
[
64
]
=
{
0
};
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
}
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
continue
;
}
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
mutiDev
=
1
;
}
break
;
}
if
(
mutiDev
){
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
sprintf
(
propertiesTmp
,
"FadeTime_%d"
,
epNum
);
kk_property_db_get_value
(
deviceCode
,
propertiesTmp
,
&
FadeTime
);
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
sprintf
(
propertiesTmp
,
"LowBrightness_%d"
,
epNum
);
kk_property_db_get_value
(
deviceCode
,
propertiesTmp
,
&
LowBrightness
);
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
sprintf
(
propertiesTmp
,
"HighBrightness_%d"
,
epNum
);
kk_property_db_get_value
(
deviceCode
,
propertiesTmp
,
&
HighBrightness
);
}
else
{
kk_property_db_get_value
(
deviceCode
,
"FadeTime"
,
&
FadeTime
);
kk_property_db_get_value
(
deviceCode
,
"LowBrightness"
,
&
LowBrightness
);
kk_property_db_get_value
(
deviceCode
,
"HighBrightness"
,
&
HighBrightness
);
}
kk_service_get_reply
(
deviceCode
,
node
->
productCode
,
msgid
,
FadeTime
,
LowBrightness
,
HighBrightness
,
epNum
,
"FadeTime"
);
return
SUCCESS_RETURN
;
}
static
int
kk_property_LightProperty_handle
(
char
*
deviceCode
,
int
epNum
,
char
*
msgid
)
{
int
res
=
0
;
int
idx
=
0
;
int
num
=
0
;
int
mutiDev
=
0
;
int
ColorTempSwitch
=
0
;
kk_tsl_data_t
*
property
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
char
*
propertiesbuf
[
64
]
=
{
0
};
char
propertiesTmp
[
64
]
=
{
0
};
res
=
dm_mgr_get_device_by_devicecode
((
char
*
)
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
}
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
continue
;
}
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
memcpy
(
propertiesTmp
,
property
->
identifier
,
strlen
(
property
->
identifier
));
split
(
propertiesTmp
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
mutiDev
=
1
;
}
break
;
}
if
(
mutiDev
){
memset
(
propertiesTmp
,
0x0
,
sizeof
(
propertiesTmp
));
sprintf
(
propertiesTmp
,
"ColorTempSwitch_%d"
,
epNum
);
kk_property_db_get_value
(
deviceCode
,
propertiesTmp
,
&
ColorTempSwitch
);
}
else
{
kk_property_db_get_value
(
deviceCode
,
"ColorTempSwitch"
,
&
ColorTempSwitch
);
}
kk_service_get_reply
(
deviceCode
,
node
->
productCode
,
msgid
,
ColorTempSwitch
,
-
1
,
-
1
,
epNum
,
"ColorTempSwitch"
);
return
SUCCESS_RETURN
;
}
static
int
kk_property_get_handle
(
cJSON
*
payload
,
char
*
deviceCode
)
{
cJSON
*
params
=
NULL
;
cJSON
*
propertyItem
=
NULL
;
cJSON
*
epNum
=
NULL
;
cJSON
*
msgId
=
NULL
;
int
epNumInt
=
1
;
int
res
=
0
;
int
idx
=
0
;
int
value
=
0
;
int
iCnt
=
0
;
if
(
payload
==
NULL
||
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
if
(
msgId
==
NULL
){
return
FAIL_RETURN
;
}
params
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
if
(
params
!=
NULL
){
epNum
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
if
(
epNum
!=
NULL
){
epNumInt
=
epNum
->
valueint
;
}
else
{
epNumInt
=
1
;
}
cJSON
*
propertyIdentifier
=
cJSON_GetObjectItem
(
params
,
"propertyIdentifier"
);
if
(
propertyIdentifier
==
NULL
){
return
FAIL_RETURN
;
}
int
array_size
=
cJSON_GetArraySize
(
propertyIdentifier
);
for
(
iCnt
=
0
;
iCnt
<
array_size
;
iCnt
++
){
cJSON
*
pSub
=
cJSON_GetArrayItem
(
propertyIdentifier
,
iCnt
);
if
(
NULL
==
pSub
){
continue
;
}
if
(
strcmp
(
pSub
->
valuestring
,
"FadeAndRange"
)
==
0
){
kk_property_FadeAndRange_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
}
else
if
(
strcmp
(
pSub
->
valuestring
,
"LightProperty"
)
==
0
){
kk_property_LightProperty_handle
(
deviceCode
,
epNumInt
,
msgId
->
valuestring
);
}
}
}
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:nanomsg数据回调,app to mid
*输入参数:data:从app 层发来的数据
...
...
@@ -463,9 +630,15 @@ void mid_cb(void* data, int len){
cJSON_Delete
(
json
);
return
;
}
}
if
(
strcmp
(
type
->
valuestring
,
KK_THING_SERVICE_PROPERTY_GET
)
==
0
){
res
=
kk_property_get_handle
(
payload
,
deviceCode
->
valuestring
);
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
" kk_property_get_handle error
\n
"
);
}
cJSON_Delete
(
json
);
return
;
}
int
devType
=
0
;
dm_mgr_get_devicetype_by_devicecode
(
deviceCode
->
valuestring
,
&
devType
);
//主机的device或过滤的
...
...
nx5_soc_gw/kk_device_def.json
View file @
db4d645b
...
...
@@ -2504,6 +2504,25 @@
}
]
},
{
"pid"
:
"01010014"
,
"name"
:
"YY Live_Neutral_Wire Dimmalbe Light Model G4"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3168
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008"
}
}
]
},
{
"pid"
:
"010C0021"
,
"name"
:
"YY Dimmalbe Light Controler 12W With ColorTemp"
,
...
...
nx5_soc_gw/smarthome_z3gw_nx5
View file @
db4d645b
No preview for this file type
tools/build-rules/_rules-top.mk
View file @
db4d645b
...
...
@@ -237,6 +237,29 @@ endif
fromdos
$(releaseDir)/script/*.sh
echo
$(PWD)
package_a133
:
@
echo
"
$(buildDate)
"
echo
"kk_a133"
rm
-rf
kk_a133
mkdir
kk_a133
mkdir
kk_a133/lib
mkdir
kk_a133/bin
mkdir
kk_a133/etc
mkdir
kk_a133/map
cp
-rf
$(TOP_DIR)
/VERSION
$(TOP_DIR)
/kk_a133/etc/
cp
-rf
$(TOP_DIR)
/tsl
$(TOP_DIR)
/kk_a133
cp
-rf
$(TOP_DIR)
/output/release/lib/
*
.so
$(TOP_DIR)
/kk_a133/lib
cp
-rf
$(TOP_DIR)
/output/release/bin/
*
$(TOP_DIR)
/kk_a133/bin
cp
-rf
$(TOP_DIR)
/opcodeMapCfg/
*
$(TOP_DIR)
/kk_a133/map
cp
-rf
$(TOP_DIR)
/config/
*
$(TOP_DIR)
/kk_a133/etc
cp
-rf
$(TOP_DIR)
/common/nanomsg/libnanomsg_a133.so
$(TOP_DIR)
/kk_a133/lib/libnanomsg.so.5
cp
-rf
$(TOP_DIR)
/common/ev/libev_a133.so
$(TOP_DIR)
/kk_a133/lib/libev.so
cp
-rf
$(TOP_DIR)
/common/curl/libcurl_a133.so
$(TOP_DIR)
/kk_a133/lib/libcurl.so.4
cp
-rf
$(TOP_DIR)
/common/curl/libcrypto_a133.so
$(TOP_DIR)
/kk_a133/lib/libcrypto.so.1.1
cp
-rf
$(TOP_DIR)
/common/curl/libssl_a133.so
$(TOP_DIR)
/kk_a133/lib/libssl.so.1.1
cp
-rf
$(TOP_DIR)
/nx5_soc_gw/smarthome_z3gw_a133
$(TOP_DIR)
/kk_a133/bin/smarthome_z3gw
cp
-rf
$(TOP_DIR)
/nx5_soc_gw/kk_device_def.json
$(TOP_DIR)
/kk_a133/etc/
squashfs
:
package
@
echo
"build squashfs"
...
...
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