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
4d9d15b7
Commit
4d9d15b7
authored
Aug 31, 2021
by
陈伟灿
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yjq' into 'master'
【20210831】修复局越网地暖控制上报问题。优化配置表解析。 See merge request chenweican/k-sdk!117
parents
9da143b4
b804d326
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
721 additions
and
584 deletions
+721
-584
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+18
-18
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+123
-123
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+191
-192
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+4
-4
application/klansdk/kk_ccu_msg.c
application/klansdk/kk_ccu_msg.c
+163
-100
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+5
-6
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+11
-11
application/klansdk/kk_lan_debug.h
application/klansdk/kk_lan_debug.h
+11
-9
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+44
-4
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+6
-3
application/klansdk/kk_lan_voice_panel.c
application/klansdk/kk_lan_voice_panel.c
+3
-3
application/klansdk/kk_lan_vp_ctrl.c
application/klansdk/kk_lan_vp_ctrl.c
+5
-3
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+77
-41
application/klansdk/kk_voice_panel_handle.h
application/klansdk/kk_voice_panel_handle.h
+2
-2
opcodeMapCfg/device_3024.json
opcodeMapCfg/device_3024.json
+56
-56
opcodeMapCfg/device_3029.json
opcodeMapCfg/device_3029.json
+2
-9
No files found.
application/kcloud/kcloud_main.c
View file @
4d9d15b7
...
...
@@ -29,31 +29,31 @@
//#include "kcloud_log.h"
static
char
s_ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
int
KK_Get_ccuid
(
_OU_
char
*
device_code
)
{
strncpy
(
device_code
,
s_ccuid
,
strlen
(
s_ccuid
));
printf
(
"HAL_Get_ccuid:%s
\n
"
,
s_ccuid
);
return
strlen
(
s_ccuid
);
{
strncpy
(
device_code
,
s_ccuid
,
strlen
(
s_ccuid
));
printf
(
"HAL_Get_ccuid:%s
\n
"
,
s_ccuid
);
return
strlen
(
s_ccuid
);
}
static
int
_setDevice_Code
(
_IN_
char
*
device_code
,
int
len
)
{
memset
(
s_ccuid
,
0x0
,
DEVICE_CODE_LEN
);
printf
(
"_setDevice_Code:%s
\n
"
,
device_code
);
strncpy
(
s_ccuid
,
device_code
,
len
);
return
len
;
memset
(
s_ccuid
,
0x0
,
DEVICE_CODE_LEN
);
printf
(
"_setDevice_Code:%s
\n
"
,
device_code
);
strncpy
(
s_ccuid
,
device_code
,
len
);
return
len
;
}
static
void
KK_Ccuid_init
(
void
)
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuidTmp
[
DEVICE_CODE_LEN
]
=
{
0
};
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
int
ccuid_len
=
0
;
HAL_Execel_cmd
(
GET_CCUID_CMD
,(
char
*
)
ccuid
,
sizeof
(
ccuid
),
&
ccuid_len
);
printf
(
"GET_CCUID_CMD:%s
\n
"
,
ccuid
);
if
(
ccuid_len
>
0
&&
ccuid_len
<=
DEVICE_CODE_LEN
){
sprintf
(
ccuidTmp
,
"CCU_%s"
,
ccuid
);
_setDevice_Code
(
ccuidTmp
,
strlen
(
ccuidTmp
)
-
1
);
//减一是因为最后有一个换行
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
_setDevice_Code
(
ccuidTmp
,
strlen
(
ccuidTmp
)
-
1
);
//减一是因为最后有一个换行
}
else
{
_setDevice_Code
(
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
}
}
static
int
mqtt_start
(
void
)
{
...
...
@@ -102,7 +102,7 @@ int main(int argc, char* argv[])
KK_Ccuid_init
();
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
kk_info_report_start
();
again:
again:
rc
=
kk_start_ccu_register
();
if
(
rc
==
0
){
rc
=
mqtt_start
();
...
...
application/kcloud/kk_info_report.c
View file @
4d9d15b7
...
...
@@ -23,146 +23,146 @@ extern int kk_get_gw_status(void);
#define TO_OLED_NANOMSG_SOCKET_ADDR "ipc:///tmp/oled_pair.ipc"
static
int
kk_info_nanomsg_init
(
void
)
{
int
socketfd
=
0
;
socketfd
=
nn_socket
(
AF_SP
,
NN_PAIR
);
if
(
socketfd
<
0
){
return
-
1
;
}
int
socketfd
=
0
;
socketfd
=
nn_socket
(
AF_SP
,
NN_PAIR
);
if
(
socketfd
<
0
){
return
-
1
;
}
if
(
nn_connect
(
socketfd
,
TO_OLED_NANOMSG_SOCKET_ADDR
)
<
0
){
WARNING_PRINT
(
"[%s][%d]connect fail!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
return
socketfd
;
}
return
socketfd
;
}
static
int
kk_info_get
(
char
*
str
)
{
int
ret
=
0
;
char
version
[
VERSION_MAXLEN
]
=
{
0
};
char
*
str_tmp
=
NULL
;
char
ccuid
[
32
]
=
{
0
};
if
(
str
==
NULL
){
return
-
1
;
}
HAL_GetVersion
(
version
);
KK_Get_ccuid
(
ccuid
);
cJSON
*
root
=
cJSON_CreateObject
();
if
(
root
)
{
cJSON
*
args
=
cJSON_CreateObject
();
if
(
args
)
{
cJSON_AddItemToObject
(
root
,
"args"
,
args
);
int
ret
=
0
;
char
version
[
VERSION_MAXLEN
]
=
{
0
};
char
*
str_tmp
=
NULL
;
char
ccuid
[
32
]
=
{
0
};
if
(
str
==
NULL
){
return
-
1
;
}
//HAL_GetVersion(version);
cJSON
*
ccu
=
cJSON_CreateObject
();
if
(
ccu
)
{
char
status
[
4
]
=
{
0
};
KK_Get_ccuid
(
ccuid
);
cJSON
*
root
=
cJSON_CreateObject
();
if
(
root
)
{
cJSON
*
args
=
cJSON_CreateObject
();
if
(
args
)
{
cJSON_AddItemToObject
(
root
,
"args"
,
args
);
cJSON_AddItemToObject
(
args
,
"ccu"
,
ccu
);
cJSON_AddStringToObject
(
ccu
,
"id"
,
&
ccuid
[
4
]);
cJSON_AddStringToObject
(
ccu
,
"version"
,
version
);
cJSON_AddStringToObject
(
ccu
,
"name"
,
"kk_new_ccu"
);
//INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status());
//if(kk_get_gw_status() == DEVICE_OFFLINE){
//memcpy(status,"2",strlen("2"));
//}
if
(
kk_get_cloud_status
()
==
DEVICE_OFFLINE
)
{
//cJSON_AddStringToObject(ccu, "status", "1");
//INFO_PRINT("_-----------------------------------------------------------11\n");
memcpy
(
status
,
"1"
,
strlen
(
"1"
));
}
else
{
//INFO_PRINT("_-----------------------------------------------------------22\n");
memcpy
(
status
,
"0"
,
strlen
(
"0"
));
}
//INFO_PRINT("------------------------------------->status :%s\n",status);
cJSON
*
ccu
=
cJSON_CreateObject
();
if
(
ccu
)
{
char
status
[
4
]
=
{
0
};
cJSON_AddStringToObject
(
ccu
,
"status"
,
status
);
}
cJSON
*
net
=
cJSON_CreateObject
();
if
(
net
)
{
char
s_IP
[
NETWORK_ADDR_LEN
]
=
{
0
};
HAL_Get_IP
(
s_IP
,
NULL
);
cJSON_AddItemToObject
(
args
,
"net"
,
net
);
cJSON_AddStringToObject
(
net
,
"interface"
,
CCU_LAN
);
cJSON_AddStringToObject
(
net
,
"ip"
,
s_IP
);
}
cJSON
*
lsc_status
=
cJSON_CreateObject
();
if
(
lsc_status
)
{
cJSON_AddStringToObject
(
args
,
"lsc_status"
,
"1"
);
}
cJSON_AddItemToObject
(
args
,
"ccu"
,
ccu
);
cJSON_AddStringToObject
(
ccu
,
"id"
,
&
ccuid
[
4
]);
cJSON_AddStringToObject
(
ccu
,
"version"
,
version
);
cJSON_AddStringToObject
(
ccu
,
"name"
,
"kk_new_ccu"
);
//INFO_PRINT("---222kk_get_cloud_status():%d\n",kk_get_cloud_status());
//if(kk_get_gw_status() == DEVICE_OFFLINE){
//memcpy(status,"2",strlen("2"));
//}
if
(
kk_get_cloud_status
()
==
DEVICE_OFFLINE
)
{
//cJSON_AddStringToObject(ccu, "status", "1");
//INFO_PRINT("_-----------------------------------------------------------11\n");
memcpy
(
status
,
"1"
,
strlen
(
"1"
));
}
else
{
//INFO_PRINT("_-----------------------------------------------------------22\n");
memcpy
(
status
,
"0"
,
strlen
(
"0"
));
}
//INFO_PRINT("------------------------------------->status :%s\n",status);
cJSON
*
qr_code
=
cJSON_CreateObject
();
if
(
qr_code
)
{
char
qrcodeStr
[
256
]
=
{
0
};
sprintf
(
qrcodeStr
,
"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB"
,
KK_CCU_PRODUCTID
,
&
ccuid
[
4
]);
cJSON_AddItemToObject
(
args
,
"qr_code"
,
qr_code
);
cJSON_AddStringToObject
(
qr_code
,
"string"
,
qrcodeStr
);
cJSON_AddBoolToObject
(
qr_code
,
"show"
,
1
);
}
cJSON
*
service
=
cJSON_CreateObject
();
if
(
service
)
{
cJSON_AddStringToObject
(
args
,
"service"
,
"1"
);
}
}
str_tmp
=
cJSON_PrintUnformatted
(
root
);
//INFO_PRINT("JSON %s\r\n", str_tmp);
strcpy
(
str
,
str_tmp
);
free
(
str_tmp
);
cJSON_Delete
(
root
);
}
else
{
ret
=
-
1
;
}
return
ret
;
cJSON_AddStringToObject
(
ccu
,
"status"
,
status
);
}
cJSON
*
net
=
cJSON_CreateObject
();
if
(
net
)
{
char
s_IP
[
NETWORK_ADDR_LEN
]
=
{
0
};
HAL_Get_IP
(
s_IP
,
NULL
);
cJSON_AddItemToObject
(
args
,
"net"
,
net
);
cJSON_AddStringToObject
(
net
,
"interface"
,
CCU_LAN
);
cJSON_AddStringToObject
(
net
,
"ip"
,
s_IP
);
}
cJSON
*
lsc_status
=
cJSON_CreateObject
();
if
(
lsc_status
)
{
cJSON_AddStringToObject
(
args
,
"lsc_status"
,
"1"
);
}
cJSON
*
qr_code
=
cJSON_CreateObject
();
if
(
qr_code
)
{
char
qrcodeStr
[
256
]
=
{
0
};
sprintf
(
qrcodeStr
,
"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB"
,
KK_CCU_PRODUCTID
,
&
ccuid
[
4
]);
cJSON_AddItemToObject
(
args
,
"qr_code"
,
qr_code
);
cJSON_AddStringToObject
(
qr_code
,
"string"
,
qrcodeStr
);
cJSON_AddBoolToObject
(
qr_code
,
"show"
,
1
);
}
cJSON
*
service
=
cJSON_CreateObject
();
if
(
service
)
{
cJSON_AddStringToObject
(
args
,
"service"
,
"1"
);
}
}
str_tmp
=
cJSON_PrintUnformatted
(
root
);
//INFO_PRINT("JSON %s\r\n", str_tmp);
strcpy
(
str
,
str_tmp
);
free
(
str_tmp
);
cJSON_Delete
(
root
);
}
else
{
ret
=
-
1
;
}
return
ret
;
}
//static int
void
*
kk_info_nanomsg_send
(
void
*
data
)
{
int
ret
=
0
;
char
str
[
1024
]
=
{
0
};
int
socketfd
=
kk_info_nanomsg_init
();
if
(
socketfd
<
0
){
return
NULL
;
}
while
(
1
){
memset
(
str
,
0x0
,
sizeof
(
str
));
ret
=
kk_info_get
(
str
);
if
(
ret
==
0
){
//printf("*********nn_send***********\n");
ret
=
nn_send
(
socketfd
,
str
,
strlen
(
str
),
1
);
if
(
ret
<
0
)
{
//WARNING_PRINT("[%s][%d]nn_send fail!!!\n",__FUNCTION__,__LINE__);
}
}
sleep
(
10
);
}
int
ret
=
0
;
char
str
[
1024
]
=
{
0
};
int
socketfd
=
kk_info_nanomsg_init
();
if
(
socketfd
<
0
){
return
NULL
;
}
while
(
1
){
memset
(
str
,
0x0
,
sizeof
(
str
));
ret
=
kk_info_get
(
str
);
if
(
ret
==
0
){
//printf("*********nn_send***********\n");
ret
=
nn_send
(
socketfd
,
str
,
strlen
(
str
),
1
);
if
(
ret
<
0
)
{
//WARNING_PRINT("[%s][%d]nn_send fail!!!\n",__FUNCTION__,__LINE__);
}
}
sleep
(
10
);
}
}
int
kk_info_report_start
(
void
)
{
int
rc
;
pthread_t
info_report_thread
;
pthread_attr_t
info_report_attr
;
pthread_mutex_init
(
&
s_data_mutex
,
NULL
);
/*创建线程*/
pthread_attr_init
(
&
info_report_attr
);
size_t
s
=
1500
;
pthread_attr_setstacksize
(
&
info_report_attr
,
s
);
pthread_attr_setdetachstate
(
&
info_report_attr
,
PTHREAD_CREATE_JOINABLE
);
rc
=
pthread_create
(
&
info_report_thread
,
&
info_report_attr
,
kk_info_nanomsg_send
,
(
void
*
)
NULL
);
//收数据
if
(
rc
)
{
WARNING_PRINT
(
"Error : unable to create thread udp_recv
\r\n
"
);
return
-
1
;
}
pthread_attr_destroy
(
&
info_report_attr
);
return
0
;
int
rc
;
pthread_t
info_report_thread
;
pthread_attr_t
info_report_attr
;
pthread_mutex_init
(
&
s_data_mutex
,
NULL
);
/*创建线程*/
pthread_attr_init
(
&
info_report_attr
);
size_t
s
=
1500
;
pthread_attr_setstacksize
(
&
info_report_attr
,
s
);
pthread_attr_setdetachstate
(
&
info_report_attr
,
PTHREAD_CREATE_JOINABLE
);
rc
=
pthread_create
(
&
info_report_thread
,
&
info_report_attr
,
kk_info_nanomsg_send
,
(
void
*
)
NULL
);
//收数据
if
(
rc
)
{
WARNING_PRINT
(
"Error : unable to create thread udp_recv
\r\n
"
);
return
-
1
;
}
pthread_attr_destroy
(
&
info_report_attr
);
return
0
;
}
\ No newline at end of file
application/kcloud/kk_register.c
View file @
4d9d15b7
...
...
@@ -23,59 +23,58 @@
int
kk_execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
)
{
if
(
cmd
==
NULL
||
buf
==
NULL
||
buf_len
==
0
)
{
INFO_PRINT
(
"arg error
\n
"
);
return
-
1
;
}
if
(
cmd
==
NULL
||
buf
==
NULL
||
buf_len
==
0
)
{
INFO_PRINT
(
"arg error
\n
"
);
return
-
1
;
}
memset
(
buf
,
0
,
buf_len
);
memset
(
buf
,
0
,
buf_len
);
FILE
*
fp
=
NULL
;
fp
=
popen
(
cmd
,
"r"
);
while
(
fgets
(
buf
,
buf_len
,
fp
)
!=
NULL
){
INFO_PRINT
(
"%s return %s"
,
cmd
,
buf
);
}
pclose
(
fp
);
*
ret_len
=
strlen
(
buf
);
return
0
;
FILE
*
fp
=
NULL
;
fp
=
popen
(
cmd
,
"r"
);
while
(
fgets
(
buf
,
buf_len
,
fp
)
!=
NULL
){
INFO_PRINT
(
"%s return %s"
,
cmd
,
buf
);
}
pclose
(
fp
);
*
ret_len
=
strlen
(
buf
);
return
0
;
}
int
kk_parse_deviceSecret
(
char
*
info
){
FILE
*
fp
;
if
(
info
==
NULL
){
return
-
1
;
}
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
if
(
infoObj
==
NULL
){
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
FILE
*
fp
;
if
(
info
==
NULL
){
return
-
1
;
}
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
if
(
infoObj
==
NULL
){
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
//cJSON *data = cJSON_GetObjectItem(infoObj,"data");
//if(data == NULL)
//{
//return -1;
//}
cJSON
*
deviceSecret
=
cJSON_GetObjectItem
(
infoObj
,
"deviceSecret"
);
if
(
deviceSecret
==
NULL
)
return
-
1
;
if
(
deviceSecret
==
NULL
)
return
-
1
;
fp
=
fopen
(
KK_DEVICESECRET_PATH
,
"w+"
);
if
(
fp
!=
NULL
){
fwrite
(
deviceSecret
->
valuestring
,
strlen
(
deviceSecret
->
valuestring
),
1
,
fp
);
fclose
(
fp
);
}
return
0
;
if
(
fp
!=
NULL
){
fwrite
(
deviceSecret
->
valuestring
,
strlen
(
deviceSecret
->
valuestring
),
1
,
fp
);
fclose
(
fp
);
}
return
0
;
}
int
kk_parse_token
(
char
*
info
){
FILE
*
fp
;
if
(
info
==
NULL
){
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
if
(
infoObj
==
NULL
){
return
-
1
;
}
FILE
*
fp
;
if
(
info
==
NULL
){
INFO_PRINT
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
}
cJSON
*
infoObj
=
cJSON_Parse
(
info
);
if
(
infoObj
==
NULL
){
return
-
1
;
}
cJSON
*
data
=
cJSON_GetObjectItem
(
infoObj
,
"data"
);
if
(
data
==
NULL
)
{
...
...
@@ -103,11 +102,11 @@ char *kk_dictionary_order(char *deviceCode, char *productCode,char *randomId)
char
str
[
3
][
16
]
=
{
0
};
char
temp
[
16
];
int
i
,
l
,
len
;
char
*
signSource
=
NULL
;
memcpy
(
&
str
[
0
],
deviceCode
,
strlen
(
deviceCode
));
memcpy
(
&
str
[
1
],
productCode
,
strlen
(
productCode
));
memcpy
(
&
str
[
2
],
randomId
,
strlen
(
randomId
));
//for (i=0;i<3;i++)
char
*
signSource
=
NULL
;
memcpy
(
&
str
[
0
],
deviceCode
,
strlen
(
deviceCode
));
memcpy
(
&
str
[
1
],
productCode
,
strlen
(
productCode
));
memcpy
(
&
str
[
2
],
randomId
,
strlen
(
randomId
));
//for (i=0;i<3;i++)
//{
//for (l=0;l<16;l++)
//{
...
...
@@ -130,15 +129,15 @@ char *kk_dictionary_order(char *deviceCode, char *productCode,char *randomId)
}
//for(i=0;i<3;i++)//输出
//INFO_PRINT("%s\n",str[i]);
len
=
strlen
(
deviceCode
)
+
strlen
(
productCode
)
+
strlen
(
randomId
)
+
1
;
signSource
=
malloc
(
len
);
if
(
signSource
==
NULL
)
{
return
NULL
;
}
memset
(
signSource
,
0
,
len
);
snprintf
(
signSource
,
len
,
"%s%s%s"
,
str
[
0
],
str
[
1
],
str
[
2
]);
INFO_PRINT
(
"signSource %s
\n
"
,
signSource
);
return
signSource
;
len
=
strlen
(
deviceCode
)
+
strlen
(
productCode
)
+
strlen
(
randomId
)
+
1
;
signSource
=
malloc
(
len
);
if
(
signSource
==
NULL
)
{
return
NULL
;
}
memset
(
signSource
,
0
,
len
);
snprintf
(
signSource
,
len
,
"%s%s%s"
,
str
[
0
],
str
[
1
],
str
[
2
]);
INFO_PRINT
(
"signSource %s
\n
"
,
signSource
);
return
signSource
;
}
static
const
char
*
base64char
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
...
...
@@ -208,7 +207,7 @@ static char * kk_create_register_info()
uint8_t
productSecret
[
64
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
int
productSecret_len
=
0
;
char
keyTmp
[
64
]
=
{
0
};
char
keyTmp
[
64
]
=
{
0
};
root
=
cJSON_CreateObject
();
HAL_Get_mac
(
mac
);
HAL_GetTime_s
(
ramdonId
);
...
...
@@ -220,29 +219,29 @@ static char * kk_create_register_info()
if
(
productSecret_len
==
0
){
utils_hmac_sha256
((
const
uint8_t
*
)
signSource
,
strlen
(
signSource
),
(
const
uint8_t
*
)
PRODUCTSECRET
,
strlen
(
PRODUCTSECRET
),
sign_hex
);
}
else
{
memcpy
(
keyTmp
,
productSecret
,
productSecret_len
-
1
);
memcpy
(
keyTmp
,
productSecret
,
productSecret_len
-
1
);
utils_hmac_sha256
((
const
uint8_t
*
)
signSource
,
strlen
(
signSource
),
(
const
uint8_t
*
)
keyTmp
,
strlen
((
const
char
*
)
keyTmp
),
sign_hex
);
}
arrayToStr
(
sign_hex
,
32
,
sign_hex_str
);
base64Out
=
malloc
(
128
);
if
(
base64Out
==
NULL
)
{
return
NULL
;
}
INFO_PRINT
(
"[%s][%d]sign_hex:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
sign_hex_str
);
//memset(base64Out, 0, 128);
//base64_encode(sign_hex_str,base64Out,strlen(sign_hex_str));
INFO_PRINT
(
"[%s][%d]base64Out:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
base64Out
);
cJSON_AddStringToObject
(
root
,
"sign"
,
sign_hex_str
);
cJSON_AddStringToObject
(
root
,
"random"
,
KK_CCU_RANDOM
);
free
(
signSource
);
free
(
base64Out
);
base64Out
=
malloc
(
128
);
if
(
base64Out
==
NULL
)
{
return
NULL
;
}
INFO_PRINT
(
"[%s][%d]sign_hex:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
sign_hex_str
);
//memset(base64Out, 0, 128);
//base64_encode(sign_hex_str,base64Out,strlen(sign_hex_str));
INFO_PRINT
(
"[%s][%d]base64Out:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
base64Out
);
cJSON_AddStringToObject
(
root
,
"sign"
,
sign_hex_str
);
cJSON_AddStringToObject
(
root
,
"random"
,
KK_CCU_RANDOM
);
free
(
signSource
);
free
(
base64Out
);
out
=
cJSON_Print
(
root
);
//cJSON_Minify(out);
cJSON_Delete
(
root
);
INFO_PRINT
(
"--------------------->kk_create_register_info:%s
\n
"
,
out
);
return
out
;
INFO_PRINT
(
"--------------------->kk_create_register_info:%s
\n
"
,
out
);
return
out
;
}
char
g_clientId
[
64
]
=
{
0
};
static
char
*
kk_create_get_jwt_info
()
...
...
@@ -270,134 +269,134 @@ static char * kk_create_get_jwt_info()
out
=
cJSON_Print
(
root
);
//cJSON_Minify(out);
cJSON_Delete
(
root
);
INFO_PRINT
(
"--------------------->kk_create_get_jwt_info:%s
\n
"
,
out
);
return
out
;
INFO_PRINT
(
"--------------------->kk_create_get_jwt_info:%s
\n
"
,
out
);
return
out
;
}
static
int
kk_send_register_info
(
int
sockfd
,
const
char
*
path
,
int
type
)
{
char
str1
[
1024
],
str2
[
1024
],
str
[
16
]
=
{
0
};
char
tmp
[
128
]
=
{
0
};
int
len
=
0
;
memset
(
str2
,
0
,
sizeof
(
str2
));
if
(
type
==
0
){
strcat
(
str2
,
kk_create_register_info
());
}
else
{
strcat
(
str2
,
kk_create_get_jwt_info
());
}
len
=
strlen
(
str2
);
sprintf
(
str
,
"%d"
,
len
);
char
str1
[
1024
],
str2
[
1024
],
str
[
16
]
=
{
0
};
char
tmp
[
128
]
=
{
0
};
int
len
=
0
;
memset
(
str2
,
0
,
sizeof
(
str2
));
if
(
type
==
0
){
strcat
(
str2
,
kk_create_register_info
());
}
else
{
strcat
(
str2
,
kk_create_get_jwt_info
());
}
len
=
strlen
(
str2
);
sprintf
(
str
,
"%d"
,
len
);
memset
(
str1
,
0
,
sizeof
(
str1
));
memset
(
tmp
,
0
,
sizeof
(
tmp
));
sprintf
(
tmp
,
"POST %s HTTP/1.1
\n
"
,
path
);
strcat
(
str1
,
tmp
);
memset
(
tmp
,
0
,
sizeof
(
tmp
));
sprintf
(
tmp
,
"Host: %s:%d
\n
"
,
IPSTR
,
PORT
);
strcat
(
str1
,
tmp
);
strcat
(
str1
,
"Content-Type: application/json
\n
"
);
strcat
(
str1
,
"Content-Length: "
);
strcat
(
str1
,
str
);
strcat
(
str1
,
"
\n\n
"
);
//str2的值为post的数据
strcat
(
str1
,
str2
);
strcat
(
str1
,
"
\r\n\r\n
"
);
INFO_PRINT
(
"%s
\n
"
,
str1
);
return
write
(
sockfd
,
str1
,
strlen
(
str1
));
memset
(
str1
,
0
,
sizeof
(
str1
));
memset
(
tmp
,
0
,
sizeof
(
tmp
));
sprintf
(
tmp
,
"POST %s HTTP/1.1
\n
"
,
path
);
strcat
(
str1
,
tmp
);
memset
(
tmp
,
0
,
sizeof
(
tmp
));
sprintf
(
tmp
,
"Host: %s:%d
\n
"
,
IPSTR
,
PORT
);
strcat
(
str1
,
tmp
);
strcat
(
str1
,
"Content-Type: application/json
\n
"
);
strcat
(
str1
,
"Content-Length: "
);
strcat
(
str1
,
str
);
strcat
(
str1
,
"
\n\n
"
);
//str2的值为post的数据
strcat
(
str1
,
str2
);
strcat
(
str1
,
"
\r\n\r\n
"
);
INFO_PRINT
(
"%s
\n
"
,
str1
);
return
write
(
sockfd
,
str1
,
strlen
(
str1
));
}
int
kk_start_ccu_register
(
void
)
{
int
sockfd
,
ret
,
i
,
h
;
struct
sockaddr_in
servaddr
;
char
buf
[
1024
]
=
{
0
},
buf2
[
1024
]
=
{
0
};
fd_set
t_set1
;
struct
timeval
tv
;
int
registerType
=
0
;
if
((
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
INFO_PRINT
(
"---socket error!
\n
"
);
return
-
1
;
};
bzero
(
&
servaddr
,
sizeof
(
servaddr
));
servaddr
.
sin_family
=
AF_INET
;
servaddr
.
sin_port
=
htons
(
PORT
);
if
(
inet_pton
(
AF_INET
,
IPSTR
,
&
servaddr
.
sin_addr
)
<=
0
){
INFO_PRINT
(
"--inet_pton error!
\n
"
);
close
(
sockfd
);
return
-
1
;
};
int
sockfd
,
ret
,
i
,
h
;
struct
sockaddr_in
servaddr
;
char
buf
[
1024
]
=
{
0
},
buf2
[
1024
]
=
{
0
};
fd_set
t_set1
;
struct
timeval
tv
;
int
registerType
=
0
;
if
((
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
<
0
)
{
INFO_PRINT
(
"---socket error!
\n
"
);
return
-
1
;
};
bzero
(
&
servaddr
,
sizeof
(
servaddr
));
servaddr
.
sin_family
=
AF_INET
;
servaddr
.
sin_port
=
htons
(
PORT
);
if
(
inet_pton
(
AF_INET
,
IPSTR
,
&
servaddr
.
sin_addr
)
<=
0
){
INFO_PRINT
(
"--inet_pton error!
\n
"
);
close
(
sockfd
);
return
-
1
;
};
if
(
connect
(
sockfd
,
(
struct
sockaddr
*
)
&
servaddr
,
sizeof
(
servaddr
))
<
0
){
INFO_PRINT
(
"connect error!
\n
"
);
close
(
sockfd
);
return
-
1
;
}
INFO_PRINT
(
"connect successful
\n
"
);
ret
=
kk_send_register_info
(
sockfd
,
"/deviceRegister/register"
,
0
);
if
(
ret
<
0
)
{
INFO_PRINT
(
"send fail
\n
"
);
close
(
sockfd
);
return
-
1
;
}
else
{
INFO_PRINT
(
"send success send %d bytes!
\n\n
"
,
ret
);
}
registerType
=
1
;
FD_ZERO
(
&
t_set1
);
FD_SET
(
sockfd
,
&
t_set1
);
tv
.
tv_sec
=
1
;
tv
.
tv_usec
=
0
;
h
=
0
;
while
(
1
){
h
=
select
(
sockfd
+
1
,
&
t_set1
,
NULL
,
NULL
,
&
tv
);
//if (h == 0) continue;
if
(
h
==
-
1
)
{
close
(
sockfd
);
return
-
1
;
};
if
(
FD_ISSET
(
sockfd
,
&
t_set1
)
){
memset
(
buf
,
0
,
1024
);
memset
(
buf2
,
0
,
1024
);
i
=
read
(
sockfd
,
buf
,
1024
);
if
(
i
==
0
){
close
(
sockfd
);
return
-
1
;
}
INFO_PRINT
(
"
\n
get %s
\n
"
,
buf
);
if
(
registerType
==
1
){
//get deviceSecret
char
*
deviceSecret
=
strstr
(
buf
,
"deviceSecret"
);
if
(
deviceSecret
!=
NULL
){
char
*
start
=
strchr
(
buf
,
'{'
);
char
*
end
=
strrchr
(
buf
,
'}'
);
strncpy
(
buf2
,
start
,
end
-
start
+
1
);
INFO_PRINT
(
"[%s][%d]buf2:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
buf2
);
ret
=
kk_parse_deviceSecret
(
buf2
);
if
(
ret
==
0
){
ret
=
kk_send_register_info
(
sockfd
,
"/auth/generateJwt"
,
1
);
if
(
ret
<
0
)
{
INFO_PRINT
(
"send fail'
\n
"
);
close
(
sockfd
);
return
-
1
;
}
else
{
printf
(
"send success send %d bytes!
\n\n
"
,
ret
);
}
registerType
=
2
;
}
}
}
else
if
(
registerType
==
2
){
char
*
jwt
=
strstr
(
buf
,
"jwt"
);
if
(
jwt
!=
NULL
){
char
*
start
=
strchr
(
buf
,
'{'
);
char
*
end
=
strrchr
(
buf
,
'}'
);
if
(
start
!=
NULL
&&
end
!=
NULL
){
strncpy
(
buf2
,
start
,
end
-
start
+
1
);
ret
=
kk_parse_token
(
buf2
);
if
(
ret
==
0
){
close
(
sockfd
);
return
0
;
}
}
}
}
}
}
close
(
sockfd
);
return
-
1
;
if
(
connect
(
sockfd
,
(
struct
sockaddr
*
)
&
servaddr
,
sizeof
(
servaddr
))
<
0
){
INFO_PRINT
(
"connect error!
\n
"
);
close
(
sockfd
);
return
-
1
;
}
INFO_PRINT
(
"connect successful
\n
"
);
ret
=
kk_send_register_info
(
sockfd
,
"/deviceRegister/register"
,
0
);
if
(
ret
<
0
)
{
INFO_PRINT
(
"send fail
\n
"
);
close
(
sockfd
);
return
-
1
;
}
else
{
INFO_PRINT
(
"send success send %d bytes!
\n\n
"
,
ret
);
}
registerType
=
1
;
FD_ZERO
(
&
t_set1
);
FD_SET
(
sockfd
,
&
t_set1
);
tv
.
tv_sec
=
1
;
tv
.
tv_usec
=
0
;
h
=
0
;
while
(
1
){
h
=
select
(
sockfd
+
1
,
&
t_set1
,
NULL
,
NULL
,
&
tv
);
//if (h == 0) continue;
if
(
h
==
-
1
)
{
close
(
sockfd
);
return
-
1
;
};
if
(
FD_ISSET
(
sockfd
,
&
t_set1
)
){
memset
(
buf
,
0
,
1024
);
memset
(
buf2
,
0
,
1024
);
i
=
read
(
sockfd
,
buf
,
1024
);
if
(
i
==
0
){
close
(
sockfd
);
return
-
1
;
}
INFO_PRINT
(
"
\n
get %s
\n
"
,
buf
);
if
(
registerType
==
1
){
//get deviceSecret
char
*
deviceSecret
=
strstr
(
buf
,
"deviceSecret"
);
if
(
deviceSecret
!=
NULL
){
char
*
start
=
strchr
(
buf
,
'{'
);
char
*
end
=
strrchr
(
buf
,
'}'
);
strncpy
(
buf2
,
start
,
end
-
start
+
1
);
INFO_PRINT
(
"[%s][%d]buf2:%s
\n
"
,
__FUNCTION__
,
__LINE__
,
buf2
);
ret
=
kk_parse_deviceSecret
(
buf2
);
if
(
ret
==
0
){
ret
=
kk_send_register_info
(
sockfd
,
"/auth/generateJwt"
,
1
);
if
(
ret
<
0
)
{
INFO_PRINT
(
"send fail'
\n
"
);
close
(
sockfd
);
return
-
1
;
}
else
{
printf
(
"send success send %d bytes!
\n\n
"
,
ret
);
}
registerType
=
2
;
}
}
}
else
if
(
registerType
==
2
){
char
*
jwt
=
strstr
(
buf
,
"jwt"
);
if
(
jwt
!=
NULL
){
char
*
start
=
strchr
(
buf
,
'{'
);
char
*
end
=
strrchr
(
buf
,
'}'
);
if
(
start
!=
NULL
&&
end
!=
NULL
){
strncpy
(
buf2
,
start
,
end
-
start
+
1
);
ret
=
kk_parse_token
(
buf2
);
if
(
ret
==
0
){
close
(
sockfd
);
return
0
;
}
}
}
}
}
}
close
(
sockfd
);
return
-
1
;
}
\ No newline at end of file
application/kcloud/mqtt_api.c
View file @
4d9d15b7
...
...
@@ -205,10 +205,10 @@ MQTTAsync KK_MQTT_Connect(void)
char
token
[
512
]
=
{
0
};
char
usrname
[
128
]
=
{
0
};
fp
=
fopen
(
KK_TOKEN_PATH
,
"r"
);
if
(
fp
!=
NULL
){
fread
(
token
,
1
,
sizeof
(
token
),
fp
);
fclose
(
fp
);
}
if
(
fp
!=
NULL
){
fread
(
token
,
1
,
sizeof
(
token
),
fp
);
fclose
(
fp
);
}
HAL_Get_mac
(
mac
);
char
ccuid
[
32
]
=
{
0
};
KK_Get_ccuid
(
ccuid
);
...
...
application/klansdk/kk_ccu_msg.c
View file @
4d9d15b7
...
...
@@ -37,30 +37,42 @@ static cJSON *bool_type_convert(cJSON *n_id,cJSON *n_dataType)
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
args
=
cJSON_CreateBool
(
n_id
->
valueint
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
bVal
=
(
n_id
->
valuedouble
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateBool
(
1
);
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateBool
(
0
);
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)){
args
=
cJSON_CreateBool
(
n_id
->
valueint
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
bVal
=
(
n_id
->
valuedouble
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
int
iVal
=
atoi
(
n_id
->
valuestring
);
bVal
=
(
iVal
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
double
dVal
=
atof
(
n_id
->
valuestring
);
bVal
=
(
dVal
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
args
=
cJSON_CreateBool
(
atoi
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
bVal
=
(
atof
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
args
=
cJSON_CreateBool
(
bVal
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateBool
(
1
);
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateBool
(
0
);
}
}
}
else
if
(
n_id
->
type
==
cJSON_False
){
args
=
cJSON_CreateNumber
(
0
);
}
else
if
(
n_id
->
type
==
cJSON_True
){
args
=
cJSON_CreateNumber
(
1
);
}
return
args
;
}
...
...
@@ -72,24 +84,46 @@ static cJSON *int_type_convert(cJSON *n_id,cJSON *n_dataType)
return
NULL
;
}
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
args
=
cJSON_CreateNumber
(
n_id
->
valueint
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
args
=
cJSON_CreateNumber
(
n_id
->
valuedouble
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
1
);
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
0
);
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
args
=
cJSON_CreateNumber
(
n_id
->
valueint
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
))
{
args
=
cJSON_CreateNumber
(
n_id
->
valuedouble
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
1
);
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
0
);
}
}
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
args
=
cJSON_CreateNumber
(
atoi
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
args
=
cJSON_CreateNumber
(
atof
(
n_id
->
valuestring
));
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
1
);
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
args
=
cJSON_CreateNumber
(
0
);
}
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
args
=
cJSON_CreateNumber
(
atoi
(
n_id
->
valuestring
)
);
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
args
=
cJSON_CreateNumber
(
(
int
)
atof
(
n_id
->
valuestring
)
);
}
else
if
(
n_id
->
type
==
cJSON_False
)
{
args
=
cJSON_CreateNumber
(
0
);
}
else
if
(
n_id
->
type
==
cJSON_True
)
{
args
=
cJSON_CreateNumber
(
1
);
}
return
args
;
}
...
...
@@ -106,24 +140,37 @@ static cJSON *string_bool_type_convert(cJSON *n_id,cJSON *n_dataType)
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
flag
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
flag
=
(
n_id
->
valuedouble
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
flag
=
1
;
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"false"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
){
flag
=
0
;
if
(
n_id
->
type
==
cJSON_True
)
{
flag
==
1
;
}
else
if
(
n_id
->
type
==
cJSON_False
){
flag
==
0
;
}
else
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)){
flag
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
flag
=
(
n_id
->
valuedouble
>
0
)
?
1
:
0
;
}
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)){
flag
=
(
atoi
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
||
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
flag
=
(
atof
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
flag
=
1
;
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"false"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
){
flag
=
0
;
}
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
flag
=
(
atoi
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
flag
=
(
atof
(
n_id
->
valuestring
)
>
0
)
?
1
:
0
;
}
if
(
flag
==
1
)
{
...
...
@@ -148,48 +195,61 @@ static cJSON *string_val_type_convert(int type,cJSON *n_id,cJSON *n_dataType)
if
(
strcmp
(
n_dataType
->
valuestring
,
"dummy"
)
==
0
)
{
return
NULL
;
}
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
if
(
type
==
1
){
val
.
dVal
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
else
{
val
.
iVal
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
if
(
type
==
1
){
val
.
dVal
=
n_id
->
valuedouble
;
}
else
{
val
.
iVal
=
n_id
->
valueint
;
if
(
n_id
->
type
==
cJSON_True
)
{
args
=
cJSON_CreateTrue
();
}
else
if
(
n_id
->
type
==
cJSON_False
){
args
=
cJSON_CreateFalse
();
}
else
if
(
n_id
->
type
==
cJSON_Number
){
if
((
strcmp
(
n_dataType
->
valuestring
,
"int"
)
==
0
)
||
(
strcmp
(
n_dataType
->
valuestring
,
"bool"
)
==
0
)){
if
(
type
==
1
){
val
.
dVal
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
else
{
val
.
iVal
=
(
n_id
->
valueint
>
0
)
?
1
:
0
;
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"double"
)
==
0
)
{
if
(
type
==
1
){
val
.
dVal
=
n_id
->
valuedouble
;
}
else
{
val
.
iVal
=
n_id
->
valueint
;
}
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
)
{
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
}
else
if
(
n_id
->
type
==
cJSON_String
){
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
1
;
val
.
dVal
=
atoi
(
n_id
->
valuestring
)
;
}
else
{
val
.
iVal
=
1
;
val
.
iVal
=
atoi
(
n_id
->
valuestring
)
;
}
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"false"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
)
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
0
;
val
.
dVal
=
atof
(
n_id
->
valuestring
)
;
}
else
{
val
.
iVal
=
0
;
val
.
iVal
=
atof
(
n_id
->
valuestring
)
;
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_int"
)
==
0
)
{
if
(
type
==
1
){
val
.
dVal
=
atoi
(
n_id
->
valuestring
);
}
else
{
val
.
iVal
=
atoi
(
n_id
->
valuestring
);
}
}
else
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_double"
)
==
0
)
{
if
(
type
==
1
){
val
.
dVal
=
atof
(
n_id
->
valuestring
);
}
else
{
val
.
iVal
=
atof
(
n_id
->
valuestring
);
}
else
if
(
n_id
->
type
==
cJSON_False
||
n_id
->
type
==
cJSON_True
){
if
(
strcmp
(
n_dataType
->
valuestring
,
"string_bool"
)
==
0
){
if
(
strcmp
(
n_id
->
valuestring
,
"true"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"TRUE"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
1
;
}
else
{
val
.
iVal
=
1
;
}
}
else
if
(
strcmp
(
n_id
->
valuestring
,
"false"
)
==
0
||
strcmp
(
n_id
->
valuestring
,
"FALSE"
)
==
0
){
if
(
type
==
1
){
val
.
dVal
=
0
;
}
else
{
val
.
iVal
=
0
;
}
}
}
}
if
(
type
==
1
){
snprintf
(
sVal
,
sizeof
(
sVal
),
"%f"
,
val
.
dVal
);
...
...
@@ -263,13 +323,13 @@ cJSON * msg_convert_value(cJSON *d_type,cJSON *s_type,cJSON *value)
if
(
d_type
==
NULL
||
s_type
==
NULL
||
value
==
NULL
||
d_type
->
type
!=
cJSON_String
||
s_type
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[ERR] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[ERR] para.
\n
"
);
return
NULL
;
}
pVal
=
cJSON_Print
(
value
);
debug_log
(
LOG_NORMAL
,
"[convert]type:%s->%s,val=%s.
\n
"
,
s_type
->
valuestring
,
d_type
->
valuestring
,
pVal
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[convert]type:%s->%s,val=%s.
\n
"
,
s_type
->
valuestring
,
d_type
->
valuestring
,
pVal
);
free
(
pVal
);
...
...
@@ -299,11 +359,11 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
if
(
s_valueRange
==
NULL
||
s_valueRange
->
type
!=
cJSON_Array
||
d_valueRange
==
NULL
||
d_valueRange
->
type
!=
cJSON_Array
){
debug_log
(
LOG_DEBUG
,
"[ERR] range.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[ERR] range.
\n
"
);
return
NULL
;
}
if
(
s_dataType
==
NULL
||
s_dataType
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[ERR] dataType.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[ERR] dataType.
\n
"
);
return
NULL
;
}
...
...
@@ -314,9 +374,9 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
sVrg
=
cJSON_Print
(
s_valueRange
);
dVrg
=
cJSON_Print
(
d_valueRange
);
pVal
=
cJSON_Print
(
value
);
debug_log
(
LOG_NORMAL
,
"[convert] s_dataType:%s,val=%s
\n
"
,
s_dataType
->
valuestring
,
pVal
);
debug_log
(
LOG_INFO
,
"s_valueRange=%s
\n
"
,
sVrg
);
debug_log
(
LOG_INFO
,
"d_valueRange=%s
\n
"
,
dVrg
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[convert] s_dataType:%s,val=%s
\n
"
,
s_dataType
->
valuestring
,
pVal
);
debug_log
(
LOG_INFO
_LEVEL
,
"s_valueRange=%s
\n
"
,
sVrg
);
debug_log
(
LOG_INFO
_LEVEL
,
"d_valueRange=%s
\n
"
,
dVrg
);
free
(
sVrg
);
free
(
dVrg
);
free
(
pVal
);
...
...
@@ -379,8 +439,11 @@ cJSON *ccu_value_convert(cJSON *s_dType,cJSON *s_range,cJSON *d_dType,cJSON *d_r
{
cJSON
*
val
=
NULL
;
if
(
strcmp
(
d_dType
->
valuestring
,
"map"
)
==
0
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
val
=
map_type_convert
(
s_dType
,
s_range
,
value
,
d_range
);
}
else
{
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
...
...
@@ -415,11 +478,11 @@ int kk_lan_get_msg_id_str(char *msgId,int size)
int
kk_lan_add_val_to_obj
(
cJSON
*
obj
,
cJSON
*
val
,
const
char
*
id
)
{
if
(
id
==
NULL
||
obj
==
NULL
||
obj
->
type
!=
cJSON_Object
||
val
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_NORMAL
,
"[add] id(%s),type(%d).
\n
"
,
id
,
val
->
type
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[add] id(%s),type(%d).
\n
"
,
id
,
val
->
type
);
if
(
val
->
type
==
cJSON_False
){
cJSON_AddFalseToObject
(
obj
,
id
);
...
...
@@ -432,7 +495,7 @@ int kk_lan_add_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}
else
if
(
val
->
type
==
cJSON_String
){
cJSON_AddStringToObject
(
obj
,
id
,
val
->
valuestring
);
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
return
-
1
;
}
return
0
;
...
...
@@ -443,12 +506,12 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
{
char
*
pVal
=
NULL
;
if
(
id
==
NULL
||
obj
==
NULL
||
obj
->
type
!=
cJSON_Object
||
val
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
pVal
=
cJSON_Print
(
val
);
debug_log
(
LOG_NORMAL
,
"[replace] id=%s,type=%d,val=%s.
\n
"
,
id
,
val
->
type
,
pVal
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[replace] id=%s,type=%d,val=%s.
\n
"
,
id
,
val
->
type
,
pVal
);
free
(
pVal
);
if
(
val
->
type
==
cJSON_False
){
...
...
@@ -462,7 +525,7 @@ int kk_lan_replace_val_to_obj(cJSON *obj,cJSON *val,const char *id)
}
else
if
(
val
->
type
==
cJSON_String
){
cJSON_ReplaceItemInObject
(
obj
,
id
,
cJSON_CreateString
(
val
->
valuestring
));
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nonsupport type(%s).
\n
"
,
val
->
type
);
return
-
1
;
}
return
0
;
...
...
application/klansdk/kk_data_handle.c
View file @
4d9d15b7
...
...
@@ -114,7 +114,7 @@ void kk_handle_sync_info(void)
return
;
}
debug_log
(
LOG_INFO
,
"[sync] send.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[sync] send.
\n
"
);
kk_ipc_send
(
IPC_APP2MID
,
send_data
,
strlen
(
send_data
)
+
1
);
free
(
send_data
);
...
...
@@ -354,7 +354,6 @@ int kk_data_handle(cJSON *json,int sockfd)
cJSON
*
opcode
=
NULL
;
cJSON
*
arg
=
NULL
;
opcode
=
cJSON_GetObjectItem
(
json
,
OPCODE_STRING
);
if
(
opcode
!=
NULL
){
if
(
strcmp
(
opcode
->
valuestring
,
LOGIN_OPCODE
)
==
0
){
...
...
@@ -712,18 +711,18 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
cJSON
*
sceneId
=
NULL
;
if
(
payload
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] payload.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] payload.
\n
"
);
return
-
1
;
}
if
((
params
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
))
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] params err.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params err.
\n
"
);
return
-
1
;
}
if
((
sceneId
=
cJSON_GetObjectItem
(
params
,
MSG_SCENE_SCENEID
))
==
NULL
||
sceneId
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] sceneId err.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] sceneId err.
\n
"
);
return
-
1
;
}
...
...
@@ -745,7 +744,7 @@ void KK_Data_FromMid(void* str,int len)
cJSON
*
info
=
NULL
,
*
payload
=
NULL
;
cJSON
*
msgtype
=
NULL
,
*
deviceCode
=
NULL
,
*
productCode
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[midware->lan] len=%d,data=%s
\n
"
,
len
,
str
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[midware->lan] len=%d,data=%s
\n
"
,
len
,
str
);
if
((
json
=
cJSON_Parse
(
str
))
==
NULL
)
{
return
;
...
...
application/klansdk/kk_lan_ctrl.c
View file @
4d9d15b7
...
...
@@ -69,34 +69,34 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
pos
=
match_opcode_pos
(
devNode
->
oldccu
,
opcode
->
valuestring
,
channel
);
if
(
pos
==-
1
){
debug_log
(
LOG_FOCUS
,
"not find
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"not find
\n
"
);
return
NULL
;
}
debug_log
(
LOG_FOCUS
,
"1
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"1
\n
"
);
newccuItem
=
cJSON_GetArrayItem
(
devNode
->
newccu
,
pos
);
oldccuItem
=
cJSON_GetArrayItem
(
devNode
->
oldccu
,
pos
);
debug_log
(
LOG_FOCUS
,
"2
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"2
\n
"
);
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
"dataType"
);
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
debug_log
(
LOG_FOCUS
,
"3
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"3
\n
"
);
n_dataType
=
cJSON_GetObjectItem
(
newccuItem
,
"dataType"
);
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_identifier
=
cJSON_GetObjectItem
(
newccuItem
,
"identifier"
);
epNum
=
cJSON_GetObjectItem
(
newccuItem
,
"channel"
);
debug_log
(
LOG_FOCUS
,
"4
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"4
\n
"
);
if
(
strcmp
(
o_dataType
->
valuestring
,
"map"
)
==
0
){
debug_log
(
LOG_FOCUS
,
"5
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"5
\n
"
);
val
=
map_type_convert
(
o_dataType
,
o_valueRange
,
arg
,
n_valueRange
);
}
else
{
debug_log
(
LOG_FOCUS
,
"6
\n
"
);
val
=
msg_convert_value
(
o_dataType
,
n
_dataType
,
arg
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"6
\n
"
);
val
=
msg_convert_value
(
n_dataType
,
o
_dataType
,
arg
);
}
debug_log
(
LOG_FOCUS
,
"7
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"7
\n
"
);
cJSON_AddStringToObject
(
params
,
"epNum"
,
epNum
->
valuestring
);
debug_log
(
LOG_FOCUS
,
"8
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"8
\n
"
);
if
(
val
->
type
==
cJSON_False
){
cJSON_AddFalseToObject
(
params
,
n_identifier
->
valuestring
);
...
...
@@ -111,7 +111,7 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
}
else
if
(
val
->
type
==
cJSON_Array
){
printf
(
"......................
\n
"
);
}
debug_log
(
LOG_FOCUS
,
"9
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"9
\n
"
);
return
params
;
}
...
...
application/klansdk/kk_lan_debug.h
View file @
4d9d15b7
...
...
@@ -4,13 +4,15 @@
#include <stdio.h>
#include <time.h>
#define LOG_NORMAL 1 //亮白色
#define LOG_DEBUG 2 //绿色
#define LOG_INFO 3 //蓝色
#define LOG_FOCUS 4 //黄色
#define LOG_WARNING 5 //蓝绿色
#define LOG_ERROR 6 //紫色
#define LOG_CRITICAL 7 //红色
#define LOG_NORMAL_LEVEL 1 //亮白色
#define LOG_DEBUG_LEVEL 2 //绿色
#define LOG_INFO_LEVEL 3 //蓝色
#define LOG_FOCUS_LEVEL 4 //黄色
#define LOG_WARNING_LEVEL 5 //蓝绿色
#define LOG_ERROR_LEVEL 6 //紫色
#define LOG_CRITICAL_LEVEL 7 //红色
#define LOG_NORMAL_ACT "\033[0;1;37m"
#define LOG_DEBUG_ACT "\033[0;1;32m"
...
...
@@ -23,7 +25,7 @@
#define syslog_en 1
#define LOG_LEVEL LOG_NORMAL
#define LOG_LEVEL LOG_NORMAL
_LEVEL
#define LOG_LEVEL_1 LOG_NORMAL_ACT
...
...
@@ -48,7 +50,7 @@
#if (syslog_en)
#define debug_log(level,format,...) do { \
if( level >= LOG_LEVEL && level <= LOG_CRITICAL) { \
if( level >= LOG_LEVEL && level <= LOG_CRITICAL
_LEVEL
) { \
char buff[64] = {0};\
time_t curTime = time(NULL); \
struct tm *c = gmtime(&curTime);\
...
...
application/klansdk/kk_lan_main.c
View file @
4d9d15b7
...
...
@@ -66,15 +66,55 @@ static void kk_lan_ccuid_init(void)
}
}
int
prg_run_singleton
(
const
char
*
prg
)
{
int
fd
;
int
ret
;
char
pid_file
[
256
]
=
{
0
};
char
pid_data
[
32
]
=
{
0
};
struct
flock
fl
;
if
(
prg
==
NULL
){
return
-
1
;
}
memset
(
pid_file
,
0
,
sizeof
(
pid_file
));
snprintf
(
pid_file
,
sizeof
(
pid_file
),
"/var/run/%s.pid"
,
prg
);
fd
=
open
(
pid_file
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
,
0644
);
if
(
fd
<
0
){
return
-
1
;
}
fl
.
l_type
=
F_WRLCK
;
fl
.
l_start
=
0
;
fl
.
l_whence
=
SEEK_SET
;
fl
.
l_len
=
0
;
ret
=
fcntl
(
fd
,
F_SETLK
,
&
fl
);
if
(
ret
<
0
){
return
-
1
;
}
memset
(
pid_data
,
0
,
sizeof
(
pid_data
));
snprintf
(
pid_data
,
sizeof
(
pid_data
),
"%d"
,
getpid
());
return
write
(
fd
,
pid_data
,
strlen
(
pid_data
));
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
r
c
=
0
;
char
*
ppp
;
int
r
et
=
0
;
open
(
"kk_lan"
,
LOG_PID
,
LOG_USER
);
if
(
prg_run_singleton
(
argv
[
0
])
<
0
){
debug_log
(
LOG_CRITICAL_LEVEL
,
"[%s]run singleton fail!
\n
"
,
argv
[
0
]);
return
-
1
;
}
kk_lan_ccuid_init
();
/*set the callback to get the device date to cloud*/
...
...
@@ -82,7 +122,7 @@ int main(int argc, char* argv[])
kk_findccu_handle_init
();
kk_map_dev_init
();
kk_login_init
();
kk_voice_panel_init
(
argc
,
argv
);
//
kk_voice_panel_init(argc,argv);
//lan_queue_init();
kk_lan_db_node_init
();
...
...
@@ -91,6 +131,6 @@ int main(int argc, char* argv[])
while
(
1
){
sleep
(
1
);
}
return
rc
;
return
0
;
}
application/klansdk/kk_lan_sync.c
View file @
4d9d15b7
...
...
@@ -428,7 +428,7 @@ int kk_sync_devices_to_sdk(cJSON *root,cJSON *data)
//
cJSON
*
_kk_sync_devicestatus_arg_build
(
kk_map_dev_node_t
*
node
)
{
int
i
,
num
=
0
;
int
i
,
num
=
0
,
n_num
=
0
,
o_num
=
0
;
cJSON
*
newccu
,
*
oldccu
;
cJSON
*
arg
=
cJSON_CreateObject
();
...
...
@@ -445,12 +445,15 @@ cJSON *_kk_sync_devicestatus_arg_build(kk_map_dev_node_t *node)
return
arg
;
}
n_num
=
cJSON_GetArraySize
(
newccu
);
o_num
=
cJSON_GetArraySize
(
oldccu
);
num
=
(
n_num
>
o_num
)
?
n_num
:
o_num
;
num
=
cJSON_GetArraySize
(
newccu
);
for
(
i
=
0
;
i
<
num
;
i
++
){
cJSON
*
newccuItem
=
cJSON_GetArrayItem
(
newccu
,
i
);
cJSON
*
oldccuItem
=
cJSON_GetArrayItem
(
oldccu
,
i
);
cJSON
*
val
=
NULL
;
cJSON
*
synType
=
cJSON_GetObjectItem
(
oldccuItem
,
"synType"
);
...
...
application/klansdk/kk_lan_voice_panel.c
View file @
4d9d15b7
...
...
@@ -315,7 +315,7 @@ void *kk_vp_manage_thread(void *arg)
break
;
case
UPDATING_8009_CONFIG_FILE_INFO
:
debug_log
(
LOG_INFO
,
"updating...
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"updating...
\n
"
);
sleep
(
1
);
//todo :超时取消
break
;
...
...
@@ -357,7 +357,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
{
NULL
,
0
,
NULL
,
0
},
};
debug_log
(
LOG_FOCUS
,
"kk_voice_panel_uart_dev_chose
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"kk_voice_panel_uart_dev_chose
\n
"
);
while
((
opt
=
getopt_long_only
(
argc
,
argv
,
string
,
long_options
,
&
option_index
))
!=
-
1
)
{
if
(
opt
==
0xAA5555AA
){
...
...
@@ -372,7 +372,7 @@ void kk_voice_panel_uart_dev_chose(int argc, char* argv[])
snprintf
(
serialDev
,
sizeof
(
serialDev
),
"%s"
,
SERIAL_NAME
);
}
debug_log
(
LOG_FOCUS
,
"serialDev=%s
\n
"
,
serialDev
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"serialDev=%s
\n
"
,
serialDev
);
}
int
kk_voice_panel_init
(
int
argc
,
char
*
argv
[])
...
...
application/klansdk/kk_lan_vp_ctrl.c
View file @
4d9d15b7
...
...
@@ -46,16 +46,18 @@ static KK_VP_CTRL vp_ctrl_table[]={
{
is_outlet_dev
,
outlet_dev_handle
}
};
static
int
light_dev_pid
[]
=
{
3023
,
3024
30
01
,
3002
,
3003
,
3022
,
30
23
,
3024
};
static
int
curtain_dev_pid
[]
=
{
3067
30
05
,
3006
,
3007
,
3008
,
3009
,
3010
,
3011
,
3026
,
3027
,
30
67
};
static
int
outlet_dev_pid
[]
=
{
30
20
30
19
,
3020
,
3037
,
3038
};
...
...
application/klansdk/kk_oldccu_msg.c
View file @
4d9d15b7
...
...
@@ -67,7 +67,7 @@ int send_msg_to_module(cJSON *root)
}
if
((
msg
=
cJSON_Print
(
root
))
!=
NULL
){
debug_log
(
LOG_INFO
,
"[lan->module]
\n
%s
\n
"
,
msg
);
debug_log
(
LOG_INFO
_LEVEL
,
"[lan->module]
\n
%s
\n
"
,
msg
);
cJSON_Minify
(
msg
);
kk_send_data_to_sdk
(
msg
);
free
(
msg
);
...
...
@@ -90,13 +90,14 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
if
(
newccuItem
==
NULL
||
newccuItem
->
type
!=
cJSON_Object
||
oldccuItem
==
NULL
||
oldccuItem
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
NULL
;
}
o_valueRange
=
cJSON_GetObjectItem
(
oldccuItem
,
"valueRange"
);
n_valueRange
=
cJSON_GetObjectItem
(
newccuItem
,
"valueRange"
);
n_dataType
=
cJSON_GetObjectItem
(
newccuItem
,
DATATYPE_STRING
);
n_value
=
cJSON_GetObjectItem
(
newccuItem
,
"value"
);
...
...
@@ -105,6 +106,7 @@ cJSON * val_conver_new2old(cJSON *newccuItem,cJSON *oldccuItem,int syn_type)
}
else
{
o_dataType
=
cJSON_GetObjectItem
(
oldccuItem
,
DATATYPE_STRING
);
}
return
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
n_value
);
}
...
...
@@ -113,18 +115,38 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg)
{
cJSON
*
msg
=
NULL
;
char
nodeBuff
[
33
]
=
{
0
};
char
valBuff
[
33
]
=
{
0
};
if
(
opcode
==
NULL
||
opcode
->
type
!=
cJSON_String
||
arg
==
NULL
||
arg
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
arg
==
NULL
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"nodeId=%d,opcode=%s,arg=%s
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuestring
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
32
,
"%d"
,
nodeId
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
memset
(
valBuff
,
0
,
sizeof
(
valBuff
));
if
(
arg
->
type
==
cJSON_String
){
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%s
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuestring
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
arg
->
valuestring
);
}
else
if
(
arg
->
type
==
cJSON_Number
){
if
(((
int
)(
arg
->
valuedouble
*
10
))
%
10
==
0
){
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%d
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valueint
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%d"
,
arg
->
valueint
);
}
else
{
debug_log
(
LOG_FOCUS_LEVEL
,
"nodeId=%d,opcode=%s,arg=%f
\n
"
,
nodeId
,
opcode
->
valuestring
,
arg
->
valuedouble
);
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%f"
,
arg
->
valuedouble
);
}
}
else
if
(
arg
->
type
==
cJSON_True
){
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
"true"
);
}
else
if
(
arg
->
type
==
cJSON_True
){
snprintf
(
valBuff
,
sizeof
(
valBuff
),
"%s"
,
"false"
);
}
msg
=
old_ccu_msg_build
(
nodeBuff
,
opcode
->
valuestring
,
"success"
,
arg
->
valuestring
);
send_msg_to_module
(
msg
);
cJSON_Delete
(
msg
);
...
...
@@ -139,7 +161,7 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
if
(
channelObj
!=
NULL
&&
epNumObj
!=
NULL
){
if
(
epNumObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
,
"[err] epNumObj.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] epNumObj.
\n
"
);
return
-
1
;
}
if
(
strlen
(
channelObj
->
valuestring
)
!=
strlen
(
epNumObj
->
valuestring
)
||
...
...
@@ -151,13 +173,13 @@ static int _kk_lan_check_channel(cJSON *channelObj,cJSON *epNumObj)
}
else
{
if
(
channelObj
==
NULL
){
if
(
epNumObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
,
"[err] epNumObj.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] epNumObj.
\n
"
);
return
-
1
;
}
channel
=
atoi
(
epNumObj
->
valuestring
);
}
else
if
(
epNumObj
==
NULL
){
if
(
channelObj
->
type
!=
cJSON_String
){
debug_log
(
LOG_INFO
,
"[err] channelObj.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] channelObj.
\n
"
);
return
-
1
;
}
channel
=
atoi
(
channelObj
->
valuestring
);
...
...
@@ -183,15 +205,15 @@ static int _kk_lan_sync_device_status(const char *deviceCode,kk_map_dev_node_t *
}
if
((
arg
=
_kk_sync_devicestatus_arg_build
(
devNode
))
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] arg.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] arg.
\n
"
);
return
-
1
;
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
1
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[err] nodeId.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] nodeId.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"[sync] device status.
\n
"
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[sync] device status.
\n
"
);
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
sizeof
(
nodeBuff
),
"%d"
,
nodeId
);
...
...
@@ -221,7 +243,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
cJSON
*
n_id
=
NULL
;
cJSON
*
item_size
=
NULL
;
int
o_item_size
=
0
,
n_item_size
=
0
;
int
item_size
=
0
;
cJSON
*
epsAry
=
NULL
,
*
epAryItem
=
NULL
,
*
epAryEpNumObj
=
NULL
;
...
...
@@ -231,27 +254,33 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
if
(
deviceCode
==
NULL
||
devNode
==
NULL
||
params
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] para.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] para.
\n
"
);
return
-
1
;
}
oldccu
=
devNode
->
oldccu
;
newccu
=
devNode
->
newccu
;
item_size
=
cJSON_GetArraySize
(
newccu
);
o_item_size
=
cJSON_GetArraySize
(
oldccu
);
n_item_size
=
cJSON_GetArraySize
(
newccu
);
item_size
=
(
n_item_size
>
o_item_size
)
?
n_item_size
:
o_item_size
;
for
(
i
=
0
;
i
<
item_size
;
i
++
){
n_item
=
cJSON_GetArrayItem
(
newccu
,
i
);
if
((
o_item
=
cJSON_GetArrayItem
(
oldccu
,
i
))
==
NULL
||
o_item
->
type
!=
cJSON_Object
){
debug_log
(
LOG_INFO
,
"[err] para.
\n
"
);
debug_log
(
LOG_INFO
_LEVEL
,
"[err] para.i=%d
\n
"
,
i
);
continue
;
}
if
((
n_id
=
cJSON_GetObjectItem
(
n_item
,
"identifier"
))
==
NULL
||
n_id
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] cfg file.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] cfg file.
\n
"
);
continue
;
}
...
...
@@ -263,16 +292,18 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
o_dataType
=
cJSON_GetObjectItem
(
o_item
,
"dataType"
);
o_valueRange
=
cJSON_GetObjectItem
(
o_item
,
"valueRange"
);
if
(
n_dataType
==
NULL
||
n_dataType
->
type
!=
cJSON_String
||
o_dataType
==
NULL
||
o_dataType
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] dataType.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] dataType.
\n
"
);
continue
;
}
channelObj
=
cJSON_GetObjectItem
(
o_item
,
"channel"
);
epNumObj
=
cJSON_GetObjectItem
(
params
,
"epNum"
);
if
((
channel
=
_kk_lan_check_channel
(
channelObj
,
epNumObj
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[channel] %d.
\n
"
,
channel
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[channel] %d.
\n
"
,
channel
);
continue
;
}
...
...
@@ -283,12 +314,12 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
epAryEpNumObj
=
cJSON_GetObjectItem
(
epAryItem
,
"epNum"
);
if
(
epAryEpNumObj
==
NULL
||
epAryEpNumObj
->
type
!=
cJSON_String
||
channel
!=
atoi
(
epAryEpNumObj
->
valuestring
)){
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[epsAry match] next.
\n
"
);
continue
;
}
if
((
valObj
=
cJSON_GetObjectItem
(
epAryItem
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[epsAry match] next.
\n
"
);
continue
;
}
else
{
mFlag
=
1
;
...
...
@@ -300,35 +331,40 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
}
}
else
{
if
((
valObj
=
cJSON_GetObjectItem
(
params
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_NORMAL
,
"[match] next.
\n
"
);
debug_log
(
LOG_NORMAL
_LEVEL
,
"[match] next.
\n
"
);
continue
;
}
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
channel
))
==-
1
){
debug_log
(
LOG_DEBUG
,
"[err] not find node.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find node.
\n
"
);
continue
;
}
if
((
opcode
=
cJSON_GetObjectItem
(
n_item
,
"opcodemap"
))
==
NULL
||
opcode
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] cfg file.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] cfg file.
\n
"
);
continue
;
}
kk_lan_replace_val_to_obj
(
n_item
,
valObj
,
"value"
);
if
((
args
=
ccu_value_convert
(
n_dataType
,
n_valueRange
,
o_dataType
,
o_valueRange
,
valObj
))
!=
NULL
){
_kk_lan_update_device_status
(
nodeId
,
opcode
,
args
);
//todo :
//cJSON_Delete(args);
}
}
_kk_lan_sync_device_status
(
deviceCode
,
devNode
);
...
...
@@ -363,7 +399,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
cJSON
*
params
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[property post] deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[property post] deviceCode(%s).
\n
"
,
deviceCode
);
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
dev
)
==
0
){
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
...
...
@@ -374,7 +410,7 @@ int kk_lan_property_post_deal(const char *deviceCode,cJSON *payload)
return
kk_lan_property_convert
(
deviceCode
,
dev
,
params
);
}
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
return
-
1
;
}
return
0
;
...
...
@@ -386,12 +422,12 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
cJSON
*
params
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[property syn] deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[property syn] deviceCode(%s).
\n
"
,
deviceCode
);
if
(
kk_map_dev_search_by_deviceCode
(
deviceCode
,
&
dev
)
==
0
){
return
kk_lan_property_convert
(
deviceCode
,
dev
,
properties
);
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] not find deviceCode(%s).
\n
"
,
deviceCode
);
return
-
1
;
}
return
0
;
...
...
@@ -400,7 +436,7 @@ int kk_lan_property_syn_deal(const char *deviceCode,cJSON *properties)
//添加场景通知
void
kk_lan_add_scene_notify
(
const
char
*
scene_id
)
{
debug_log
(
LOG_FOCUS
,
"[notify] add scene(%s).
\n
"
,
scene_id
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] add scene(%s).
\n
"
,
scene_id
);
kk_handle_sync_info
();
}
...
...
@@ -408,7 +444,7 @@ void kk_lan_add_scene_notify(const char* scene_id)
//删除场景通知
void
kk_lan_delete_scene_notify
(
const
char
*
scene_id
)
{
debug_log
(
LOG_FOCUS
,
"[notify] delete scene(%s).
\n
"
,
scene_id
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] delete scene(%s).
\n
"
,
scene_id
);
cJSON
*
msg
=
old_ccu_msg_build
(
scene_id
,
"DELETE_SCENE"
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
send_msg_to_module
(
msg
);
...
...
@@ -422,7 +458,7 @@ int kk_lan_arming_status_notify(int type)
{
cJSON
*
msg
=
NULL
;
debug_log
(
LOG_FOCUS
,
"[notify] arming status(%d).
\n
"
,
type
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[notify] arming status(%d).
\n
"
,
type
);
if
(
type
==
0
){
msg
=
old_ccu_msg_build
(
WILDCARD_CHARACTER_STR
,
GUARD_STATUS_ARMING_LEAVE_HOME
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
...
...
@@ -433,7 +469,7 @@ int kk_lan_arming_status_notify(int type)
}
else
if
(
type
==
3
){
msg
=
old_ccu_msg_build
(
WILDCARD_CHARACTER_STR
,
ARMING_STATUS_GUARD_ZONE
,
SUCCESS_STR
,
WILDCARD_CHARACTER_STR
);
}
else
{
debug_log
(
LOG_DEBUG
,
"[err] unknow type(%d).
\n
"
,
type
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] unknow type(%d).
\n
"
,
type
);
return
-
1
;
}
...
...
@@ -451,11 +487,11 @@ static int _kk_lan_delete_node(const char *deviceCode,const char *nodeid)
kk_map_dev_node_t
*
dev
;
if
(
deviceCode
==
NULL
||
nodeid
==
NULL
){
debug_log
(
LOG_DEBUG
,
"[err] params.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params.
\n
"
);
return
-
1
;
}
debug_log
(
LOG_FOCUS
,
"[del dev node] id(%s).
\n
"
,
nodeid
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[del dev node] id(%s).
\n
"
,
nodeid
);
arg
=
cJSON_CreateObject
();
_deviceCode_switchto_mac
(
deviceCode
,
mac
);
...
...
@@ -476,7 +512,7 @@ static int _kk_lan_delete_device(const char *deviceCode)
num
=
kk_lan_db_node_get_all
(
deviceCode
,
list
);
debug_log
(
LOG_FOCUS
,
"[del dev] deviceCode(%s)/node num(%d).
\n
"
,
deviceCode
,
num
);
debug_log
(
LOG_FOCUS
_LEVEL
,
"[del dev] deviceCode(%s)/node num(%d).
\n
"
,
deviceCode
,
num
);
for
(
i
=
0
;
i
<
num
;
i
++
){
memset
(
nodeId
,
0
,
sizeof
(
nodeId
));
...
...
@@ -500,13 +536,13 @@ int kk_lan_device_delete_notify(cJSON *payload)
if
((
params
=
cJSON_GetObjectItem
(
payload
,
"params"
))
==
NULL
||
params
->
type
!=
cJSON_Object
){
debug_log
(
LOG_DEBUG
,
"[err] params.
\n
"
);
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] params.
\n
"
);
return
-
1
;
}
if
((
deviceCode
=
cJSON_GetObjectItem
(
params
,
"deviceCode"
))
==
NULL
||
params
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
,
"[err] deviceCode.
\n
"
);
deviceCode
->
type
!=
cJSON_String
){
debug_log
(
LOG_DEBUG
_LEVEL
,
"[err] deviceCode.
\n
"
);
return
-
1
;
}
...
...
application/klansdk/kk_voice_panel_handle.h
View file @
4d9d15b7
...
...
@@ -6,9 +6,9 @@
#include "kk_voice_panel_cfg.h"
#define VP_CONFIG_FILE_MD5 "voice_data.MD5"
#define VP_CONFIG_FILE "/etc/smarthome/voice_data.json"
#define VP_CONFIG_FILE_TAR_GZ "voice_data.tar.gz"
#define VP_CONFIG_FILE_MD5 "/data/kk/voice_data.MD5"
#define VP_CONFIG_FILE_TAR_GZ "/data/kk/voice_data.tar.gz"
#define OPCODE_8009_SNAPSHOOT 0x1000
...
...
opcodeMapCfg/device_3024.json
View file @
4d9d15b7
{
"productCode"
:
"3024"
,
"operateType"
:
"3"
,
"channel"
:
3
,
"newccu"
:[
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
},
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"2"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
},
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"3"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
}
],
"oldccu"
:[
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"OFF"
,
"ON"
]
},
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"2"
,
"valueRange"
:[
"OFF"
,
"ON"
]
},
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"3"
,
"valueRange"
:[
"OFF"
,
"ON"
]
}
]
}
{
"productCode"
:
"3024"
,
"operateType"
:
"3"
,
"channel"
:
3
,
"newccu"
:[
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"1"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
},
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"2"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
},
{
"identifier"
:
"PowerSwitch"
,
"opcodemap"
:
"SWITCH"
,
"dataType"
:
"int"
,
"channel"
:
"3"
,
"valueRange"
:[
0
,
1
],
"value"
:
0
}
],
"oldccu"
:[
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"1"
,
"valueRange"
:[
"OFF"
,
"ON"
]
},
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"2"
,
"valueRange"
:[
"OFF"
,
"ON"
]
},
{
"opcode"
:
"SWITCH"
,
"identifiermap"
:
"PowerSwitch"
,
"dataType"
:
"map"
,
"channel"
:
"3"
,
"valueRange"
:[
"OFF"
,
"ON"
]
}
]
}
\ No newline at end of file
opcodeMapCfg/device_3029.json
View file @
4d9d15b7
...
...
@@ -47,13 +47,6 @@
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
22
},{
"identifier"
:
"time_off"
,
"opcodemap"
:
"FLOOR_HEATING_DEV_STATUS"
,
"dataType"
:
"dummy"
,
"channel"
:
"1"
,
"valueRange"
:[],
"value"
:
0
}
],
"oldccu"
:[
...
...
@@ -76,7 +69,7 @@
},{
"opcode"
:
"SET_WORK_TEMPERATURE"
,
"identifiermap"
:
"Temperature"
,
"dataType"
:
"double"
,
"dataType"
:
"
string_
double"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"work_temperature"
,
...
...
@@ -84,7 +77,7 @@
},{
"opcode"
:
"FLOOR_HEATING_SET_TIME_OFF"
,
"identifiermap"
:
"TimingOffTime"
,
"dataType"
:
"
double
"
,
"dataType"
:
"
fit
"
,
"channel"
:
"1"
,
"valueRange"
:[],
"syn"
:
"time_off"
,
...
...
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