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
7b21e73c
Commit
7b21e73c
authored
Nov 08, 2021
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1108代码合并
parent
fd31b751
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
8280 additions
and
7205 deletions
+8280
-7205
application/klansdk/Serial.c
application/klansdk/Serial.c
+450
-448
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+33
-0
application/klansdk/kk_data_mng.c
application/klansdk/kk_data_mng.c
+1
-1
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+4
-0
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+1614
-1456
application/klansdk/kk_lan_sync.h
application/klansdk/kk_lan_sync.h
+97
-76
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+521
-463
application/klansdk/kk_lan_voice_panel.h
application/klansdk/kk_lan_voice_panel.h
+58
-30
application/klansdk/kk_lan_vp_ctrl.c
application/klansdk/kk_lan_vp_ctrl.c
+1275
-660
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+2
-0
application/klansdk/kk_voice_panel_cfg.c
application/klansdk/kk_voice_panel_cfg.c
+1271
-1261
application/klansdk/kk_voice_panel_handle.c
application/klansdk/kk_voice_panel_handle.c
+1816
-1628
application/klansdk/kk_voice_panel_handle.h
application/klansdk/kk_voice_panel_handle.h
+100
-92
application/klansdk/uart_proto.c
application/klansdk/uart_proto.c
+895
-947
application/klansdk/uart_proto.h
application/klansdk/uart_proto.h
+143
-143
No files found.
application/klansdk/Serial.c
View file @
7b21e73c
...
...
@@ -245,6 +245,7 @@ void eSerial_start()
#endif
serial_fd
=
devOpen
(
serialDev
);
printf
(
"------------------------------------>serial_fd=%d
\n
"
,
serial_fd
);
}
/***********************************************************
...
...
@@ -290,7 +291,8 @@ teSerial_Status eSerial_Read(unsigned char *data)
}
else
{
printf
(
"Serial read: %d
\n
"
,
res
);
printf
(
"Serial read: %d,serial_fd=%d
\n
"
,
res
,
serial_fd
);
if
(
res
==
0
)
{
...
...
application/klansdk/kk_data_handle.c
View file @
7b21e73c
...
...
@@ -374,6 +374,22 @@ int kk_data_handle(cJSON *json,int sockfd)
kk_zb_devs_hw_ack
(
sockfd
,
conditions
);
}
else
if
(
strcmp
(
opcode
->
valuestring
,
GET_HISTORY_ALARM_LOG
)
==
0
){
kk_handle_get_history_info
();
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"SOUND_VAL"
)
==
0
){
arg
=
cJSON_GetObjectItem
(
json
,
ARG_STRING
);
int
val
=
atoi
(
arg
->
valuestring
);
if
(
val
>
100
){
val
=
100
;
}
else
if
(
val
<
0
){
val
=
0
;
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"SOUND_SWITCH"
)
==
0
){
arg
=
cJSON_GetObjectItem
(
json
,
ARG_STRING
);
if
(
strcmp
(
arg
->
valuestring
,
"on"
)){
}
else
if
(
strcmp
(
arg
->
valuestring
,
"off"
)){
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
DEL_HISTORY_ALARM_LOG
)
==
0
){
cJSON
*
key
=
cJSON_GetObjectItem
(
json
,
"arg"
);
if
(
key
!=
NULL
){
...
...
@@ -495,8 +511,19 @@ int is_arming_status_notify(cJSON *payload)
return
-
1
;
}
static
void
kk_dev_node_onoffline_handle
(
const
char
*
deviceCode
,
int
online
)
{
kk_map_dev_node_t
*
node
=
NULL
;
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
node
)
!=
0
){
return
;
}
node
->
online_status
=
(
online
==
1
)
?
1
:
0
;
}
static
int
kk_device_onoffline_handle
(
cJSON
*
payload
,
int
online
)
{
if
(
payload
==
NULL
){
return
-
1
;
}
...
...
@@ -504,6 +531,9 @@ static int kk_device_onoffline_handle(cJSON *payload,int online)
if
(
params
==
NULL
)
return
-
1
;
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
params
,
"deviceCode"
);
if
(
deviceCode
==
NULL
)
return
-
1
;
kk_dev_node_onoffline_handle
(
deviceCode
->
valuestring
,
online
);
cJSON
*
hw_info
=
kk_zb_dev_hw_info_build_by_deviceCode
(
0
,
deviceCode
->
valuestring
,
online
);
cJSON
*
root
;
cJSON
*
array
=
cJSON_CreateArray
();
...
...
@@ -515,6 +545,9 @@ static int kk_device_onoffline_handle(cJSON *payload,int online)
cJSON_AddItemToObject
(
root
,
"arg"
,
array
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
return
0
;
}
static
int
kk_del_historyalarm_handle
(
cJSON
*
payload
)
...
...
application/klansdk/kk_data_mng.c
View file @
7b21e73c
...
...
@@ -141,7 +141,7 @@ static kk_map_dev_node_t *kk_map_dev_node_create(const char *deviceCode,const ch
memcpy
(
node
->
deviceCode
,
deviceCode
,
strlen
(
deviceCode
));
memcpy
(
node
->
productCode
,
productCode
,
strlen
(
productCode
));
node
->
online_status
=
(
strcmp
(
onlineStatus
,
"1"
)
==
0
)
?
1
:
0
;
debug_log
(
LOG_ALERT_LEVEL
,
"[add node]node->deviceCode=%s
\n
"
,
node
->
deviceCode
);
debug_log
(
LOG_ALERT_LEVEL
,
"[add node]node->deviceCode=%s
,node->online_status=%d
\n
"
,
node
->
deviceCode
,
node
->
online_status
);
memcpy
(
node
->
opearteType
,
optype
->
valuestring
,
strlen
(
optype
->
valuestring
));
node
->
channelNum
=
channel
->
valueint
;
...
...
application/klansdk/kk_lan_main.c
View file @
7b21e73c
...
...
@@ -157,6 +157,10 @@ int kk_sync_timer_is_running(void)
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
=
0
;
...
...
application/klansdk/kk_lan_sync.c
View file @
7b21e73c
...
...
@@ -971,6 +971,152 @@ char *speedMap[] = {
"UNKONWN"
,
"UNKONWN"
,
};
static
INDOOR_AIR_DEV
indoor_air_status
[
MAX_AC_GW_AIR_NUM
];
int
indoor_airstatus_table_match_item
(
const
char
*
deviceCode
)
{
int
i
;
for
(
i
=
0
;
i
<
MAX_AC_GW_AIR_NUM
;
i
++
){
if
(
strcmp
(
deviceCode
,
indoor_air_status
[
i
].
deviceCode
)
==
0
){
return
i
;
}
}
return
-
1
;
}
int
indoor_airstatus_table_find_empty_item
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
MAX_AC_GW_AIR_NUM
;
i
++
){
if
(
strlen
(
indoor_air_status
[
i
].
deviceCode
)
==
0
){
return
i
;
}
}
return
-
1
;
}
int
indoor_airstatus_table_match_status_item
(
int
epNum
,
INDOOR_AIR_STATUS
*
status
)
{
int
i
;
INDOOR_AIR_STATUS
*
ptr
=
status
;
for
(
i
=
0
;
i
<
MAX_AC_INDOOR_AIR_NUM
;
i
++
,
ptr
++
){
if
(
ptr
->
epNum
==
epNum
){
return
i
;
}
}
return
-
1
;
}
int
indoor_airstatus_table_find_empty_status_item
(
INDOOR_AIR_STATUS
*
status
)
{
int
i
;
INDOOR_AIR_STATUS
*
ptr
=
status
;
for
(
i
=
0
;
i
<
MAX_AC_INDOOR_AIR_NUM
;
i
++
,
ptr
++
){
if
(
ptr
->
epNum
==
0
){
return
i
;
}
}
return
-
1
;
}
int
indoor_airstatus_table_insert_item
(
const
char
*
deviceCode
,
int
epNum
,
int
online
,
int
PowerSwitch
,
double
Temperature
,
int
WindSpeed
,
int
WorkMode
)
{
if
(
PowerSwitch
==
0
&&
Temperature
==
0
&&
WindSpeed
==
0
&&
WorkMode
==
0
){
return
-
1
;
}
int
ix
=
indoor_airstatus_table_match_item
(
deviceCode
);
if
(
ix
!=-
1
){
int
ix2
=
indoor_airstatus_table_match_status_item
(
epNum
,
indoor_air_status
[
ix
].
status
);
if
(
ix2
!=-
1
){
indoor_air_status
[
ix
].
status
[
ix2
].
online
=
online
;
indoor_air_status
[
ix
].
status
[
ix2
].
PowerSwitch
=
PowerSwitch
;
indoor_air_status
[
ix
].
status
[
ix2
].
Temperature
=
Temperature
;
indoor_air_status
[
ix
].
status
[
ix2
].
WindSpeed
=
WindSpeed
;
indoor_air_status
[
ix
].
status
[
ix2
].
WorkMode
=
WorkMode
;
debug_log
(
LOG_NOTICE_LEVEL
,
"[update] ix=%d,ix2=%d
\n
"
,
ix
,
ix2
);
}
else
{
ix2
=
indoor_airstatus_table_find_empty_status_item
(
indoor_air_status
[
ix
].
status
);
if
(
ix2
==-
1
){
debug_log
(
LOG_WARNING_LEVEL
,
"table full!!!
\n
"
);
return
-
1
;
}
debug_log
(
LOG_NOTICE_LEVEL
,
"[add] epNum=%d,ix2=%d
\n
"
,
epNum
,
ix2
);
indoor_air_status
[
ix
].
status
[
ix2
].
epNum
=
epNum
;
indoor_air_status
[
ix
].
status
[
ix2
].
online
=
online
;
indoor_air_status
[
ix
].
status
[
ix2
].
PowerSwitch
=
PowerSwitch
;
indoor_air_status
[
ix
].
status
[
ix2
].
Temperature
=
Temperature
;
indoor_air_status
[
ix
].
status
[
ix2
].
WindSpeed
=
WindSpeed
;
indoor_air_status
[
ix
].
status
[
ix2
].
WorkMode
=
WorkMode
;
}
}
else
{
ix
=
indoor_airstatus_table_find_empty_item
();
if
(
ix
==-
1
){
debug_log
(
LOG_WARNING_LEVEL
,
"table full!!!
\n
"
);
return
-
1
;
}
debug_log
(
LOG_NOTICE_LEVEL
,
"[add] deviceCode=%s
\n
"
,
deviceCode
);
snprintf
(
indoor_air_status
[
ix
].
deviceCode
,
PRODUCT_CODE_LEN
,
"%s"
,
deviceCode
);
indoor_air_status
[
ix
].
status
[
0
].
epNum
=
epNum
;
indoor_air_status
[
ix
].
status
[
0
].
online
=
online
;
indoor_air_status
[
ix
].
status
[
0
].
PowerSwitch
=
PowerSwitch
;
indoor_air_status
[
ix
].
status
[
0
].
Temperature
=
Temperature
;
indoor_air_status
[
ix
].
status
[
0
].
WindSpeed
=
WindSpeed
;
indoor_air_status
[
ix
].
status
[
0
].
WorkMode
=
WorkMode
;
}
return
0
;
}
INDOOR_AIR_STATUS
*
indoor_airstatus_table_find_item
(
const
char
*
deviceCode
,
int
epNum
)
{
int
ix
=
indoor_airstatus_table_match_item
(
deviceCode
);
if
(
ix
!=-
1
){
int
ix2
=
indoor_airstatus_table_match_status_item
(
epNum
,
indoor_air_status
[
ix
].
status
);
if
(
ix2
!=-
1
){
return
&
indoor_air_status
[
ix
].
status
[
ix2
];
}
}
return
NULL
;
}
int
indoor_airstatus_table_delete_item
(
const
char
*
deviceCode
)
{
debug_log
(
LOG_NOTICE_LEVEL
,
"[delete] deviceCode=%s
\n
"
,
deviceCode
);
int
ix
=
indoor_airstatus_table_match_item
(
deviceCode
);
if
(
ix
!=-
1
){
memset
(
indoor_air_status
[
ix
].
deviceCode
,
0
,
PRODUCT_CODE_LEN
);
for
(
int
i
=
0
;
i
<
MAX_AC_INDOOR_AIR_NUM
;
i
++
){
memset
(
&
indoor_air_status
[
ix
].
status
[
i
],
0
,
sizeof
(
INDOOR_AIR_STATUS
));
}
}
else
{
return
-
1
;
}
return
0
;
}
int
kk_send_indoorAir_status
(
cJSON
*
info
,
const
char
*
deviceCode
)
{
char
epStr
[
4
]
=
{
0
};
...
...
@@ -1011,6 +1157,8 @@ int kk_send_indoorAir_status(cJSON *info,const char *deviceCode)
cJSON_AddStringToObject
(
arg
,
"runModel"
,
modeMap
[
WorkMode
->
valueint
]);
cJSON_AddItemToObject
(
root
,
"arg"
,
arg
);
indoor_airstatus_table_insert_item
(
deviceCode
,
atoi
(
epNum
->
valuestring
),
1
,
PowerSwitch
->
valueint
,
Temperature
->
valuedouble
,
WindSpeed
->
valueint
,
WorkMode
->
valueint
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
return
0
;
...
...
@@ -1052,6 +1200,7 @@ cJSON *kk_sync_central_ac_to_sdk(cJSON *root,cJSON *data)
kk_creater_nodeid
(
deviceCode
->
valuestring
,
1
,
ac_gw_nodeid
);
cJSON
*
properties
=
cJSON_GetObjectItem
(
subitem
,
"properties"
);
cJSON
*
onlineStatus
=
cJSON_GetObjectItem
(
subitem
,
"onlineStatus"
);
cJSON
*
indoorItem
=
cJSON_CreateObject
();
kk_get_ac_indoor_info_by_deviceCode
(
data
,
deviceCode
->
valuestring
,
roomId
,
NULL
,
1
);
...
...
@@ -1065,6 +1214,8 @@ cJSON *kk_sync_central_ac_to_sdk(cJSON *root,cJSON *data)
cJSON
*
epsAry
=
cJSON_GetObjectItem
(
properties
,
"eps"
);
cJSON
*
EpTotal
=
cJSON_GetObjectItem
(
properties
,
"EpTotal"
);
int
epsize
=
cJSON_GetArraySize
(
epsAry
);
g_indoor_item
=
(
CENTRAL_AC_INDOOR_ITEM
*
)
malloc
(
sizeof
(
CENTRAL_AC_INDOOR_ITEM
)
*
epsize
);
if
(
g_indoor_item
==
NULL
){
...
...
@@ -1097,6 +1248,13 @@ cJSON *kk_sync_central_ac_to_sdk(cJSON *root,cJSON *data)
memcpy
(
g_indoor_item
[
k
].
ac_gw_status
.
speed
,
speedMap
[
WindSpeed
->
valueint
],
strlen
(
speedMap
[
WindSpeed
->
valueint
]));
cJSON
*
WorkMode
=
cJSON_GetObjectItem
(
infoItem
,
"WorkMode"
);
memcpy
(
g_indoor_item
[
k
].
ac_gw_status
.
mode
,
modeMap
[
WorkMode
->
valueint
],
strlen
(
modeMap
[
WorkMode
->
valueint
]));
cJSON
*
epNum
=
cJSON_GetObjectItem
(
infoItem
,
"epNum"
);
indoor_airstatus_table_insert_item
(
deviceCode
->
valuestring
,
epNum
->
valueint
,
onlineStatus
->
valueint
,
PowerSwitch
->
valueint
,
Temperature
->
valuedouble
,
WindSpeed
->
valueint
,
WorkMode
->
valueint
);
debug_log
(
LOG_EMERG_LEVEL
,
"mark!!!
\n
"
);
}
kk_create_new_central_ac
(
gwDeviceCode
->
valuestring
,
deviceCode
->
valuestring
,
nodeid
);
}
...
...
application/klansdk/kk_lan_sync.h
View file @
7b21e73c
...
...
@@ -3,6 +3,8 @@
#include "cJSON.h"
#define MAX_AC_GW_AIR_NUM 5
#define MAX_AC_INDOOR_AIR_NUM 16
#define AIR_AC_INDOOR_ID_SIZE 8
#define AIR_AC_INDOOR_ROOM_ID_SIZE 24
...
...
@@ -46,6 +48,23 @@ typedef struct{
}
SYN_SCENE_ITEM
;
typedef
struct
{
int
epNum
;
int
online
;
int
PowerSwitch
;
double
Temperature
;
int
WindSpeed
;
int
WorkMode
;
}
INDOOR_AIR_STATUS
;
typedef
struct
{
char
deviceCode
[
PRODUCT_CODE_LEN
];
INDOOR_AIR_STATUS
status
[
MAX_AC_INDOOR_AIR_NUM
];
}
INDOOR_AIR_DEV
;
cJSON
*
kk_get_raw_sync_data
(
cJSON
*
payload
);
...
...
@@ -64,7 +83,9 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type);
int
indoor_airstatus_table_insert_item
(
const
char
*
deviceCode
,
int
epNum
,
int
online
,
int
PowerSwitch
,
double
Temperature
,
int
WindSpeed
,
int
WorkMode
);
INDOOR_AIR_STATUS
*
indoor_airstatus_table_find_item
(
const
char
*
deviceCode
,
int
epNum
);
int
indoor_airstatus_table_delete_item
(
const
char
*
deviceCode
);
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
7b21e73c
...
...
@@ -96,9 +96,14 @@ typedef struct {
}
vpCFGInfo
;
typedef
struct
{
int
state
;
int
set_time_flag
;
int
get_ver_flag
;
int
ota_update_flag
;
int
file_update_flag
;
vpCFGInfo
cfg_info
;
int
updateFlag
;
}
VP_MANAGE
;
...
...
@@ -185,36 +190,20 @@ static int _vp_config_file_version_load(void)
return
1
;
}
void
kk_vp_set_updateFlag
(
int
flag
)
{
vp_mag
.
updateFlag
=
(
flag
!=
0
)
?
1
:
0
;
}
void
kk_v
p_config_file_update
(
void
)
void
kk_v
oice_update_config_file
(
void
)
{
if
(
vp_mag
.
updateFlag
==
0
){
return
;
}
kk_vp_config_file_update_stop
(
vp_mag
.
cfg_info
.
f_ver
);
if
(
vp_mag
.
state
==
UPDATING_8009_CONFIG_FILE_INFO
||
vp_mag
.
state
==
START_8009_CONFIG_FILE_UPDATE
){
kk_vp_set_state_machine
(
STOP_8009_CONFIG_FILE_UPDATE
);
}
else
{
kk_vp_set_state_machine
(
START_8009_CONFIG_FILE_UPDATE
);
}
kk_vp_config_file_update_start
(
vp_mag
.
cfg_info
.
next_ver
);
kk_vp_set_updateFlag
(
0
);
vp_mag
.
file_update_flag
=
1
;
}
void
kk_vp_set_state_machine
(
int
state
)
{
if
(
vp_mag
.
state
!=
state
){
INFO_PRINT
(
"[vp state machine]%d->%d
\n
"
,
vp_mag
.
state
,
state
);
vp_mag
.
state
=
state
;
}
}
int
kk_vp_get_config_file_version
(
void
)
{
...
...
@@ -244,8 +233,9 @@ void kk_vp_cfg_info_check(uint32_t f_ver,uint32_t f_size,uint32_t crc32)
printf
(
"[VP]File Version=%08x,File Size=%08x,CRC32=%08x
\n
"
,
f_ver
,
f_size
,
crc32
);
printf
(
"[LAN]File Version=%08x,File Size=%08x,CRC32=%08x
\n
"
,
vp_mag
.
cfg_info
.
f_ver
,
vp_mag
.
cfg_info
.
f_size
,
vp_mag
.
cfg_info
.
crc32
);
kk_vp_set_updateFlag
(
1
);
printf
(
"[%s][%d]update config file.
\n
"
,
__FUNCTION__
,
__LINE__
);
debug_log
(
LOG_EMERG_LEVEL
,
"-------------------->start update config file<------------------
\n
"
);
kk_voice_update_config_file
();
}
}
...
...
@@ -254,13 +244,29 @@ void kk_vp_update_result_check(uint8_t status,uint32_t f_ver)
if
(
status
==
0
&&
(
vp_mag
.
cfg_info
.
f_ver
==
f_ver
)
){
vp_mag
.
cfg_info
.
next_ver
=
vp_mag
.
cfg_info
.
f_ver
+
1
;
printf
(
"[cfg ver]File Version=%08x
\n
"
,
vp_mag
.
cfg_info
.
f_ver
);
kk_vp_set_state_machine
(
GET_8009_CONFIG_FILE_INFO
);
}
else
{
kk_vp_set_updateFlag
(
1
);
printf
(
"[%s][%d]update config file.
\n
"
,
__FUNCTION__
,
__LINE__
);
debug_log
(
LOG_EMERG_LEVEL
,
"-------------------->start update config file again<------------------
\n
"
);
kk_voice_update_config_file
();
}
}
void
kk_voice_reset_ver_flag
(
void
)
{
vp_mag
.
get_ver_flag
=
0
;
vp_mag
.
ota_update_flag
=
0
;
}
void
kk_voice_set_time_flag
(
void
)
{
vp_mag
.
set_time_flag
=
1
;
}
void
kk_get_voice_version
(
void
)
{
debug_log
(
LOG_INFO_LEVEL
,
"mark!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\n
"
);
vp_mag
.
get_ver_flag
=
1
;
}
...
...
@@ -270,13 +276,11 @@ void kk_vp_update_result_check(uint8_t status,uint32_t f_ver)
int
kk_vp_config_file_info_check
(
int
f_ver
,
int
f_size
,
int
crc32
)
{
kk_vp_set_state_machine
(
UPDATING_8009_CONFIG_FILE_INFO
);
if
(
vp_mag
.
cfg_info
.
f_ver
==
f_ver
&&
vp_mag
.
cfg_info
.
f_size
==
f_size
&&
vp_mag
.
cfg_info
.
crc32
==
crc32
){
kk_vp_set_state_machine
(
UPDATING_8009_CONFIG_FILE_INFO
);
return
1
;
}
...
...
@@ -301,6 +305,8 @@ void kk_voice_ota_mtu_set(uint16_t mtu)
void
kk_vp_manage_init
(
void
)
{
kk_voice_ota_mtu_set
(
KK_VOICE_OTA_MTU
);
vp_scene_id_map_load
();
_vp_config_file_version_load
();
vp_mag
.
cfg_info
.
f_size
=
_vp_get_cfg_file_size
();
...
...
@@ -310,63 +316,80 @@ void kk_vp_manage_init(void)
void
*
kk_vp_manage_thread
(
void
*
arg
)
{
INFO_PRINT
(
"[%s] start...
\n
"
,
__FUNCTION__
);
usleep
(
100
*
1000
);
kk_vp_manage_init
();
while
(
1
)
{
kk_vp_config_file_update
();
if
(
vp_mag
.
file_update_flag
==
1
||
vp_mag
.
ota_update_flag
==
1
){
sleep
(
1
);
continue
;
}
kk_vp_get_config_file_info
();
sleep
(
60
*
30
);
}
switch
(
vp_mag
.
state
){
case
GET_8009_SNAPSHOOT_STATE
:
kk_vp_get_8009_snapshoot
();
kk_vp_get_ota_file_info
();
ERROR_PRINT
(
"[%s]thread end...
\n
"
,
__FUNCTION__
);
return
0
;
}
sleep
(
5
);
break
;
static
void
*
kk_voice_ctrl_status_thread
(
void
*
arg
)
{
debug_log
(
LOG_INFO_LEVEL
,
"[%s] start...
\n
"
,
__FUNCTION__
);
case
SET_8009_SYSTEM
:
kk_vp_set_8009_system_time
();
sleep
(
5
);
break
;
case
START_8009_CONFIG_FILE_UPDATE
:
#define SET_8009_TIME (60*60)
kk_vp_config_file_update_start
(
vp_mag
.
cfg_info
.
next_ver
);
kk_vp_set_state_machine
(
UPDATING_8009_CONFIG_FILE_INFO
);
break
;
case
UPDATING_8009_CONFIG_FILE_INFO
:
//debug_log(LOG_INFO,"updating...\n");
static
time_t
set_time
;
while
(
1
)
{
int
delay
=
1
;
time_t
curTime
=
time
(
NULL
);
if
(
vp_mag
.
get_ver_flag
==
0
){
debug_log
(
LOG_DEBUG_LEVEL
,
"get 8009 snapshoot
\n
"
);
kk_vp_get_8009_snapshoot
();
sleep
(
2
);
continue
;
}
if
(
vp_mag
.
set_time_flag
==
0
){
struct
tm
*
c
=
localtime
(
&
curTime
);
if
(
c
->
tm_year
!=
70
){
set_time
=
curTime
;
debug_log
(
LOG_NOTICE_LEVEL
,
"set 8009 system time
\n
"
);
kk_vp_set_8009_system_time
();
}
sleep
(
2
);
continue
;
}
if
(
vp_mag
.
file_update_flag
==
1
||
vp_mag
.
ota_update_flag
==
1
){
sleep
(
1
);
//todo :超时取消
break
;
continue
;
}
case
STOP_8009_CONFIG_FILE_UPDATE
:
kk_vp_config_file_update_stop
(
vp_mag
.
cfg_info
.
f_ver
);
if
(
vp_mag
.
updateFlag
==
1
){
kk_vp_set_state_machine
(
UPDATING_8009_CONFIG_FILE_INFO
);
}
else
{
kk_vp_set_state_machine
(
GET_8009_CONFIG_FILE_INFO
);
if
((
curTime
-
set_time
)
>=
SET_8009_TIME
){
set_time
=
curTime
;
debug_log
(
LOG_NOTICE_LEVEL
,
"[timing %ds] set 8009 system time
\n
"
,
SET_8009_TIME
);
kk_vp_set_8009_system_time
();
}
sleep
(
3
);
break
;
case
GET_8009_CONFIG_FILE_INFO
:
kk_vp_get_config_file_info
();
sleep
(
15
);
break
;
default:
break
;
if
(
delay
){
usleep
(
100
*
1000
);
}
usleep
(
50
*
1000
);
}
ERROR_PRINT
(
"[%s]thread end...
\n
"
,
__FUNCTION__
);
return
0
;
}
void
kk_voice_panel_uart_dev_chose
(
int
argc
,
char
*
argv
[])
{
int
flag
=
0
;
...
...
@@ -407,12 +430,43 @@ static int kk_vp_cfg_file_dir_create(void){
return
system
(
cmd
);
}
static
pthread_mutex_t
voice_uart_mutex
;
void
voice_uart_lock
(
void
)
{
pthread_mutex_lock
(
&
voice_uart_mutex
);
}
void
voice_uart_unlock
(
void
)
{
pthread_mutex_unlock
(
&
voice_uart_mutex
);
}
void
kk_voice_ota_start
(
char
*
in
)
{
char
file
[
128
]
=
{
0
};
char
*
ptr
=
strstr
(
in
,
"_"
);
if
(
ptr
!=
NULL
)
{
snprintf
(
file
,
sizeof
(
file
),
"/data/OTA/%s"
,
ptr
+
1
);
}
else
{
snprintf
(
file
,
sizeof
(
file
),
"/data/OTA/%s"
,
in
);
}
debug_log
(
LOG_WARNING_LEVEL
,
"%s.
\n
"
,
file
);
kk_vp_ota_file_update_start
(
file
);
}
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[])
{
size_t
s
=
1500
;
pthread_t
uart_tid
=
0
;
pthread_t
mag_tid
=
0
;
pthread_t
t_tid
=
0
;
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
...
...
@@ -443,6 +497,10 @@ int kk_voice_panel_init(int argc, char* argv[])
return
-
3
;
}
if
((
pthread_create
(
&
t_tid
,
NULL
,
kk_voice_ctrl_status_thread
,
NULL
))
!=
0
)
{
return
-
4
;
}
return
0
;
}
...
...
application/klansdk/kk_lan_voice_panel.h
View file @
7b21e73c
...
...
@@ -8,23 +8,51 @@
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[]);
#define GET_8009_SNAPSHOOT_STATE 0
#define SET_8009_SYSTEM 1
#define START_8009_CONFIG_FILE_UPDATE 2
#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
);
void
voice_uart_lock
(
void
);
void
voice_uart_unlock
(
void
);
void
kk_voice_ota_start
(
char
*
in
);
int
kk_voice_exit_factory_mode
(
void
);
void
kk_voice_ota_mtu_set
(
uint16_t
mtu
);
void
kk_voice_update_config_file
(
void
);
void
kk_voice_reset_ver_flag
(
void
);
void
kk_get_voice_version
(
void
);
#endif
application/klansdk/kk_lan_vp_ctrl.c
View file @
7b21e73c
This diff is collapsed.
Click to expand it.
application/klansdk/kk_oldccu_msg.c
View file @
7b21e73c
...
...
@@ -560,7 +560,9 @@ int kk_lan_device_delete_notify(cJSON *payload)
return
-
1
;
}
indoor_airstatus_table_delete_item
(
deviceCode
->
valuestring
);
_kk_lan_delete_device
(
deviceCode
->
valuestring
);
return
0
;
}
...
...
application/klansdk/kk_voice_panel_cfg.c
View file @
7b21e73c
...
...
@@ -390,7 +390,11 @@ static int kk_vp_sync_device_multi_eps(_IN cJSON *zbDevsAry,_IN cJSON *dev,_IN c
if
(
kk_map_dev_search_by_deviceCode
(
pDevs
->
mac
,
&
node
)
==
0
){
/*if(strcmp(pDevs->online,"1")==0){
node->online_status = 1;
}else{
node->online_status = 0;
}*/
snprintf
(
pDevs
->
operateType
,
sizeof
(
pDevs
->
operateType
)
-
1
,
"%s"
,
node
->
opearteType
);
}
else
{
...
...
@@ -467,6 +471,12 @@ static int kk_vp_sync_device_single_ep(_IN cJSON *zbDevsAry,_IN cJSON *dev,_IN c
if
(
kk_map_dev_search_by_deviceCode
(
pDevs
->
mac
,
&
node
)
==
0
){
snprintf
(
pDevs
->
operateType
,
sizeof
(
pDevs
->
operateType
)
-
1
,
"%s"
,
node
->
opearteType
);
/*if(strcmp(pDevs->online,"1")==0){
node->online_status = 1;
}else{
node->online_status = 0;
}*/
}
else
{
if
(
is_ac_gw_pid
(
atoi
(
pDevs
->
pid
))
!=
0
){
...
...
application/klansdk/kk_voice_panel_handle.c
View file @
7b21e73c
This diff is collapsed.
Click to expand it.
application/klansdk/kk_voice_panel_handle.h
View file @
7b21e73c
...
...
@@ -37,6 +37,7 @@
#define KK_VOICE_OTA_MTU 128
typedef
void
(
*
vp_handle_func
)(
pro_data_t
*
pro_data
);
...
...
@@ -65,7 +66,7 @@ void kk_vp_get_config_file_info(void);
void
kk_vp_get_ota_file_info
(
void
);
void
kk_vp_ota_file_update_start
(
char
*
file
);
void
kk_vp_ota_file_update_stop
(
uint32_t
ver
);
...
...
@@ -86,6 +87,10 @@ 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
);
...
...
@@ -93,7 +98,10 @@ 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
);
void
vp_send_data_build
(
uint16_t
opCode
,
int
len
,
uint8_t
*
data
);
void
kk_voice_set_time_flag
(
void
);
#endif
application/klansdk/uart_proto.c
View file @
7b21e73c
...
...
@@ -378,11 +378,11 @@ uint8_t cf_to_uint8_t(control_field_t *cf)
return
((((
uint8_t
)(
cf
->
ack
)))
+
((
cf
->
dir
)
<<
5
)
+
((
cf
->
sof_flag
)
<<
4
)
+
((
cf
->
mf_flag
)
<<
3
));
}
uint
8_t
proto_frame_to_uart
(
pro_data_t
*
pro_data
,
uint8_t
*
uart_data
)
uint
16_t
proto_frame_to_uart
(
pro_data_t
*
pro_data
,
uint8_t
*
uart_data
)
{
uint
8_t
i
=
0
;
uint
16_t
i
=
0
;
uint16_t
cf
;
uint8_t
len
;
int
len
;
uint16_t
crc
;
uart_data
[
i
++
]
=
PRO_SOF_1
;
...
...
@@ -422,7 +422,7 @@ void pro_send_link_ack(pro_data_t *pro_data)
uint8_t
buf
[
PRO_LINK_PAKCET_SIZE
];
uint16_t
len
=
2
;
uint16_t
crc
;
uint
8_t
i
=
0
;
uint
16_t
i
=
0
;
buf
[
i
++
]
=
PRO_SOF_1
;
buf
[
i
++
]
=
PRO_SOF_2
;
...
...
@@ -464,16 +464,15 @@ void dev_send_uart(uint8_t *data, uint16_t data_len)
static
void
uart_protocol_print
(
pro_data_t
*
pro_data
)
{
debug_log
(
LOG_DEBUG_LEVEL
,
"
\n
[VP->LAN]
\n
"
);
debug_log
(
LOG_DEBUG_LEVEL
,
"seq:
\t\t
%02X
\n
"
,
pro_data
->
seq
);
debug_log
(
LOG_DEBUG_LEVEL
,
"channel:
\t
%02X
\n
"
,
pro_data
->
ch
);
debug_log
(
LOG_DEBUG_LEVEL
,
"opcode:
\t
\t
%04X
\n
"
,
pro_data
->
opcode
);
debug_log
(
LOG_DEBUG_LEVEL
,
"opcode:
\t
%04X
\n
"
,
pro_data
->
opcode
);
debug_log
(
LOG_DEBUG_LEVEL
,
"args_len:
\t
%d
\n
"
,
pro_data
->
args_len
);
char
print_buf
[
512
]
=
{
0
};
int
i
=
0
;
snprintf
(
print_buf
,
sizeof
(
print_buf
),
"args:
\t
\t
"
);
snprintf
(
print_buf
,
sizeof
(
print_buf
),
"args:
\t
"
);
for
(
i
=
0
;
i
<
pro_data
->
args_len
;
i
++
)
{
...
...
@@ -499,7 +498,7 @@ void connect_status_ack(pro_data_t pro_data)
pro_data_tmp
.
arg
[
pro_data_tmp
.
args_len
++
]
=
0
;
// err status
uint8_t
data_buf
[
255
]
=
{
0
};
uint8_t
data_len
=
0
;
int
data_len
=
0
;
data_len
=
proto_frame_to_uart
(
&
pro_data_tmp
,
data_buf
);
dev_send_uart
(
data_buf
,
data_len
);
...
...
@@ -518,7 +517,7 @@ void system_restart_ack(pro_data_t pro_data)
pro_data_tmp
.
arg
[
pro_data_tmp
.
args_len
++
]
=
0
;
// err status
uint8_t
data_buf
[
255
]
=
{
0
};
uint8_t
data_len
=
0
;
int
data_len
=
0
;
data_len
=
proto_frame_to_uart
(
&
pro_data_tmp
,
data_buf
);
dev_send_uart
(
data_buf
,
data_len
);
...
...
@@ -744,7 +743,7 @@ void set_mac_ack(pro_data_t pro_data)
pro_data_tmp
.
cf
.
sof_flag
=
0
;
//pro_data_tmp.arg[pro_data_tmp.args_len++] = 0; // err status
uint8_t
mac_len
=
pro_data_tmp
.
arg
[
0
];
int
mac_len
=
pro_data_tmp
.
arg
[
0
];
int
i
=
0
;
for
(
i
=
0
;
i
<
mac_len
;
i
++
)
...
...
@@ -771,7 +770,7 @@ void set_mac_ack(pro_data_t pro_data)
pro_data_tmp
.
args_len
++
;
uint8_t
data_buf
[
255
]
=
{
0
};
uint8_t
data_len
=
0
;
int
data_len
=
0
;
data_len
=
proto_frame_to_uart
(
&
pro_data_tmp
,
data_buf
);
dev_send_uart
(
data_buf
,
data_len
);
...
...
@@ -806,7 +805,7 @@ void read_flash_mac_ack(pro_data_t pro_data)
uint8_t
data_buf
[
255
]
=
{
0
};
uint8_t
data_len
=
0
;
int
data_len
=
0
;
data_len
=
proto_frame_to_uart
(
&
pro_data_tmp
,
data_buf
);
dev_send_uart
(
data_buf
,
data_len
);
...
...
@@ -876,7 +875,7 @@ extern void kk_vp_opcode_handle(pro_data_t *pro_data);
void
uart_frame_handle
()
{
uint8_t
*
data
=
g_uart_data
.
data
;
uint8_t
data_len
=
g_uart_data
.
data_len
;
int
data_len
=
g_uart_data
.
data_len
;
pro_data_t
pro_data
;
//uint8_t pro_data_buf[256];
...
...
@@ -891,57 +890,6 @@ void uart_frame_handle()
kk_vp_opcode_handle
(
&
pro_data
);
// handle msg
switch
(
pro_data
.
opcode
)
{
case
OPCODE_CONNECT_STATUS_QUERY
:
{
connect_status_ack
(
pro_data
);
break
;
}
case
OPCODE_BURN_MAC
:
{
//��ʱ��֧��
set_mac_ack
(
pro_data
);
break
;
}
case
OPCODE_READ_MAC
:
{
read_mac_ack
(
pro_data
);
break
;
}
case
OPCODE_READ_VERSION
:
{
read_version_ack
(
pro_data
);
break
;
}
case
OPCODE_EXIT_SUBBOARD_TEST
:
{
exit_subboard_test_ack
(
pro_data
);
break
;
}
case
OPCODE_READ_MAC_FROM_FLASH
:
{
read_flash_mac_ack
(
pro_data
);
break
;
}
case
OPCODE_SYSTEM_RESTART
:
{
system_restart_ack
(
pro_data
);
break
;
}
default:
{
//GW_LOG_DBG("gw others opcode %04X ack\n", pro_data.opcode);
break
;
}
}
return
;
}
application/klansdk/uart_proto.h
View file @
7b21e73c
...
...
@@ -113,7 +113,7 @@ typedef struct
uint8_t
ch
;
uint16_t
opcode
;
uint16_t
args_len
;
uint8_t
arg
[
256
];
uint8_t
arg
[
1024
];
}
pro_data_t
;
int
my_system
(
const
char
*
cmd
);
...
...
@@ -130,7 +130,7 @@ int get_proto_frame(uint8_t *data, uint16_t data_len, pro_data_t *pro_data);
void
pro_send_link_ack
(
pro_data_t
*
pro_data
);
uint
8_t
proto_frame_to_uart
(
pro_data_t
*
pro_data
,
uint8_t
*
uart_data
);
uint
16_t
proto_frame_to_uart
(
pro_data_t
*
pro_data
,
uint8_t
*
uart_data
);
int
get_uart_frame
(
uint8_t
*
buf
,
int
len
);
void
uart_frame_handle
();
...
...
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