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
f7ac64c6
Commit
f7ac64c6
authored
Nov 08, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,增加离线语音OTA功能;2,修改编译级别为werror
【提交人】陈伟灿
parent
ac14fe24
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
387 additions
and
203 deletions
+387
-203
application/kcloud/kcloud_config.h
application/kcloud/kcloud_config.h
+0
-2
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+34
-16
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+15
-3
application/klansdk/kk_lan_voice_panel.h
application/klansdk/kk_lan_voice_panel.h
+3
-27
application/klansdk/kk_opcode.h
application/klansdk/kk_opcode.h
+6
-0
application/klansdk/kk_voice_panel_handle.c
application/klansdk/kk_voice_panel_handle.c
+235
-64
application/klansdk/kk_voice_panel_handle.h
application/klansdk/kk_voice_panel_handle.h
+9
-9
common/api/com_api.c
common/api/com_api.c
+2
-2
common/api/tcp_channel.c
common/api/tcp_channel.c
+6
-4
common/hal/HAL_OS_linux.c
common/hal/HAL_OS_linux.c
+1
-1
common/hal/kk_product.h
common/hal/kk_product.h
+2
-0
midware/midware/area/kk_area_handle.c
midware/midware/area/kk_area_handle.c
+11
-9
midware/midware/area/kk_area_handle.h
midware/midware/area/kk_area_handle.h
+6
-0
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+3
-1
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+38
-52
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+2
-1
midware/midware/midware.c
midware/midware/midware.c
+2
-2
midware/midware/ota/iotx_ota.c
midware/midware/ota/iotx_ota.c
+3
-3
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+1
-0
midware/midware/scene/kk_scene_handle.h
midware/midware/scene/kk_scene_handle.h
+1
-0
midware/tsl/tsl_handle/kk_tsl_api.c
midware/tsl/tsl_handle/kk_tsl_api.c
+5
-5
midware/tsl/tsl_handle/kk_tsl_parse.c
midware/tsl/tsl_handle/kk_tsl_parse.c
+1
-1
tools/board/config.linux.nx5
tools/board/config.linux.nx5
+1
-1
No files found.
application/kcloud/kcloud_config.h
View file @
f7ac64c6
...
...
@@ -19,8 +19,6 @@ typedef enum {
RETURN_FAIL
=
-
1
,
RETURN_SUCCESS
=
0
,
}
kk_kcloud_error_code_t
;
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#define HOST_NAME "dev.nj-ikonke.site"
int
KK_Get_ccuid
(
char
*
device_code
);
#endif
...
...
application/klansdk/kk_data_handle.c
View file @
f7ac64c6
...
...
@@ -379,8 +379,41 @@ int kk_data_handle(cJSON *json,int sockfd)
if
(
key
!=
NULL
){
kk_handle_del_history_info
(
key
->
valuestring
);
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
VOICE_VOLUME_CTRL
)
==
0
){
cJSON
*
vol
=
cJSON_GetObjectItem
(
json
,
"arg"
);
if
(
vol
!=
NULL
){
kk_voice_control
(
atoi
(
vol
->
valuestring
));
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
VOICE_SWITCH_CTRL
)
==
0
){
cJSON
*
onff
=
cJSON_GetObjectItem
(
json
,
"arg"
);
int
value
=
0
;
if
(
onff
!=
NULL
){
if
(
strcmp
(
onff
->
valuestring
,
"on"
)
==
0
){
value
=
1
;
}
else
{
value
=
0
;
}
kk_voice_switch
(
value
);
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
VOICE_VERSION_QUERY
)
==
0
){
char
ver
[
16
]
=
{
0
};
kk_vp_voice_version_get
(
ver
,
sizeof
(
ver
));
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"nodeid"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
VOICE_VERSION_QUERY
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddStringToObject
(
root
,
"arg"
,
ver
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
}
else
if
(
strcmp
(
opcode
->
valuestring
,
VOICE_OTA
)
==
0
){
cJSON
*
otafile
=
cJSON_GetObjectItem
(
json
,
"arg"
);
if
(
otafile
!=
NULL
){
kk_voice_ota_mtu_set
(
KK_VOICE_OTA_MTU
);
kk_vp_ota_file_update_start
(
otafile
->
valuestring
);
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
EXIT_VOICE_FACTORY
)
==
0
){
kk_voice_exit_factory_mode
();
}
else
{
kk_ccu_opcode_handle
(
json
);
}
}
...
...
@@ -416,24 +449,13 @@ static int kk_parse_syncinfo(cJSON *payload)
gwdevicecode
=
cJSON_GetObjectItem
(
gwitem
,
MSG_DEVICE_CODE_STR
)
->
valuestring
;
if
(
subdevices
!=
NULL
){
subitem
=
subdevices
->
child
;
while
(
subitem
!=
NULL
){
deviceCode
=
cJSON_GetObjectItem
(
subitem
,
MSG_DEVICE_CODE_STR
)
->
valuestring
;
productCode
=
cJSON_GetObjectItem
(
subitem
,
MSG_PRODUCT_CODE_STR
)
->
valuestring
;
onlineStatus
=
cJSON_GetObjectItem
(
subitem
,
MSG_ONLINE_STATUS_STR
);
properties
=
cJSON_GetObjectItem
(
subitem
,
MSG_PROPERTIES_STR
);
kk_map_dev_node_add
(
deviceCode
,
productCode
,
gwdevicecode
,(
onlineStatus
->
valueint
==
1
)
?
"1"
:
"0"
);
kk_lan_property_syn_deal
(
deviceCode
,
properties
);
subitem
=
subitem
->
next
;
}
}
...
...
@@ -444,10 +466,6 @@ static int kk_parse_syncinfo(cJSON *payload)
}
int
is_ccu_msg
(
cJSON
*
productCode
,
cJSON
*
deviceCode
)
{
char
ccuid
[
33
]
=
{
0
};
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
f7ac64c6
...
...
@@ -282,15 +282,27 @@ int kk_vp_config_file_info_check(int f_ver,int f_size,int crc32)
}
return
0
;
}
int
kk_voice_exit_factory_mode
(
void
)
{
uint8_t
data
[
1
]
=
{
1
};
vp_send_data_build
(
OPCODE_COMPLETED_TEST_OP
,
sizeof
(
data
),
data
);
return
1
;
}
void
kk_voice_ota_mtu_set
(
uint16_t
mtu
)
{
uint8_t
res
[
3
]
=
{
0
};
res
[
0
]
=
0xff
;
res
[
1
]
=
(
mtu
>>
8
)
&
0xff
;
res
[
2
]
=
mtu
&
0xff
;
INFO_PRINT
(
"[set] MTU OTA SIZE = %d
\n
"
,
mtu
);
vp_send_data_build
(
OPCODE_VOICE_SWITCH
,
sizeof
(
res
),
res
);
}
void
kk_vp_manage_init
(
void
)
{
vp_scene_id_map_load
();
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
_vp_config_file_version_load
();
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
vp_mag
.
cfg_info
.
f_size
=
_vp_get_cfg_file_size
();
vp_mag
.
cfg_info
.
crc32
=
_vp_get_cfg_file_crc32
();
}
...
...
application/klansdk/kk_lan_voice_panel.h
View file @
f7ac64c6
...
...
@@ -14,41 +14,17 @@ int kk_voice_panel_init(int argc, char* argv[]);
#define UPDATING_8009_CONFIG_FILE_INFO 3
#define STOP_8009_CONFIG_FILE_UPDATE 4
#define GET_8009_CONFIG_FILE_INFO 5
#define KK_VOICE_OTA_MTU 128
void
kk_vp_set_state_machine
(
int
state
);
void
kk_vp_set_config_file_version
(
int
ver
);
int
kk_vp_config_file_info_check
(
int
f_ver
,
int
f_size
,
int
crc32
);
void
kk_vp_update_result_check
(
uint8_t
status
,
uint32_t
f_ver
);
void
kk_vp_set_config_file_version
(
int
ver
);
void
kk_vp_cfg_info_check
(
uint32_t
f_ver
,
uint32_t
f_size
,
uint32_t
crc32
);
void
kk_vp_cfg_info_set
(
uint32_t
f_ver
,
uint32_t
f_size
,
uint32_t
crc32
);
void
kk_vp_set_updateFlag
(
int
flag
);
void
kk_voice_ota_mtu_set
(
uint16_t
mtu
);
int
kk_voice_exit_factory_mode
(
void
);
#endif
application/klansdk/kk_opcode.h
View file @
f7ac64c6
...
...
@@ -28,6 +28,12 @@
#define ZIGBEE_DEV_HW_INFO_PUSH "ZIGBEE_DEV_HW_INFO_PUSH"
#define GET_HISTORY_ALARM_LOG "GET_HISTORY_ALARM_LOG"
#define DEL_HISTORY_ALARM_LOG "DEL_HISTORY_ALARM_LOG"
#define VOICE_VOLUME_CTRL "SOUND_VAL"
#define VOICE_SWITCH_CTRL "VOICE_SWITCH"
#define VOICE_VERSION_QUERY "VOICE_VERSION"
#define VOICE_OTA_FINISH "VOICE_OTA_FINISH"
#define VOICE_OTA "VOICE_OTA"
#define EXIT_VOICE_FACTORY "EXIT_VOICE_FACTORY"
#define SWITCH_OPCODE "SWITCH"
#define GET_HISTORY_MSG_TYPE "/thing/service/historyAlarm"
#define DEL_HISTORY_MSG_TYPE "/thing/service/delAlarm"
...
...
application/klansdk/kk_voice_panel_handle.c
View file @
f7ac64c6
...
...
@@ -3,7 +3,6 @@
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include "kk_newccu_msg.h"
#include "kk_voice_panel_cfg.h"
#include "kk_voice_panel_handle.h"
...
...
@@ -11,7 +10,7 @@
#include "kk_lan_vp_ctrl.h"
#include "Serial.h"
#include "kk_oldccu_msg.h"
#include <ctype.h>
#define MK_VERSION(x) ((*x<<24) | (*(x+1)<<16) | (*(x+2)<<8) | *(x+3))
#define MK_UINT32(x) ((*x<<24) | (*(x+1)<<16) | (*(x+2)<<8) | *(x+3))
...
...
@@ -50,7 +49,8 @@ static void kk_vp_ota_file_update_start_handle(pro_data_t *pro_data);
static
void
kk_vp_ota_file_update_stop_handle
(
pro_data_t
*
pro_data
);
static
void
kk_vp_ota_info_query_handle
(
pro_data_t
*
pro_data
);
static
void
kk_vp_ota_file_update_status_handle
(
pro_data_t
*
pro_data
);
static
void
kk_voice_switch_handle
(
pro_data_t
*
pro_data
);
static
void
kk_voice_volume_handle
(
pro_data_t
*
pro_data
);
static
VP_OPCODE_HANDLE
vp_opcode_table
[]
=
{
...
...
@@ -71,6 +71,8 @@ static VP_OPCODE_HANDLE vp_opcode_table[] = {
{
OPCODE_VOICE_OTA_REQUEST
,
kk_vp_ota_file_update_data_req_handle
},
{
OPCODE_VOICE_OTA_UPGRADE_STOP
,
kk_vp_ota_file_update_stop_handle
},
{
OPCODE_VOICE_OTA_STATUS_NOTIFY
,
kk_vp_ota_file_update_status_handle
},
{
OPCODE_VOICE_SWITCH
,
kk_voice_switch_handle
},
{
OPCODE_VOICE_CONTROL
,
kk_voice_volume_handle
}
};
...
...
@@ -564,20 +566,6 @@ static void vp_close_fd()
}
}
static
void
open_ota_fd
()
{
ota_fp
=
fopen
(
VP_OTA_FILE_BZIP
,
"rb"
);
if
(
ota_fp
==
NULL
){
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
VP_OTA_FILE_BZIP
);
}
}
static
void
close_ota_fd
()
{
if
(
ota_fp
!=
NULL
){
fclose
(
ota_fp
);
}
}
...
...
@@ -605,6 +593,23 @@ static void close_ota_fd()
static
char
s_voice_sw
[
16
]
=
{
0
};
int
kk_vp_voice_version_get
(
char
*
ver
,
int
len
)
{
if
(
ver
==
NULL
||
len
<
strlen
(
s_voice_sw
)){
return
-
1
;
}
memcpy
(
ver
,
s_voice_sw
,
strlen
(
s_voice_sw
));
return
0
;
}
int
kk_vp_voice_version_set
(
char
*
ver
,
int
len
)
{
if
(
ver
==
NULL
||
len
>=
strlen
(
s_voice_sw
)){
return
-
1
;
}
memcpy
(
s_voice_sw
,
ver
,
strlen
(
ver
));
return
0
;
}
static
void
kk_vp_get_8009_snapshoot_handle
(
pro_data_t
*
pro_data
)
{
uint8_t
err
;
...
...
@@ -636,7 +641,9 @@ static void kk_vp_get_8009_snapshoot_handle(pro_data_t *pro_data)
kk_vp_set_state_machine
(
SET_8009_SYSTEM
);
kk_vp_set_config_file_version
(
f_ver
);
memset
(
s_voice_sw
,
0x0
,
sizeof
(
s_voice_sw
));
//string version=std::to_string(pro_data->arg[1])+"."+std::to_string(pro_data->arg[2])+"."+std::to_string(pro_data->arg[3]);
sprintf
(
s_voice_sw
,
"%d.%d.%d"
,
pro_data
->
arg
[
1
],
pro_data
->
arg
[
2
],
pro_data
->
arg
[
3
]);
debug_log
(
LOG_INFO_LEVEL
,
"
\n
sv=%06X,hv=%06X,%d-%d-%d %d:%d:%d,volume=%d,f_ver=%08X
\n
"
,
sv
,
hv
,
year
,
month
,
day
,
hour
,
minute
,
second
,
volume
,
f_ver
);
}
...
...
@@ -1158,24 +1165,7 @@ void kk_vp_get_ota_file_info(void)
vp_send_data_build
(
OPCODE_VOICE_OTA_INFO_GET
,
sizeof
(
res
),
res
);
}
static
int
_vp_get_ota_file_size
(
void
)
{
int
size
=
0
;
FILE
*
fp
=
NULL
;
fp
=
fopen
(
VP_OTA_FILE_BZIP
,
"r"
);
if
(
fp
==
NULL
){
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
VP_OTA_FILE_BZIP
);
return
0
;
}
fseek
(
fp
,
0
,
SEEK_END
);
size
=
ftell
(
fp
);
fclose
(
fp
);
return
size
;
}
static
int
_vp_get_ota_file_crc32
(
void
)
static
int
_vp_get_ota_file_crc32
(
char
*
file
)
{
char
*
buff
=
NULL
;
char
*
pRead
=
NULL
;
...
...
@@ -1185,10 +1175,11 @@ static int _vp_get_ota_file_crc32(void)
uint32_t
crc32
=
0
;
FILE
*
fp
=
NULL
;
int
size
=
0
;
fp
=
fopen
(
VP_OTA_FILE_BZIP
,
"r"
);
char
filePath
[
218
]
=
{
0
};
sprintf
(
filePath
,
"/data/OTA/%s"
,
file
);
fp
=
fopen
(
filePath
,
"r"
);
if
(
fp
==
NULL
){
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
VP_OTA_FILE_BZIP
);
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
filePath
);
printf
(
"open err.
\n
"
);
return
-
1
;
}
...
...
@@ -1207,7 +1198,7 @@ static int _vp_get_ota_file_crc32(void)
while
(
remain
>
0
){
r_len
=
fread
(
pRead
,
1
,
size
,
fp
);
if
(
remain
>=
r_len
){
if
(
remain
>=
r_len
){
remain
-=
r_len
;
pRead
+=
r_len
;
printf
(
"[remain]r_len=%d,remain=%d
\n
"
,
r_len
,
remain
);
...
...
@@ -1226,15 +1217,87 @@ static int _vp_get_ota_file_crc32(void)
return
crc32
;
}
void
kk_vp_ota_file_update_start
(
uint32_t
ver
)
static
int
get_ota_file_version
(
char
*
file
)
{
char
s
[
128
];
char
*
ota_file
=
NULL
;
char
*
pstart
=
NULL
;
if
(
file
==
NULL
){
return
-
1
;
}
pstart
=
strstr
(
file
,
"_"
);
if
(
pstart
!=
NULL
){
ota_file
=
pstart
+
1
;
}
else
{
ota_file
=
file
;
}
snprintf
(
s
,
sizeof
(
s
),
"%s"
,
ota_file
);
debug_log
(
LOG_NOTICE_LEVEL
,
"ota file ver=%s
\n
"
,
s
);
char
*
d
=
"."
;
char
*
p
;
p
=
strtok
(
s
,
d
);
int
vBuff
[
3
]
=
{
0
};
int
off
=
0
;
while
(
p
)
{
if
(
isdigit
(
*
p
))
{
vBuff
[
off
++
]
=
atoi
(
p
);
if
(
off
==
3
){
break
;
}
}
p
=
strtok
(
NULL
,
d
);
}
return
((
vBuff
[
0
]
&
0xff
)
<<
16
)
|
((
vBuff
[
1
]
&
0xff
)
<<
8
)
|
(
vBuff
[
2
]
&
0xff
);
}
static
int
_vp_get_ota_file_size
(
char
*
file
)
{
int
size
=
0
;
FILE
*
fp
=
NULL
;
char
filePath
[
218
]
=
{
0
};
sprintf
(
filePath
,
"/data/OTA/%s"
,
file
);
fp
=
fopen
(
filePath
,
"r"
);
if
(
fp
==
NULL
){
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
filePath
);
return
0
;
}
fseek
(
fp
,
0
,
SEEK_END
);
size
=
ftell
(
fp
);
fclose
(
fp
);
return
size
;
}
static
void
open_ota_fd
(
char
*
file
)
{
char
filePath
[
218
]
=
{
0
};
sprintf
(
filePath
,
"/data/OTA/%s"
,
file
);
if
(
ota_fp
!=
NULL
){
fclose
(
ota_fp
);
}
ota_fp
=
fopen
(
filePath
,
"rb"
);
if
(
ota_fp
==
NULL
){
debug_log
(
LOG_WARNING_LEVEL
,
"[%s]fopen err!
\n
"
,
filePath
);
}
debug_log
(
LOG_WARNING_LEVEL
,
"open %s
\n
"
,
filePath
);
}
void
kk_vp_ota_file_update_start
(
char
*
file
)
{
if
(
file
==
NULL
){
return
;
}
debug_log
(
LOG_WARNING_LEVEL
,
"file=%s
\n
"
,
file
);
uint8_t
data
[
11
]
=
{
0
};
uint32_t
f_ver
,
f_size
,
crc32
;
f_ver
=
ver
;
f_size
=
_vp_get_ota_file_size
();
crc32
=
_vp_get_ota_file_crc32
();
f_ver
=
get_ota_file_version
(
file
)
;
f_size
=
_vp_get_ota_file_size
(
file
);
crc32
=
_vp_get_ota_file_crc32
(
file
);
data
[
0
]
=
(
f_ver
>>
16
)
&
0xff
;
data
[
1
]
=
(
f_ver
>>
8
)
&
0xff
;
...
...
@@ -1255,11 +1318,17 @@ void kk_vp_ota_file_update_start(uint32_t ver)
debug_log
(
LOG_DEBUG_LEVEL
,
"[LAN->VP]ota file update start,OPCODE=%04X
\n
"
,
OPCODE_VOICE_OTA_UPGRADE_STATR
);
debug_log
(
LOG_DEBUG_LEVEL
,
"File Version=%d.%d.%d,File Size=%d,CRC32 Value=%08X
\n
"
,
(
f_ver
>>
16
)
&
0xff
,(
f_ver
>>
8
&
0xff
),
f_ver
&
0xff
,
f_size
,
crc32
);
char
dateTime
[
64
]
=
{
0
};
time_t
curTime
=
time
(
NULL
);
struct
tm
*
ptm
=
localtime
(
&
curTime
);
snprintf
(
dateTime
,
sizeof
(
dateTime
),
"%d-%d-%d %d:%d:%d"
,(
ptm
->
tm_year
+
1900
),(
ptm
->
tm_mon
+
1
),
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
);
debug_log
(
LOG_EMERG_LEVEL
,
"ota start time:%s
\n
"
,
dateTime
);
vp_send_data_build
(
OPCODE_VOICE_OTA_UPGRADE_STATR
,
sizeof
(
data
),
data
);
open_ota_fd
();
open_ota_fd
(
file
);
}
void
kk_vp_ota_file_update_stop
(
uint32_t
ver
)
{
...
...
@@ -1442,14 +1511,14 @@ static void kk_vp_ota_file_update_start_handle(pro_data_t *pro_data)
static
void
kk_vp_ota_file_update_data_req_handle
(
pro_data_t
*
pro_data
)
{
uint8_
t
err
=
0
;
in
t
err
=
0
;
uint32_t
offset
;
uint16_t
req_size
;
uint8_t
data
[
256
]
=
{
0
};
uint
8
_t
len
=
0
;
uint
8
_t
r_len
=
0
;
uint
8
_t
t_len
=
0
;
uint8_t
data
[
1024
]
=
{
0
};
uint
16
_t
len
=
0
;
uint
16
_t
r_len
=
0
;
uint
16
_t
t_len
=
0
;
uint8_t
*
pCrc
=
NULL
;
uint32_t
crc
;
...
...
@@ -1471,8 +1540,7 @@ static void kk_vp_ota_file_update_data_req_handle(pro_data_t *pro_data)
printf("[file version] not match!%d,%d\n",f_ver,kk_vp_get_config_file_version());
err = 2;
}*/
data
[
len
++
]
=
err
;
data
[
len
++
]
=
(
offset
>>
24
)
&
0xff
;
...
...
@@ -1485,14 +1553,12 @@ static void kk_vp_ota_file_update_data_req_handle(pro_data_t *pro_data)
data
[
len
++
]
=
req_size
&
0xff
;
pCrc
=
&
data
[
len
];
if
(
err
==
0
){
int
err
=
fseek
(
ota_fp
,
offset
,
SEEK_SET
);
if
(
err
==
0
){
while
(
req_size
>
t_len
){
r_len
=
fread
(
&
data
[
len
],
1
,
req_size
,
ota_fp
);
if
(
r_len
>=
0
){
if
(
r_len
>
0
){
t_len
+=
r_len
;
len
+=
r_len
;
}
else
{
...
...
@@ -1503,15 +1569,12 @@ static void kk_vp_ota_file_update_data_req_handle(pro_data_t *pro_data)
debug_log
(
LOG_ERROR_LEVEL
,
"[fseek fail]offset=%d
\n
"
,
offset
);
}
}
crc
=
CreateCrc32
(
pCrc
,
req_size
);
data
[
len
++
]
=
(
crc
>>
24
)
&
0xff
;
data
[
len
++
]
=
(
crc
>>
16
)
&
0xff
;
data
[
len
++
]
=
(
crc
>>
8
)
&
0xff
;
data
[
len
++
]
=
crc
&
0xff
;
vp_reply_data_build
(
pro_data
->
seq
,
pro_data
->
ch
,
OPCODE_VOICE_OTA_REQUEST
,
len
,
data
);
usleep
(
100
*
1000
);
}
...
...
@@ -1532,13 +1595,24 @@ static void kk_vp_ota_file_update_stop_handle(pro_data_t *pro_data)
debug_log
(
LOG_DEBUG_LEVEL
,
"[VP OTA STOP] ver=%d.%d.%d
\n
"
,
pro_data
->
arg
[
1
],
pro_data
->
arg
[
2
],
pro_data
->
arg
[
3
]);
}
}
static
int
kk_voice_ota_finish_notify
(
char
*
ver
)
{
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"nodeid"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
VOICE_OTA_FINISH
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddStringToObject
(
root
,
"arg"
,
ver
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
return
0
;
}
static
void
kk_vp_ota_file_update_status_handle
(
pro_data_t
*
pro_data
)
{
int
err
=
0
;
int
ver
;
char
verBuf
[
16
]
=
{
0
};
unsigned
char
status
;
if
(
pro_data
->
args_len
!=
4
){
return
;
}
...
...
@@ -1546,9 +1620,15 @@ static void kk_vp_ota_file_update_status_handle(pro_data_t *pro_data)
ver
=
MK_UINT24
(
&
pro_data
->
arg
[
0
]);
status
=
pro_data
->
arg
[
3
];
debug_log
(
LOG_DEBUG_LEVEL
,
"
\n
ver=%d.%d.%d,status=%d
\n
"
,
pro_data
->
arg
[
0
],
pro_data
->
arg
[
1
],
pro_data
->
arg
[
2
],
status
);
if
(
status
==
0x00
){
kk_vp_set_state_machine
(
GET_8009_SNAPSHOOT_STATE
);
sprintf
(
verBuf
,
"%d.%d.%d"
,
pro_data
->
arg
[
0
],
pro_data
->
arg
[
1
],
pro_data
->
arg
[
2
]);
kk_vp_voice_version_set
(
verBuf
,
strlen
(
verBuf
));
kk_voice_ota_finish_notify
(
verBuf
);
debug_log
(
LOG_NOTICE_LEVEL
,
"
\n
*********************OTA SUCCESS******************
\n
"
);
}
debug_log
(
LOG_DEBUG_LEVEL
,
"
\n
ver=%d.%d.%d,status=%d
\n
"
,
pro_data
->
arg
[
0
],
pro_data
->
arg
[
1
],
pro_data
->
arg
[
2
],
status
);
uint8_t
data
[
5
]
=
{
0
};
data
[
0
]
=
err
;
...
...
@@ -1559,7 +1639,12 @@ static void kk_vp_ota_file_update_status_handle(pro_data_t *pro_data)
vp_reply_data_build
(
pro_data
->
seq
,
pro_data
->
ch
,
OPCODE_VOICE_OTA_STATUS_NOTIFY
,
sizeof
(
data
),
data
);
//kk_vp_update_result_check(status,ver);
char
dateTime
[
64
]
=
{
0
};
time_t
curTime
=
time
(
NULL
);
struct
tm
*
ptm
=
localtime
(
&
curTime
);
snprintf
(
dateTime
,
sizeof
(
dateTime
),
"%d-%d-%d %d:%d:%d"
,(
ptm
->
tm_year
+
1900
),(
ptm
->
tm_mon
+
1
),
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
);
debug_log
(
LOG_EMERG_LEVEL
,
"ota stop time:%s
\n
"
,
dateTime
);
}
...
...
@@ -1584,6 +1669,92 @@ static void kk_vp_ota_info_query_handle(pro_data_t *pro_data)
}
static
void
kk_voice_switch_handle
(
pro_data_t
*
pro_data
)
{
int
err
=
0
;
int
ver
;
unsigned
char
status
;
if
((
err
=
pro_data
->
arg
[
0
])
==
0
)
{
debug_log
(
LOG_DEBUG_LEVEL
,
"switch=%d
\n
"
,
pro_data
->
arg
[
1
]);
}
}
static
void
kk_voice_volume_handle
(
pro_data_t
*
pro_data
)
{
int
err
=
0
;
int
ver
;
unsigned
char
status
;
char
vol
[
8
]
=
{
0
};
if
((
err
=
pro_data
->
arg
[
0
])
==
0
)
{
debug_log
(
LOG_DEBUG_LEVEL
,
"volume=%d
\n
"
,
pro_data
->
arg
[
1
]);
sprintf
(
vol
,
"%d"
,
pro_data
->
arg
[
1
]);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"node"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
"VOLUME_CTRL"
);
cJSON_AddStringToObject
(
root
,
"arg"
,
vol
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
}
}
#define SOUND_SETE_VP_CH 9
void
vp_send_data_build_ex
(
uint16_t
opCode
,
int
len
,
uint8_t
*
data
)
{
uint8_t
data_buf
[
1024
]
=
{
0
};
int
data_len
=
0
;
pro_data_t
pro_data
;
memset
(
&
pro_data
,
0
,
sizeof
(
pro_data_t
));
pro_data
.
seq
=
vp_get_seq
();
pro_data
.
ch
=
SOUND_SETE_VP_CH
;
pro_data
.
opcode
=
opCode
;
pro_data
.
cf
.
ack
=
0
;
pro_data
.
cf
.
dir
=
1
;
pro_data
.
cf
.
sof_flag
=
1
;
pro_data
.
args_len
=
len
;
memcpy
(
pro_data
.
arg
,
data
,
len
);
data_len
=
proto_frame_to_uart
(
&
pro_data
,
data_buf
);
debug_log
(
LOG_INFO_LEVEL
,
"
\n
[LAN->VP]len=%d
\n
"
,
data_len
);
uint8_t
dataStr
[
512
]
=
{
0
};
for
(
int
i
=
0
;
i
<
data_len
;
i
++
){
snprintf
((
char
*
)
dataStr
+
strlen
((
char
*
)
dataStr
),
sizeof
(
dataStr
),
"%02X "
,
data_buf
[
i
]);
}
debug_log
(
LOG_INFO_LEVEL
,
"%s
\n\n
"
,
dataStr
);
eSerial_WriteBuffer
(
data_buf
,
data_len
);
}
void
kk_voice_control
(
int
val
)
{
uint8_t
res
[
1
]
=
{
0
};
if
(
val
>
100
){
val
=
100
;
}
else
if
(
val
<
0
){
val
=
0
;
}
res
[
0
]
=
val
;
debug_log
(
LOG_DEBUG_LEVEL
,
"sound control
\n
"
);
vp_send_data_build_ex
(
OPCODE_VOICE_CONTROL
,
sizeof
(
res
),
res
);
}
void
kk_voice_switch
(
int
val
)
{
uint8_t
res
[
3
]
=
{
0
};
if
(
val
==
0
||
val
==
1
){
res
[
0
]
=
val
;
res
[
1
]
=
0xff
;
res
[
2
]
=
0xff
;
debug_log
(
LOG_DEBUG_LEVEL
,
"voice switch
\n
"
);
vp_send_data_build
(
OPCODE_VOICE_SWITCH
,
sizeof
(
res
),
res
);
}
}
\ No newline at end of file
application/klansdk/kk_voice_panel_handle.h
View file @
f7ac64c6
...
...
@@ -17,6 +17,7 @@
#define OPCODE_8009_SNAPSHOOT 0x1000
#define OPCODE_SNAPSHOOT 0x1001
#define OPCODE_SCENE_ID_NOTIFY 0x1003
#define OPCODE_VOICE_CONTROL 0x1008
#define OPCODE_SYSTEM_TIME_SET 0x1009
#define OPCODE_SYSTEM_TIME_GET 0x100A
#define OPCODE_ACTION_NOTIFY 0x100B
...
...
@@ -26,8 +27,8 @@
#define OPCODE_CONFIG_FILE_INFO_GET 0x100F
#define OPCODE_CONFIG_FILE_UPDATE_STATUS 0x1010
#define OPCODE_VOICE_CONTROL_NOTIFY 0x1022
#define OPCODE_VOICE_SWITCH 0x1023
#define OPCODE_COMPLETED_TEST_OP 0xEDB4
#define OPCODE_VOICE_OTA_UPGRADE_STATR 0x1016
#define OPCODE_VOICE_OTA_REQUEST 0x1017
#define OPCODE_VOICE_OTA_UPGRADE_STOP 0x1018
...
...
@@ -64,7 +65,7 @@ void kk_vp_get_config_file_info(void);
void
kk_vp_get_ota_file_info
(
void
);
void
kk_vp_ota_file_update_start
(
uint32_t
ver
);
void
kk_vp_ota_file_update_stop
(
uint32_t
ver
);
...
...
@@ -85,15 +86,14 @@ void vp_scene_id_map_deinit(void);
int
vp_scene_id_item_add
(
int
scene_id
);
int
vp_scene_id_item_load
(
int
scene_id
,
uint16_t
map_id
);
int
vp_scene_id_map_save
(
void
);
int
_vp_get_cfg_file_crc32
(
void
);
int
_vp_get_cfg_file_size
(
void
);
void
kk_voice_control
(
int
val
);
int
kk_vp_voice_version_get
(
char
*
ver
,
int
len
);
void
kk_voice_switch
(
int
val
);
void
kk_vp_ota_file_update_start
(
char
*
file
);
void
vp_send_data_build
(
uint16_t
opCode
,
uint8_t
len
,
uint8_t
*
data
);
#endif
common/api/com_api.c
View file @
f7ac64c6
...
...
@@ -94,7 +94,7 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
loop_ctrl
->
isconnect
=
1
;
//if sub, need filter sbuscribe str
if
(
IPC_PLAT2MID
==
loop_ctrl
->
type
||
IPC_MID2PLAT
==
loop_ctrl
->
type
){
validDat
=
_parse_data_by_subscribe
((
char
*
)
dat
,
bytes
,
&
validLen
,
&
chlMark
);
validDat
=
_parse_data_by_subscribe
((
char
*
)
dat
,
bytes
,
&
validLen
,
(
void
**
)
&
chlMark
);
}
else
{
validDat
=
dat
;
validLen
=
bytes
;
...
...
@@ -293,7 +293,7 @@ int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type,char* chlMark, char* i
*
*
==================================*/
void
loop_thread
(
void
*
arg
){
void
*
loop_thread
(
void
*
arg
){
INFO_PRINT
(
"loop_thread start!
\r\n
"
);
ev_run
(
gloop
,
0
);
...
...
common/api/tcp_channel.c
View file @
f7ac64c6
...
...
@@ -615,23 +615,24 @@ static void accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
return 0;
}*/
static
void
loop_tcp_thread
(
void
*
arg
){
static
void
*
loop_tcp_thread
(
void
*
arg
){
INFO_PRINT
(
"loop_tcp_thread start!
\r\n
"
);
int
sd
;
g_loop
=
ev_loop_new
(
EVBACKEND_EPOLL
);
if
(
NULL
==
g_loop
)
{
INFO_PRINT
(
"loop create failed
\r\n
"
);
return
;
return
NULL
;
}
if
(
server_socket_init
(
&
sd
,
NULL
,
CCU_TCP_PORT
)
<
0
)
{
INFO_PRINT
(
"server init failed
\r\n
"
);
return
;
return
NULL
;
}
ev_io_init
(
&
w_accept
,
accept_cb
,
sd
,
EV_READ
);
ev_io_start
(
g_loop
,
&
w_accept
);
ev_run
(
g_loop
,
0
);
close
(
sd
);
return
NULL
;
INFO_PRINT
(
"loop_tcp_thread================== end
\n
"
);
}
...
...
@@ -828,7 +829,7 @@ err1:
return
-
1
;
}
static
void
loop_tcp_client_thread
(
void
*
arg
){
static
void
*
loop_tcp_client_thread
(
void
*
arg
){
INFO_PRINT
(
"loop_tcp_client_thread start!
\r\n
"
);
char
buf
[
1024
]
=
{
0
};
int
ret
=
0
;
...
...
@@ -904,6 +905,7 @@ static void loop_tcp_client_thread(void *arg){
INFO_PRINT
(
"network error, try connect again!
\n
"
);
close
(
g_client_ctrl
.
sd
);
}
return
NULL
;
INFO_PRINT
(
"loop_tcp_client_thread================== end
\n
"
);
}
...
...
common/hal/HAL_OS_linux.c
View file @
f7ac64c6
...
...
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <ctype.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/prctl.h>
...
...
common/hal/kk_product.h
View file @
f7ac64c6
...
...
@@ -46,6 +46,8 @@
#define OTA_IMG_PATH "/data/OTA/"
#define OTA_IMG_FILE "/data/OTA/app_squashfs.img"
#define OTA_IMG_FILE_MD5 "/data/OTA/app_squashfs.img.md5"
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
enum
{
DEVICE_OFFLINE
=
0
,
DEVICE_ONLINE
,
...
...
midware/midware/area/kk_area_handle.c
View file @
f7ac64c6
...
...
@@ -115,7 +115,7 @@ int kk_area_init(void)
if
(
res
!=
SUCCESS_RETURN
){
ERROR_PRINT
(
"[%s][%d]kk_area_init FAIL!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
}
kk_floor_add
(
"默认"
,
"1"
);
//创建默认楼层
//
kk_floor_add("默认","1");//创建默认楼层
return
SUCCESS_RETURN
;
}
static
int
kk_check_room_exist
(
const
char
*
roomId
)
...
...
@@ -303,11 +303,13 @@ int kk_floor_add(const char *name,const char *floorId)
kk_area_ctx_t
*
ctx
=
_kk_area_get_ctx
();
char
*
sqlCmd
=
NULL
;
char
*
zErrMsg
=
0
;
const
char
*
insertCmd
=
NULL
;
if
(
kk_check_floor_exist
(
floorId
)){
return
SUCCESS_RETURN
;
}
const
char
*
insertCmd
=
"insert into floorInfo (name, floorId) \
values ('%s','%s');"
;
insertCmd
=
"UPDATE floorInfo SET name='%s' WHERE floorId= '%s'"
;
}
else
{
insertCmd
=
"insert into floorInfo (name, floorId) \
values ('%s','%s');"
;
}
_kk_area_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
name
,
floorId
);
...
...
@@ -758,7 +760,7 @@ cJSON * kk_get_roomids_by_floorId(const char* floorId)
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
cJSON
*
roomJson
=
cJSON_CreateObject
();
pRoomId
=
sqlite3_column_text
(
stmt
,
DB_ROOM_ID
);
pRoomId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_ROOM_ID
);
cJSON_AddStringToObject
(
roomJson
,
"roomId"
,
pRoomId
);
cJSON_AddItemToArray
(
roomIdsAry
,
roomJson
);
}
...
...
@@ -766,7 +768,7 @@ cJSON * kk_get_roomids_by_floorId(const char* floorId)
sqlite3_free
(
sqlCmd
);
return
roomIdsAry
;
}
char
*
kk_get_floorIds_ary
(
void
)
kk_floor_list_t
*
kk_get_floorIds_ary
(
void
)
{
sqlite3_stmt
*
stmt
;
char
*
pfloorId
=
NULL
;
...
...
@@ -880,7 +882,7 @@ static int kk_check_floorId(int nodeId)
_kk_area_lock
();
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pnode
=
sqlite3_column_text
(
stmt
,
DB_FLOOR_ID
);
pnode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_FLOOR_ID
);
if
(
atoi
(
pnode
)
==
nodeId
)
{
isExist
=
1
;
...
...
@@ -891,7 +893,7 @@ static int kk_check_floorId(int nodeId)
_kk_area_unlock
();
return
isExist
;
}
int
kk_creater_
node
id
(
char
*
floorId
)
int
kk_creater_
floor
id
(
char
*
floorId
)
{
static
int
next
=
100
;
...
...
midware/midware/area/kk_area_handle.h
View file @
f7ac64c6
...
...
@@ -53,5 +53,11 @@ int kk_room_set_floor_info(const char*floorId,const char* floorName,const char *
int
kk_floor_delete_all
(
void
);
int
kk_floor_delete_by_id
(
char
*
floorId
);
int
kk_set_floor_to_default
(
const
char
*
floorId
);
kk_floor_list_t
*
kk_get_floorIds_ary
(
void
);
int
kk_floor_add
(
const
char
*
name
,
const
char
*
floorId
);
cJSON
*
kk_get_roomids_by_floorId
(
const
char
*
floorId
);
int
kk_creater_floorid
(
char
*
floorId
);
void
kk_free_floor_list
(
void
);
cJSON
*
kk_get_roomIds_ary
(
void
);
#endif
midware/midware/dm/kk_dm_msg.h
View file @
f7ac64c6
...
...
@@ -40,7 +40,7 @@ typedef struct {
#define DM_READ_ONLY
#endif
#define DM_MSG_VERSION "1.0"
const
char
DM_MSG_INFO
[]
DM_READ_ONLY
;
//
const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_REGISTER_TOPIC_REPLY "/thing/sub/register_reply"
#define KK_ADD_TOPIC_REPLY "/thing/topo/add_reply"
...
...
@@ -118,6 +118,8 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_THING_SERVICE_DEL_HISTORYALARM_REPLY "/thing/service/delAlarm_reply"
#define KK_THING_SERVICE_DELETEFLOORS "/thing/service/deleteFloors"
#define KK_THING_SERVICE_DELETEFLOORS_REPLY "/thing/service/deleteFloors_reply"
#define KK_THING_SERVICE_UPDATEFLOORS "/thing/service/updateFloors"
#define KK_THING_SERVICE_UPDATEFLOORS_REPLY "/thing/service/updateFloors_reply"
void
kk_sendData2app
(
void
*
info
,
void
*
payload
,
int
isAsync
);
int
dm_msg_thing_sub_register
(
_IN_
char
productCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
...
...
midware/midware/dm/kk_linkkit.c
View file @
f7ac64c6
...
...
@@ -706,19 +706,8 @@ static int kk_service_execute_action(cJSON *action,dm_mgr_dev_node_t *node)
}
void
*
param
=
cJSON_Print
(
action
);
kk_msg_execute_property_set
(
node
->
productCode
,
node
->
deviceCode
,
param
,
node
->
fatherDeviceCode
);
#if 0
for(idx = 0; idx < shadow->property_number; idx++){
pCurrentItem = shadow->properties + idx;
if(pCurrentItem != NULL){
cJSON *pCurrentData = cJSON_GetObjectItem(action, pCurrentItem->identifier);
if(pCurrentData != NULL){
}
}
}
#endif
free
(
param
);
param
=
NULL
;
return
SUCCESS_RETURN
;
...
...
@@ -816,6 +805,25 @@ static int kk_service_setFloor_handle(cJSON *params)
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:更新楼层
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_updateFloor_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
floorId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETER
;
kk_floor_add
(
name
->
valuestring
,
floorId
->
valuestring
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:添加楼层REPLY
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
...
...
@@ -878,32 +886,12 @@ static int kk_service_addFloor_handle(cJSON *params,cJSON *msgId,cJSON *root)
if
(
params
==
NULL
||
msgId
==
NULL
||
root
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
floorArray
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOORS
);
if
(
floorArray
==
NULL
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
return
INVALID_PARAMETER
;
}
//kk_floor_delete_all();
cJSON
*
item
=
floorArray
->
child
;
while
(
item
!=
NULL
){
cJSON
*
name
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETER
;
kk_creater_nodeid
(
floorId
);
kk_floor_add
(
name
->
valuestring
,
floorId
);
cJSON
*
rooms
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ROOM_FLOOR_ROOMS
);
if
(
rooms
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
itemroom
=
rooms
->
child
;
while
(
itemroom
!=
NULL
){
cJSON
*
roomid
=
cJSON_GetObjectItem
(
itemroom
,
MSG_AREA_ROOM_ROOMID
);
if
(
roomid
==
NULL
){
return
INVALID_PARAMETER
;
}
kk_room_set_floor_info
(
floorId
,
name
->
valuestring
,
roomid
->
valuestring
);
itemroom
=
itemroom
->
next
;
}
kk_service_addFloor_reply
(
root
,
msgId
,
floorId
,
name
->
valuestring
);
item
=
item
->
next
;
}
cJSON
*
name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETER
;
kk_creater_floorid
(
floorId
);
kk_floor_add
(
name
->
valuestring
,
floorId
);
kk_service_addFloor_reply
(
root
,
msgId
,
floorId
,
name
->
valuestring
);
return
SUCCESS_RETURN
;
}
...
...
@@ -916,23 +904,12 @@ static int kk_service_addFloor_handle(cJSON *params,cJSON *msgId,cJSON *root)
*************************************************************/
static
int
kk_service_deleteFloor_handle
(
cJSON
*
params
)
{
char
floorId
[
16
]
=
{
0
};
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
floorArray
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOORS
);
if
(
floorArray
==
NULL
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
return
INVALID_PARAMETER
;
}
cJSON
*
item
=
floorArray
->
child
;
while
(
item
!=
NULL
){
cJSON
*
floorId
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
)
return
INVALID_PARAMETER
;
kk_floor_delete_by_id
(
floorId
->
valuestring
);
kk_set_floor_to_default
(
floorId
->
valuestring
);
item
=
item
->
next
;
}
cJSON
*
floorId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_FLOOR_ID
);
if
(
floorId
==
NULL
)
return
INVALID_PARAMETER
;
kk_floor_delete_by_id
(
floorId
->
valuestring
);
return
SUCCESS_RETURN
;
}
/************************************************************
...
...
@@ -1766,6 +1743,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
kk_msg_execute_property_set
(
node
->
productCode
,
node
->
deviceCode
,
out_
,
node
->
fatherDeviceCode
);
cJSON_Delete
(
root_
);
free
(
out_
);
out_
=
NULL
;
}
}
}
...
...
@@ -1870,6 +1848,13 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
kk_service_getFloor_handle
(
info_root
,
msgId
);
//kk_service_common_reply(info_root,msgId,KK_THING_SERVICE_SETFLOOR_REPLY);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_UPDATEFLOORS
)
==
0
){
INFO_PRINT
(
"UPDATEFLOOR
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_updateFloor_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATEFLOORS_REPLY
);
}
else
{
INFO_PRINT
(
"Error msgtype!!!
\n
"
);
}
...
...
@@ -1878,6 +1863,7 @@ directReturn:
_iotx_linkkit_mutex_unlock
();
if
(
payload_Str
!=
NULL
){
free
(
payload_Str
);
payload_Str
=
NULL
;
}
cJSON_Delete
(
json
);
}
...
...
midware/midware/dm/kk_sub_db.c
View file @
f7ac64c6
...
...
@@ -19,6 +19,7 @@
#include "sqlite3.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "kk_area_handle.h"
extern
sqlite3
*
g_kk_pDb
;
typedef
struct
{
...
...
@@ -699,7 +700,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *room
continue
;
}
if
(
strcmp
(
typeArray
[
k
],
"air conditioning gateway"
)
==
0
){
_kk_indoor_air_handle
(
pDeviceCode
,
sceneId
,
propertyName
,
propertyValue
,
type
,
delay
,
node
->
fatherDeviceCode
);
_kk_indoor_air_handle
(
pDeviceCode
,
(
char
*
)
sceneId
,(
char
*
)
propertyName
,(
char
*
)
propertyValue
,(
char
*
)
type
,
delay
,
node
->
fatherDeviceCode
);
continue
;
}
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
...
...
midware/midware/midware.c
View file @
f7ac64c6
...
...
@@ -1435,8 +1435,8 @@ int main(const int argc, const char **argv)
}
kk_sqlite_init
();
kk_tsl_api_init
();
kk_ipc_init
(
IPC_MID2APP
,
mid_cb
,
NULL
,
NULL
);
kk_ipc_init
(
IPC_MID2PLAT
,
mid2p_cb
,
NULL
,
"*"
);
kk_ipc_init
(
IPC_MID2APP
,
(
ipc_cb
*
)
mid_cb
,
NULL
,
NULL
);
kk_ipc_init
(
IPC_MID2PLAT
,
(
ipc_cb
*
)
mid2p_cb
,
NULL
,
"*"
);
kk_init_dmproc
();
kk_heartbeat_init
();
...
...
midware/midware/ota/iotx_ota.c
View file @
f7ac64c6
...
...
@@ -510,7 +510,7 @@ do_exit:
#undef MSG_REQUEST_LEN
}
const
char
OTA_DM_MSG_INFO
[]
=
"{
\"
msgtype
\"
:
\"
%s
\"
,
\"
productCode
\"
:
\"
%s
\"
,
\"
deviceCode
\"
:
\"
%s
\"
}"
;
const
char
KK_URI_OTA_PROCESS
[]
=
"/ota/device/progress/%s/%s"
;
int
OTA_publishProgress
(
void
*
handle
,
char
*
payload
){
OTA_Struct_pt
h_ota
=
(
OTA_Struct_pt
)
handle
;
...
...
@@ -535,7 +535,7 @@ int OTA_publishProgress(void *handle, char* payload){
/* inform OTA to topic: "/ota/device/progress/$(product_key)/$(device_name)" */
// int topicLen = strlen(DM_MSG_INFO) + strlen(h_ota->product_key) + strlen(h_ota->device_name) + 1;
int
topicLen
=
strlen
(
DM_MSG_INFO
)
+
10
+
msgTypeLen
+
strlen
(
h_ota
->
product_key
)
+
strlen
(
h_ota
->
device_name
)
+
1
;
int
topicLen
=
strlen
(
OTA_
DM_MSG_INFO
)
+
10
+
msgTypeLen
+
strlen
(
h_ota
->
product_key
)
+
strlen
(
h_ota
->
device_name
)
+
1
;
char
*
topicBuf
=
malloc
(
topicLen
);
if
(
topicBuf
==
NULL
){
OTA_LOG_ERROR
(
"MALLOC is NULL
\n
"
);
...
...
@@ -543,7 +543,7 @@ int OTA_publishProgress(void *handle, char* payload){
return
IOT_OTAE_INVALID_PARAM
;
}
HAL_Snprintf
(
topicBuf
,
topicLen
,
DM_MSG_INFO
,
msgTypeStr
,
h_ota
->
product_key
,
h_ota
->
device_name
,
""
);
HAL_Snprintf
(
topicBuf
,
topicLen
,
OTA_
DM_MSG_INFO
,
msgTypeStr
,
h_ota
->
product_key
,
h_ota
->
device_name
,
""
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"info"
,
topicBuf
);
...
...
midware/midware/scene/kk_scene_handle.c
View file @
f7ac64c6
...
...
@@ -46,6 +46,7 @@ static int kk_scene_embed_find(const char *sceneId);
static
int
kk_scene_invokeService_find
(
const
char
*
sceneId
);
int
kk_scene_push_timer_info
(
time_t
starttime
,
int
repeatday
,
char
*
sceneId
);
int
bodySensor_load
(
void
);
/*************************************************************
函数实现
*************************************************************/
...
...
midware/midware/scene/kk_scene_handle.h
View file @
f7ac64c6
...
...
@@ -84,5 +84,6 @@ int kk_scene_parse_deletescene(char *sceneId);
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
);
int
BodySensorTrigger_check
(
void
);
#endif
midware/tsl/tsl_handle/kk_tsl_api.c
View file @
f7ac64c6
...
...
@@ -1388,7 +1388,7 @@ int kk_tsl_get_event_by_identifier(_IN_ kk_tsl_t *dev_shadow, _IN_ char *identif
static
int
_kk_tsl_get_service_by_identifier
(
_IN_
kk_tsl_t
*
shadow
,
_IN_
char
*
identifier
,
_OU_
void
**
service
)
{
int
index
=
0
;
kk_tsl_
event_t
*
search_event
=
NULL
;
kk_tsl_
service_t
*
search_service
=
NULL
;
if
(
shadow
==
NULL
||
identifier
==
NULL
||
service
==
NULL
||
*
service
!=
NULL
)
{
...
...
@@ -1396,10 +1396,10 @@ static int _kk_tsl_get_service_by_identifier(_IN_ kk_tsl_t *shadow, _IN_ char *i
}
for
(
index
=
0
;
index
<
shadow
->
service_number
;
index
++
)
{
search_
event
=
shadow
->
services
+
index
;
if
((
strlen
(
search_
event
->
identifier
)
==
strlen
(
identifier
))
&&
(
memcmp
(
search_
event
->
identifier
,
identifier
,
strlen
(
identifier
))
==
0
))
{
*
service
=
(
void
*
)
search_
event
;
search_
service
=
shadow
->
services
+
index
;
if
((
strlen
(
search_
service
->
identifier
)
==
strlen
(
identifier
))
&&
(
memcmp
(
search_
service
->
identifier
,
identifier
,
strlen
(
identifier
))
==
0
))
{
*
service
=
(
void
*
)
search_
service
;
return
SUCCESS_RETURN
;
}
}
...
...
midware/tsl/tsl_handle/kk_tsl_parse.c
View file @
f7ac64c6
...
...
@@ -292,7 +292,7 @@ static int _kk_tsl_array_enum_parse(_IN_ kk_tsl_data_value_t *data_value, _IN_ l
}
static
int
_kk_tsl_array_date_parse
(
_IN_
kk_tsl_data_value_t
*
data_value
,
_IN_
lite_cjson_t
*
root
)
{
kk_tsl_data_value_complex_t
*
complex_array
=
(
kk_tsl_data_value_t
*
)
data_value
->
value
;
kk_tsl_data_value_complex_t
*
complex_array
=
(
kk_tsl_data_value_
complex_
t
*
)
data_value
->
value
;
complex_array
->
value
=
malloc
((
complex_array
->
size
)
*
(
sizeof
(
char
*
)));
if
(
complex_array
->
value
==
NULL
)
{
...
...
tools/board/config.linux.nx5
View file @
f7ac64c6
CONFIG_ENV_CFLAGS += \
-Os -W
all
\
-Os -W
error
\
-g3 --coverage \
-D_PLATFORM_IS_LINUX_ \
...
...
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