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
0ae047b0
Commit
0ae047b0
authored
Aug 07, 2020
by
whmaizmy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】增加通过mac获取设备信息
【提交人】陈伟灿
parent
60bc7224
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
57 deletions
+60
-57
midware/midware/dm/iotx_dm.h
midware/midware/dm/iotx_dm.h
+0
-13
midware/midware/dm/kk_dm_api.c
midware/midware/dm/kk_dm_api.c
+0
-29
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+51
-8
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+1
-2
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+3
-3
midware/midware/midware.c
midware/midware/midware.c
+2
-2
midware/tsl/tsl_handle/kk_tsl_common.h
midware/tsl/tsl_handle/kk_tsl_common.h
+3
-0
No files found.
midware/midware/dm/iotx_dm.h
View file @
0ae047b0
...
...
@@ -137,19 +137,6 @@ typedef struct {
iotx_dm_event_callback
event_callback
;
}
iotx_dm_init_params_t
;
typedef
enum
{
IOTX_DM_DEV_AVAIL_ENABLE
,
IOTX_DM_DEV_AVAIL_DISABLE
}
iotx_dm_dev_avail_t
;
typedef
enum
{
IOTX_DM_DEV_STATUS_UNAUTHORIZED
,
/* Subdev Created */
IOTX_DM_DEV_STATUS_AUTHORIZED
,
/* Receive Topo Add Notify */
IOTX_DM_DEV_STATUS_REGISTERED
,
/* Receive Subdev Registered */
IOTX_DM_DEV_STATUS_ATTACHED
,
/* Receive Subdev Topo Add Reply */
IOTX_DM_DEV_STATUS_LOGINED
,
/* Receive Subdev Login Reply */
IOTX_DM_DEV_STATUS_ONLINE
/* After All Topic Subscribed */
}
iotx_dm_dev_status_t
;
typedef
enum
{
DM_TSL_SERVICE_GET_FAILED
=
-
13
,
...
...
midware/midware/dm/kk_dm_api.c
View file @
0ae047b0
...
...
@@ -32,35 +32,6 @@ static void _dm_api_unlock(void)
}
}
int
iotx_dm_subdev_create
(
_IN_
char
product_key
[
PRODUCT_KEY_MAXLEN
],
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_OU_
int
*
devid
)
{
int
res
=
0
;
if
(
product_key
==
NULL
||
device_name
==
NULL
||
(
strlen
(
product_key
)
>=
PRODUCT_KEY_MAXLEN
)
||
(
strlen
(
device_name
)
>=
DEVICE_NAME_MAXLEN
)
||
devid
==
NULL
)
{
return
INVALID_PARAMETER
;
}
if
(
device_secret
!=
NULL
&&
strlen
(
device_secret
)
>=
DEVICE_SECRET_MAXLEN
)
{
return
INVALID_PARAMETER
;
}
_dm_api_lock
();
res
=
dm_mgr_device_create
(
IOTX_DM_DEVICE_SUBDEV
,
product_key
,
device_name
,
device_secret
,
devid
);
if
(
res
!=
SUCCESS_RETURN
)
{
_dm_api_unlock
();
return
FAIL_RETURN
;
}
_dm_api_unlock
();
return
SUCCESS_RETURN
;
}
int
kk_dm_subdev_register
(
_IN_
int
devid
)
{
int
res
=
0
;
...
...
midware/midware/dm/kk_dm_mng.c
View file @
0ae047b0
...
...
@@ -167,7 +167,7 @@ static int _dm_init_tsl_params(int devId)
return
res
;
}
int
dm_mgr_device_create
(
_IN_
int
dev_type
,
_IN_
char
product_key
[
PRODUCT_KEY_MAXLEN
],
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_OU_
int
*
devid
)
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
devid
)
{
int
res
=
0
;
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
...
...
@@ -184,6 +184,9 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char product_key[PRODUCT_KEY_MA
if
(
device_secret
!=
NULL
&&
strlen
(
device_secret
)
>=
DEVICE_SECRET_MAXLEN
)
{
return
INVALID_PARAMETER
;
}
if
(
device_mac
!=
NULL
&&
strlen
(
device_mac
)
>=
DEVICE_MAC_MAXLEN
)
{
return
INVALID_PARAMETER
;
}
res
=
_dm_mgr_search_dev_by_pkdn
(
product_key
,
device_name
,
&
node
);
if
(
res
==
SUCCESS_RETURN
)
{
...
...
@@ -210,6 +213,10 @@ int dm_mgr_device_create(_IN_ int dev_type, _IN_ char product_key[PRODUCT_KEY_MA
if
(
device_secret
!=
NULL
)
{
memcpy
(
node
->
device_secret
,
device_secret
,
strlen
(
device_secret
));
}
if
(
device_mac
!=
NULL
)
{
memcpy
(
node
->
device_mac
,
device_mac
,
strlen
(
device_mac
));
}
//node->dev_status = IOTX_DM_DEV_STATUS_AUTHORIZED;
memset
(
name
,
0x0
,
sizeof
(
name
));
kk_get_tsl_by_productKey
(
product_key
,
name
);
...
...
@@ -255,6 +262,46 @@ int dm_mgr_search_device_by_pkdn(_IN_ char product_key[PRODUCT_KEY_MAXLEN], _IN_
return
SUCCESS_RETURN
;
}
int
dm_mgr_get_device_by_mac
(
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
dm_mgr_dev_node_t
**
node
)
{
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
dm_mgr_dev_node_t
*
search_node
=
NULL
;
list_for_each_entry
(
search_node
,
&
ctx
->
dev_list
,
linked_list
,
dm_mgr_dev_node_t
)
{
if
((
strlen
(
search_node
->
device_mac
)
==
strlen
(
device_mac
))
&&
(
memcmp
(
search_node
->
device_mac
,
device_mac
,
strlen
(
device_mac
))
==
0
))
{
/* dm_log_debug("Device Found, Product Key: %s, Device Name: %s", product_key, device_name); */
if
(
node
)
{
*
node
=
search_node
;
}
return
SUCCESS_RETURN
;
}
}
printf
(
"Device Not Found, device_mac: %s
\n
"
,
device_mac
);
return
FAIL_RETURN
;
}
int
dm_mgr_get_devId_by_mac
(
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
devid
)
{
int
res
=
0
;
dm_mgr_dev_node_t
*
node
=
NULL
;
if
(
device_mac
==
NULL
)
{
return
INVALID_PARAMETER
;
}
res
=
dm_mgr_get_device_by_mac
(
device_mac
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
}
if
(
devid
)
{
*
devid
=
node
->
devid
;
}
return
SUCCESS_RETURN
;
}
int
dm_mgr_init
(
void
)
{
int
res
=
0
;
...
...
@@ -284,7 +331,7 @@ int dm_mgr_init(void)
//memcpy(device_name,"aIqEbWno8yDdsjCX15iq",strlen("aIqEbWno8yDdsjCX15iq"));
//_dm_mgr_legacy_thing_created(IOTX_DM_LOCAL_NODE_DEVID);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_GATEWAY
,
product_key
,
device_name
,
device_secret
,
&
devId
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_GATEWAY
,
product_key
,
device_name
,
device_secret
,
NULL
,
&
devId
);
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
}
...
...
@@ -685,10 +732,6 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
return
FAIL_RETURN
;
}
if
(
node
->
dev_status
<
IOTX_DM_DEV_STATUS_LOGINED
)
{
return
FAIL_RETURN
;
}
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
service_prefix
=
DM_URI_EXT_SESSION_PREFIX
;
request
.
service_name
=
DM_URI_COMBINE_LOGOUT
;
...
...
@@ -773,10 +816,10 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
int
dm_mgr_subdev_create
(
_IN_
char
product_key
[
PRODUCT_KEY_MAXLEN
],
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_OU_
int
*
devid
){
_IN_
char
device_name
[
DEVICE_NAME_MAXLEN
],
_IN_
char
device_secret
[
DEVICE_SECRET_MAXLEN
],
_IN_
char
device_mac
[
DEVICE_MAC_MAXLEN
],
_OU_
int
*
devid
){
int
res
=
0
;
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_SUBDEV
,
product_key
,
device_name
,
device_secret
,
devid
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_SUBDEV
,
product_key
,
device_name
,
device_secret
,
device_mac
,
devid
);
if
(
res
!=
SUCCESS_RETURN
)
{
printf
(
"subdev open Failed
\n
"
);
return
FAIL_RETURN
;
...
...
midware/midware/dm/kk_dm_mng.h
View file @
0ae047b0
...
...
@@ -17,8 +17,7 @@ typedef struct {
char
product_key
[
PRODUCT_KEY_MAXLEN
];
char
device_name
[
DEVICE_NAME_MAXLEN
];
char
device_secret
[
DEVICE_SECRET_MAXLEN
];
iotx_dm_dev_avail_t
status
;
iotx_dm_dev_status_t
dev_status
;
char
device_mac
[
DEVICE_MAC_MAXLEN
];
struct
list_head
linked_list
;
}
dm_mgr_dev_node_t
;
...
...
midware/midware/dm/kk_linkkit.c
View file @
0ae047b0
...
...
@@ -241,7 +241,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
printf
(
"_iotx_linkkit_event_callback topic: [%s] ,payload= %s
\n
"
,
topic
->
valuestring
,
payload
->
valuestring
);
if
(
strcmp
(
payload
->
valuestring
,
"addsub"
)
==
0
){
kk_mid_subdev_add
(
"a1OYuSallan"
,
"allanWno8yDdsjCX15iq"
,
""
);
kk_mid_subdev_add
(
"a1OYuSallan"
,
"allanWno8yDdsjCX15iq"
,
""
,
""
);
}
else
{
printf
(
"rrr topic: [%s] ,payload= %s
\n
"
,
topic
->
valuestring
,
payload
->
valuestring
);
...
...
@@ -1745,10 +1745,10 @@ int iot_linkkit_subdev_query_id(char product_key[IOTX_PRODUCT_KEY_LEN + 1], char
#endif /* #ifdef DEVICE_MODEL_GATEWAY */
int
kk_mid_subdev_add
(
char
product_key
[
PRODUCT_KEY_MAXLEN
],
char
device_name
[
DEVICE_NAME_MAXLEN
],
char
device_secret
[
DEVICE_SECRET_MAXLEN
]){
int
kk_mid_subdev_add
(
char
product_key
[
PRODUCT_KEY_MAXLEN
],
char
device_name
[
DEVICE_NAME_MAXLEN
],
char
device_secret
[
DEVICE_SECRET_MAXLEN
]
,
char
device_mac
[
DEVICE_MAC_MAXLEN
]
){
int
res
=
0
;
int
devid
=
0
;
res
=
dm_mgr_subdev_create
(
product_key
,
device_name
,
device_secret
,
&
devid
);
res
=
dm_mgr_subdev_create
(
product_key
,
device_name
,
device_secret
,
device_mac
,
&
devid
);
if
(
res
!=
SUCCESS_RETURN
)
{
printf
(
"subdev create Failed
\n
"
);
return
FAIL_RETURN
;
...
...
midware/midware/midware.c
View file @
0ae047b0
...
...
@@ -32,7 +32,7 @@ void mid_cb(void* data, int len){
payload
=
cJSON_GetObjectItem
(
json
,
"payload"
);
printf
(
"mid_cb topic: [%s] ,payload= %s
\n
"
,
topic
->
valuestring
,
payload
->
valuestring
);
if
(
strcmp
(
payload
->
valuestring
,
"addsub"
)
==
0
){
kk_mid_subdev_add
(
"a1OYuSallan"
,
"allanWno8yDdsjCX15iq"
,
""
);
kk_mid_subdev_add
(
"a1OYuSallan"
,
"allanWno8yDdsjCX15iq"
,
""
,
""
);
}
else
{
void
*
buf
=
malloc
(
len
);
memcpy
(
buf
,
data
,
len
);
...
...
@@ -191,7 +191,7 @@ int main(const int argc, const char **argv)
ct
=
1
;
kk_set_tsl_by_productKey
(
"a1OYuSallan"
,
"model.json"
);
kk_mid_subdev_add
(
"a1OYuSallan"
,
"allanWno8yDdsjCX15iq"
,
""
);
kk_mid_subdev_add
(
"a1OYuSallan"
,
"allanWno8yDdsjCX15iq"
,
""
,
""
);
}
/*memset(buf, 0, 100);
...
...
midware/tsl/tsl_handle/kk_tsl_common.h
View file @
0ae047b0
...
...
@@ -15,6 +15,8 @@
#define PRODUCT_KEY_MAXLEN (32 + 1)
#define DEVICE_NAME_MAXLEN (32 + 1)
#define DEVICE_SECRET_MAXLEN (64 + 1)
#define DEVICE_MAC_MAXLEN (16 + 1)
#define TSL_PATH_MAXLEN (64 + 1)
#define DM_UTILS_UINT16_STRLEN (5)
...
...
@@ -66,6 +68,7 @@
#define KK_TSL_GATAWAY_MAC_IDENTIFIER "MACAddress"
#define KK_TSL_GATAWAY_PORT_IDENTIFIER "Port"
#define KK_TSL_GATAWAY_SN_IDENTIFIER "SN"
#define KK_TSL_GATAWAY_WHITELIST_IDENTIFIER "WhiteListState"
typedef
enum
{
KK_TSL_DATA_TARGET_SERVICE_INPUT_DATA
,
...
...
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