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
8df7914e
Commit
8df7914e
authored
Sep 27, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】去warning处理
【提交人】陈伟灿
parent
84ab334e
Changes
34
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
140 additions
and
93 deletions
+140
-93
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+8
-3
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+9
-2
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+1
-6
common/api/ccu_ver.h
common/api/ccu_ver.h
+1
-1
common/hal/kk_hal.h
common/hal/kk_hal.h
+8
-0
common/mqtt/MQTTProtocolClient.c
common/mqtt/MQTTProtocolClient.c
+5
-3
midware/midware/area/kk_area_handle.h
midware/midware/area/kk_area_handle.h
+1
-0
midware/midware/dm/dm_fota.c
midware/midware/dm/dm_fota.c
+3
-1
midware/midware/dm/dm_ota.c
midware/midware/dm/dm_ota.c
+4
-2
midware/midware/dm/kk_dm_api.c
midware/midware/dm/kk_dm_api.c
+8
-6
midware/midware/dm/kk_dm_api.h
midware/midware/dm/kk_dm_api.h
+2
-1
midware/midware/dm/kk_dm_heartbeat.c
midware/midware/dm/kk_dm_heartbeat.c
+2
-1
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+6
-5
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+2
-1
midware/midware/dm/kk_dm_msg.c
midware/midware/dm/kk_dm_msg.c
+22
-23
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+2
-1
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+2
-1
midware/midware/dm/kk_linkkit.h
midware/midware/dm/kk_linkkit.h
+1
-0
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+1
-1
midware/midware/dm/kk_property_db.h
midware/midware/dm/kk_property_db.h
+1
-1
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+1
-1
midware/midware/dm/kk_sub_db.h
midware/midware/dm/kk_sub_db.h
+1
-1
midware/midware/dm/kk_sync_data.c
midware/midware/dm/kk_sync_data.c
+9
-5
midware/midware/history/kk_history_db.c
midware/midware/history/kk_history_db.c
+3
-3
midware/midware/midware.c
midware/midware/midware.c
+6
-6
midware/midware/ota/iotx_ota.c
midware/midware/ota/iotx_ota.c
+1
-1
midware/midware/ota/iotx_ota.h
midware/midware/ota/iotx_ota.h
+2
-1
midware/midware/ota/iotx_ota_internal.h
midware/midware/ota/iotx_ota_internal.h
+1
-0
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+13
-9
midware/midware/scene/kk_scene_handle.h
midware/midware/scene/kk_scene_handle.h
+2
-0
midware/midware/timer/kk_timer_handle.c
midware/midware/timer/kk_timer_handle.c
+2
-2
midware/midware/utils/infra_defs.h
midware/midware/utils/infra_defs.h
+1
-1
midware/tsl/tsl_handle/kk_tsl_api.h
midware/tsl/tsl_handle/kk_tsl_api.h
+2
-1
onboot.sh
onboot.sh
+7
-3
No files found.
application/kcloud/kk_register.c
View file @
8df7914e
...
@@ -358,14 +358,19 @@ int kk_start_ccu_register(void)
...
@@ -358,14 +358,19 @@ int kk_start_ccu_register(void)
INFO_PRINT
(
"send success send %d bytes!
\n\n
"
,
ret
);
INFO_PRINT
(
"send success send %d bytes!
\n\n
"
,
ret
);
}
}
registerType
=
1
;
registerType
=
1
;
FD_ZERO
(
&
t_set1
);
FD_SET
(
sockfd
,
&
t_set1
);
tv
.
tv_sec
=
1
;
tv
.
tv_sec
=
1
;
tv
.
tv_usec
=
0
;
tv
.
tv_usec
=
0
;
h
=
0
;
h
=
0
;
while
(
1
){
while
(
1
){
FD_ZERO
(
&
t_set1
);
FD_SET
(
sockfd
,
&
t_set1
);
h
=
select
(
sockfd
+
1
,
&
t_set1
,
NULL
,
NULL
,
&
tv
);
h
=
select
(
sockfd
+
1
,
&
t_set1
,
NULL
,
NULL
,
&
tv
);
//if (h == 0) continue;
if
(
h
==
0
)
{
INFO_PRINT
(
"kk_register receive nothing
\n
"
);
continue
;
}
if
(
h
<
0
)
{
if
(
h
<
0
)
{
close
(
sockfd
);
close
(
sockfd
);
return
-
1
;
return
-
1
;
...
...
application/kcloud/mqtt_api.c
View file @
8df7914e
...
@@ -111,7 +111,6 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
...
@@ -111,7 +111,6 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
}
}
KK_reset_sub_flag
();
KK_reset_sub_flag
();
WARNING_PRINT
(
"Connect failed, rc %d
\n
"
,
response
?
response
->
code
:
0
);
WARNING_PRINT
(
"Connect failed, rc %d
\n
"
,
response
?
response
->
code
:
0
);
}
}
void
onConnect
(
void
*
context
,
MQTTAsync_successData
*
response
)
void
onConnect
(
void
*
context
,
MQTTAsync_successData
*
response
)
...
@@ -278,6 +277,10 @@ int KK_MQTT_SubTopic(char *topicName)
...
@@ -278,6 +277,10 @@ int KK_MQTT_SubTopic(char *topicName)
opts
.
onFailure
=
onOptFail
;
opts
.
onFailure
=
onOptFail
;
opts
.
context
=
(
void
*
)
OPT_SUB
;
opts
.
context
=
(
void
*
)
OPT_SUB
;
if
(
s_cloudStatus
==
DEVICE_OFFLINE
){
ERROR_PRINT
(
"Failed to KK_MQTT_SubTopic, s_cloudStatus == DEVICE_OFFLINE
\n
"
);
return
-
1
;
}
if
((
rc
=
MQTTAsync_subscribe
(
s_Client
,
topicName
,
QOS
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
if
((
rc
=
MQTTAsync_subscribe
(
s_Client
,
topicName
,
QOS
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
{
{
ERROR_PRINT
(
"Failed to start subscribe, return code:%d.
\n
"
,
rc
);
ERROR_PRINT
(
"Failed to start subscribe, return code:%d.
\n
"
,
rc
);
...
@@ -291,7 +294,7 @@ int KK_MQTT_SendMsg(char *topicName,const char *payload)
...
@@ -291,7 +294,7 @@ int KK_MQTT_SendMsg(char *topicName,const char *payload)
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
MQTTAsync_message
pubmsg
=
MQTTAsync_message_initializer
;
int
rc
;
int
rc
;
cJSON_Minify
(
payload
);
cJSON_Minify
(
(
char
*
)
payload
);
INFO_PRINT
(
"mqtt send payload :%s.
\n
"
,
payload
);
INFO_PRINT
(
"mqtt send payload :%s.
\n
"
,
payload
);
opts
.
onSuccess
=
onOptSuccess
;
opts
.
onSuccess
=
onOptSuccess
;
opts
.
onFailure
=
onOptFail
;
opts
.
onFailure
=
onOptFail
;
...
@@ -336,6 +339,10 @@ int KK_MQTT_UnsubTopic(const char *topicName)
...
@@ -336,6 +339,10 @@ int KK_MQTT_UnsubTopic(const char *topicName)
opts
.
onFailure
=
onOptFail
;
opts
.
onFailure
=
onOptFail
;
opts
.
context
=
(
void
*
)
OPT_UNSUB
;
opts
.
context
=
(
void
*
)
OPT_UNSUB
;
if
(
s_cloudStatus
==
DEVICE_OFFLINE
){
ERROR_PRINT
(
"Failed to KK_MQTT_UnsubTopic, s_cloudStatus == DEVICE_OFFLINE
\n
"
);
return
-
1
;
}
if
((
rc
=
MQTTAsync_unsubscribe
(
s_Client
,
topicName
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
if
((
rc
=
MQTTAsync_unsubscribe
(
s_Client
,
topicName
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
{
{
ERROR_PRINT
(
"Failed to start unubscribe, return code:%d.
\n
"
,
rc
);
ERROR_PRINT
(
"Failed to start unubscribe, return code:%d.
\n
"
,
rc
);
...
...
application/klansdk/kk_lan_main.c
View file @
8df7914e
...
@@ -126,12 +126,7 @@ void kk_sync_info_push(void)
...
@@ -126,12 +126,7 @@ void kk_sync_info_push(void)
void
handler
(
int
signum
)
void
handler
(
int
signum
)
{
{
printf
(
"[sig]---------------------->signum=%d
\n
"
,
signum
);
debug_log
(
LOG_CRIT_LEVEL
,
"[sig]---------------------->signum=%d
\n
"
,
signum
);
if
(
signum
==
SIGALRM
){
printf
(
"[SIGALRM]
\n
"
);
}
if
(
signum
!=
17
&&
signum
!=
SIGALRM
){
if
(
signum
!=
17
&&
signum
!=
SIGALRM
){
exit
(
-
1
);
exit
(
-
1
);
}
}
...
...
common/api/ccu_ver.h
View file @
8df7914e
#ifndef _KK_CCU_VER_H_
#ifndef _KK_CCU_VER_H_
#define _KK_CCU_VER_H_
#define _KK_CCU_VER_H_
#define KK_CCU_VERSION "1.
1
.0"
#define KK_CCU_VERSION "1.
3
.0"
#define KK_VERSION_FILE_PATH "/app/ccuApps/VERSION"
#define KK_VERSION_FILE_PATH "/app/ccuApps/VERSION"
...
...
common/hal/kk_hal.h
View file @
8df7914e
...
@@ -22,6 +22,7 @@ time_t HAL_GetTime_s(char *outStr);
...
@@ -22,6 +22,7 @@ time_t HAL_GetTime_s(char *outStr);
long
long
HAL_GetTime_ms
();
long
long
HAL_GetTime_ms
();
int
HAL_Snprintf
(
_IN_
char
*
str
,
const
int
len
,
const
char
*
fmt
,
...);
int
HAL_Snprintf
(
_IN_
char
*
str
,
const
int
len
,
const
char
*
fmt
,
...);
int
HAL_Vsnprintf
(
_IN_
char
*
str
,
_IN_
const
int
len
,
_IN_
const
char
*
format
,
va_list
ap
);
int
HAL_Vsnprintf
(
_IN_
char
*
str
,
_IN_
const
int
len
,
_IN_
const
char
*
format
,
va_list
ap
);
void
HAL_Printf
(
_IN_
const
char
*
fmt
,
...);
void
*
HAL_MutexCreate
(
void
);
void
*
HAL_MutexCreate
(
void
);
void
HAL_MutexLock
(
_IN_
void
*
mutex
);
void
HAL_MutexLock
(
_IN_
void
*
mutex
);
void
HAL_MutexUnlock
(
_IN_
void
*
mutex
);
void
HAL_MutexUnlock
(
_IN_
void
*
mutex
);
...
@@ -43,4 +44,11 @@ int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
...
@@ -43,4 +44,11 @@ int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
int
HAL_SetProduct_Type
(
_IN_
char
*
product_type
);
int
HAL_SetProduct_Type
(
_IN_
char
*
product_type
);
int
HAL_SetProduct_Code
(
_IN_
char
*
product_code
);
int
HAL_SetProduct_Code
(
_IN_
char
*
product_code
);
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
);
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
);
void
HAL_Firmware_Persistence_Start
(
void
*
fileName
);
int
HAL_Firmware_Persistence_Write
(
_IN_
char
*
buffer
,
_IN_
uint32_t
length
);
int
HAL_Firmware_Persistence_Stop
(
void
);
void
HAL_Reboot
(
void
);
void
*
HAL_Malloc
(
_IN_
uint32_t
size
);
void
HAL_Free
(
_IN_
void
*
ptr
);
int
HAL_Get_TimeZone
(
void
);
#endif
#endif
common/mqtt/MQTTProtocolClient.c
View file @
8df7914e
...
@@ -564,11 +564,13 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
...
@@ -564,11 +564,13 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
publish
.
payloadlen
=
m
->
publish
->
payloadlen
;
publish
.
payloadlen
=
m
->
publish
->
payloadlen
;
}
}
publish
.
MQTTVersion
=
m
->
MQTTVersion
;
publish
.
MQTTVersion
=
m
->
MQTTVersion
;
if
(
publish
.
MQTTVersion
>=
MQTTVERSION_5
)
if
(
publish
.
MQTTVersion
>=
MQTTVERSION_5
)
{
publish
.
properties
=
m
->
properties
;
publish
.
properties
=
m
->
properties
;
else
}
else
{
Protocol_processPublication
(
&
publish
,
client
,
0
);
/* only for 3.1.1 and lower */
Protocol_processPublication
(
&
publish
,
client
,
0
);
/* only for 3.1.1 and lower */
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
}
#if !defined(NO_PERSISTENCE)
#if !defined(NO_PERSISTENCE)
rc
+=
MQTTPersistence_remove
(
client
,
rc
+=
MQTTPersistence_remove
(
client
,
(
m
->
MQTTVersion
>=
MQTTVERSION_5
)
?
PERSISTENCE_V5_PUBLISH_RECEIVED
:
PERSISTENCE_PUBLISH_RECEIVED
,
(
m
->
MQTTVersion
>=
MQTTVERSION_5
)
?
PERSISTENCE_V5_PUBLISH_RECEIVED
:
PERSISTENCE_PUBLISH_RECEIVED
,
...
...
midware/midware/area/kk_area_handle.h
View file @
8df7914e
...
@@ -36,5 +36,6 @@ int kk_get_room_armingstate(const char* roomId);
...
@@ -36,5 +36,6 @@ int kk_get_room_armingstate(const char* roomId);
int
kk_get_roomId_by_deviceCode
(
const
char
*
deviceCode
,
const
char
*
epNum
,
char
*
roomId
,
int
size
);
int
kk_get_roomId_by_deviceCode
(
const
char
*
deviceCode
,
const
char
*
epNum
,
char
*
roomId
,
int
size
);
int
kk_get_device_roomInfo
(
const
char
*
deviceCode
,
int
epNum
,
char
*
roomName
,
char
*
roomId
);
int
kk_get_device_roomInfo
(
const
char
*
deviceCode
,
int
epNum
,
char
*
roomName
,
char
*
roomId
);
int
kk_room_reset_armingstate
(
void
);
int
kk_room_reset_armingstate
(
void
);
cJSON
*
kk_get_roomIds_ary
(
void
);
#endif
#endif
midware/midware/dm/dm_fota.c
View file @
8df7914e
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
*/
*/
//#include "../dm/iotx_dm_internal.h"
//#include "../dm/iotx_dm_internal.h"
#include "dm_fota.h"
#include "dm_fota.h"
#include "kk_hal.h"
#include "dm_ota.h"
#include "../ota/ota_api.h"
#include "../ota/ota_api.h"
#include "iotx_ota.h"
#define dm_log_err printf
#define dm_log_err printf
#define dm_log_debug printf
#define dm_log_debug printf
#define dm_log_info printf
#define dm_log_info printf
...
...
midware/midware/dm/dm_ota.c
View file @
8df7914e
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
#include <curl/curl.h>
#include <curl/curl.h>
#include "com_api.h"
#include "com_api.h"
#include "kk_log.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "iotx_ota.h"
#include "kk_dm_queue.h"
static
dm_ota_ctx_t
g_dm_ota_ctx
;
static
dm_ota_ctx_t
g_dm_ota_ctx
;
static
dm_ota_ctx_t
*
_dm_ota_get_ctx
(
void
)
static
dm_ota_ctx_t
*
_dm_ota_get_ctx
(
void
)
...
@@ -178,7 +180,7 @@ enum{
...
@@ -178,7 +180,7 @@ enum{
OTA_STATE_UPGRADE_FAIL
,
OTA_STATE_UPGRADE_FAIL
,
};
};
static
char
*
s_url
=
NULL
;
static
char
*
s_url
=
NULL
;
int
HAL_Get_ccuid
(
_OU_
char
*
device_code
);
int
kk_publishProgress
(
int
process
,
int
state
)
int
kk_publishProgress
(
int
process
,
int
state
)
{
{
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
...
...
midware/midware/dm/kk_dm_api.c
View file @
8df7914e
...
@@ -6,13 +6,15 @@
...
@@ -6,13 +6,15 @@
#include "kk_dm_api.h"
#include "kk_dm_api.h"
#include "kk_tsl_common.h"
#include "kk_tsl_common.h"
#include "kk_dm_mng.h"
#include "kk_tsl_api.h"
#include "com_api.h"
#include "com_api.h"
#include "dm_ota.h"
#include "dm_ota.h"
#include "kk_log.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "kk_hal.h"
#include "kk_dm_queue.h"
#include "kk_dm_queue.h"
#include "kk_linkkit.h"
#include "dm_fota.h"
static
dm_api_ctx_t
g_dm_api_ctx
;
static
dm_api_ctx_t
g_dm_api_ctx
;
static
dm_api_ctx_t
*
_dm_api_get_ctx
(
void
)
static
dm_api_ctx_t
*
_dm_api_get_ctx
(
void
)
...
@@ -332,7 +334,7 @@ int iotx_dm_subscribe_node(dm_mgr_dev_node_t *node)
...
@@ -332,7 +334,7 @@ int iotx_dm_subscribe_node(dm_mgr_dev_node_t *node)
ERROR_PRINT
(
"
\n
[%d][%s] malloc faild kk_ipc_send
\n
"
,
__LINE__
,
__FUNCTION__
);
ERROR_PRINT
(
"
\n
[%d][%s] malloc faild kk_ipc_send
\n
"
,
__LINE__
,
__FUNCTION__
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
INFO_PRINT
(
"
\n
[%d][%s] [%lu] send app to subscribe mqtt
\n
"
,
__LINE__
,
__FUNCTION__
,
HAL_UptimeMs
());
INFO_PRINT
(
"
\n
[%d][%s] [%l
l
u] send app to subscribe mqtt
\n
"
,
__LINE__
,
__FUNCTION__
,
HAL_UptimeMs
());
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
...
@@ -371,7 +373,7 @@ int iotx_dm_subscribe(_IN_ int devid)
...
@@ -371,7 +373,7 @@ int iotx_dm_subscribe(_IN_ int devid)
ERROR_PRINT
(
"
\n
[%d][%s] malloc faild kk_ipc_send
\n
"
,
__LINE__
,
__FUNCTION__
);
ERROR_PRINT
(
"
\n
[%d][%s] malloc faild kk_ipc_send
\n
"
,
__LINE__
,
__FUNCTION__
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
INFO_PRINT
(
"
\n
[%d][%s] [%lu] send app to subscribe mqtt
\n
"
,
__LINE__
,
__FUNCTION__
,
HAL_UptimeMs
());
INFO_PRINT
(
"
\n
[%d][%s] [%l
l
u] send app to subscribe mqtt
\n
"
,
__LINE__
,
__FUNCTION__
,
HAL_UptimeMs
());
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
...
@@ -402,9 +404,9 @@ int kk_dm_get_property_type(const char* deviceCode,const char *key)
...
@@ -402,9 +404,9 @@ int kk_dm_get_property_type(const char* deviceCode,const char *key)
if
(
deviceCode
==
NULL
){
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
(
char
*
)
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
return
kk_tsl_get_property_type
(
node
->
dev_shadow
,
key
);
return
kk_tsl_get_property_type
(
node
->
dev_shadow
,
(
char
*
)
key
);
}
}
midware/midware/dm/kk_dm_api.h
View file @
8df7914e
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#ifndef _KK_DM_API_H_
#ifndef _KK_DM_API_H_
#define _KK_DM_API_H_
#define _KK_DM_API_H_
#include "iotx_dm.h"
#include "iotx_dm.h"
#include "kk_dm_mng.h"
#define CONFIG_DISPATCH_QUEUE_MAXLEN (50)
#define CONFIG_DISPATCH_QUEUE_MAXLEN (50)
...
@@ -43,4 +43,5 @@ int iotx_dm_subscribe(_IN_ int devid);
...
@@ -43,4 +43,5 @@ int iotx_dm_subscribe(_IN_ int devid);
void
kk_dm_ota_report_version
(
_IN_
int
devid
,
char
*
version
);
void
kk_dm_ota_report_version
(
_IN_
int
devid
,
char
*
version
);
void
kk_dm_ota_send
(
void
*
data
,
int
len
);
void
kk_dm_ota_send
(
void
*
data
,
int
len
);
int
kk_dm_get_property_type
(
const
char
*
deviceCode
,
const
char
*
key
);
int
kk_dm_get_property_type
(
const
char
*
deviceCode
,
const
char
*
key
);
int
iotx_dm_subscribe_node
(
dm_mgr_dev_node_t
*
node
);
#endif
#endif
midware/midware/dm/kk_dm_heartbeat.c
View file @
8df7914e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "kk_log.h"
#include "kk_log.h"
#include "kk_tsl_common.h"
#include "kk_tsl_common.h"
#include "kk_dm_mng.h"
#include "kk_dm_mng.h"
#include "kk_dm_msg.h"
#include "kk_hal.h"
#include "kk_hal.h"
/*************************************************************
/*************************************************************
...
@@ -142,7 +143,7 @@ int kk_heartbeat_init(void)
...
@@ -142,7 +143,7 @@ int kk_heartbeat_init(void)
ctx
->
hearbeat_thread_running
=
1
;
ctx
->
hearbeat_thread_running
=
1
;
s_start_time
=
HAL_Uptimes
();
s_start_time
=
HAL_Uptimes
();
res
=
pthread_create
(
&
ctx
->
hearbeat_thread
,
NULL
,
kk_heartbeat_yield
,
NULL
);
res
=
pthread_create
(
(
pthread_t
*
)
&
ctx
->
hearbeat_thread
,
NULL
,
kk_heartbeat_yield
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
ERROR_PRINT
(
"HAL_ThreadCreate ota Failed
\n
"
);
ERROR_PRINT
(
"HAL_ThreadCreate ota Failed
\n
"
);
//IOT_Linkkit_Close(mid_ctx->master_devid);
//IOT_Linkkit_Close(mid_ctx->master_devid);
...
...
midware/midware/dm/kk_dm_mng.c
View file @
8df7914e
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "kk_dm_msg.h"
#include "kk_dm_msg.h"
#include "kk_dm_api.h"
#include "kk_dm_api.h"
#include "kk_tsl_api.h"
#include "kk_tsl_api.h"
#include "kk_tsl_parse.h"
#include "kk_tsl_load.h"
#include "kk_tsl_load.h"
#include "iot_export_linkkit.h"
#include "iot_export_linkkit.h"
#include "kk_product.h"
#include "kk_product.h"
...
@@ -26,7 +27,7 @@ const char DM_URI_REPLY_SUFFIX[] DM_READ_ONLY = "_reply";
...
@@ -26,7 +27,7 @@ const char DM_URI_REPLY_SUFFIX[] DM_READ_ONLY = "_reply";
const
char
DM_URI_OTA_DEVICE_INFORM
[]
DM_READ_ONLY
=
"/ota/device/inform/%s/%s"
;
const
char
DM_URI_OTA_DEVICE_INFORM
[]
DM_READ_ONLY
=
"/ota/device/inform/%s/%s"
;
const
char
DM_URI_THING_EVENT_PROPERTY_POST_METHOD
[]
DM_READ_ONLY
=
"thing.event.property.post"
;
const
char
DM_URI_THING_EVENT_PROPERTY_POST_METHOD
[]
DM_READ_ONLY
=
"thing.event.property.post"
;
int
HAL_Get_ccuid
(
_OU_
char
*
device_code
);
static
dm_mgr_ctx
g_dm_mgr
=
{
0
};
static
dm_mgr_ctx
g_dm_mgr
=
{
0
};
static
dm_mgr_ctx
*
_dm_mgr_get_ctx
(
void
)
static
dm_mgr_ctx
*
_dm_mgr_get_ctx
(
void
)
{
{
...
@@ -298,7 +299,7 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
...
@@ -298,7 +299,7 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
{
{
int
heartbeat
=
0
;
int
heartbeat
=
0
;
kk_msg_parse_productType
(
tsl_str
,
node
->
productType
);
kk_msg_parse_productType
(
tsl_str
,
node
->
productType
);
res
=
kk_tsl_create
(
tsl_str
,
strlen
(
tsl_str
),
&
node
->
dev_shadow
,
&
heartbeat
,
&
node
->
dormancyDev
);
res
=
kk_tsl_create
(
tsl_str
,
strlen
(
tsl_str
),
&
node
->
dev_shadow
,
&
heartbeat
,
(
int
*
)
&
node
->
dormancyDev
);
free
(
tsl_str
);
free
(
tsl_str
);
if
(
res
!=
0
){
if
(
res
!=
0
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -518,8 +519,8 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp)
...
@@ -518,8 +519,8 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp)
INFO_PRINT
(
"[%s][%d]search_node->productCode:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
productCode
);
INFO_PRINT
(
"[%s][%d]search_node->productCode:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
productCode
);
INFO_PRINT
(
"[%s][%d]search_node->hb_timeout:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
hb_timeout
);
INFO_PRINT
(
"[%s][%d]search_node->hb_timeout:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
hb_timeout
);
INFO_PRINT
(
"[%s][%d]search_node->isOffline:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
isOffline
);
INFO_PRINT
(
"[%s][%d]search_node->isOffline:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
isOffline
);
INFO_PRINT
(
"[%s][%d]search_node->timestamp:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
timestamp
);
INFO_PRINT
(
"[%s][%d]search_node->timestamp:%
l
d
\n
"
,
__FUNCTION__
,
__LINE__
,
search_node
->
timestamp
);
INFO_PRINT
(
"[%s][%d]timestamp:%d
\n
"
,
__FUNCTION__
,
__LINE__
,
timestamp
);
INFO_PRINT
(
"[%s][%d]timestamp:%
l
d
\n
"
,
__FUNCTION__
,
__LINE__
,
timestamp
);
}
}
if
((
timestamp
-
search_node
->
timestamp
)
>=
search_node
->
hb_timeout
){
if
((
timestamp
-
search_node
->
timestamp
)
>=
search_node
->
hb_timeout
){
if
(
search_node
->
isOffline
!=
KK_DEV_OFFLINE
){
if
(
search_node
->
isOffline
!=
KK_DEV_OFFLINE
){
...
@@ -873,7 +874,7 @@ int dm_mgr_upstream_thing_service_post(_IN_ int devid, _IN_ char *identifier, _I
...
@@ -873,7 +874,7 @@ int dm_mgr_upstream_thing_service_post(_IN_ int devid, _IN_ char *identifier, _I
return
res
;
return
res
;
}
}
const
char
DM_URI_THING_SERVICE_RESPONSE
[]
=
"/thing/service/%
.*
s_reply"
;
const
char
DM_URI_THING_SERVICE_RESPONSE
[]
=
"/thing/service/%s_reply"
;
static
int
_kk_mgr_upstream_response_assemble
(
_IN_
int
devid
,
_IN_
char
*
msgid
,
_IN_
int
msgid_len
,
static
int
_kk_mgr_upstream_response_assemble
(
_IN_
int
devid
,
_IN_
char
*
msgid
,
_IN_
int
msgid_len
,
_IN_
const
char
*
identfy
,
_IN_
int
code
,
_OU_
kk_msg_request_payload_t
*
request
,
_OU_
kk_msg_response_t
*
response
)
_IN_
const
char
*
identfy
,
_IN_
int
code
,
_OU_
kk_msg_request_payload_t
*
request
,
_OU_
kk_msg_response_t
*
response
)
{
{
...
...
midware/midware/dm/kk_dm_mng.h
View file @
8df7914e
...
@@ -121,5 +121,6 @@ int dm_mgr_subdev_create(int devtype,_IN_ char productCode[PRODUCT_CODE_MAXLEN],
...
@@ -121,5 +121,6 @@ int dm_mgr_subdev_create(int devtype,_IN_ char productCode[PRODUCT_CODE_MAXLEN],
_IN_
char
mac
[
DEVICE_MAC_MAXLEN
],
_IN_
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
int
isOffline
,
_OU_
int
*
devid
,
_OU_
int
*
heartbeat
);
_IN_
char
mac
[
DEVICE_MAC_MAXLEN
],
_IN_
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
],
_IN_
int
isOffline
,
_OU_
int
*
devid
,
_OU_
int
*
heartbeat
);
int
dm_mgr_subdev_delete
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
int
dm_mgr_subdev_delete
(
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
int
dm_msg_thing_property_post_all
(
char
*
deviceCode
);
int
dm_msg_thing_property_post_all
(
char
*
deviceCode
);
int
dm_mgr_get_gw_deviceCode
(
_OU_
dm_mgr_dev_node_t
**
node
);
int
dm_mgr_get_gw_deviceCode
(
_OU_
dm_mgr_dev_node_t
**
node
);
void
dm_mgr_resubscribe
(
void
);
#endif
#endif
midware/midware/dm/kk_dm_msg.c
View file @
8df7914e
#include "kk_dm_msg.h"
#include "kk_dm_msg.h"
#include "kk_property_db.h"
#include "kk_dm_queue.h"
#include "kk_dm_queue.h"
#include "lite-cjson.h"
#include "lite-cjson.h"
#include "kk_hal.h"
#include "kk_hal.h"
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "kk_log.h"
#include "kk_log.h"
#include "kk_utils.h"
#include "kk_utils.h"
#include "kk_sync_data.h"
#include "kk_sync_data.h"
int
HAL_Get_ccuid
(
_OU_
char
*
device_code
);
const
char
DM_MSG_REQUEST
[]
DM_READ_ONLY
=
"{
\"
msgId
\"
:
\"
%s
\"
,
\"
version
\"
:
\"
%s
\"
,
\"
params
\"
:%s,
\"
time
\"
:
\"
%lu
\"
,
\"
method
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_REQUEST
[]
DM_READ_ONLY
=
"{
\"
msgId
\"
:
\"
%s
\"
,
\"
version
\"
:
\"
%s
\"
,
\"
params
\"
:%s,
\"
time
\"
:
\"
%lu
\"
,
\"
method
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
extern
void
kk_sendData2gw
(
void
*
data
,
int
len
,
char
*
chalMark
);
extern
void
kk_sendData2gw
(
void
*
data
,
int
len
,
char
*
chalMark
);
...
@@ -899,7 +899,7 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
...
@@ -899,7 +899,7 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
}
}
payload
=
kk_tsl_get_post_event_str
(
node
->
dev_shadow
,(
char
*
)
identifier
,
strlen
(
identifier
));
payload
=
kk_tsl_get_post_event_str
(
node
->
dev_shadow
,(
char
*
)
identifier
,
strlen
(
identifier
));
if
(
payload
!=
NULL
){
if
(
payload
!=
NULL
){
res
=
kk_tsl_get_event_by_identifier
(
node
->
dev_shadow
,
identifier
,
&
event
);
res
=
kk_tsl_get_event_by_identifier
(
node
->
dev_shadow
,
(
char
*
)
identifier
,
&
event
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
payload
);
free
(
payload
);
ERROR_PRINT
(
"dm_msg_thing_event_post failed
\n
"
);
ERROR_PRINT
(
"dm_msg_thing_event_post failed
\n
"
);
...
@@ -916,7 +916,7 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
...
@@ -916,7 +916,7 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
dm_mgr_upstream_thing_event_post_ex
(
node
->
devid
,
(
char
*
)
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
),
msgId
);
dm_mgr_upstream_thing_event_post_ex
(
node
->
devid
,
(
char
*
)
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
),
msgId
);
}
else
}
else
{
{
dm_mgr_upstream_thing_event_post
(
node
->
devid
,
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
));
dm_mgr_upstream_thing_event_post
(
node
->
devid
,
(
char
*
)
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
));
}
}
free
(
method
);
free
(
method
);
method
=
NULL
;
method
=
NULL
;
...
@@ -932,9 +932,9 @@ int dm_msg_scene_event_post(const char *identifier,kk_tsl_t *dev_shadow,const ch
...
@@ -932,9 +932,9 @@ int dm_msg_scene_event_post(const char *identifier,kk_tsl_t *dev_shadow,const ch
void
*
event
=
NULL
;
void
*
event
=
NULL
;
char
*
method
=
NULL
;
char
*
method
=
NULL
;
payload
=
kk_tsl_get_post_event_str
(
dev_shadow
,
identifier
,
strlen
(
identifier
));
payload
=
kk_tsl_get_post_event_str
(
dev_shadow
,
(
char
*
)
identifier
,
strlen
(
identifier
));
if
(
payload
!=
NULL
){
if
(
payload
!=
NULL
){
res
=
kk_tsl_get_event_by_identifier
(
dev_shadow
,
identifier
,
&
event
);
res
=
kk_tsl_get_event_by_identifier
(
dev_shadow
,
(
char
*
)
identifier
,
&
event
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
payload
);
free
(
payload
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -945,7 +945,7 @@ int dm_msg_scene_event_post(const char *identifier,kk_tsl_t *dev_shadow,const ch
...
@@ -945,7 +945,7 @@ int dm_msg_scene_event_post(const char *identifier,kk_tsl_t *dev_shadow,const ch
free
(
payload
);
free
(
payload
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
dm_mgr_upstream_thing_event_post_ex
(
KK_DM_DEVICE_CCU_DEVICEID
,
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
),
msgId
);
dm_mgr_upstream_thing_event_post_ex
(
KK_DM_DEVICE_CCU_DEVICEID
,
(
char
*
)
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
),
msgId
);
free
(
method
);
free
(
method
);
method
=
NULL
;
method
=
NULL
;
free
(
payload
);
free
(
payload
);
...
@@ -966,13 +966,13 @@ int dm_msg_thing_service_post(const char *deviceCode, const char *identifier)
...
@@ -966,13 +966,13 @@ int dm_msg_thing_service_post(const char *deviceCode, const char *identifier)
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
(
char
*
)
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
payload
=
kk_tsl_get_post_service_str
(
node
->
dev_shadow
,
identifier
);
payload
=
kk_tsl_get_post_service_str
(
node
->
dev_shadow
,
(
char
*
)
identifier
);
if
(
payload
!=
NULL
){
if
(
payload
!=
NULL
){
res
=
kk_tsl_get_service_by_identifier
(
node
->
dev_shadow
,
identifier
,
&
service
);
res
=
kk_tsl_get_service_by_identifier
(
node
->
dev_shadow
,
(
char
*
)
identifier
,
&
service
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
free
(
payload
);
free
(
payload
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -983,7 +983,7 @@ int dm_msg_thing_service_post(const char *deviceCode, const char *identifier)
...
@@ -983,7 +983,7 @@ int dm_msg_thing_service_post(const char *deviceCode, const char *identifier)
free
(
payload
);
free
(
payload
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
dm_mgr_upstream_thing_service_post
(
node
->
devid
,
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
));
dm_mgr_upstream_thing_service_post
(
node
->
devid
,
(
char
*
)
identifier
,
strlen
(
identifier
),
method
,
payload
,
strlen
(
payload
));
free
(
method
);
free
(
method
);
method
=
NULL
;
method
=
NULL
;
free
(
payload
);
free
(
payload
);
...
@@ -1192,7 +1192,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -1192,7 +1192,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
}
}
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
else
if
(
current_data
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
sprintf
(
tmpValue
,
"%
u
"
,
current_data
->
data_value
.
value_double
);
sprintf
(
tmpValue
,
"%
f
"
,
current_data
->
data_value
.
value_double
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
kk_property_db_update_value
(
deviceCode
,
tmp_identifiers
,
tmpValue
);
_kk_property_handle
(
&
subPropertyInfoBuf
,
current_data
->
data_value
.
type
,
current_data
->
identifier
,
&
current_data
->
data_value
.
value_double
);
_kk_property_handle
(
&
subPropertyInfoBuf
,
current_data
->
data_value
.
type
,
current_data
->
identifier
,
&
current_data
->
data_value
.
value_double
);
...
@@ -1216,7 +1216,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -1216,7 +1216,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
//cJSON_DeleteItemFromObject(params,property->identifier);
//cJSON_DeleteItemFromObject(params,property->identifier);
}
}
}
}
int
epIdx
[
4
]
=
{
0
};
char
epIdx
[
4
]
=
{
0
};
for
(
idx
=
0
;
idx
<
epNumInt
;
idx
++
){
for
(
idx
=
0
;
idx
<
epNumInt
;
idx
++
){
countPro
=
propertyInfoBuf
[
idx
].
num
;
countPro
=
propertyInfoBuf
[
idx
].
num
;
memset
(
epIdx
,
0x0
,
sizeof
(
epIdx
));
memset
(
epIdx
,
0x0
,
sizeof
(
epIdx
));
...
@@ -1265,7 +1265,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
...
@@ -1265,7 +1265,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_msg_cloud_status_notify
(
c
onst
c
har
*
deviceCode
,
const
char
*
productCode
)
int
kk_msg_cloud_status_notify
(
char
*
deviceCode
,
const
char
*
productCode
)
{
{
char
*
method
=
"thing.service.cloudStatus"
;
char
*
method
=
"thing.service.cloudStatus"
;
char
*
req_info
=
NULL
,
*
payload
=
NULL
;
char
*
req_info
=
NULL
,
*
payload
=
NULL
;
...
@@ -1345,7 +1345,7 @@ int kk_msg_execute_property_set(const char *productCode,const char *deviceCode,c
...
@@ -1345,7 +1345,7 @@ int kk_msg_execute_property_set(const char *productCode,const char *deviceCode,c
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
void
*
buf
=
cJSON_Print
(
root
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
(
char
*
)
fatherDeviceCode
);
free
(
buf
);
free
(
buf
);
free
(
req_info
);
free
(
req_info
);
free
(
payload
);
free
(
payload
);
...
@@ -1466,7 +1466,7 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
...
@@ -1466,7 +1466,7 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
method
=
KK_THING_METHOD_UPDATESCENC
;
method
=
KK_THING_METHOD_UPDATESCENC
;
msgType
=
KK_THING_SERVICE_UPDATESCENC
;
msgType
=
KK_THING_SERVICE_UPDATESCENC
;
}
}
res
=
dm_mgr_get_device_by_devicecode
(
fatherDeviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
(
char
*
)
fatherDeviceCode
,
&
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
;
...
@@ -1499,7 +1499,7 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
...
@@ -1499,7 +1499,7 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
void
*
buf
=
cJSON_Print
(
root
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
(
char
*
)
fatherDeviceCode
);
free
(
buf
);
free
(
buf
);
free
(
req_info
);
free
(
req_info
);
free
(
payload
);
free
(
payload
);
...
@@ -1517,7 +1517,7 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
...
@@ -1517,7 +1517,7 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
(
fatherDeviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
(
char
*
)
fatherDeviceCode
,
&
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
;
...
@@ -1550,7 +1550,7 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
...
@@ -1550,7 +1550,7 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
void
*
buf
=
cJSON_Print
(
root
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
(
char
*
)
fatherDeviceCode
);
free
(
buf
);
free
(
buf
);
free
(
req_info
);
free
(
req_info
);
free
(
payload
);
free
(
payload
);
...
@@ -1567,7 +1567,7 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
...
@@ -1567,7 +1567,7 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
dm_mgr_dev_node_t
*
node
=
NULL
;
dm_mgr_dev_node_t
*
node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
(
fatherDeviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
(
char
*
)
fatherDeviceCode
,
&
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
;
...
@@ -1600,9 +1600,8 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
...
@@ -1600,9 +1600,8 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
cJSON
*
payloadObj
=
cJSON_Parse
(
payload
);
cJSON
*
payloadObj
=
cJSON_Parse
(
payload
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"info"
,
infoObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
cJSON_AddItemToObject
(
root
,
"payload"
,
payloadObj
);
void
*
buf
=
cJSON_Print
(
root
);
char
*
buf
=
cJSON_Print
(
root
);
printf
(
"----------------->buf:%s
\n
"
,
buf
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
(
char
*
)
fatherDeviceCode
);
kk_sendData2gw
(
buf
,
strlen
(
buf
),
fatherDeviceCode
);
free
(
buf
);
free
(
buf
);
free
(
req_info
);
free
(
req_info
);
free
(
payload
);
free
(
payload
);
...
...
midware/midware/dm/kk_dm_msg.h
View file @
8df7914e
...
@@ -153,7 +153,8 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
...
@@ -153,7 +153,8 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
int
dm_msg_thing_syncinfo_reply
(
void
);
int
dm_msg_thing_syncinfo_reply
(
void
);
int
dm_msg_thing_syncinfopush_reply
(
void
);
int
dm_msg_thing_syncinfopush_reply
(
void
);
void
kk_split
(
char
*
src
,
const
char
*
separator
,
char
**
dest
,
int
*
num
);
void
kk_split
(
char
*
src
,
const
char
*
separator
,
char
**
dest
,
int
*
num
);
int
kk_msg_cloud_status_notify
(
const
char
*
deviceCode
,
const
char
*
productCode
);
int
kk_msg_cloud_status_notify
(
char
*
deviceCode
,
const
char
*
productCode
);
int
dm_msg_thing_syncdeviceinfo_reply
(
cJSON
*
msgId
);
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
...
...
midware/midware/dm/kk_linkkit.c
View file @
8df7914e
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
#define dm_log_debug WARNING_PRINT
#define dm_log_debug WARNING_PRINT
#define dm_log_info INFO_PRINT
#define dm_log_info INFO_PRINT
int
HAL_Get_ccuid
(
_OU_
char
*
device_code
);
extern
void
kk_sendData2gw
(
void
*
data
,
int
len
,
char
*
chalMark
);
extern
void
kk_sendData2gw
(
void
*
data
,
int
len
,
char
*
chalMark
);
static
int
s_gateway_add_flag
=
0
;
static
int
s_gateway_add_flag
=
0
;
...
@@ -1218,6 +1218,7 @@ int kk_service_arming_set(char *state)
...
@@ -1218,6 +1218,7 @@ int kk_service_arming_set(char *state)
kk_property_db_update
(
node
->
deviceCode
);
kk_property_db_update
(
node
->
deviceCode
);
//dm_msg_thing_property_set_reply(deviceCode->valuestring,payload_Str, strlen(payload_Str), NULL);
//dm_msg_thing_property_set_reply(deviceCode->valuestring,payload_Str, strlen(payload_Str), NULL);
dm_msg_ccu_property_post
(
node
);
dm_msg_ccu_property_post
(
node
);
return
res
;
}
}
/************************************************************
/************************************************************
*功能描述:收到云端数据后的回调处理
*功能描述:收到云端数据后的回调处理
...
...
midware/midware/dm/kk_linkkit.h
View file @
8df7914e
...
@@ -12,4 +12,5 @@ void IOT_Linkkit_Yield(int timeout_ms);
...
@@ -12,4 +12,5 @@ void IOT_Linkkit_Yield(int timeout_ms);
int
IOT_Linkkit_Close
(
int
devid
);
int
IOT_Linkkit_Close
(
int
devid
);
int
kk_mid_subdev_add
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_mid_subdev_add
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_mid_subdev_batch_add
(
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_mid_subdev_batch_add
(
char
productCode
[
PRODUCT_CODE_MAXLEN
],
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
fatherDeviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_service_arming_set
(
char
*
state
);
#endif
#endif
midware/midware/dm/kk_property_db.c
View file @
8df7914e
...
@@ -244,7 +244,7 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
...
@@ -244,7 +244,7 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
_kk_property_db_lock
();
_kk_property_db_lock
();
//传感器类默认安防等级为离家安防
//传感器类默认安防等级为离家安防
if
(
strcmp
(
identifier
,
"SensorType"
)
==
0
&&
devtype
==
KK_DM_DEVICE_SUBDEV
){
if
(
strcmp
(
identifier
,
"SensorType"
)
==
0
&&
devtype
==
KK_DM_DEVICE_SUBDEV
){
res
=
dm_mgr_get_device_by_devicecode
(
deviceCode
,
&
node
);
res
=
dm_mgr_get_device_by_devicecode
(
(
char
*
)
deviceCode
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
...
midware/midware/dm/kk_property_db.h
View file @
8df7914e
...
@@ -44,7 +44,6 @@ int kk_property_db_init(void);
...
@@ -44,7 +44,6 @@ int kk_property_db_init(void);
int
kk_property_db_get_rawdata
(
const
char
*
identifier
,
const
int
dev_type
,
kk_prop_raw_struct_t
*
raw
,
int
count
);
int
kk_property_db_get_rawdata
(
const
char
*
identifier
,
const
int
dev_type
,
kk_prop_raw_struct_t
*
raw
,
int
count
);
int
kk_property_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
);
int
kk_property_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
);
int
kk_property_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
devtype
);
int
kk_property_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
devtype
);
int
kk_property_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
);
int
kk_property_db_get_value_directly
(
const
char
*
deviceCode
,
const
char
*
identifier
,
char
*
value
);
int
kk_property_db_get_value_directly
(
const
char
*
deviceCode
,
const
char
*
identifier
,
char
*
value
);
int
kk_property_db_get_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
void
*
value
);
int
kk_property_db_get_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
void
*
value
);
int
kk_property_db_update
(
const
char
*
deviceCode
);
int
kk_property_db_update
(
const
char
*
deviceCode
);
...
@@ -57,5 +56,6 @@ int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_
...
@@ -57,5 +56,6 @@ int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_
int
kk_indoorAir_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
,
int
epNum
);
int
kk_indoorAir_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
,
int
epNum
);
int
kk_indoorAir_query_epnums
(
const
char
*
deviceCode
,
int
epList
[]);
int
kk_indoorAir_query_epnums
(
const
char
*
deviceCode
,
int
epList
[]);
int
kk_check_property_exist
(
const
char
*
deviceCode
,
const
char
*
identifier
);
int
kk_check_property_exist
(
const
char
*
deviceCode
,
const
char
*
identifier
);
int
kk_indoorAir_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
#endif
#endif
midware/midware/dm/kk_sub_db.c
View file @
8df7914e
...
@@ -650,7 +650,7 @@ static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *property
...
@@ -650,7 +650,7 @@ static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *property
}
}
return
0
;
return
0
;
}
}
int
kk_subDev_set_action_by_productType
(
c
onst
char
*
productType
,
const
char
*
sceneId
,
const
char
*
propertyName
,
const
char
*
propertyValue
,
const
char
*
type
,
int
delay
)
int
kk_subDev_set_action_by_productType
(
c
har
*
productType
,
char
*
sceneId
,
char
*
propertyName
,
char
*
propertyValue
,
char
*
type
,
int
delay
)
{
{
int
res
=
0
;
int
res
=
0
;
sqlite3_stmt
*
stmt
;
sqlite3_stmt
*
stmt
;
...
...
midware/midware/dm/kk_sub_db.h
View file @
8df7914e
...
@@ -19,7 +19,7 @@ int kk_subDev_send_property_get_from_db(void);
...
@@ -19,7 +19,7 @@ int kk_subDev_send_property_get_from_db(void);
int
kk_subDev_send_property_get
(
const
char
*
fatherDeviceCode
);
int
kk_subDev_send_property_get
(
const
char
*
fatherDeviceCode
);
int
kk_subDev_check_scene_support
(
const
char
*
deviceCode
);
int
kk_subDev_check_scene_support
(
const
char
*
deviceCode
);
int
kk_subDev_set_action_by_productType
(
c
onst
char
*
productType
,
const
char
*
sceneId
,
const
char
*
propertyName
,
const
char
*
propertyValue
,
const
char
*
type
,
int
delay
);
int
kk_subDev_set_action_by_productType
(
c
har
*
productType
,
char
*
sceneId
,
char
*
propertyName
,
char
*
propertyValue
,
char
*
type
,
int
delay
);
int
kk_subDev_update_offline
(
int
isOffline
,
const
char
*
deviceCode
);
int
kk_subDev_update_offline
(
int
isOffline
,
const
char
*
deviceCode
);
int
kk_subDev_getSensors_reply
(
SensorType_t
*
list
);
int
kk_subDev_getSensors_reply
(
SensorType_t
*
list
);
int
kk_load_subDevice
(
void
);
int
kk_load_subDevice
(
void
);
...
...
midware/midware/dm/kk_sync_data.c
View file @
8df7914e
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#include "kk_area_handle.h"
#include "kk_area_handle.h"
#include "kk_sub_db.h"
#include "kk_sub_db.h"
#include "kk_hal.h"
#include "kk_hal.h"
#include "kk_dm_msg.h"
#include "kk_linkkit.h"
extern
sqlite3
*
g_kk_pDb
;
extern
sqlite3
*
g_kk_pDb
;
static
int
kk_check_multi_ep_num
(
char
*
deviceCode
);
static
int
kk_check_multi_ep_num
(
char
*
deviceCode
);
...
@@ -217,7 +219,7 @@ static int kk_check_multi_ep_num(char *deviceCode)
...
@@ -217,7 +219,7 @@ static int kk_check_multi_ep_num(char *deviceCode)
propertyStr
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_IDENTIFITER
);
propertyStr
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_IDENTIFITER
);
char
*
propertiesbuf
[
64
]
=
{
0
};
char
*
propertiesbuf
[
64
]
=
{
0
};
int
num
=
0
;
int
num
=
0
;
split
(
propertyStr
,
"_"
,
propertiesbuf
,
&
num
);
kk_
split
(
propertyStr
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
>=
2
){
if
(
num
>=
2
){
return
1
;
return
1
;
}
}
...
@@ -352,7 +354,7 @@ static cJSON *kk_get_properties_info(char *deviceCode,int devType)
...
@@ -352,7 +354,7 @@ static cJSON *kk_get_properties_info(char *deviceCode,int devType)
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
char
*
propertiesbuf
[
64
]
=
{
0
};
char
*
propertiesbuf
[
64
]
=
{
0
};
int
num
=
0
;
int
num
=
0
;
split
(
propertyStr
,
"_"
,
propertiesbuf
,
&
num
);
kk_
split
(
propertyStr
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
if
(
num
==
2
){
if
(
strcmp
(
propertiesbuf
[
1
],
"1"
)
==
0
){
if
(
strcmp
(
propertiesbuf
[
1
],
"1"
)
==
0
){
if
(
propertyItem1
==
NULL
){
if
(
propertyItem1
==
NULL
){
...
@@ -462,7 +464,7 @@ static cJSON *kk_get_indoor_properties_info(char *deviceCode)
...
@@ -462,7 +464,7 @@ static cJSON *kk_get_indoor_properties_info(char *deviceCode)
sqlite3_finalize
(
stmt
);
sqlite3_finalize
(
stmt
);
return
obj
;
return
obj
;
}
}
static
int
kk_get_properties_info_obj
(
char
*
deviceCode
)
static
cJSON
*
kk_get_properties_info_obj
(
char
*
deviceCode
)
{
{
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
int
num
=
0
;
int
num
=
0
;
...
@@ -779,7 +781,7 @@ static int kk_get_panel_scenes_actions_info(cJSON *actionItem,int id)
...
@@ -779,7 +781,7 @@ static int kk_get_panel_scenes_actions_info(cJSON *actionItem,int id)
char
*
propertiesbuf
[
64
]
=
{
0
};
char
*
propertiesbuf
[
64
]
=
{
0
};
int
num
=
0
;
int
num
=
0
;
split
(
propertyName
,
"_"
,
propertiesbuf
,
&
num
);
kk_
split
(
propertyName
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
if
(
num
==
2
){
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_SCENE_PROPERTYNAME_STR
,
propertiesbuf
[
0
]);
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_SCENE_PROPERTYNAME_STR
,
propertiesbuf
[
0
]);
}
else
{
}
else
{
...
@@ -844,7 +846,7 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,int id)
...
@@ -844,7 +846,7 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,int id)
char
*
propertiesbuf
[
64
]
=
{
0
};
char
*
propertiesbuf
[
64
]
=
{
0
};
int
num
=
0
;
int
num
=
0
;
split
(
propertyName
,
"_"
,
propertiesbuf
,
&
num
);
kk_
split
(
propertyName
,
"_"
,
propertiesbuf
,
&
num
);
if
(
num
==
2
){
if
(
num
==
2
){
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_SCENE_PROPERTYNAME_STR
,
propertiesbuf
[
0
]);
cJSON_AddStringToObject
(
actionItem
,
KK_SYNC_SCENE_PROPERTYNAME_STR
,
propertiesbuf
[
0
]);
cJSON_AddNumberToObject
(
actionItem
,
KK_SYNC_SCENE_EPNUM_STR
,
atoi
(
propertiesbuf
[
1
]));
cJSON_AddNumberToObject
(
actionItem
,
KK_SYNC_SCENE_EPNUM_STR
,
atoi
(
propertiesbuf
[
1
]));
...
@@ -900,6 +902,7 @@ static int kk_build_repeatday_string(int repeatday,char *repeatStr,int size)
...
@@ -900,6 +902,7 @@ static int kk_build_repeatday_string(int repeatday,char *repeatStr,int size)
if
(
pos
>
0
){
if
(
pos
>
0
){
repeatStr
[
pos
-
1
]
=
'\0'
;
repeatStr
[
pos
-
1
]
=
'\0'
;
}
}
return
0
;
}
}
int
kk_is_trigger_timing
(
char
*
sceneId
)
int
kk_is_trigger_timing
(
char
*
sceneId
)
...
@@ -1185,6 +1188,7 @@ static int kk_get_ccu_properties(cJSON *property)
...
@@ -1185,6 +1188,7 @@ static int kk_get_ccu_properties(cJSON *property)
*返 回 值:1:存在;0:不存在
*返 回 值:1:存在;0:不存在
*其他说明:
*其他说明:
*************************************************************/
*************************************************************/
int
HAL_Get_ccuid
(
_OU_
char
*
device_code
);
char
*
kk_sync_get_info
()
char
*
kk_sync_get_info
()
{
{
char
*
out
=
NULL
;
char
*
out
=
NULL
;
...
...
midware/midware/history/kk_history_db.c
View file @
8df7914e
...
@@ -182,16 +182,16 @@ cJSON * kk_history_get_sensor_info(void)
...
@@ -182,16 +182,16 @@ cJSON * kk_history_get_sensor_info(void)
cJSON
*
arrayObj
=
cJSON_CreateArray
();
cJSON
*
arrayObj
=
cJSON_CreateArray
();
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
cJSON
*
infoItem
=
cJSON_CreateObject
();
cJSON
*
infoItem
=
cJSON_CreateObject
();
pDeviceCode
=
(
c
onst
c
har
*
)
sqlite3_column_text
(
stmt
,
DB_SENSOR_DEVICECODE
);
pDeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SENSOR_DEVICECODE
);
dm_mgr_dev_node_t
*
search_node
=
NULL
;
dm_mgr_dev_node_t
*
search_node
=
NULL
;
res
=
dm_mgr_get_device_by_devicecode
(
pDeviceCode
,
&
search_node
);
res
=
dm_mgr_get_device_by_devicecode
(
pDeviceCode
,
&
search_node
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
continue
;
continue
;
}
}
cJSON_AddStringToObject
(
infoItem
,
"productCode"
,
search_node
->
productCode
);
cJSON_AddStringToObject
(
infoItem
,
"productCode"
,
search_node
->
productCode
);
pident
=
(
c
onst
c
har
*
)
sqlite3_column_text
(
stmt
,
DB_SENSOR_IDENTIFIER
);
pident
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SENSOR_IDENTIFIER
);
cJSON_AddStringToObject
(
infoItem
,
"identifier"
,
pident
);
cJSON_AddStringToObject
(
infoItem
,
"identifier"
,
pident
);
pValue
=
(
c
onst
c
har
*
)
sqlite3_column_text
(
stmt
,
DB_SENSOR_VALUE
);
pValue
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SENSOR_VALUE
);
cJSON_AddStringToObject
(
infoItem
,
"value"
,
pValue
);
cJSON_AddStringToObject
(
infoItem
,
"value"
,
pValue
);
rtime
=
sqlite3_column_int
(
stmt
,
DB_SENSOR_RECORDTIME
);
rtime
=
sqlite3_column_int
(
stmt
,
DB_SENSOR_RECORDTIME
);
cJSON_AddNumberToObject
(
infoItem
,
"alarm_time"
,
rtime
);
cJSON_AddNumberToObject
(
infoItem
,
"alarm_time"
,
rtime
);
...
...
midware/midware/midware.c
View file @
8df7914e
...
@@ -102,8 +102,8 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
...
@@ -102,8 +102,8 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
}
}
static
int
HAL_Ccuid_init
(
void
)
static
int
HAL_Ccuid_init
(
void
)
{
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
char
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
char
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
...
@@ -1390,14 +1390,14 @@ int main(const int argc, const char **argv)
...
@@ -1390,14 +1390,14 @@ int main(const int argc, const char **argv)
g_timezone
=
HAL_Get_TimeZone
();
g_timezone
=
HAL_Get_TimeZone
();
mid_ctx
->
g_mid_dispatch_thread_running
=
1
;
mid_ctx
->
g_mid_dispatch_thread_running
=
1
;
res
=
pthread_create
(
&
mid_ctx
->
g_mid_dispatch_thread
,
NULL
,
mid_dispatch_yield
,
NULL
);
res
=
pthread_create
(
(
pthread_t
*
)
&
mid_ctx
->
g_mid_dispatch_thread
,
NULL
,
mid_dispatch_yield
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
ERROR_PRINT
(
"HAL_ThreadCreate mid Failed
\n
"
);
ERROR_PRINT
(
"HAL_ThreadCreate mid Failed
\n
"
);
//IOT_Linkkit_Close(mid_ctx->master_devid);
//IOT_Linkkit_Close(mid_ctx->master_devid);
return
-
1
;
return
-
1
;
}
}
mid_ctx
->
g_ota_dispatch_thread_running
=
1
;
mid_ctx
->
g_ota_dispatch_thread_running
=
1
;
res
=
pthread_create
(
&
mid_ctx
->
g_ota_dispatch_thread
,
NULL
,
ota_dispatch_yield
,
NULL
);
res
=
pthread_create
(
(
pthread_t
*
)
&
mid_ctx
->
g_ota_dispatch_thread
,
NULL
,
ota_dispatch_yield
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
ERROR_PRINT
(
"HAL_ThreadCreate ota Failed
\n
"
);
ERROR_PRINT
(
"HAL_ThreadCreate ota Failed
\n
"
);
//IOT_Linkkit_Close(mid_ctx->master_devid);
//IOT_Linkkit_Close(mid_ctx->master_devid);
...
@@ -1405,7 +1405,7 @@ int main(const int argc, const char **argv)
...
@@ -1405,7 +1405,7 @@ int main(const int argc, const char **argv)
}
}
// recv gateway add cmd and ack to gateway
// recv gateway add cmd and ack to gateway
res
=
pthread_create
(
&
mid_ctx
->
g_udp_dispatch_thread
,
NULL
,
udp_dispatch_yield
,
NULL
);
res
=
pthread_create
(
(
pthread_t
*
)
&
mid_ctx
->
g_udp_dispatch_thread
,
NULL
,
udp_dispatch_yield
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
ERROR_PRINT
(
"HAL_ThreadCreate udp Failed
\n
"
);
ERROR_PRINT
(
"HAL_ThreadCreate udp Failed
\n
"
);
//IOT_Linkkit_Close(mid_ctx->master_devid);
//IOT_Linkkit_Close(mid_ctx->master_devid);
...
@@ -1413,7 +1413,7 @@ int main(const int argc, const char **argv)
...
@@ -1413,7 +1413,7 @@ int main(const int argc, const char **argv)
}
}
mid_ctx
->
g_ccuProChg_dispatch_thread_running
=
1
;
mid_ctx
->
g_ccuProChg_dispatch_thread_running
=
1
;
res
=
pthread_create
(
&
mid_ctx
->
g_ccuProChg_dispatch_thread
,
NULL
,
ccu_property_monitor
,
NULL
);
res
=
pthread_create
(
(
pthread_t
*
)
&
mid_ctx
->
g_ccuProChg_dispatch_thread
,
NULL
,
ccu_property_monitor
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
ERROR_PRINT
(
"HAL_ThreadCreate Failed
\n
"
);
ERROR_PRINT
(
"HAL_ThreadCreate Failed
\n
"
);
return
-
1
;
return
-
1
;
...
...
midware/midware/ota/iotx_ota.c
View file @
8df7914e
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
*
*
*/
*/
#include "iotx_ota_internal.h"
#include "com_api.h"
#include "com_api.h"
#include "cJSON.h"
#include "cJSON.h"
#include "iotx_ota.h"
#include "kk_dm_msg.h"
#include "kk_dm_msg.h"
...
...
midware/midware/ota/iotx_ota.h
View file @
8df7914e
...
@@ -4,12 +4,13 @@
...
@@ -4,12 +4,13 @@
#ifndef __IOTX_OTA_H__
#ifndef __IOTX_OTA_H__
#define __IOTX_OTA_H__
#define __IOTX_OTA_H__
#include "iotx_ota_internal.h"
int
iotx_ota_get_config
(
void
*
handle
,
const
char
*
configScope
,
const
char
*
getType
,
int
iotx_ota_get_config
(
void
*
handle
,
const
char
*
configScope
,
const
char
*
getType
,
const
char
*
attributeKeys
);
const
char
*
attributeKeys
);
int
iotx_req_image
(
void
*
handle
,
const
char
*
version
);
int
iotx_req_image
(
void
*
handle
,
const
char
*
version
);
int
ota_callback
(
void
*
pcontext
,
const
char
*
msg
,
uint32_t
msg_len
,
iotx_ota_topic_types_t
type
);
#endif
/* #ifndef __IOTX_OTA_H__ */
#endif
/* #ifndef __IOTX_OTA_H__ */
midware/midware/ota/iotx_ota_internal.h
View file @
8df7914e
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "infra_sha256.h"
#include "infra_sha256.h"
#include "infra_json_parser.h"
#include "infra_json_parser.h"
#include "ota_api.h"
#include "ota_api.h"
#include "kk_hal.h"
//#include "iotx_ota_config.h"
//#include "iotx_ota_config.h"
//#include "ota_wrapper.h"
//#include "ota_wrapper.h"
...
...
midware/midware/scene/kk_scene_handle.c
View file @
8df7914e
...
@@ -17,11 +17,13 @@
...
@@ -17,11 +17,13 @@
#include "kk_scene_db.h"
#include "kk_scene_db.h"
#include "kk_sub_db.h"
#include "kk_sub_db.h"
#include "kk_tsl_load.h"
#include "kk_tsl_load.h"
#include "kk_tsl_parse.h"
#include "kk_dm_api.h"
#include "kk_dm_api.h"
#include "kk_dm_msg.h"
#include "kk_dm_msg.h"
#include "kk_property_db.h"
#include "kk_property_db.h"
#include "kk_hal.h"
#include "kk_hal.h"
#include "kk_log.h"
#include "kk_log.h"
#include "kk_linkkit.h"
#include <time.h>
#include <time.h>
...
@@ -111,7 +113,7 @@ static int kk_scene_tsl_load(void)
...
@@ -111,7 +113,7 @@ static int kk_scene_tsl_load(void)
tsl_str
=
kk_load_json
(
"15"
,
KK_DEVICE_TSL_TYPE
);
tsl_str
=
kk_load_json
(
"15"
,
KK_DEVICE_TSL_TYPE
);
if
(
tsl_str
!=
NULL
)
if
(
tsl_str
!=
NULL
)
{
{
res
=
kk_tsl_create
(
tsl_str
,
strlen
(
tsl_str
),
&
s_scene_shadow
,
&
heartTime
,
&
isDormancyDev
);
res
=
kk_tsl_create
(
tsl_str
,
strlen
(
tsl_str
),
&
s_scene_shadow
,
&
heartTime
,
(
int
*
)
&
isDormancyDev
);
free
(
tsl_str
);
free
(
tsl_str
);
if
(
res
!=
0
){
if
(
res
!=
0
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
@@ -972,13 +974,13 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
...
@@ -972,13 +974,13 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
if
(
delay
==
NULL
)
return
FAIL_RETURN
;
if
(
delay
==
NULL
)
return
FAIL_RETURN
;
int
idelay
=
delay
->
valueint
;
int
idelay
=
delay
->
valueint
;
if
(
propertyValue
->
type
==
cJSON_String
){
if
(
propertyValue
->
type
==
cJSON_String
){
kk_subDev_set_action_by_productType
(
productType
->
valuestring
,
sceneId
,
propertyName
->
valuestring
,
kk_subDev_set_action_by_productType
(
productType
->
valuestring
,
(
char
*
)
sceneId
,
propertyName
->
valuestring
,
propertyValue
->
valuestring
,
type
->
valuestring
,
idelay
);
propertyValue
->
valuestring
,
type
->
valuestring
,
idelay
);
}
else
{
}
else
{
printf
(
"1111
\r\n
"
);
printf
(
"1111
\r\n
"
);
char
*
str
=
cJSON_PrintUnformatted
(
propertyValue
);
char
*
str
=
cJSON_PrintUnformatted
(
propertyValue
);
printf
(
"222
\r\n
"
);
printf
(
"222
\r\n
"
);
kk_subDev_set_action_by_productType
(
productType
->
valuestring
,
sceneId
,
propertyName
->
valuestring
,
kk_subDev_set_action_by_productType
(
productType
->
valuestring
,
(
char
*
)
sceneId
,
propertyName
->
valuestring
,
str
,
type
->
valuestring
,
idelay
);
str
,
type
->
valuestring
,
idelay
);
printf
(
"333
\r\n
"
);
printf
(
"333
\r\n
"
);
free
(
str
);
free
(
str
);
...
@@ -1283,7 +1285,7 @@ int kk_scene_get_quickpanel_info(const char* buttonId,char *deviceCode,char *sce
...
@@ -1283,7 +1285,7 @@ int kk_scene_get_quickpanel_info(const char* buttonId,char *deviceCode,char *sce
sqlCmd
=
sqlite3_mprintf
(
"select * from QuickPanelScene where buttonId = '%s' and deviceCode = '%s'"
,
buttonId
,
deviceCode
);
sqlCmd
=
sqlite3_mprintf
(
"select * from QuickPanelScene where buttonId = '%s' and deviceCode = '%s'"
,
buttonId
,
deviceCode
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pSceneId
=
sqlite3_column_text
(
stmt
,
DB_QUICKPANEL_SCENEID
);
pSceneId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_QUICKPANEL_SCENEID
);
*
bindType
=
sqlite3_column_int
(
stmt
,
DB_QUICKPANEL_BINDTYPE
);
*
bindType
=
sqlite3_column_int
(
stmt
,
DB_QUICKPANEL_BINDTYPE
);
memcpy
(
sceneId
,
pSceneId
,
strlen
(
pSceneId
));
memcpy
(
sceneId
,
pSceneId
,
strlen
(
pSceneId
));
res
=
SUCCESS_RETURN
;
res
=
SUCCESS_RETURN
;
...
@@ -1387,6 +1389,7 @@ static time_t kk_scene_creat_new_starttime(time_t starttime,time_t current)
...
@@ -1387,6 +1389,7 @@ static time_t kk_scene_creat_new_starttime(time_t starttime,time_t current)
static
time_t
kk_scene_creat_timer_starttime
(
int
week
,
int
starttime
,
time_t
current
)
static
time_t
kk_scene_creat_timer_starttime
(
int
week
,
int
starttime
,
time_t
current
)
{
{
time_t
newTime
=
0
;
time_t
newTime
=
0
;
time_t
res
=
0
;
char
curWeek
=
0
;
char
curWeek
=
0
;
int
startNew
=
0
;
int
startNew
=
0
;
int
i
=
0
;
int
i
=
0
;
...
@@ -1407,17 +1410,18 @@ static time_t kk_scene_creat_timer_starttime(int week,int starttime,time_t curre
...
@@ -1407,17 +1410,18 @@ static time_t kk_scene_creat_timer_starttime(int week,int starttime,time_t curre
}
}
if
(
curWeek
&
week
){
if
(
curWeek
&
week
){
newTime
=
current
+
86400
*
i
;
newTime
=
current
+
86400
*
i
;
return
kk_scene_creat_new_starttime
(
startNew
,
newTime
);
res
=
kk_scene_creat_new_starttime
(
startNew
,
newTime
);
}
else
{
}
else
{
re
turn
kk_scene_creat_new_starttime
(
startNew
,
current
);
re
s
=
kk_scene_creat_new_starttime
(
startNew
,
current
);
}
}
}
}
}
}
else
else
{
{
re
turn
kk_scene_creat_new_starttime
(
startNew
,
current
);
re
s
=
kk_scene_creat_new_starttime
(
startNew
,
current
);
}
}
return
res
;
}
}
/************************************************************
/************************************************************
...
@@ -1805,7 +1809,7 @@ static int kk_scene_start_action(const char *deviceCode,const char *propertyName
...
@@ -1805,7 +1809,7 @@ static int kk_scene_start_action(const char *deviceCode,const char *propertyName
memcpy
(
actionInfo
->
propertyValue
,
valueS
,
strlen
(
valueS
));
memcpy
(
actionInfo
->
propertyValue
,
valueS
,
strlen
(
valueS
));
if
(
delay
==
0
){
if
(
delay
==
0
){
if
(
strcmp
(
propertyName
,
"ArmingState"
)
==
0
){
if
(
strcmp
(
propertyName
,
"ArmingState"
)
==
0
){
kk_service_arming_set
(
valueS
);
kk_service_arming_set
(
(
char
*
)
valueS
);
}
else
{
}
else
{
kk_scene_send_action_msg
(
actionInfo
);
kk_scene_send_action_msg
(
actionInfo
);
}
}
...
...
midware/midware/scene/kk_scene_handle.h
View file @
8df7914e
...
@@ -82,5 +82,7 @@ int kk_scene_parse_updatescene(const cJSON* arg,char *sceneId);
...
@@ -82,5 +82,7 @@ int kk_scene_parse_updatescene(const cJSON* arg,char *sceneId);
int
kk_scene_parse_deletescene
(
char
*
sceneId
);
int
kk_scene_parse_deletescene
(
char
*
sceneId
);
int
kk_scene_delete_send_to_gw
(
const
char
*
sceneId
);
int
kk_scene_delete_send_to_gw
(
const
char
*
sceneId
);
int
kk_scene_parse_scene_action
(
const
cJSON
*
str
,
const
char
*
sceneId
,
int
isUpdate
);
int
kk_scene_parse_scene_action
(
const
cJSON
*
str
,
const
char
*
sceneId
,
int
isUpdate
);
int
kk_scene_execute_quickpanel
(
const
char
*
buttonId
,
char
*
deviceCode
);
int
kk_scene_action_add
(
const
char
*
gwdeviceCode
,
const
char
*
sceneId
,
kk_scene_action_detail_t
detail
);
#endif
#endif
midware/midware/timer/kk_timer_handle.c
View file @
8df7914e
...
@@ -41,7 +41,7 @@ typedef struct kk_timer_list{
...
@@ -41,7 +41,7 @@ typedef struct kk_timer_list{
}
kk_timer_info_t
;
}
kk_timer_info_t
;
static
kk_timer_info_t
*
p_timer_info_list
=
NULL
;
static
kk_timer_info_t
*
p_timer_info_list
=
NULL
;
int
kk_del_expired_timer_from_list
(
uint64_t
current
);
static
kk_timer_ctx_t
s_kk_timer_ctx
=
{
NULL
,
NULL
,
0
,
0
};
static
kk_timer_ctx_t
s_kk_timer_ctx
=
{
NULL
,
NULL
,
0
,
0
};
static
kk_timer_ctx_t
*
_kk_timer_get_ctx
(
void
)
static
kk_timer_ctx_t
*
_kk_timer_get_ctx
(
void
)
...
@@ -98,7 +98,7 @@ int kk_timer_init(void)
...
@@ -98,7 +98,7 @@ int kk_timer_init(void)
if
(
ctx
->
mutex
==
NULL
)
{
if
(
ctx
->
mutex
==
NULL
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
res
=
pthread_create
(
&
ctx
->
s_timer_thread
,
NULL
,
kk_timer_yield
,
NULL
);
res
=
pthread_create
(
(
pthread_t
*
)
&
ctx
->
s_timer_thread
,
NULL
,
kk_timer_yield
,
NULL
);
if
(
res
<
0
)
{
if
(
res
<
0
)
{
ERROR_PRINT
(
"HAL_ThreadCreate mid Failed
\n
"
);
ERROR_PRINT
(
"HAL_ThreadCreate mid Failed
\n
"
);
//IOT_Linkkit_Close(mid_ctx->master_devid);
//IOT_Linkkit_Close(mid_ctx->master_devid);
...
...
midware/midware/utils/infra_defs.h
View file @
8df7914e
...
@@ -42,7 +42,7 @@ extern "C" {
...
@@ -42,7 +42,7 @@ extern "C" {
#define _IN_OPT_
#define _IN_OPT_
#endif
#endif
#define NETWORK_ADDR_LEN (16)
//
#define NETWORK_ADDR_LEN (16)
#define HAL_MAC_LEN (17 + 1)
/* MAC地址的长度 */
#define HAL_MAC_LEN (17 + 1)
/* MAC地址的长度 */
#define STR_SHORT_LEN (32)
#define STR_SHORT_LEN (32)
#ifndef ETH_ALEN
#ifndef ETH_ALEN
...
...
midware/tsl/tsl_handle/kk_tsl_api.h
View file @
8df7914e
...
@@ -99,5 +99,6 @@ int kk_tsl_get_property_type(_IN_ kk_tsl_t *dev_shadow, _IN_ char *key);
...
@@ -99,5 +99,6 @@ int kk_tsl_get_property_type(_IN_ kk_tsl_t *dev_shadow, _IN_ char *key);
int
kk_tsl_get_event_by_identifier
(
_IN_
kk_tsl_t
*
dev_shadow
,
_IN_
char
*
identifier
,
_OU_
void
**
event
);
int
kk_tsl_get_event_by_identifier
(
_IN_
kk_tsl_t
*
dev_shadow
,
_IN_
char
*
identifier
,
_OU_
void
**
event
);
int
kk_tsl_get_event_method
(
_IN_
void
*
event
,
_OU_
char
**
method
);
int
kk_tsl_get_event_method
(
_IN_
void
*
event
,
_OU_
char
**
method
);
int
kk_tsl_get_service_by_identifier
(
_IN_
kk_tsl_t
*
dev_shadow
,
_IN_
char
*
identifier
,
_OU_
void
**
service
);
int
kk_tsl_get_service_by_identifier
(
_IN_
kk_tsl_t
*
dev_shadow
,
_IN_
char
*
identifier
,
_OU_
void
**
service
);
int
kk_tsl_get_service_method
(
_IN_
void
*
service
,
_OU_
char
**
method
);
int
kk_tsl_get_service_method
(
_IN_
void
*
service
,
_OU_
char
**
method
);
void
kk_tsl_destroy
(
_IN_
kk_tsl_t
**
shadow
);
#endif
#endif
onboot.sh
View file @
8df7914e
...
@@ -53,10 +53,14 @@ fi
...
@@ -53,10 +53,14 @@ fi
if
[
!
-d
"
$tsl_Dir
"
]
;
then
if
[
!
-d
"
$tsl_Dir
"
]
;
then
cp
-rf
$filepath
/tsl
${
run_Dir
}
/
cp
-rf
$filepath
/tsl
${
run_Dir
}
/
else
else
defaultVer
=
`
cat
${
filepath
}
/tsl/version
`
if
[
!
-f
"
${
run_Dir
}
/tsl/version"
]
;
then
curVer
=
`
cat
${
run_Dir
}
/tsl/version
`
if
[
$defaultVer
!=
$curVer
]
;
then
cp
-rf
$filepath
/tsl
${
run_Dir
}
/
cp
-rf
$filepath
/tsl
${
run_Dir
}
/
else
defaultVer
=
`
cat
${
filepath
}
/tsl/version
`
curVer
=
`
cat
${
run_Dir
}
/tsl/version
`
if
[
$defaultVer
!=
$curVer
]
;
then
cp
-rf
$filepath
/tsl
${
run_Dir
}
/
fi
fi
fi
fi
fi
#if [ ! -d "$map_Dir" ]; then
#if [ ! -d "$map_Dir" ]; then
...
...
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