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
1cb9ada1
Commit
1cb9ada1
authored
Aug 25, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,去掉productType相关设置;2,增加mac的数据保存
parent
19e63444
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
445 additions
and
309 deletions
+445
-309
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+12
-17
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+0
-12
common/hal/HAL_OS_linux.c
common/hal/HAL_OS_linux.c
+1
-1
midware/midware/dm/kk_dm_api.c
midware/midware/dm/kk_dm_api.c
+3
-3
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+50
-125
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+2
-4
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+51
-80
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+13
-12
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+26
-12
midware/midware/midware.c
midware/midware/midware.c
+284
-40
midware/tsl/tsl_handle/kk_tsl_api.c
midware/tsl/tsl_handle/kk_tsl_api.c
+2
-2
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+1
-1
No files found.
application/kcloud/kcloud_data_handle.c
View file @
1cb9ada1
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#define KK_CLOUDSTATE_MSG "/thing/ccu/cloudstate"
#define KK_CLOUDSTATE_MSG "/thing/ccu/cloudstate"
const
char
DM_MSG_TO_MIDDWARE
[]
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
product
Type
\"
:
\"
%s
\"
,
\"
product
Code
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_TO_MIDDWARE
[]
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
#define KK_TOPIC_SERVICE_DELIMITER '/'
#define KK_TOPIC_SERVICE_DELIMITER '/'
int
_kk_sendto_cloud
(
cJSON
*
root
)
int
_kk_sendto_cloud
(
cJSON
*
root
)
...
@@ -136,11 +136,11 @@ static int _kk_topic_parse_msgType(_IN_ char *topic, _IN_ int start_deli,_OU_ ch
...
@@ -136,11 +136,11 @@ static int _kk_topic_parse_msgType(_IN_ char *topic, _IN_ int start_deli,_OU_ ch
}
}
static
int
_kk_topic_parse_pkdn
(
_IN_
char
*
topic
,
_IN_
int
start_deli
,
static
int
_kk_topic_parse_pkdn
(
_IN_
char
*
topic
,
_IN_
int
start_deli
,
_OU_
char
productType
[
PRODUCT_TYPE_LEN
],
_OU_
char
productCode
[
PRODUCT_CODE_LEN
],
_OU_
char
deviceCode
[
DEVICE_CODE_LEN
])
_OU_
char
productCode
[
PRODUCT_CODE_LEN
],
_OU_
char
deviceCode
[
DEVICE_CODE_LEN
])
{
{
int
res
=
0
,
start
=
0
,
end
=
0
,
slice
=
0
,
slice1
=
0
;
int
res
=
0
,
start
=
0
,
end
=
0
,
slice
=
0
;
if
(
topic
==
NULL
||
productType
==
NULL
||
deviceCode
==
NULL
)
{
if
(
topic
==
NULL
||
deviceCode
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
res
=
kk_utils_memtok
(
topic
,
strlen
(
topic
),
KK_TOPIC_SERVICE_DELIMITER
,
start_deli
,
&
start
);
res
=
kk_utils_memtok
(
topic
,
strlen
(
topic
),
KK_TOPIC_SERVICE_DELIMITER
,
start_deli
,
&
start
);
...
@@ -151,18 +151,14 @@ static int _kk_topic_parse_pkdn(_IN_ char *topic, _IN_ int start_deli,
...
@@ -151,18 +151,14 @@ static int _kk_topic_parse_pkdn(_IN_ char *topic, _IN_ int start_deli,
if
(
res
!=
0
)
{
if
(
res
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
res
=
kk_utils_memtok
(
topic
,
strlen
(
topic
),
KK_TOPIC_SERVICE_DELIMITER
,
start_deli
+
2
,
&
slice1
);
if
(
res
!=
0
)
{
res
=
kk_utils_memtok
(
topic
,
strlen
(
topic
),
KK_TOPIC_SERVICE_DELIMITER
,
start_deli
+
2
,
&
end
);
return
-
1
;
}
res
=
kk_utils_memtok
(
topic
,
strlen
(
topic
),
KK_TOPIC_SERVICE_DELIMITER
,
start_deli
+
3
,
&
end
);
if
(
res
!=
0
)
{
if
(
res
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
memcpy
(
productType
,
topic
+
start
+
1
,
slice
-
start
-
1
);
memcpy
(
productCode
,
topic
+
start
+
1
,
slice
-
start
-
1
);
memcpy
(
productCode
,
topic
+
slice
+
1
,
slice1
-
slice
-
1
);
memcpy
(
deviceCode
,
topic
+
slice
+
1
,
end
-
slice
-
1
);
memcpy
(
deviceCode
,
topic
+
slice1
+
1
,
end
-
slice1
-
1
);
return
0
;
return
0
;
}
}
...
@@ -174,14 +170,13 @@ static char * _kk_data_create(const char *topic,const char *data)
...
@@ -174,14 +170,13 @@ static char * _kk_data_create(const char *topic,const char *data)
char
*
infoStr
=
NULL
;
char
*
infoStr
=
NULL
;
int
infoStr_len
=
0
;
int
infoStr_len
=
0
;
int
res
=
0
;
int
res
=
0
;
char
productType
[
PRODUCT_TYPE_LEN
]
=
{
0
};
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
deviceCode
[
DEVICE_CODE_LEN
]
=
{
0
};
char
deviceCode
[
DEVICE_CODE_LEN
]
=
{
0
};
char
*
msgStr
=
NULL
;
char
*
msgStr
=
NULL
;
res
=
_kk_topic_parse_pkdn
((
char
*
)
topic
,
2
,
productType
,
productCode
,
deviceCode
);
res
=
_kk_topic_parse_pkdn
((
char
*
)
topic
,
3
,
productCode
,
deviceCode
);
res
|=
_kk_topic_parse_msgType
((
char
*
)
topic
,
5
,
&
msgStr
);
res
|=
_kk_topic_parse_msgType
((
char
*
)
topic
,
5
,
&
msgStr
);
infoStr_len
=
strlen
(
DM_MSG_TO_MIDDWARE
)
+
strlen
(
product
Type
)
+
strlen
(
product
Code
)
+
strlen
(
deviceCode
)
+
strlen
(
msgStr
)
+
10
;
infoStr_len
=
strlen
(
DM_MSG_TO_MIDDWARE
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
strlen
(
msgStr
)
+
10
;
infoStr
=
malloc
(
infoStr_len
);
infoStr
=
malloc
(
infoStr_len
);
if
(
infoStr
==
NULL
){
if
(
infoStr
==
NULL
){
ERROR_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
ERROR_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
...
@@ -189,7 +184,7 @@ static char * _kk_data_create(const char *topic,const char *data)
...
@@ -189,7 +184,7 @@ static char * _kk_data_create(const char *topic,const char *data)
return
NULL
;
return
NULL
;
}
}
memset
(
infoStr
,
0x0
,
infoStr_len
);
memset
(
infoStr
,
0x0
,
infoStr_len
);
snprintf
(
infoStr
,
infoStr_len
,
DM_MSG_TO_MIDDWARE
,
msgStr
,
product
Type
,
product
Code
,
deviceCode
);
snprintf
(
infoStr
,
infoStr_len
,
DM_MSG_TO_MIDDWARE
,
msgStr
,
productCode
,
deviceCode
);
root
=
cJSON_CreateObject
();
root
=
cJSON_CreateObject
();
cJSON
*
infoObj
=
cJSON_Parse
(
infoStr
);
cJSON
*
infoObj
=
cJSON_Parse
(
infoStr
);
...
@@ -222,7 +217,7 @@ int KK_Send_CloudState(int state)
...
@@ -222,7 +217,7 @@ int KK_Send_CloudState(int state)
return
-
1
;
return
-
1
;
}
}
memset
(
infoStr
,
0x0
,
infoStr_len
);
memset
(
infoStr
,
0x0
,
infoStr_len
);
snprintf
(
infoStr
,
infoStr_len
,
DM_MSG_TO_MIDDWARE
,
KK_CLOUDSTATE_MSG
,
""
,
""
,
""
);
snprintf
(
infoStr
,
infoStr_len
,
DM_MSG_TO_MIDDWARE
,
KK_CLOUDSTATE_MSG
,
""
,
""
);
payloadStr_len
=
strlen
(
DM_MSG_CLOUDSTATE
)
+
10
;
payloadStr_len
=
strlen
(
DM_MSG_CLOUDSTATE
)
+
10
;
payloadStr
=
malloc
(
payloadStr_len
);
payloadStr
=
malloc
(
payloadStr_len
);
...
...
application/kcloud/kk_topic_mng.c
View file @
1cb9ada1
...
@@ -10,18 +10,6 @@
...
@@ -10,18 +10,6 @@
const
char
KK_URI_SYS_PREFIX
[]
=
"/sys/kk/%s/%s/#"
;
const
char
KK_URI_SYS_PREFIX
[]
=
"/sys/kk/%s/%s/#"
;
const
char
KK_URI_SYS_PREFIX_EX
[]
=
"/sys/kk/%s/%s"
;
const
char
KK_URI_SYS_PREFIX_EX
[]
=
"/sys/kk/%s/%s"
;
const
char
DM_URI_THING_SUB_REGISTER
[]
=
"thing/sub/register"
;
const
char
DM_URI_THING_SUB_UNREGISTER
[]
=
"thing/sub/unregister"
;
const
char
DM_URI_THING_TOPO_ADD
[]
=
"thing/topo/add"
;
const
char
DM_URI_THING_TOPO_DELETE
[]
=
"thing/topo/delete"
;
const
char
DM_URI_THING_TOPO_GET
[]
=
"thing/topo/get"
;
const
char
DM_URI_THING_LIST_FOUND
[]
=
"thing/list/found"
;
const
char
DM_URI_COMBINE_LOGIN
[]
=
"combine/login"
;
const
char
DM_URI_COMBINE_LOGOUT
[]
=
"combine/logout"
;
const
char
DM_URI_THING_EVENT_PROPERTY_POST
[]
=
"thing/event/property/post"
;
const
char
DM_URI_THING_EVENT_POST
[]
=
"thing/event/%.*s/post"
;
const
char
DM_URI_THING_SERVICE_RESPONSE
[]
=
"thing/service/%.*s_reply"
;
const
char
DM_URI_THING_SERVICE_PROPERTY_SET_REPLY
[]
=
"thing/service/property/set_reply"
;
const
char
KK_URI_OTA_PREFIX
[]
=
"/ota/device/upgrade/kk/%s/%s/#"
;
const
char
KK_URI_OTA_PREFIX
[]
=
"/ota/device/upgrade/kk/%s/%s/#"
;
const
char
KK_URI_OTA_PROCESS
[]
=
"/ota/device/progress/%s/%s"
;
const
char
KK_URI_OTA_PROCESS
[]
=
"/ota/device/progress/%s/%s"
;
const
char
KK_URI_OTA_INFORM
[]
=
"/ota/device/inform/%s/%s"
;
const
char
KK_URI_OTA_INFORM
[]
=
"/ota/device/inform/%s/%s"
;
...
...
common/hal/HAL_OS_linux.c
View file @
1cb9ada1
...
@@ -537,7 +537,7 @@ int HAL_Get_mac(char* mac)
...
@@ -537,7 +537,7 @@ int HAL_Get_mac(char* mac)
int
HAL_Get_SN
(
char
sn
[
SN_ADDR_LEN
])
int
HAL_Get_SN
(
char
sn
[
SN_ADDR_LEN
])
{
{
strncpy
(
sn
,
"1
1111111111111111111111111111111
"
,
SN_ADDR_LEN
);
strncpy
(
sn
,
"1
5
"
,
SN_ADDR_LEN
);
return
0
;
//just for test
return
0
;
//just for test
}
}
...
...
midware/midware/dm/kk_dm_api.c
View file @
1cb9ada1
...
@@ -302,12 +302,12 @@ int iotx_dm_subscribe(_IN_ int devid)
...
@@ -302,12 +302,12 @@ int iotx_dm_subscribe(_IN_ int devid)
//send app to subscribe mqtt
//send app to subscribe mqtt
const
char
subscribe_cmd
[]
=
const
char
subscribe_cmd
[]
=
"{
\"
cmd
\"
:
\"
subscribe
\"
,
\"
data
\"
:{
\"
product
Type
\"
:
\"
%s
\"
,
\"
product
Code
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}}"
;
"{
\"
cmd
\"
:
\"
subscribe
\"
,
\"
data
\"
:{
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}}"
;
int
len
=
strlen
(
subscribe_cmd
)
+
strlen
(
node
->
productType
)
+
strlen
(
node
->
productCode
)
+
strlen
(
node
->
deviceCode
)
+
1
;
int
len
=
strlen
(
subscribe_cmd
)
+
strlen
(
node
->
productCode
)
+
strlen
(
node
->
deviceCode
)
+
1
;
void
*
buf
=
malloc
(
len
);
void
*
buf
=
malloc
(
len
);
if
(
buf
){
if
(
buf
){
HAL_Snprintf
(
buf
,
len
,
subscribe_cmd
,
node
->
product
Type
,
node
->
product
Code
,
node
->
deviceCode
);
HAL_Snprintf
(
buf
,
len
,
subscribe_cmd
,
node
->
productCode
,
node
->
deviceCode
);
kk_ipc_send
(
IPC_MID2APP
,
buf
,
len
);
kk_ipc_send
(
IPC_MID2APP
,
buf
,
len
);
free
(
buf
);
free
(
buf
);
}
else
{
}
else
{
...
...
midware/midware/dm/kk_dm_mng.c
View file @
1cb9ada1
...
@@ -60,16 +60,13 @@ int dm_mgr_search_dev_by_devid(_IN_ int devid, _OU_ dm_mgr_dev_node_t **node)
...
@@ -60,16 +60,13 @@ int dm_mgr_search_dev_by_devid(_IN_ int devid, _OU_ dm_mgr_dev_node_t **node)
ERROR_PRINT
(
"Device Not Found, devid: %d"
,
devid
);
ERROR_PRINT
(
"Device Not Found, devid: %d"
,
devid
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
static
int
_dm_mgr_search_dev_by_pkdn
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
static
int
_dm_mgr_search_dev_by_pkdn
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_mgr_dev_node_t
**
node
)
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_mgr_dev_node_t
**
node
)
{
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_dev_node_t
*
search_node
=
NULL
;
dm_mgr_dev_node_t
*
search_node
=
NULL
;
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
dm_mgr_dev_node_t
)
{
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
dm_mgr_dev_node_t
)
{
if
((
strlen
(
search_node
->
productType
)
==
strlen
(
productType
))
&&
if
(
(
strlen
(
search_node
->
deviceCode
)
==
strlen
(
deviceCode
))
&&
(
memcmp
(
search_node
->
productType
,
productType
,
strlen
(
productType
))
==
0
)
&&
(
strlen
(
search_node
->
deviceCode
)
==
strlen
(
deviceCode
))
&&
(
memcmp
(
search_node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
))
==
0
))
{
(
memcmp
(
search_node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
))
==
0
))
{
/* dm_log_debug("Device Found, Product Key: %s, Device Name: %s", product_key, device_name); */
/* dm_log_debug("Device Found, Product Key: %s, Device Name: %s", product_key, device_name); */
if
(
node
)
{
if
(
node
)
{
...
@@ -79,7 +76,7 @@ static int _dm_mgr_search_dev_by_pkdn(_IN_ char productType[PRODUCT_TYPE_MAXLEN]
...
@@ -79,7 +76,7 @@ static int _dm_mgr_search_dev_by_pkdn(_IN_ char productType[PRODUCT_TYPE_MAXLEN]
}
}
}
}
ERROR_PRINT
(
"Device Not Found,
Product Type: %s, Device Code: %s"
,
productType
,
deviceCode
);
ERROR_PRINT
(
"Device Not Found,
Device Code: %s"
,
deviceCode
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
static
int
_dm_mgr_next_devid
(
void
)
static
int
_dm_mgr_next_devid
(
void
)
...
@@ -91,10 +88,10 @@ static int _dm_mgr_next_devid(void)
...
@@ -91,10 +88,10 @@ static int _dm_mgr_next_devid(void)
static
int
_dm_init_tsl_params
(
int
devId
)
static
int
_dm_init_tsl_params
(
int
devId
)
{
{
int
res
=
0
;
int
res
=
0
;
char
version
[
VERSION_MAXLEN
];
char
version
[
VERSION_MAXLEN
]
=
{
0
}
;
char
s_IP
[
NETWORK_ADDR_LEN
];
char
s_IP
[
NETWORK_ADDR_LEN
]
=
{
0
}
;
char
s_mac
[
MAC_ADDR_LEN
];
char
s_mac
[
MAC_ADDR_LEN
]
=
{
0
}
;
char
s_SN
[
SN_ADDR_LEN
];
char
s_SN
[
SN_ADDR_LEN
]
=
{
0
}
;
int
port
=
0
;
int
port
=
0
;
/*******set version***********/
/*******set version***********/
...
@@ -148,8 +145,8 @@ static int _dm_init_tsl_params(int devId)
...
@@ -148,8 +145,8 @@ static int _dm_init_tsl_params(int devId)
}
}
return
res
;
return
res
;
}
}
int
dm_mgr_device_create
(
_IN_
int
dev_type
,
_IN_
char
productType
[
PRODUCT_TYP
E_MAXLEN
],
int
dm_mgr_device_create
(
_IN_
int
dev_type
,
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_COD
E_MAXLEN
],
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
fatherMac
[
DEVICE_MAC
_MAXLEN
],
_OU_
int
*
devid
)
_IN_
char
mac
[
DEVICE_MAC_MAXLEN
],
_IN_
char
fatherDeviceCode
[
DEVICE_CODE
_MAXLEN
],
_OU_
int
*
devid
)
{
{
int
res
=
0
;
int
res
=
0
;
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
...
@@ -158,14 +155,11 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char productType[PRODUCT_TYPE_M
...
@@ -158,14 +155,11 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char productType[PRODUCT_TYPE_M
int
idx
=
0
;
int
idx
=
0
;
if
(
productType
!=
NULL
&&
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
{
return
INVALID_PARAMETER
;
}
if
(
deviceCode
!=
NULL
&&
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
{
if
(
deviceCode
!=
NULL
&&
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
res
=
_dm_mgr_search_dev_by_pkdn
(
productType
,
deviceCode
,
&
node
);
res
=
_dm_mgr_search_dev_by_pkdn
(
deviceCode
,
&
node
);
if
(
res
==
SUCCESS_RETURN
)
{
if
(
res
==
SUCCESS_RETURN
)
{
if
(
devid
)
{
if
(
devid
)
{
*
devid
=
node
->
devid
;
*
devid
=
node
->
devid
;
...
@@ -185,17 +179,17 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char productType[PRODUCT_TYPE_M
...
@@ -185,17 +179,17 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char productType[PRODUCT_TYPE_M
node
->
devid
=
_dm_mgr_next_devid
();
node
->
devid
=
_dm_mgr_next_devid
();
node
->
dev_type
=
dev_type
;
node
->
dev_type
=
dev_type
;
node
->
dev_shadow
=
NULL
;
node
->
dev_shadow
=
NULL
;
if
(
productType
!=
NULL
)
{
memcpy
(
node
->
productType
,
productType
,
strlen
(
productType
));
}
if
(
productCode
!=
NULL
)
{
if
(
productCode
!=
NULL
)
{
memcpy
(
node
->
productCode
,
productCode
,
strlen
(
productCode
));
memcpy
(
node
->
productCode
,
productCode
,
strlen
(
productCode
));
}
}
if
(
deviceCode
!=
NULL
)
{
if
(
deviceCode
!=
NULL
)
{
memcpy
(
node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
memcpy
(
node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
}
}
if
(
dev_type
!=
KK_DM_DEVICE_CCU
&&
fatherMac
!=
NULL
)
{
if
(
mac
!=
NULL
)
{
memcpy
(
node
->
fatherMac
,
fatherMac
,
strlen
(
fatherMac
));
memcpy
(
node
->
mac
,
mac
,
strlen
(
mac
));
}
if
(
dev_type
!=
KK_DM_DEVICE_CCU
&&
fatherDeviceCode
!=
NULL
)
{
memcpy
(
node
->
fatherDeviceCode
,
fatherDeviceCode
,
strlen
(
fatherDeviceCode
));
}
}
//node->dev_status = IOTX_DM_DEV_STATUS_AUTHORIZED;
//node->dev_status = IOTX_DM_DEV_STATUS_AUTHORIZED;
...
@@ -221,17 +215,16 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char productType[PRODUCT_TYPE_M
...
@@ -221,17 +215,16 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char productType[PRODUCT_TYPE_M
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
dm_mgr_search_device_by_pkdn
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
int
dm_mgr_search_device_by_pkdn
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
int
*
devid
)
_OU_
int
*
devid
)
{
{
int
res
=
0
;
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
if
(
productType
==
NULL
||
deviceCode
==
NULL
)
{
if
(
deviceCode
==
NULL
)
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
res
=
_dm_mgr_search_dev_by_pkdn
(
productType
,
deviceCode
,
&
node
);
res
=
_dm_mgr_search_dev_by_pkdn
(
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -243,55 +236,9 @@ int dm_mgr_search_device_by_pkdn(_IN_ char productType[PRODUCT_TYPE_MAXLEN], _IN
...
@@ -243,55 +236,9 @@ int dm_mgr_search_device_by_pkdn(_IN_ char productType[PRODUCT_TYPE_MAXLEN], _IN
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
dm_mgr_search_mac_by_topic
(
_IN_
char
*
topic
,
_OU_
char
mac
[
DEVICE_MAC_MAXLEN
])
{
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
char
productType
[
PRODUCT_TYPE_MAXLEN
]
=
{
0
};
char
deviceCode
[
DEVICE_CODE_MAXLEN
]
=
{
0
};
if
(
topic
==
NULL
)
{
return
INVALID_PARAMETER
;
}
res
=
kk_msg_uri_parse_pkdn
((
char
*
)
topic
,
strlen
(
topic
),
2
+
KK_URI_OFFSET
,
4
+
KK_URI_OFFSET
,
productType
,
deviceCode
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
res
=
_dm_mgr_search_dev_by_pkdn
(
productType
,
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
memcpy
(
mac
,
node
->
deviceCode
,
DEVICE_MAC_MAXLEN
);
return
SUCCESS_RETURN
;
}
int
dm_mgr_search_mac_by_pkdn
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
char
mac
[
DEVICE_MAC_MAXLEN
])
{
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
if
(
productType
==
NULL
||
deviceCode
==
NULL
)
{
int
dm_mgr_get_devicetype_by_devicecode
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
int
*
deviceType
)
return
INVALID_PARAMETER
;
}
res
=
_dm_mgr_search_dev_by_pkdn
(
productType
,
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
memcpy
(
mac
,
node
->
deviceCode
,
DEVICE_MAC_MAXLEN
);
return
SUCCESS_RETURN
;
}
int
dm_mgr_get_deviceType_by_mac
(
_IN_
char
deviceCode
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
deviceType
)
{
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
...
@@ -312,7 +259,7 @@ int dm_mgr_get_deviceType_by_mac(_IN_ char deviceCode[DEVICE_MAC_MAXLEN], _OU_ i
...
@@ -312,7 +259,7 @@ int dm_mgr_get_deviceType_by_mac(_IN_ char deviceCode[DEVICE_MAC_MAXLEN], _OU_ i
}
}
int
dm_mgr_get_device_by_
mac
(
_IN_
char
deviceCode
[
DEVICE_MAC
_MAXLEN
],
_OU_
dm_mgr_dev_node_t
**
node
)
int
dm_mgr_get_device_by_
devicecode
(
_IN_
char
deviceCode
[
DEVICE_CODE
_MAXLEN
],
_OU_
dm_mgr_dev_node_t
**
node
)
{
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_dev_node_t
*
search_node
=
NULL
;
dm_mgr_dev_node_t
*
search_node
=
NULL
;
...
@@ -332,7 +279,7 @@ int dm_mgr_get_device_by_mac(_IN_ char deviceCode[DEVICE_MAC_MAXLEN], _OU_ dm_mg
...
@@ -332,7 +279,7 @@ int dm_mgr_get_device_by_mac(_IN_ char deviceCode[DEVICE_MAC_MAXLEN], _OU_ dm_mg
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
int
dm_mgr_get_devId_by_
mac
(
_IN_
char
deviceCode
[
DEVICE_MAC
_MAXLEN
],
_OU_
int
*
devid
)
int
dm_mgr_get_devId_by_
devicecode
(
_IN_
char
deviceCode
[
DEVICE_CODE
_MAXLEN
],
_OU_
int
*
devid
)
{
{
int
res
=
0
;
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
...
@@ -341,7 +288,7 @@ int dm_mgr_get_devId_by_mac(_IN_ char deviceCode[DEVICE_MAC_MAXLEN],_OU_ int *de
...
@@ -341,7 +288,7 @@ int dm_mgr_get_devId_by_mac(_IN_ char deviceCode[DEVICE_MAC_MAXLEN],_OU_ int *de
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_
devicecode
(
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -372,9 +319,9 @@ int dm_mgr_init(void)
...
@@ -372,9 +319,9 @@ int dm_mgr_init(void)
{
{
int
res
=
0
;
int
res
=
0
;
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
char
productType
[
PRODUCT_TYPE_MAXLEN
]
=
{
0
};
char
productCode
[
PRODUCT_CODE_MAXLEN
]
=
{
0
};
char
productCode
[
PRODUCT_CODE_MAXLEN
]
=
{
0
};
char
deviceCode
[
DEVICE_CODE_MAXLEN
]
=
{
0
};
char
deviceCode
[
DEVICE_CODE_MAXLEN
]
=
{
0
};
char
mac
[
DEVICE_MAC_MAXLEN
]
=
{
0
};
int
devId
=
0
;
int
devId
=
0
;
memset
(
ctx
,
0
,
sizeof
(
dm_mgr_ctx
));
memset
(
ctx
,
0
,
sizeof
(
dm_mgr_ctx
));
...
@@ -391,9 +338,8 @@ int dm_mgr_init(void)
...
@@ -391,9 +338,8 @@ int dm_mgr_init(void)
//HAL_GetProduct_Type(product_key);
//HAL_GetProduct_Type(product_key);
//HAL_GetProduct_Code(device_name);
//HAL_GetProduct_Code(device_name);
memset
(
deviceCode
,
0x0
,
sizeof
(
deviceCode
));
HAL_Get_mac
(
mac
);
HAL_Get_mac
(
deviceCode
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
"CCU_66666"
,
mac
,
""
,
&
devId
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_TYPE
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
"CCU_66666"
,
""
,
&
devId
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
goto
ERROR
;
}
}
...
@@ -401,13 +347,6 @@ int dm_mgr_init(void)
...
@@ -401,13 +347,6 @@ int dm_mgr_init(void)
_dm_init_tsl_params
(
devId
);
_dm_init_tsl_params
(
devId
);
}
}
//res = dm_mgr_device_create(KK_DM_DEVICE_GATEWAY,KK_DM_GW_DEVICE_PRODUCT_TYPE,KK_DM_GW_DEVICE_PRODUCT_CODE,"1122334455667788",deviceCode,&devId);
//if (res != SUCCESS_RETURN) {
// goto ERROR;
//}
//sleep(3);
//kk_dm_subdev_topo_add(devId);
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
ERROR:
ERROR:
...
@@ -473,7 +412,6 @@ static int _dm_mgr_upstream_request_assemble(_IN_ int msgid, _IN_ int devid,
...
@@ -473,7 +412,6 @@ static int _dm_mgr_upstream_request_assemble(_IN_ int msgid, _IN_ int devid,
}
}
memset
(
request
->
msgTypeStr
,
0x0
,
msgTypeLen
);
memset
(
request
->
msgTypeStr
,
0x0
,
msgTypeLen
);
snprintf
(
request
->
msgTypeStr
,
msgTypeLen
,
DM_URI_THING_EVENT_POST
,
identify
);
snprintf
(
request
->
msgTypeStr
,
msgTypeLen
,
DM_URI_THING_EVENT_POST
,
identify
);
memcpy
(
request
->
productType
,
node
->
productType
,
strlen
(
node
->
productType
));
memcpy
(
request
->
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
request
->
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
request
->
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
memcpy
(
request
->
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
request
->
params
=
payload_param
;
request
->
params
=
payload_param
;
...
@@ -566,7 +504,6 @@ static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid,
...
@@ -566,7 +504,6 @@ static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid,
}
}
memset
(
response
->
msgTypeStr
,
0x0
,
msgTypeLen
);
memset
(
response
->
msgTypeStr
,
0x0
,
msgTypeLen
);
snprintf
(
response
->
msgTypeStr
,
msgTypeLen
,
DM_URI_THING_SERVICE_RESPONSE
,
identfy
);
snprintf
(
response
->
msgTypeStr
,
msgTypeLen
,
DM_URI_THING_SERVICE_RESPONSE
,
identfy
);
memcpy
(
response
->
productType
,
node
->
productType
,
strlen
(
node
->
productType
));
memcpy
(
response
->
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
response
->
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
response
->
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
memcpy
(
response
->
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
response
->
code
=
code
;
response
->
code
=
code
;
...
@@ -632,18 +569,17 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
...
@@ -632,18 +569,17 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_THING_SUB_REGISTER
;
request
.
msgTypeStr
=
DM_URI_THING_SUB_REGISTER
;
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_thing_sub_register
(
node
->
productType
,
node
->
productCode
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_thing_sub_register
(
node
->
productCode
,
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -683,7 +619,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
...
@@ -683,7 +619,7 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -691,13 +627,12 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
...
@@ -691,13 +627,12 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_THING_SUB_UNREGISTER
;
request
.
msgTypeStr
=
DM_URI_THING_SUB_UNREGISTER
;
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_thing_sub_unregister
(
node
->
productType
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_thing_sub_unregister
(
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -728,7 +663,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
...
@@ -728,7 +663,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
{
{
int
res
=
0
;
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
father
_node
=
NULL
;
dm_mgr_dev_node_t
*
gw
_node
=
NULL
;
dm_msg_request_t
request
;
dm_msg_request_t
request
;
if
(
devid
<
0
)
{
if
(
devid
<
0
)
{
...
@@ -741,7 +676,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
...
@@ -741,7 +676,7 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
ERROR_PRINT
(
"ERROR res:%d
\n
"
,
res
);
ERROR_PRINT
(
"ERROR res:%d
\n
"
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
father
_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw
_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
...
@@ -750,13 +685,12 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
...
@@ -750,13 +685,12 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_THING_TOPO_ADD
;
request
.
msgTypeStr
=
DM_URI_THING_TOPO_ADD
;
memcpy
(
request
.
productType
,
father_node
->
productType
,
strlen
(
father_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
father_node
->
productCode
,
strlen
(
father_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
father_node
->
deviceCode
,
strlen
(
father_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_thing_topo_add
(
node
->
productType
,
node
->
productCode
,
node
->
deviceCode
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_thing_topo_add
(
node
->
productCode
,
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -799,7 +733,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
...
@@ -799,7 +733,7 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -807,15 +741,13 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
...
@@ -807,15 +741,13 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_THING_TOPO_DELETE
;
request
.
msgTypeStr
=
DM_URI_THING_TOPO_DELETE
;
memcpy
(
request
.
identity
,
""
,
strlen
(
""
));
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_thing_topo_delete
(
node
->
productType
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_thing_topo_delete
(
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -851,11 +783,10 @@ int dm_mgr_upstream_thing_topo_get(void)
...
@@ -851,11 +783,10 @@ int dm_mgr_upstream_thing_topo_get(void)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_THING_TOPO_GET
;
request
.
msgTypeStr
=
DM_URI_THING_TOPO_GET
;
HAL_GetProduct_Type
(
request
.
productType
);
HAL_GetProduct_Code
(
request
.
deviceCode
);
HAL_GetProduct_Code
(
request
.
deviceCode
);
res
=
_dm_mgr_search_dev_by_pkdn
(
request
.
productType
,
request
.
deviceCode
,
&
node
);
res
=
_dm_mgr_search_dev_by_pkdn
(
request
.
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -901,7 +832,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
...
@@ -901,7 +832,7 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -909,13 +840,12 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
...
@@ -909,13 +840,12 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_THING_LIST_FOUND
;
request
.
msgTypeStr
=
DM_URI_THING_LIST_FOUND
;
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_thing_list_found
(
node
->
productType
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_thing_list_found
(
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -955,18 +885,16 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
...
@@ -955,18 +885,16 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
if
(
devid
!=
0
){
if
(
strlen
(
node
->
fatherDeviceCode
)
>
0
){
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
}
else
{
}
else
{
memcpy
(
request
.
productType
,
node
->
productType
,
strlen
(
node
->
productType
));
memcpy
(
request
.
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
request
.
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
request
.
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
}
}
...
@@ -977,7 +905,7 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
...
@@ -977,7 +905,7 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_status_online
(
node
->
productType
,
node
->
productCode
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_status_online
(
node
->
productCode
,
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -1019,7 +947,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
...
@@ -1019,7 +947,7 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -1027,13 +955,12 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
...
@@ -1027,13 +955,12 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_COMBINE_LOGIN
;
request
.
msgTypeStr
=
DM_URI_COMBINE_LOGIN
;
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_combine_login
(
node
->
productType
,
node
->
productCode
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_combine_login
(
node
->
productCode
,
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -1074,7 +1001,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
...
@@ -1074,7 +1001,7 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_
mac
(
node
->
fatherMac
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
node
->
fatherDeviceCode
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"ERROR [%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -1082,13 +1009,12 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
...
@@ -1082,13 +1009,12 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
DM_URI_COMBINE_LOGOUT
;
request
.
msgTypeStr
=
DM_URI_COMBINE_LOGOUT
;
memcpy
(
request
.
productType
,
gw_node
->
productType
,
strlen
(
gw_node
->
productType
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
productCode
,
gw_node
->
productCode
,
strlen
(
gw_node
->
productCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
memcpy
(
request
.
deviceCode
,
gw_node
->
deviceCode
,
strlen
(
gw_node
->
deviceCode
));
/* Get Params And Method */
/* Get Params And Method */
res
=
dm_msg_combine_logout
(
node
->
productType
,
node
->
deviceCode
,
&
request
);
res
=
dm_msg_combine_logout
(
node
->
deviceCode
,
&
request
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -1137,7 +1063,6 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
...
@@ -1137,7 +1063,6 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
sprintf
(
request
.
msgTypeStr
,
KK_URI_OTA_INFORM
,
node
->
productCode
,
node
->
deviceCode
);
sprintf
(
request
.
msgTypeStr
,
KK_URI_OTA_INFORM
,
node
->
productCode
,
node
->
deviceCode
);
memcpy
(
request
.
productType
,
node
->
productType
,
PRODUCT_TYPE_MAXLEN
);
memcpy
(
request
.
productCode
,
node
->
productCode
,
PRODUCT_CODE_MAXLEN
);
memcpy
(
request
.
productCode
,
node
->
productCode
,
PRODUCT_CODE_MAXLEN
);
memcpy
(
request
.
deviceCode
,
node
->
deviceCode
,
DEVICE_CODE_MAXLEN
);
memcpy
(
request
.
deviceCode
,
node
->
deviceCode
,
DEVICE_CODE_MAXLEN
);
...
@@ -1172,11 +1097,11 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
...
@@ -1172,11 +1097,11 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
int
dm_mgr_subdev_create
(
int
devtype
,
_IN_
char
productType
[
PRODUCT_TYP
E_MAXLEN
],
int
dm_mgr_subdev_create
(
int
devtype
,
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_COD
E_MAXLEN
],
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
fatherMac
[
DEVICE_MAC
_MAXLEN
],
_OU_
int
*
devid
){
_IN_
char
mac
[
DEVICE_MAC_MAXLEN
],
_IN_
char
fatherDeviceCode
[
DEVICE_CODE
_MAXLEN
],
_OU_
int
*
devid
){
int
res
=
0
;
int
res
=
0
;
res
=
dm_mgr_device_create
(
devtype
,
product
Type
,
productCode
,
deviceCode
,
fatherM
ac
,
devid
);
res
=
dm_mgr_device_create
(
devtype
,
product
Code
,
deviceCode
,
fatherDeviceCode
,
m
ac
,
devid
);
if
(
TSL_ALREADY_EXIST
==
res
)
if
(
TSL_ALREADY_EXIST
==
res
)
{
{
ERROR_PRINT
(
"SUBDEV ALREADY EXIST!!!
\n
"
);
ERROR_PRINT
(
"SUBDEV ALREADY EXIST!!!
\n
"
);
...
...
midware/midware/dm/kk_dm_mng.h
View file @
1cb9ada1
...
@@ -20,10 +20,10 @@ typedef struct {
...
@@ -20,10 +20,10 @@ typedef struct {
int
devid
;
int
devid
;
int
dev_type
;
int
dev_type
;
kk_tsl_t
*
dev_shadow
;
kk_tsl_t
*
dev_shadow
;
char
productType
[
PRODUCT_TYPE
_MAXLEN
];
char
mac
[
DEVICE_MAC
_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
father
Mac
[
DEVICE_MAC
_MAXLEN
];
char
father
DeviceCode
[
DEVICE_CODE
_MAXLEN
];
struct
list_head
linked_list
;
struct
list_head
linked_list
;
}
dm_mgr_dev_node_t
;
}
dm_mgr_dev_node_t
;
...
@@ -40,7 +40,6 @@ typedef struct {
...
@@ -40,7 +40,6 @@ typedef struct {
//const char *service_name;
//const char *service_name;
char
*
msgTypeStr
;
char
*
msgTypeStr
;
char
identity
[
IDENTIFY_MAXLEN
];
char
identity
[
IDENTIFY_MAXLEN
];
char
productType
[
PRODUCT_TYPE_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
*
params
;
char
*
params
;
...
@@ -50,7 +49,6 @@ typedef struct {
...
@@ -50,7 +49,6 @@ typedef struct {
}
dm_msg_request_t
;
}
dm_msg_request_t
;
typedef
struct
{
typedef
struct
{
char
*
msgTypeStr
;
char
*
msgTypeStr
;
char
productType
[
PRODUCT_TYPE_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
productCode
[
PRODUCT_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
...
...
midware/midware/dm/kk_dm_msg.c
View file @
1cb9ada1
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
const
char
DM_MSG_REQUEST
[]
DM_READ_ONLY
=
"{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
%s
\"
,
\"
params
\"
:%.*s,
\"
method
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_REQUEST
[]
DM_READ_ONLY
=
"{
\"
msgId
\"
:
\"
%d
\"
,
\"
version
\"
:
\"
%s
\"
,
\"
params
\"
:%.*s,
\"
method
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
product
Type
\"
:
\"
%s
\"
,
\"
product
Code
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
void
kk_sendData2app
(
void
*
info
,
void
*
payload
){
void
kk_sendData2app
(
void
*
info
,
void
*
payload
){
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
root
=
cJSON_CreateObject
();
...
@@ -24,31 +24,28 @@ void kk_sendData2app(void *info, void *payload){
...
@@ -24,31 +24,28 @@ void kk_sendData2app(void *info, void *payload){
}
}
const
char
DM_MSG_THING_SUB_REGISTER_METHOD
[]
=
"thing.sub.register"
;
const
char
DM_MSG_THING_SUB_REGISTER_METHOD
[]
=
"thing.sub.register"
;
const
char
DM_MSG_THING_SUB_REGISTER_PARAMS
[]
=
"[{
\"
product
Type
\"
:
\"
%s
\"
,
\"
product
Code
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}]"
;
const
char
DM_MSG_THING_SUB_REGISTER_PARAMS
[]
=
"[{
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}]"
;
int
dm_msg_thing_sub_register
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_thing_sub_register
(
_IN_
char
productCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
productCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_OU_
dm_msg_request_t
*
request
)
{
{
int
params_len
=
0
;
int
params_len
=
0
;
char
*
params
=
NULL
;
char
*
params
=
NULL
;
if
(
request
==
NULL
||
productType
==
NULL
||
deviceCode
==
NULL
||
if
(
request
==
NULL
||
deviceCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
request
->
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
params_len
=
strlen
(
DM_MSG_THING_SUB_REGISTER_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
1
;
params_len
=
strlen
(
DM_MSG_THING_SUB_REGISTER_PARAMS
)
+
strlen
(
productCode
)
+
strlen
(
deviceCode
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
if
(
params
==
NULL
)
{
if
(
params
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
params
,
0
,
params_len
);
memset
(
params
,
0
,
params_len
);
snprintf
(
params
,
params_len
,
DM_MSG_THING_SUB_REGISTER_PARAMS
,
productType
,
productCode
,
deviceCode
);
snprintf
(
params
,
params_len
,
DM_MSG_THING_SUB_REGISTER_PARAMS
,
productCode
,
deviceCode
);
/* Get Params */
/* Get Params */
request
->
params
=
params
;
request
->
params
=
params
;
...
@@ -61,29 +58,25 @@ int dm_msg_thing_sub_register(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -61,29 +58,25 @@ int dm_msg_thing_sub_register(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
}
}
const
char
DM_MSG_THING_SUB_UNREGISTER_METHOD
[]
DM_READ_ONLY
=
"thing.sub.unregister"
;
const
char
DM_MSG_THING_SUB_UNREGISTER_METHOD
[]
DM_READ_ONLY
=
"thing.sub.unregister"
;
const
char
DM_MSG_THING_SUB_UNREGISTER_PARAMS
[]
DM_READ_ONLY
=
"[{
\"
productKey
\"
:
\"
%s
\"
,
\"
deviceName
\"
:
\"
%s
\"
}]"
;
const
char
DM_MSG_THING_SUB_UNREGISTER_PARAMS
[]
DM_READ_ONLY
=
"[{
\"
deviceCode
\"
:
\"
%s
\"
}]"
;
int
dm_msg_thing_sub_unregister
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_thing_sub_unregister
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
{
{
int
params_len
=
0
;
int
params_len
=
0
;
char
*
params
=
NULL
;
char
*
params
=
NULL
;
if
(
request
==
NULL
||
productType
==
NULL
||
deviceCode
==
NULL
||
if
(
request
==
NULL
||
deviceCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
request
->
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
params_len
=
strlen
(
DM_MSG_THING_SUB_UNREGISTER_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
deviceCode
)
+
1
;
params_len
=
strlen
(
DM_MSG_THING_SUB_UNREGISTER_PARAMS
)
+
strlen
(
deviceCode
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
if
(
params
==
NULL
)
{
if
(
params
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
params
,
0
,
params_len
);
memset
(
params
,
0
,
params_len
);
snprintf
(
params
,
params_len
,
DM_MSG_THING_SUB_UNREGISTER_PARAMS
,
productType
,
deviceCode
);
snprintf
(
params
,
params_len
,
DM_MSG_THING_SUB_UNREGISTER_PARAMS
,
deviceCode
);
/* Get Params */
/* Get Params */
request
->
params
=
params
;
request
->
params
=
params
;
...
@@ -95,14 +88,13 @@ int dm_msg_thing_sub_unregister(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -95,14 +88,13 @@ int dm_msg_thing_sub_unregister(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
const
char
DM_MSG_THING_TOPO_ADD_SIGN_SOURCE
[]
DM_READ_ONLY
=
"clientId%sdevice
Name%sproductKey
%stimestamp%s"
;
const
char
DM_MSG_THING_TOPO_ADD_SIGN_SOURCE
[]
DM_READ_ONLY
=
"clientId%sdevice
Code
%stimestamp%s"
;
const
char
DM_MSG_THING_TOPO_ADD_METHOD
[]
DM_READ_ONLY
=
"thing.topo.add"
;
const
char
DM_MSG_THING_TOPO_ADD_METHOD
[]
DM_READ_ONLY
=
"thing.topo.add"
;
const
char
DM_MSG_THING_TOPO_ADD_PARAMS
[]
DM_READ_ONLY
=
const
char
DM_MSG_THING_TOPO_ADD_PARAMS
[]
DM_READ_ONLY
=
//"[{\"productKey\":\"%s\",\"deviceName\":\"%s\",\"signmethod\":\"%s\",\"sign\":\"%s\",\"timestamp\":\"%s\",\"clientId\":\"%s\"}]";
//"[{\"productKey\":\"%s\",\"deviceName\":\"%s\",\"signmethod\":\"%s\",\"sign\":\"%s\",\"timestamp\":\"%s\",\"clientId\":\"%s\"}]";
"[{
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
,
\"
mac
\"
:
\"
%s
\"
}]"
;
"[{
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
,
\"
mac
\"
:
\"
%s
\"
}]"
;
int
dm_msg_thing_topo_add
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_thing_topo_add
(
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
mac
[
DEVICE_MAC_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
mac
[
DEVICE_MAC_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_OU_
dm_msg_request_t
*
request
)
{
{
...
@@ -116,12 +108,10 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -116,12 +108,10 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
char
sign
[
65
]
=
{
0
};
char
sign
[
65
]
=
{
0
};
if
(
request
==
NULL
||
productType
==
NULL
||
if
(
request
==
NULL
||
productCode
==
NULL
||
deviceCode
==
NULL
||
deviceCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
productCode
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
productCode
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
request
->
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
...
@@ -131,18 +121,18 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -131,18 +121,18 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
/* dm_log_debug("Time Stamp: %s", timestamp); */
/* dm_log_debug("Time Stamp: %s", timestamp); */
/* Client ID */
/* Client ID */
HAL_Snprintf
(
client_id
,
PRODUCT_TYPE_MAXLEN
+
DEVICE_CODE_MAXLEN
+
1
,
"%s.%s"
,
productType
,
deviceCode
);
HAL_Snprintf
(
client_id
,
DEVICE_CODE_MAXLEN
+
1
,
"%s"
,
deviceCode
);
/* Sign */
/* Sign */
sign_source_len
=
strlen
(
DM_MSG_THING_TOPO_ADD_SIGN_SOURCE
)
+
strlen
(
client_id
)
+
sign_source_len
=
strlen
(
DM_MSG_THING_TOPO_ADD_SIGN_SOURCE
)
+
strlen
(
client_id
)
+
strlen
(
deviceCode
)
+
strlen
(
productType
)
+
strlen
(
timestamp
)
+
1
;
strlen
(
deviceCode
)
+
strlen
(
timestamp
)
+
1
;
sign_source
=
malloc
(
sign_source_len
);
sign_source
=
malloc
(
sign_source_len
);
if
(
sign_source
==
NULL
)
{
if
(
sign_source
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
sign_source
,
0
,
sign_source_len
);
memset
(
sign_source
,
0
,
sign_source_len
);
HAL_Snprintf
(
sign_source
,
sign_source_len
,
DM_MSG_THING_TOPO_ADD_SIGN_SOURCE
,
client_id
,
HAL_Snprintf
(
sign_source
,
sign_source_len
,
DM_MSG_THING_TOPO_ADD_SIGN_SOURCE
,
client_id
,
deviceCode
,
productType
,
timestamp
);
deviceCode
,
timestamp
);
/* dm_log_debug("Sign Srouce: %s", sign_source); */
/* dm_log_debug("Sign Srouce: %s", sign_source); */
#if 0
#if 0
...
@@ -164,7 +154,7 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -164,7 +154,7 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
/* Params */
/* Params */
request
->
method
=
(
char
*
)
DM_MSG_THING_TOPO_ADD_METHOD
;
request
->
method
=
(
char
*
)
DM_MSG_THING_TOPO_ADD_METHOD
;
params_len
=
strlen
(
DM_MSG_THING_TOPO_ADD_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
deviceCode
)
+
params_len
=
strlen
(
DM_MSG_THING_TOPO_ADD_PARAMS
)
+
strlen
(
deviceCode
)
+
strlen
(
sign_method
)
+
strlen
(
sign
)
+
strlen
(
timestamp
)
+
strlen
(
client_id
)
+
1
;
strlen
(
sign_method
)
+
strlen
(
sign
)
+
strlen
(
timestamp
)
+
strlen
(
client_id
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
...
@@ -183,32 +173,28 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -183,32 +173,28 @@ int dm_msg_thing_topo_add(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
}
}
const
char
DM_MSG_THING_TOPO_DELETE_METHOD
[]
DM_READ_ONLY
=
"thing.topo.delete"
;
const
char
DM_MSG_THING_TOPO_DELETE_METHOD
[]
DM_READ_ONLY
=
"thing.topo.delete"
;
const
char
DM_MSG_THING_TOPO_DELETE_PARAMS
[]
DM_READ_ONLY
=
"[{
\"
productKey
\"
:
\"
%s
\"
,
\"
deviceName
\"
:
\"
%s
\"
}]"
;
const
char
DM_MSG_THING_TOPO_DELETE_PARAMS
[]
DM_READ_ONLY
=
"[{
\"
deviceCode
\"
:
\"
%s
\"
}]"
;
int
dm_msg_thing_topo_delete
(
_IN_
char
productType
[
PRODUCT_CODE_MAXLEN
],
int
dm_msg_thing_topo_delete
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
{
{
char
*
params
=
NULL
;
char
*
params
=
NULL
;
int
params_len
=
0
;
int
params_len
=
0
;
if
(
request
==
NULL
||
productType
==
NULL
||
if
(
request
==
NULL
||
deviceCode
==
NULL
||
deviceCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
request
->
productType
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
/* Params */
/* Params */
request
->
method
=
(
char
*
)
DM_MSG_THING_TOPO_DELETE_METHOD
;
request
->
method
=
(
char
*
)
DM_MSG_THING_TOPO_DELETE_METHOD
;
params_len
=
strlen
(
DM_MSG_THING_TOPO_DELETE_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
deviceCode
)
+
1
;
params_len
=
strlen
(
DM_MSG_THING_TOPO_DELETE_PARAMS
)
+
strlen
(
deviceCode
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
if
(
params
==
NULL
)
{
if
(
params
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
params
,
0
,
params_len
);
memset
(
params
,
0
,
params_len
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_THING_TOPO_DELETE_PARAMS
,
deviceCode
,
deviceCode
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_THING_TOPO_DELETE_PARAMS
,
deviceCode
);
request
->
params
=
params
;
request
->
params
=
params
;
request
->
params_len
=
strlen
(
request
->
params
);
request
->
params_len
=
strlen
(
request
->
params
);
...
@@ -240,16 +226,14 @@ int dm_msg_thing_topo_delete(_IN_ char productType[PRODUCT_CODE_MAXLEN],
...
@@ -240,16 +226,14 @@ int dm_msg_thing_topo_delete(_IN_ char productType[PRODUCT_CODE_MAXLEN],
}
}
const
char
DM_MSG_THING_LIST_FOUND_METHOD
[]
DM_READ_ONLY
=
"thing.list.found"
;
const
char
DM_MSG_THING_LIST_FOUND_METHOD
[]
DM_READ_ONLY
=
"thing.list.found"
;
const
char
DM_MSG_THING_LIST_FOUND_PARAMS
[]
DM_READ_ONLY
=
"[{
\"
productKey
\"
:
\"
%s
\"
,
\"
deviceName
\"
:
\"
%s
\"
}]"
;
const
char
DM_MSG_THING_LIST_FOUND_PARAMS
[]
DM_READ_ONLY
=
"[{
\"
deviceCode
\"
:
\"
%s
\"
}]"
;
int
dm_msg_thing_list_found
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_thing_list_found
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_OU_
dm_msg_request_t
*
request
)
{
{
char
*
params
=
NULL
;
char
*
params
=
NULL
;
int
params_len
=
0
;
int
params_len
=
0
;
if
(
productType
==
NULL
||
deviceCode
==
NULL
||
if
(
deviceCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
request
==
NULL
)
{
request
==
NULL
)
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
...
@@ -257,13 +241,13 @@ int dm_msg_thing_topo_delete(_IN_ char productType[PRODUCT_CODE_MAXLEN],
...
@@ -257,13 +241,13 @@ int dm_msg_thing_topo_delete(_IN_ char productType[PRODUCT_CODE_MAXLEN],
/* Params */
/* Params */
request
->
method
=
(
char
*
)
DM_MSG_THING_LIST_FOUND_METHOD
;
request
->
method
=
(
char
*
)
DM_MSG_THING_LIST_FOUND_METHOD
;
params_len
=
strlen
(
DM_MSG_THING_LIST_FOUND_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
deviceCode
)
+
1
;
params_len
=
strlen
(
DM_MSG_THING_LIST_FOUND_PARAMS
)
+
strlen
(
deviceCode
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
if
(
params
==
NULL
)
{
if
(
params
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
params
,
0
,
params_len
);
memset
(
params
,
0
,
params_len
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_THING_LIST_FOUND_PARAMS
,
productType
,
deviceCode
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_THING_LIST_FOUND_PARAMS
,
deviceCode
);
request
->
params
=
params
;
request
->
params
=
params
;
request
->
params_len
=
strlen
(
request
->
params
);
request
->
params_len
=
strlen
(
request
->
params
);
...
@@ -273,8 +257,7 @@ int dm_msg_thing_topo_delete(_IN_ char productType[PRODUCT_CODE_MAXLEN],
...
@@ -273,8 +257,7 @@ int dm_msg_thing_topo_delete(_IN_ char productType[PRODUCT_CODE_MAXLEN],
const
char
DM_MSG_COMBINE_STATUS_ONLINE_METHOD
[]
DM_READ_ONLY
=
"thing.status.online"
;
const
char
DM_MSG_COMBINE_STATUS_ONLINE_METHOD
[]
DM_READ_ONLY
=
"thing.status.online"
;
const
char
DM_MSG_COMBINE_STATUS_ONLINE
[]
DM_READ_ONLY
=
const
char
DM_MSG_COMBINE_STATUS_ONLINE
[]
DM_READ_ONLY
=
"{
\"
deviceCode
\"
:
\"
%s
\"
}"
;
"{
\"
deviceCode
\"
:
\"
%s
\"
}"
;
int
dm_msg_status_online
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_status_online
(
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
{
{
char
*
params
=
NULL
;
char
*
params
=
NULL
;
...
@@ -285,12 +268,10 @@ const char DM_MSG_COMBINE_STATUS_ONLINE[] DM_READ_ONLY =
...
@@ -285,12 +268,10 @@ const char DM_MSG_COMBINE_STATUS_ONLINE[] DM_READ_ONLY =
char
sign
[
64
]
=
{
0
};
char
sign
[
64
]
=
{
0
};
if
(
request
==
NULL
||
productType
==
NULL
||
if
(
request
==
NULL
||
deviceCode
==
NULL
||
productCode
==
NULL
||
deviceCode
==
NULL
||
productCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
productCode
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
productCode
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
request
->
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
...
@@ -318,12 +299,11 @@ const char DM_MSG_COMBINE_STATUS_ONLINE[] DM_READ_ONLY =
...
@@ -318,12 +299,11 @@ const char DM_MSG_COMBINE_STATUS_ONLINE[] DM_READ_ONLY =
}
}
const
char
DM_MSG_COMBINE_LOGIN_SIGN_SOURCE
[]
DM_READ_ONLY
=
"clientId%sdevice
Name%sproductKey
%stimestamp%s"
;
const
char
DM_MSG_COMBINE_LOGIN_SIGN_SOURCE
[]
DM_READ_ONLY
=
"clientId%sdevice
Code
%stimestamp%s"
;
const
char
DM_MSG_COMBINE_LOGIN_METHOD
[]
DM_READ_ONLY
=
"combine.login"
;
const
char
DM_MSG_COMBINE_LOGIN_METHOD
[]
DM_READ_ONLY
=
"combine.login"
;
const
char
DM_MSG_COMBINE_LOGIN_PARAMS
[]
DM_READ_ONLY
=
const
char
DM_MSG_COMBINE_LOGIN_PARAMS
[]
DM_READ_ONLY
=
"{
\"
productKey
\"
:
\"
%s
\"
,
\"
deviceName
\"
:
\"
%s
\"
,
\"
clientId
\"
:
\"
%s
\"
,
\"
timestamp
\"
:
\"
%s
\"
,
\"
signMethod
\"
:
\"
%s
\"
,
\"
sign
\"
:
\"
%s
\"
,
\"
cleanSession
\"
:
\"
%s
\"
}"
;
"{
\"
deviceCode
\"
:
\"
%s
\"
,
\"
clientId
\"
:
\"
%s
\"
,
\"
timestamp
\"
:
\"
%s
\"
,
\"
signMethod
\"
:
\"
%s
\"
,
\"
sign
\"
:
\"
%s
\"
,
\"
cleanSession
\"
:
\"
%s
\"
}"
;
int
dm_msg_combine_login
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_combine_login
(
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
productCode
[
PRODUCT_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
{
{
char
*
params
=
NULL
;
char
*
params
=
NULL
;
...
@@ -335,13 +315,10 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -335,13 +315,10 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
char
*
sign_method
=
DM_MSG_SIGN_METHOD_HMACSHA1
;
char
*
sign_method
=
DM_MSG_SIGN_METHOD_HMACSHA1
;
char
sign
[
64
]
=
{
0
};
char
sign
[
64
]
=
{
0
};
if
(
request
==
NULL
||
if
(
request
==
NULL
||
productType
==
NULL
||
deviceCode
==
NULL
||
productCode
==
NULL
||
deviceCode
==
NULL
||
productCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
productCode
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
productCode
)
>=
PRODUCT_CODE_MAXLEN
)
||
(
strlen
(
request
->
productType
)
>=
PRODUCT_TYPE_MAXLEN
)
||
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
(
strlen
(
request
->
deviceCode
)
>=
DEVICE_CODE_MAXLEN
))
{
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
...
@@ -351,18 +328,18 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -351,18 +328,18 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
/* dm_log_debug("Time Stamp: %s", timestamp); */
/* dm_log_debug("Time Stamp: %s", timestamp); */
/* Client ID */
/* Client ID */
HAL_Snprintf
(
client_id
,
PRODUCT_TYPE_MAXLEN
+
DEVICE_CODE_MAXLEN
+
20
,
"%s
.%s|_v=sdk-c-3.0.1|"
,
productType
,
deviceCode
);
HAL_Snprintf
(
client_id
,
PRODUCT_TYPE_MAXLEN
+
DEVICE_CODE_MAXLEN
+
20
,
"%s
|_v=sdk-c-3.0.1|"
,
deviceCode
);
/* Sign */
/* Sign */
sign_source_len
=
strlen
(
DM_MSG_COMBINE_LOGIN_SIGN_SOURCE
)
+
strlen
(
client_id
)
+
sign_source_len
=
strlen
(
DM_MSG_COMBINE_LOGIN_SIGN_SOURCE
)
+
strlen
(
client_id
)
+
strlen
(
deviceCode
)
+
strlen
(
productType
)
+
strlen
(
timestamp
)
+
1
;
strlen
(
deviceCode
)
+
strlen
(
timestamp
)
+
1
;
sign_source
=
malloc
(
sign_source_len
);
sign_source
=
malloc
(
sign_source_len
);
if
(
sign_source
==
NULL
)
{
if
(
sign_source
==
NULL
)
{
return
DM_MEMORY_NOT_ENOUGH
;
return
DM_MEMORY_NOT_ENOUGH
;
}
}
memset
(
sign_source
,
0
,
sign_source_len
);
memset
(
sign_source
,
0
,
sign_source_len
);
HAL_Snprintf
(
sign_source
,
sign_source_len
,
DM_MSG_COMBINE_LOGIN_SIGN_SOURCE
,
client_id
,
HAL_Snprintf
(
sign_source
,
sign_source_len
,
DM_MSG_COMBINE_LOGIN_SIGN_SOURCE
,
client_id
,
deviceCode
,
productType
,
timestamp
);
deviceCode
,
timestamp
);
/* dm_log_debug("Sign Srouce: %s", sign_source); */
/* dm_log_debug("Sign Srouce: %s", sign_source); */
#if 0
#if 0
...
@@ -384,7 +361,7 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -384,7 +361,7 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
/* Params */
/* Params */
request
->
method
=
(
char
*
)
DM_MSG_COMBINE_LOGIN_METHOD
;
request
->
method
=
(
char
*
)
DM_MSG_COMBINE_LOGIN_METHOD
;
params_len
=
strlen
(
DM_MSG_COMBINE_LOGIN_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
deviceCode
)
+
params_len
=
strlen
(
DM_MSG_COMBINE_LOGIN_PARAMS
)
+
strlen
(
deviceCode
)
+
strlen
(
sign_method
)
+
strlen
(
sign
)
+
strlen
(
timestamp
)
+
strlen
(
client_id
)
+
1
;
strlen
(
sign_method
)
+
strlen
(
sign
)
+
strlen
(
timestamp
)
+
strlen
(
client_id
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
...
@@ -392,7 +369,7 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -392,7 +369,7 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
return
DM_MEMORY_NOT_ENOUGH
;
return
DM_MEMORY_NOT_ENOUGH
;
}
}
memset
(
params
,
0
,
params_len
);
memset
(
params
,
0
,
params_len
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_COMBINE_LOGIN_PARAMS
,
productType
,
deviceCode
,
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_COMBINE_LOGIN_PARAMS
,
deviceCode
,
client_id
,
timestamp
,
sign_method
,
sign
,
"true"
);
client_id
,
timestamp
,
sign_method
,
sign
,
"true"
);
request
->
params
=
params
;
request
->
params
=
params
;
...
@@ -403,32 +380,29 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
...
@@ -403,32 +380,29 @@ int dm_msg_combine_login(_IN_ char productType[PRODUCT_TYPE_MAXLEN],
const
char
DM_MSG_COMBINE_LOGOUT_METHOD
[]
DM_READ_ONLY
=
"combine.logout"
;
const
char
DM_MSG_COMBINE_LOGOUT_METHOD
[]
DM_READ_ONLY
=
"combine.logout"
;
const
char
DM_MSG_COMBINE_LOGOUT_PARAMS
[]
DM_READ_ONLY
=
"{
\"
productKey
\"
:
\"
%s
\"
,
\"
deviceName
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_COMBINE_LOGOUT_PARAMS
[]
DM_READ_ONLY
=
"{
\"
deviceCode
\"
:
\"
%s
\"
}"
;
int
dm_msg_combine_logout
(
_IN_
char
productType
[
PRODUCT_TYPE_MAXLEN
],
int
dm_msg_combine_logout
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
_OU_
dm_msg_request_t
*
request
)
{
{
char
*
params
=
NULL
;
char
*
params
=
NULL
;
int
params_len
=
0
;
int
params_len
=
0
;
if
(
productType
==
NULL
||
deviceCode
==
NULL
||
if
(
deviceCode
==
NULL
||
(
strlen
(
productType
)
>=
PRODUCT_TYPE_MAXLEN
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
(
strlen
(
deviceCode
)
>=
DEVICE_CODE_MAXLEN
)
||
request
==
NULL
)
)
{
request
==
NULL
){
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
/* Params */
/* Params */
request
->
method
=
(
char
*
)
DM_MSG_COMBINE_LOGOUT_METHOD
;
request
->
method
=
(
char
*
)
DM_MSG_COMBINE_LOGOUT_METHOD
;
params_len
=
strlen
(
DM_MSG_COMBINE_LOGOUT_PARAMS
)
+
strlen
(
productType
)
+
strlen
(
deviceCode
)
+
1
;
params_len
=
strlen
(
DM_MSG_COMBINE_LOGOUT_PARAMS
)
+
strlen
(
deviceCode
)
+
1
;
params
=
malloc
(
params_len
);
params
=
malloc
(
params_len
);
if
(
params
==
NULL
)
{
if
(
params
==
NULL
)
{
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
params
,
0
,
params_len
);
memset
(
params
,
0
,
params_len
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_COMBINE_LOGOUT_PARAMS
,
productType
,
deviceCode
);
HAL_Snprintf
(
params
,
params_len
,
DM_MSG_COMBINE_LOGOUT_PARAMS
,
deviceCode
);
request
->
params
=
params
;
request
->
params
=
params
;
request
->
params_len
=
strlen
(
request
->
params
);
request
->
params_len
=
strlen
(
request
->
params
);
...
@@ -489,15 +463,14 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
...
@@ -489,15 +463,14 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
snprintf
(
payload
,
payload_len
,
DM_MSG_REQUEST
,
request
->
msgid
,
snprintf
(
payload
,
payload_len
,
DM_MSG_REQUEST
,
request
->
msgid
,
DM_MSG_VERSION
,
request
->
params_len
,
request
->
params
,
request
->
method
);
DM_MSG_VERSION
,
request
->
params_len
,
request
->
params
,
request
->
method
);
req_info_len
=
strlen
(
DM_MSG_INFO
)
+
10
+
strlen
(
request
->
product
Type
)
+
strlen
(
request
->
product
Code
)
+
strlen
(
request
->
deviceCode
)
+
strlen
(
request
->
msgTypeStr
)
+
1
;
req_info_len
=
strlen
(
DM_MSG_INFO
)
+
10
+
strlen
(
request
->
productCode
)
+
strlen
(
request
->
deviceCode
)
+
strlen
(
request
->
msgTypeStr
)
+
1
;
req_info
=
malloc
(
req_info_len
);
req_info
=
malloc
(
req_info_len
);
if
(
req_info
==
NULL
)
{
if
(
req_info
==
NULL
)
{
free
(
payload
);
free
(
payload
);
return
MEMORY_NOT_ENOUGH
;
return
MEMORY_NOT_ENOUGH
;
}
}
memset
(
req_info
,
0
,
req_info_len
);
memset
(
req_info
,
0
,
req_info_len
);
snprintf
(
req_info
,
req_info_len
,
DM_MSG_INFO
,
request
->
msgTypeStr
,
snprintf
(
req_info
,
req_info_len
,
DM_MSG_INFO
,
request
->
msgTypeStr
,
request
->
productCode
,
request
->
deviceCode
);
request
->
productType
,
request
->
productCode
,
request
->
deviceCode
);
memset
(
&
lite
,
0
,
sizeof
(
lite_cjson_t
));
memset
(
&
lite
,
0
,
sizeof
(
lite_cjson_t
));
res
=
lite_cjson_parse
(
payload
,
payload_len
,
&
lite
);
res
=
lite_cjson_parse
(
payload
,
payload_len
,
&
lite
);
...
@@ -551,7 +524,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
...
@@ -551,7 +524,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
snprintf
(
payload
,
payload_len
,
DM_MSG_RESPONSE_WITH_DATA
,
snprintf
(
payload
,
payload_len
,
DM_MSG_RESPONSE_WITH_DATA
,
request
->
id
.
value_length
,
request
->
id
.
value
,
response
->
code
,
data_len
,
data
);
request
->
id
.
value_length
,
request
->
id
.
value
,
response
->
code
,
data_len
,
data
);
res_info_len
=
strlen
(
DM_MSG_INFO
)
+
10
+
strlen
(
response
->
product
Type
)
+
strlen
(
response
->
product
Code
)
+
strlen
(
response
->
deviceCode
)
+
strlen
(
response
->
msgTypeStr
)
+
1
;
res_info_len
=
strlen
(
DM_MSG_INFO
)
+
10
+
strlen
(
response
->
productCode
)
+
strlen
(
response
->
deviceCode
)
+
strlen
(
response
->
msgTypeStr
)
+
1
;
res_info
=
malloc
(
res_info_len
);
res_info
=
malloc
(
res_info_len
);
if
(
res_info
==
NULL
)
{
if
(
res_info
==
NULL
)
{
free
(
payload
);
free
(
payload
);
...
@@ -559,8 +532,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
...
@@ -559,8 +532,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
}
}
memset
(
res_info
,
0
,
res_info_len
);
memset
(
res_info
,
0
,
res_info_len
);
snprintf
(
res_info
,
res_info_len
,
DM_MSG_INFO
,
response
->
msgTypeStr
,
snprintf
(
res_info
,
res_info_len
,
DM_MSG_INFO
,
response
->
msgTypeStr
,
response
->
productCode
,
response
->
deviceCode
);
response
->
productType
,
response
->
productCode
,
response
->
deviceCode
);
memset
(
&
lite
,
0
,
sizeof
(
lite_cjson_t
));
memset
(
&
lite
,
0
,
sizeof
(
lite_cjson_t
));
...
@@ -662,7 +634,7 @@ int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *pa
...
@@ -662,7 +634,7 @@ int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *pa
memset
(
&
request
,
0
,
sizeof
(
kk_msg_request_payload_t
));
memset
(
&
request
,
0
,
sizeof
(
kk_msg_request_payload_t
));
memset
(
&
response
,
0
,
sizeof
(
kk_msg_response_t
));
memset
(
&
response
,
0
,
sizeof
(
kk_msg_response_t
));
res
=
dm_mgr_get_device_by_
mac
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_
devicecode
(
deviceCode
,
&
node
);
if
(
res
<
SUCCESS_RETURN
)
{
if
(
res
<
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"dm_mgr_search_device_by_pkdn failed"
);
ERROR_PRINT
(
"dm_mgr_search_device_by_pkdn failed"
);
return
res
;
return
res
;
...
@@ -674,7 +646,6 @@ int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *pa
...
@@ -674,7 +646,6 @@ int dm_msg_thing_property_set_reply(char deviceCode[DEVICE_CODE_MAXLEN],char *pa
}
}
response
.
msgTypeStr
=
DM_URI_THING_SERVICE_PROPERTY_SET_REPLY
;
response
.
msgTypeStr
=
DM_URI_THING_SERVICE_PROPERTY_SET_REPLY
;
memcpy
(
response
.
productType
,
node
->
productType
,
strlen
(
node
->
productType
));
memcpy
(
response
.
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
response
.
productCode
,
node
->
productCode
,
strlen
(
node
->
productCode
));
memcpy
(
response
.
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
memcpy
(
response
.
deviceCode
,
node
->
deviceCode
,
strlen
(
node
->
deviceCode
));
response
.
code
=
(
res
==
SUCCESS_RETURN
)
?
(
IOTX_DM_ERR_CODE_SUCCESS
)
:
(
IOTX_DM_ERR_CODE_REQUEST_ERROR
);
response
.
code
=
(
res
==
SUCCESS_RETURN
)
?
(
IOTX_DM_ERR_CODE_SUCCESS
)
:
(
IOTX_DM_ERR_CODE_REQUEST_ERROR
);
...
...
midware/midware/dm/kk_linkkit.c
View file @
1cb9ada1
...
@@ -249,7 +249,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -249,7 +249,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
//get devicececret and save it
//get devicececret and save it
INFO_PRINT
(
" topic:register_reply
\n
"
);
INFO_PRINT
(
" topic:register_reply
\n
"
);
dm_msg_response_payload_t
response
;
dm_msg_response_payload_t
response
;
res
=
dm_msg_response_parse
((
char
*
)
payload_Str
,
strlen
(
payload
_Str
)
+
1
,
&
response
);
res
=
dm_msg_response_parse
((
char
*
)
payload_Str
,
strlen
(
payload
->
valuestring
)
+
1
,
&
response
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
goto
directReturn
;
goto
directReturn
;
}
}
...
@@ -263,7 +263,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -263,7 +263,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
//
//
INFO_PRINT
(
" topic:add_reply
\n
"
);
INFO_PRINT
(
" topic:add_reply
\n
"
);
dm_msg_response_payload_t
response
;
dm_msg_response_payload_t
response
;
res
=
dm_msg_response_parse
((
char
*
)
payload_Str
,
strlen
(
payload
_Str
)
+
1
,
&
response
);
res
=
dm_msg_response_parse
((
char
*
)
payload_Str
,
strlen
(
payload
->
valuestring
)
+
1
,
&
response
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
goto
directReturn
;
goto
directReturn
;
}
}
...
@@ -272,12 +272,12 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -272,12 +272,12 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_callback_remove
(
atoi
(
response
.
id
.
value
),
response
.
code
.
value_int
);
_iotx_linkkit_upstream_callback_remove
(
atoi
(
response
.
id
.
value
),
response
.
code
.
value_int
);
_iotx_linkkit_upstream_mutex_unlock
();
_iotx_linkkit_upstream_mutex_unlock
();
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_LOGIN_TOPIC_REPLY
)
||
strstr
(
typeJson
->
valuestring
,
KK_ONLINE_TOPIC_REPLY
)
){
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_LOGIN_TOPIC_REPLY
)){
//====todo======
//====todo======
//
//
INFO_PRINT
(
" topic:login_reply
\n
"
);
INFO_PRINT
(
" topic:login_reply
\n
"
);
dm_msg_response_payload_t
response
;
dm_msg_response_payload_t
response
;
res
=
dm_msg_response_parse
((
char
*
)
payload_Str
,
strlen
(
payload
_Str
)
+
1
,
&
response
);
res
=
dm_msg_response_parse
((
char
*
)
payload_Str
,
strlen
(
payload
->
valuestring
)
+
1
,
&
response
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
goto
directReturn
;
goto
directReturn
;
}
}
...
@@ -305,6 +305,9 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -305,6 +305,9 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
}
iotx_dm_dev_online
(
0
);
//first online,report the online status
usleep
(
200000
);
kk_tsl_post_property
(
0
,
NULL
);
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)){
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_OTA_DEVICE_UPGRADE
)){
INFO_PRINT
(
"ota upgrade...
\n
"
);
INFO_PRINT
(
"ota upgrade...
\n
"
);
kk_dm_ota_send
(
data
,
strlen
(
data
)
+
1
);
kk_dm_ota_send
(
data
,
strlen
(
data
)
+
1
);
...
@@ -1035,7 +1038,6 @@ int _iotx_linkkit_slave_connect(int devid)
...
@@ -1035,7 +1038,6 @@ int _iotx_linkkit_slave_connect(int devid)
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
#if 0
/* Subdev Register */
/* Subdev Register */
res
=
kk_dm_subdev_register
(
devid
);
res
=
kk_dm_subdev_register
(
devid
);
if
(
res
<
SUCCESS_RETURN
)
{
if
(
res
<
SUCCESS_RETURN
)
{
...
@@ -1076,8 +1078,6 @@ int _iotx_linkkit_slave_connect(int devid)
...
@@ -1076,8 +1078,6 @@ int _iotx_linkkit_slave_connect(int devid)
_iotx_linkkit_upstream_mutex_unlock
();
_iotx_linkkit_upstream_mutex_unlock
();
}
}
#endif
/* Subdev Add Topo */
/* Subdev Add Topo */
res
=
kk_dm_subdev_topo_add
(
devid
);
res
=
kk_dm_subdev_topo_add
(
devid
);
...
@@ -1339,7 +1339,7 @@ static int _iotx_linkkit_subdev_login(int devid)
...
@@ -1339,7 +1339,7 @@ static int _iotx_linkkit_subdev_login(int devid)
void
*
semaphore
=
NULL
;
void
*
semaphore
=
NULL
;
void
*
callback
=
NULL
;
void
*
callback
=
NULL
;
res
=
iotx_dm_
dev_online
(
devid
);
//iotx_dm_
subdev_login(devid);
res
=
iotx_dm_subdev_login
(
devid
);
if
(
res
<
SUCCESS_RETURN
)
{
if
(
res
<
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -1672,18 +1672,18 @@ int iot_linkkit_subdev_query_id(char product_key[IOTX_PRODUCT_KEY_LEN + 1], char
...
@@ -1672,18 +1672,18 @@ int iot_linkkit_subdev_query_id(char product_key[IOTX_PRODUCT_KEY_LEN + 1], char
#endif /* #ifdef DEVICE_MODEL_GATEWAY */
#endif /* #ifdef DEVICE_MODEL_GATEWAY */
int
kk_mid_subdev_add
(
int
devType
,
char
product
Type
[
PRODUCT_TYPE_MAXLEN
],
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
fatherMac
[
DEVICE_MAC
_MAXLEN
]){
int
kk_mid_subdev_add
(
int
devType
,
char
product
Code
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE
_MAXLEN
]){
int
res
=
0
;
int
res
=
0
;
int
devid
=
0
;
int
devid
=
0
;
res
=
dm_mgr_subdev_create
(
devType
,
productType
,
productCode
,
deviceCode
,
fatherMac
,
&
devid
);
res
=
dm_mgr_subdev_create
(
devType
,
productCode
,
deviceCode
,
mac
,
fatherDeviceCode
,
&
devid
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"subdev create Failed
\n
"
);
ERROR_PRINT
(
"subdev create Failed
\n
"
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
INFO_PRINT
(
"subdev open susseed, devid = %d
\n
"
,
devid
);
INFO_PRINT
(
"subdev open susseed, devid = %d
\n
"
,
devid
);
res
=
kk_subDev_insert_db
(
devType
,
productCode
,
deviceCode
,
fatherM
ac
,
"1.1.0"
);
res
=
kk_subDev_insert_db
(
KK_DM_DEVICE_SUBDEV
,
productCode
,
deviceCode
,
fatherDeviceCode
,
m
ac
,
"1.1.0"
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -1703,3 +1703,4 @@ int kk_mid_subdev_add(int devType, char productType[PRODUCT_TYPE_MAXLEN], char p
...
@@ -1703,3 +1703,4 @@ int kk_mid_subdev_add(int devType, char productType[PRODUCT_TYPE_MAXLEN], char p
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
midware/midware/dm/kk_sub_db.c
View file @
1cb9ada1
...
@@ -12,6 +12,18 @@ typedef struct {
...
@@ -12,6 +12,18 @@ typedef struct {
int
subDevNum
;
int
subDevNum
;
sqlite3
*
pDb
;
sqlite3
*
pDb
;
}
kk_subDb_ctx_t
;
}
kk_subDb_ctx_t
;
typedef
enum
{
DB_IDX
=
0
,
DB_ONLINE
,
DB_PRODUCTCODE
,
DB_DEVICECODE
,
DB_MAC
,
DB_FATHERDEVICECODE
,
DB_VERSION
,
DB_AUTH
,
DB_DEVTYPE
,
};
static
kk_subDb_ctx_t
s_kk_subDb_ctx
=
{
NULL
,
0
,
NULL
};
static
kk_subDb_ctx_t
s_kk_subDb_ctx
=
{
NULL
,
0
,
NULL
};
static
kk_subDb_ctx_t
*
_kk_subDb_get_ctx
(
void
)
static
kk_subDb_ctx_t
*
_kk_subDb_get_ctx
(
void
)
...
@@ -54,7 +66,8 @@ static int kk_subDev_db_Init(void)
...
@@ -54,7 +66,8 @@ static int kk_subDev_db_Init(void)
isOnline INTEGER, \
isOnline INTEGER, \
productCode varchar(33), \
productCode varchar(33), \
deviceCode varchar(33), \
deviceCode varchar(33), \
fatherMac varchar(17), \
mac varchar(17), \
fatherDeviceCode varchar(33), \
version varchar(33), \
version varchar(33), \
isAuth INTEGER, \
isAuth INTEGER, \
devType INTEGER)"
;
devType INTEGER)"
;
...
@@ -90,8 +103,9 @@ static int _kk_load_subDevice(void)
...
@@ -90,8 +103,9 @@ static int _kk_load_subDevice(void)
INFO_PRINT
(
"_kk_load_subDevice total_column = %d
\n
"
,
sqlite3_column_count
(
stmt
));
INFO_PRINT
(
"_kk_load_subDevice total_column = %d
\n
"
,
sqlite3_column_count
(
stmt
));
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
res
=
dm_mgr_subdev_create
(
sqlite3_column_int
(
stmt
,
7
),
""
,
sqlite3_column_text
(
stmt
,
2
),
sqlite3_column_text
(
stmt
,
3
),
res
=
dm_mgr_subdev_create
(
sqlite3_column_int
(
stmt
,
DB_DEVTYPE
),
sqlite3_column_text
(
stmt
,
DB_PRODUCTCODE
),
sqlite3_column_text
(
stmt
,
4
),
&
devId
);
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
),
sqlite3_column_text
(
stmt
,
DB_MAC
),
sqlite3_column_text
(
stmt
,
DB_FATHERDEVICECODE
),
&
devId
);
if
(
res
!=
SUCCESS_RETURN
){
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
"[%s][%d]dm_mgr_subdev_create FAIL!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
ERROR_PRINT
(
"[%s][%d]dm_mgr_subdev_create FAIL!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
...
@@ -104,7 +118,7 @@ static int _kk_load_subDevice(void)
...
@@ -104,7 +118,7 @@ static int _kk_load_subDevice(void)
//再上线
//再上线
iotx_dm_subscribe
(
devId
);
iotx_dm_subscribe
(
devId
);
kk_dm_ota_report_version
(
devId
,
sqlite3_column_text
(
stmt
,
5
));
//version
kk_dm_ota_report_version
(
devId
,
sqlite3_column_text
(
stmt
,
DB_VERSION
));
//version
//usleep(100000);
//usleep(100000);
}
}
sqlite3_finalize
(
stmt
);
sqlite3_finalize
(
stmt
);
...
@@ -142,7 +156,7 @@ static int _kk_check_subDev_exist(const char* deviceCode)
...
@@ -142,7 +156,7 @@ static int _kk_check_subDev_exist(const char* deviceCode)
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
INFO_PRINT
(
"total_column = %d
\n
"
,
sqlite3_column_count
(
stmt
));
INFO_PRINT
(
"total_column = %d
\n
"
,
sqlite3_column_count
(
stmt
));
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pmac
=
sqlite3_column_text
(
stmt
,
3
);
pmac
=
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
);
if
(
!
strcmp
(
deviceCode
,
pmac
))
if
(
!
strcmp
(
deviceCode
,
pmac
))
{
{
isExist
=
1
;
isExist
=
1
;
...
@@ -159,10 +173,10 @@ static int _kk_check_subDev_exist(const char* deviceCode)
...
@@ -159,10 +173,10 @@ static int _kk_check_subDev_exist(const char* deviceCode)
}
}
int
kk_subDev_insert_db
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
\
int
kk_subDev_insert_db
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
\
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
father
Mac
[
DEVICE_MAC
_MAXLEN
],
char
version
[
DEVICE_VERSION_MAXLEN
])
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
father
DeviceCode
[
DEVICE_CODE
_MAXLEN
],
char
version
[
DEVICE_VERSION_MAXLEN
])
{
{
const
char
*
insertCmd
=
"insert into SubDeviceInfo (idx,isOnline,productCode,deviceCode,fatherMac,version,isAuth,devType) \
const
char
*
insertCmd
=
"insert into SubDeviceInfo (idx,isOnline,productCode,deviceCode,
mac,
fatherMac,version,isAuth,devType) \
values ('%d','%d', '%s','%s','%s','%s','%d','%d');"
;
values ('%d','%d', '%s','%s','%s','%s','%
s','%
d','%d');"
;
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
char
*
zErrMsg
=
0
;
...
@@ -175,7 +189,7 @@ int kk_subDev_insert_db(int devType,char productCode[PRODUCT_CODE_MAXLEN], \
...
@@ -175,7 +189,7 @@ int kk_subDev_insert_db(int devType,char productCode[PRODUCT_CODE_MAXLEN], \
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
_kk_subDb_lock
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
ctx
->
subDevNum
,
0
,
productCode
,
deviceCode
,
father
Mac
,
version
,
0
,
devType
);
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
ctx
->
subDevNum
,
0
,
productCode
,
deviceCode
,
father
DeviceCode
,
version
,
0
,
devType
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
if
(
rc
!=
SQLITE_OK
){
...
@@ -189,7 +203,7 @@ int kk_subDev_insert_db(int devType,char productCode[PRODUCT_CODE_MAXLEN], \
...
@@ -189,7 +203,7 @@ int kk_subDev_insert_db(int devType,char productCode[PRODUCT_CODE_MAXLEN], \
_kk_subDb_unlock
();
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_subDev_delete_by
Mac
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
])
int
kk_subDev_delete_by
_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
])
{
{
const
char
*
deleteCmd
=
"delete from SubDeviceInfo where deviceCode = %s;"
;
const
char
*
deleteCmd
=
"delete from SubDeviceInfo where deviceCode = %s;"
;
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
...
@@ -213,7 +227,7 @@ int kk_subDev_delete_byMac(char deviceCode[DEVICE_CODE_MAXLEN])
...
@@ -213,7 +227,7 @@ int kk_subDev_delete_byMac(char deviceCode[DEVICE_CODE_MAXLEN])
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_subDev_update_online
(
int
isOnline
,
const
char
*
device
_mac
)
int
kk_subDev_update_online
(
int
isOnline
,
const
char
*
device
Code
)
{
{
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
int
len
=
0
;
int
len
=
0
;
...
@@ -222,7 +236,7 @@ int kk_subDev_update_online(int isOnline,const char *device_mac)
...
@@ -222,7 +236,7 @@ int kk_subDev_update_online(int isOnline,const char *device_mac)
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
_kk_subDb_lock
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE SubDeviceInfo SET isOnline=%d WHERE deviceCode=%s"
,
isOnline
,
device
_mac
);
sqlCmd
=
sqlite3_mprintf
(
"UPDATE SubDeviceInfo SET isOnline=%d WHERE deviceCode=%s"
,
isOnline
,
device
Code
);
INFO_PRINT
(
"kk_subDev_update_online sqlCmd:%s
\n
"
,
sqlCmd
);
INFO_PRINT
(
"kk_subDev_update_online sqlCmd:%s
\n
"
,
sqlCmd
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
if
(
rc
!=
SQLITE_OK
){
...
...
midware/midware/midware.c
View file @
1cb9ada1
...
@@ -28,7 +28,6 @@ char * g_filerToPlatTable[] =
...
@@ -28,7 +28,6 @@ char * g_filerToPlatTable[] =
{
KK_LOGIN_TOPIC_REPLY
},
{
KK_LOGIN_TOPIC_REPLY
},
{
KK_THING_OTA_DEVICE_UPGRADE
},
{
KK_THING_OTA_DEVICE_UPGRADE
},
{
KK_THING_CLOUDSTATE_MSG
},
{
KK_THING_CLOUDSTATE_MSG
},
{
KK_ONLINE_TOPIC_REPLY
},
};
};
static
int
_kk_filter_to_plat
(
const
char
*
msgtype
)
static
int
_kk_filter_to_plat
(
const
char
*
msgtype
)
...
@@ -77,19 +76,19 @@ void mid_cb(void* data, int len){
...
@@ -77,19 +76,19 @@ void mid_cb(void* data, int len){
}
}
int
devType
=
0
;
int
devType
=
0
;
dm_mgr_get_device
Type_by_mac
(
deviceCode
->
valuestring
,
&
devType
);
dm_mgr_get_device
type_by_devicecode
(
deviceCode
->
valuestring
,
&
devType
);
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
if
(
devType
==
KK_DM_DEVICE_GATEWAY
){
kk_ipc_send_ex
(
IPC_MID2PLAT
,
data
,
strlen
(
data
),
deviceCode
->
valuestring
);
//send to gw itself
kk_ipc_send_ex
(
IPC_MID2PLAT
,
data
,
strlen
(
data
),
deviceCode
->
valuestring
);
//send to gw itself
}
else
if
(
devType
==
KK_DM_DEVICE_SUBDEV
){
}
else
if
(
devType
==
KK_DM_DEVICE_SUBDEV
){
dm_mgr_dev_node_t
*
gw_node
=
NULL
;
dm_mgr_dev_node_t
*
gw_node
=
NULL
;
res
=
dm_mgr_get_device_by_
mac
(
deviceCode
->
valuestring
,
&
gw_node
);
res
=
dm_mgr_get_device_by_
devicecode
(
deviceCode
->
valuestring
,
&
gw_node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
ERROR_PRINT
(
"res:%d
\n
"
,
res
);
ERROR_PRINT
(
"res:%d
\n
"
,
res
);
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
cJSON_Delete
(
info
);
cJSON_Delete
(
info
);
return
;
return
;
}
}
kk_ipc_send_ex
(
IPC_MID2PLAT
,
data
,
strlen
(
data
),
gw_node
->
father
Mac
);
//send to sub device
kk_ipc_send_ex
(
IPC_MID2PLAT
,
data
,
strlen
(
data
),
gw_node
->
father
DeviceCode
);
//send to sub device
}
}
else
{
else
{
ERROR_PRINT
(
"wrong type
\n
"
);
ERROR_PRINT
(
"wrong type
\n
"
);
...
@@ -140,33 +139,40 @@ void kk_platMsg_handle(void* data, char* chalMark){
...
@@ -140,33 +139,40 @@ void kk_platMsg_handle(void* data, char* chalMark){
char
*
out
;
char
*
out
;
int
res
=
0
;
int
res
=
0
;
cJSON
*
json
;
cJSON
*
json
;
cJSON
*
method
;
cJSON
*
info
;
cJSON
*
info_dcode
;
cJSON
*
params
;
cJSON
*
params
;
cJSON
*
jsonPay
;
cJSON
*
jsonPay
;
cJSON
*
pro
Type
;
cJSON
*
msg
Type
;
cJSON
*
proCode
;
cJSON
*
proCode
;
cJSON
*
devCode
;
cJSON
*
devCode
;
cJSON
*
mac
;
cJSON
*
mac
;
cJSON
*
payload
;
json
=
cJSON_Parse
(
data
);
json
=
cJSON_Parse
(
data
);
if
(
!
json
)
{
if
(
!
json
)
{
WARNING_PRINT
(
"Error before: [%s]
\n
"
,
"cJSON_Parse"
);
WARNING_PRINT
(
"Error before: [%s]
\n
"
,
"cJSON_Parse"
);
}
}
else
{
else
{
method
=
cJSON_GetObjectItem
(
json
,
"method"
);
info
=
cJSON_GetObjectItem
(
json
,
"info"
);
mac
=
cJSON_GetObjectItem
(
json
,
"mac"
);
payload
=
cJSON_GetObjectItem
(
json
,
"payload"
);
if
(
method
!=
NULL
&&
strcmp
(
method
->
valuestring
,
"thing.topo.add"
)
==
0
){
if
(
info
!=
NULL
){
msgType
=
cJSON_GetObjectItem
(
info
,
"msgType"
);
jsonPay
=
cJSON_GetObjectItem
(
json
,
"params"
);
info_dcode
=
cJSON_GetObjectItem
(
info
,
"deviceCode"
);
proType
=
cJSON_GetObjectItem
(
jsonPay
,
"productType"
);
}
if
(
payload
!=
NULL
){
jsonPay
=
cJSON_GetObjectItem
(
payload
,
"params"
);
}
if
(
info_dcode
!=
NULL
&&
msgType
!=
NULL
&&
strcmp
(
msgType
->
valuestring
,
"/thing/topo/add"
)
==
0
){
proCode
=
cJSON_GetObjectItem
(
jsonPay
,
"productCode"
);
proCode
=
cJSON_GetObjectItem
(
jsonPay
,
"productCode"
);
devCode
=
cJSON_GetObjectItem
(
jsonPay
,
"deviceCode"
);
devCode
=
cJSON_GetObjectItem
(
jsonPay
,
"deviceCode"
);
INFO_PRINT
(
"productType productCode mac: [%s][%s] [%s]
\n
"
,
proType
->
valuestring
,
proCode
->
valuestring
,
mac
->
valuestring
);
mac
=
cJSON_GetObjectItem
(
jsonPay
,
"mac"
);
kk_mid_subdev_add
(
KK_DM_DEVICE_SUBDEV
,
proType
->
valuestring
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
);
INFO_PRINT
(
"deviceCode productCode mac: [%s][%s] [%s]
\n
"
,
devCode
->
valuestring
,
proCode
->
valuestring
,
mac
->
valuestring
);
kk_mid_subdev_add
(
KK_DM_DEVICE_SUBDEV
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
,
info_dcode
->
valuestring
);
}
else
if
(
method
!=
NULL
&&
mac
!=
NULL
){
}
else
if
(
info_dcode
!=
NULL
&&
strcmp
(
msgType
->
valuestring
,
"/thing/event/property/post"
)
==
0
){
INFO_PRINT
(
"save property and send to cloud
\n
"
);
INFO_PRINT
(
"save property and send to cloud
\n
"
);
kk_tsl_property_set_by
Mac
(
mac
->
valuestring
,
data
,
strlen
(
data
)
+
1
);
kk_tsl_property_set_by
_devicecode
(
info_dcode
->
valuestring
,
payload
,
strlen
(
payload
)
+
1
);
}
else
{
}
else
{
INFO_PRINT
(
"kk_platMsg_handle data: don't handle it [%s]
\n
"
,
data
);
INFO_PRINT
(
"kk_platMsg_handle data: don't handle it [%s]
\n
"
,
data
);
...
@@ -311,7 +317,6 @@ void *udp_dispatch_yield(void *args){
...
@@ -311,7 +317,6 @@ void *udp_dispatch_yield(void *args){
cJSON
*
infoObj
=
NULL
;
cJSON
*
infoObj
=
NULL
;
cJSON
*
payloadObj
=
NULL
;
cJSON
*
payloadObj
=
NULL
;
cJSON
*
msgtype
=
NULL
;
cJSON
*
msgtype
=
NULL
;
cJSON
*
proType
=
NULL
;
cJSON
*
proCode
=
NULL
;
cJSON
*
proCode
=
NULL
;
cJSON
*
devCode
=
NULL
;
cJSON
*
devCode
=
NULL
;
cJSON
*
params
=
NULL
;
cJSON
*
params
=
NULL
;
...
@@ -357,11 +362,10 @@ void *udp_dispatch_yield(void *args){
...
@@ -357,11 +362,10 @@ void *udp_dispatch_yield(void *args){
continue
;
continue
;
}
}
proType
=
cJSON_GetObjectItem
(
infoObj
,
"productType"
);
proCode
=
cJSON_GetObjectItem
(
infoObj
,
"productCode"
);
proCode
=
cJSON_GetObjectItem
(
infoObj
,
"productCode"
);
devCode
=
cJSON_GetObjectItem
(
infoObj
,
"deviceCode"
);
devCode
=
cJSON_GetObjectItem
(
infoObj
,
"deviceCode"
);
params
=
cJSON_GetObjectItem
(
payloadObj
,
"params"
);
params
=
cJSON_GetObjectItem
(
payloadObj
,
"params"
);
if
(
pro
Type
==
NULL
||
pro
Code
==
NULL
||
devCode
==
NULL
||
params
==
NULL
){
if
(
proCode
==
NULL
||
devCode
==
NULL
||
params
==
NULL
){
ERROR_PRINT
(
"productType productCode deviceCode params parameters are error
\n
"
);
ERROR_PRINT
(
"productType productCode deviceCode params parameters are error
\n
"
);
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
continue
;
continue
;
...
@@ -375,16 +379,16 @@ void *udp_dispatch_yield(void *args){
...
@@ -375,16 +379,16 @@ void *udp_dispatch_yield(void *args){
continue
;
continue
;
}
}
INFO_PRINT
(
"
productType productCode deviceCode mac: [%s][%s][%s][%s]
\n
"
,
proType
->
valuestring
,
proCode
->
valuestring
,
INFO_PRINT
(
"
productCode deviceCode mac: [%s][%s][%s][%s]
\n
"
,
proCode
->
valuestring
,
devCode
->
valuestring
,
macstr
->
valuestring
);
devCode
->
valuestring
,
macstr
->
valuestring
);
char
device_code
[
DEVICE_CODE_LEN
]
=
{
0
};
char
device_code
[
DEVICE_CODE_LEN
]
=
{
0
};
HAL_GetDevice_Code
(
device_code
);
HAL_GetDevice_Code
(
device_code
);
int
res
=
kk_mid_subdev_add
(
KK_DM_DEVICE_GATEWAY
,
proType
->
valuestring
,
proCode
->
valuestring
,
devCode
->
valuestring
,
device_code
);
int
res
=
kk_mid_subdev_add
(
KK_DM_DEVICE_GATEWAY
,
proCode
->
valuestring
,
devCode
->
valuestring
,
macstr
->
valuestring
,
device_code
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
WARNING_PRINT
(
"
kk_mid_gw_add
error"
);
WARNING_PRINT
(
"
dm_mgr_gw_create
error"
);
}
}
//
kk_ipc_send(IPC_MID2APP, szDec, size);
kk_ipc_send
(
IPC_MID2APP
,
szDec
,
size
);
memset
(
host_ip
,
0
,
sizeof
(
host_ip
));
memset
(
host_ip
,
0
,
sizeof
(
host_ip
));
memset
(
mac
,
0
,
sizeof
(
mac
));
memset
(
mac
,
0
,
sizeof
(
mac
));
...
@@ -436,7 +440,7 @@ void *ccu_property_monitor(void *args)
...
@@ -436,7 +440,7 @@ void *ccu_property_monitor(void *args)
int
needReport
=
0
;
int
needReport
=
0
;
static
int
s_cloudStatus
=
0
;
static
int
s_cloudStatus
=
0
;
int
cloudState
=
0
;
int
cloudState
=
0
;
int
time_second
=
1
0
;
int
time_second
=
6
0
;
static
int
alreadyRepord
=
0
;
static
int
alreadyRepord
=
0
;
while
(
mid_ctx
->
g_ccuProChg_dispatch_thread_running
)
{
while
(
mid_ctx
->
g_ccuProChg_dispatch_thread_running
)
{
//dm_ota_yield(MID_YIELD_TIMEOUT_MS);
//dm_ota_yield(MID_YIELD_TIMEOUT_MS);
...
@@ -467,24 +471,11 @@ void *ccu_property_monitor(void *args)
...
@@ -467,24 +471,11 @@ void *ccu_property_monitor(void *args)
needReport
=
1
;
needReport
=
1
;
}
}
}
}
if
(
alreadyRepord
){
time_second
=
60
;
}
else
{
time_second
=
10
;
}
if
(
needReport
&&
(
cloudState
==
1
)){
if
(
needReport
&&
(
cloudState
==
1
)){
//kk_tsl_post_property(0,NULL);
//kk_tsl_post_property(0,NULL);
needReport
=
0
;
needReport
=
0
;
if
(
alreadyRepord
==
0
){
iotx_dm_dev_online
(
0
);
//first online,report the online status
time_second
=
60
;
}
else
{
kk_tsl_post_property
(
0
,
NULL
);
kk_tsl_post_property
(
0
,
NULL
);
}
}
alreadyRepord
=
1
;
}
INFO_PRINT
(
"time_second:%d,s_cloudStatus:%d
\n
"
,
time_second
,
s_cloudStatus
);
INFO_PRINT
(
"time_second:%d,s_cloudStatus:%d
\n
"
,
time_second
,
s_cloudStatus
);
sleep
(
time_second
);
sleep
(
time_second
);
}
}
...
@@ -505,6 +496,9 @@ int main(const int argc, const char **argv)
...
@@ -505,6 +496,9 @@ int main(const int argc, const char **argv)
{
{
int
res
=
0
;
int
res
=
0
;
char
*
tsl_str
;
int
i
;
kk_tsl_t
*
dev_shadow
[
30
]
=
{
NULL
};
mid_ctx_t
*
mid_ctx
=
kk_mid_get_ctx
();
mid_ctx_t
*
mid_ctx
=
kk_mid_get_ctx
();
kk_zlog_init
(
"midware"
);
kk_zlog_init
(
"midware"
);
...
@@ -513,6 +507,255 @@ int main(const int argc, const char **argv)
...
@@ -513,6 +507,255 @@ int main(const int argc, const char **argv)
kk_set_product_info
();
kk_set_product_info
();
kk_tsl_api_init
();
kk_tsl_api_init
();
#if 0
tsl_str = kk_load_json("15", KK_DM_DEVICE_CCU);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("2", KK_DM_DEVICE_GATEWAY);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("11", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("24", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("83", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("84", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("85", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("89", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("90", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("91", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("96", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("97", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("98", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("102", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("103", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("104", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("105", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("106", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("1002", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("1003", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("1004", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("1007", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("1022", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
tsl_str = kk_load_json("2102", KK_DM_DEVICE_SUBDEV);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&dev_shadow[i]);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
}
}
i++;
#endif
#if 1
kk_ipc_init
(
IPC_MID2APP
,
mid_cb
,
NULL
,
NULL
);
kk_ipc_init
(
IPC_MID2APP
,
mid_cb
,
NULL
,
NULL
);
kk_ipc_init
(
IPC_MID2PLAT
,
mid2p_cb
,
NULL
,
"*"
);
kk_ipc_init
(
IPC_MID2PLAT
,
mid2p_cb
,
NULL
,
"*"
);
...
@@ -561,6 +804,7 @@ int main(const int argc, const char **argv)
...
@@ -561,6 +804,7 @@ int main(const int argc, const char **argv)
}
}
int
ct
=
0
;
int
ct
=
0
;
#endif
for
(;;)
{
for
(;;)
{
usleep
(
200000
);
usleep
(
200000
);
kk_platMsg_dispatch
();
kk_platMsg_dispatch
();
...
...
midware/tsl/tsl_handle/kk_tsl_api.c
View file @
1cb9ada1
...
@@ -1240,14 +1240,14 @@ int kk_msg_uri_parse_pkdn(_IN_ char *uri, _IN_ int uri_len, _IN_ int start_deli,
...
@@ -1240,14 +1240,14 @@ int kk_msg_uri_parse_pkdn(_IN_ char *uri, _IN_ int uri_len, _IN_ int start_deli,
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_tsl_property_set_by
Mac
(
const
char
mac
[
DEVICE_MAC
_MAXLEN
],
const
char
*
payload
,
unsigned
int
payload_len
)
int
kk_tsl_property_set_by
_devicecode
(
const
char
deviceCode
[
DEVICE_CODE
_MAXLEN
],
const
char
*
payload
,
unsigned
int
payload_len
)
{
{
kk_msg_request_payload_t
request
;
kk_msg_request_payload_t
request
;
int
res
=
0
,
devid
=
0
;
int
res
=
0
,
devid
=
0
;
memset
(
&
request
,
0
,
sizeof
(
kk_msg_request_payload_t
));
memset
(
&
request
,
0
,
sizeof
(
kk_msg_request_payload_t
));
res
=
dm_mgr_get_devId_by_
mac
(
mac
,
&
devid
);
res
=
dm_mgr_get_devId_by_
devicecode
(
deviceCode
,
&
devid
);
if
(
res
!=
SUCCESS_RETURN
){
if
(
res
!=
SUCCESS_RETURN
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
...
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
1cb9ada1
...
@@ -356,7 +356,7 @@ $(TARGET_FILE): $(APPLICATION_OBJECTS) $(LIBRARIES)
...
@@ -356,7 +356,7 @@ $(TARGET_FILE): $(APPLICATION_OBJECTS) $(LIBRARIES)
@
echo
-e
'\n$@ build success'
@
echo
-e
'\n$@ build success'
else
else
$(TARGET_FILE)
:
$(APPLICATION_OBJECTS) $(LIBRARIES)
$(TARGET_FILE)
:
$(APPLICATION_OBJECTS) $(LIBRARIES)
$(LD)
$^
$(LINKER_FLAGS)
-lm
-L
.
-
static
-lapi_com
-static
-lnanomsg
-lanl
-pthread
-static
-lev
-ltinfo
-o
$(TARGET_FILE)
$(LD)
$^
$(LINKER_FLAGS)
-lm
-L
.
-
lapi_com
-lnanomsg
-lanl
-pthread
-lev
-ltinfo
-o
$(TARGET_FILE)
@
echo
-e
'\n$@ build success'
@
echo
-e
'\n$@ build success'
endif
endif
...
...
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