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
be597969
Commit
be597969
authored
Aug 02, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改ccuid获取方式修改
【提交人】陈伟灿
parent
a8988572
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
13 deletions
+49
-13
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+7
-5
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+6
-3
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+6
-1
midware/midware/dm/kk_sync_data.c
midware/midware/dm/kk_sync_data.c
+1
-1
midware/midware/midware.c
midware/midware/midware.c
+29
-3
No files found.
midware/midware/dm/kk_dm_mng.c
View file @
be597969
...
...
@@ -531,6 +531,8 @@ int dm_mgr_init(void)
int
res
=
0
;
dm_mgr_ctx
*
ctx
=
_dm_mgr_get_ctx
();
char
mac
[
DEVICE_MAC_MAXLEN
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
int
devId
=
0
,
heartbeat
=
0
;
memset
(
ctx
,
0
,
sizeof
(
dm_mgr_ctx
));
...
...
@@ -542,19 +544,19 @@ int dm_mgr_init(void)
/* Init Device Id*/
ctx
->
global_devid
=
1
;
kk_property_db_init
();
HAL_Get_ccuid
(
ccuid
);
/* Init Device List */
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
HAL_Get_mac
(
mac
);
kk_sync_init
();
//kk_sync_get_info();
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
KK_CCU_ID
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
ccuid
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
}
else
{
kk_property_db_update
(
KK_CCU_ID
);
kk_property_db_update
(
ccuid
);
}
...
...
@@ -1105,7 +1107,7 @@ int dm_mgr_upstream_thing_topo_get(void)
memset
(
&
request
,
0
,
sizeof
(
dm_msg_request_t
));
request
.
msgTypeStr
=
(
char
*
)
DM_URI_THING_TOPO_GET
;
HAL_Get
Device_Code
(
request
.
deviceCode
);
HAL_Get
_ccuid
(
request
.
deviceCode
);
res
=
_dm_mgr_search_dev_by_pkdn
(
request
.
deviceCode
,
&
node
);
...
...
midware/midware/dm/kk_linkkit.c
View file @
be597969
...
...
@@ -929,6 +929,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_mutex_unlock
();
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_SERVICE_PROPERTY_SET
)){
INFO_PRINT
(
"property set
\n
"
);
char
ccuid
[
32
]
=
{
0
};
dm_mgr_dev_node_t
*
node
=
NULL
;
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
);
...
...
@@ -939,12 +940,14 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
kk_property_db_update
(
KK_CCU_ID
);
HAL_Get_ccuid
(
ccuid
);
kk_property_db_update
(
ccuid
);
//dm_msg_thing_property_set_reply(deviceCode->valuestring,payload_Str, strlen(payload_Str), NULL);
dm_msg_ccu_property_post
(
node
);
}
}
else
if
(
strstr
(
typeJson
->
valuestring
,
KK_THING_CLOUDSTATE_MSG
)){
INFO_PRINT
(
"cloud state notify
\n
"
);
char
ccuid
[
32
]
=
{
0
};
s_CloudStatusRecv
=
1
;
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
MSG_IOTClOUDSTATE_STR
);
...
...
@@ -963,8 +966,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{
ERROR_PRINT
(
"[%s][%d] res:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
res
);
}
kk_property_db_update
(
KK_CCU_ID
);
HAL_Get_ccuid
(
ccuid
);
kk_property_db_update
(
ccuid
);
if
(
s_CloudStatus
){
node
->
isOffline
=
KK_DEV_ONLINE
;
...
...
midware/midware/dm/kk_property_db.c
View file @
be597969
...
...
@@ -189,7 +189,12 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
return
SUCCESS_RETURN
;
}
_kk_property_db_lock
();
//传感器类默认安防等级为离家安防
if
(
strcmp
(
identifier
,
"SensorType"
)
==
0
&&
devtype
==
KK_DM_DEVICE_SUBDEV
){
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
"1"
,
valuetype
,
devtype
);
}
else
{
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
""
,
valuetype
,
devtype
);
}
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
...
...
midware/midware/dm/kk_sync_data.c
View file @
be597969
...
...
@@ -466,7 +466,7 @@ char *kk_sync_get_info()
kk_get_rooms_info
(
data
);
kk_get_devices_info
(
data
);
kk_get_scenes_info
(
data
);
HAL_Get
Device_Code
(
ccu_deviceCode
);
HAL_Get
_ccuid
(
ccu_deviceCode
);
HAL_GetProduct_Code
(
ccu_productCode
);
HAL_GetVersion
(
version
);
cJSON_AddStringToObject
(
data
,
KK_SYNC_DEVICECODE_STR
,
ccu_deviceCode
);
...
...
midware/midware/midware.c
View file @
be597969
...
...
@@ -61,6 +61,32 @@ char * g_filerToPlatTable[] =
(
char
*
){
KK_THING_SERVICE_NEGATIVE
},
(
char
*
){
KK_THING_SERVICE_SYNCINFO
},
};
static
char
s_ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
int
HAL_Get_ccuid
(
_OU_
char
*
device_code
)
{
strncpy
(
device_code
,
s_ccuid
,
strlen
(
s_ccuid
));
printf
(
"HAL_Get_ccuid:%s
\n
"
,
s_ccuid
);
return
strlen
(
s_ccuid
);
}
static
int
_setDevice_Code
(
_IN_
char
*
device_code
,
int
len
)
{
memset
(
s_ccuid
,
0x0
,
DEVICE_CODE_LEN
);
printf
(
"_setDevice_Code:%s
\n
"
,
device_code
);
strncpy
(
s_ccuid
,
device_code
,
len
);
return
len
;
}
static
void
HAL_Ccuid_init
(
void
)
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
_setDevice_Code
(
ccuid
,
ccuid_len
-
1
);
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
}
/************************************************************
*功能描述:过滤不需要下发给网关的消息
*输入参数:msgtype:消息类型
...
...
@@ -520,7 +546,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
//判断网关还是子设备
if
(
strcmp
(
info_dcode
->
valuestring
,
devCode
->
valuestring
)
==
0
){
char
ccu_deviceCode
[
DEVICE_CODE_MAXLEN
]
=
{
0
};
HAL_Get
Device_Code
(
ccu_deviceCode
);
HAL_Get
_ccuid
(
ccu_deviceCode
);
kk_mid_subdev_add
(
KK_DM_DEVICE_GATEWAY
,
proCode
->
valuestring
,
devCode
->
valuestring
,
mac
->
valuestring
,
ccu_deviceCode
);
cJSON
*
sceneSupportStr
=
cJSON_GetObjectItem
(
jsonPay
,
MSG_SCENE_SUPPORT
);
if
(
sceneSupportStr
!=
NULL
&&!
strcmp
(
sceneSupportStr
->
valuestring
,
"1"
)){
...
...
@@ -963,7 +989,7 @@ void *udp_dispatch_yield(void *args){
memset
(
mac
,
0
,
sizeof
(
mac
));
memset
(
szOut
,
0
,
sizeof
(
szOut
));
HAL_Get_IP
(
host_ip
,
NULL
);
HAL_Get
Device_Code
(
device_code
);
HAL_Get
_ccuid
(
device_code
);
// printf("[%s][%d]inet_ntoa(from.sin_addr):%s\n",__FUNCTION__,__LINE__,inet_ntoa(from.sin_addr));
// printf("[%s][%d]host_ip:%s\n",__FUNCTION__,__LINE__,host_ip);
// if(strcmp(inet_ntoa(from.sin_addr),host_ip) == 0){
...
...
@@ -1090,7 +1116,7 @@ int main(const int argc, const char **argv)
open
(
"midware"
,
LOG_PID
,
LOG_USER
);
memset
(
mid_ctx
,
0
,
sizeof
(
mid_ctx_t
));
HAL_Ccuid_init
();
kk_sqlite_init
();
kk_tsl_api_init
();
kk_ipc_init
(
IPC_MID2APP
,
mid_cb
,
NULL
,
NULL
);
...
...
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