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
80b88e71
Commit
80b88e71
authored
Jan 20, 2022
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】修改a133平台ccuid获取方式
【提交人】陈伟灿
parent
97845c72
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
20 additions
and
145 deletions
+20
-145
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+1
-1
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+2
-2
application/klansdk/kk_ccu_msg.c
application/klansdk/kk_ccu_msg.c
+0
-4
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+1
-1
application/klansdk/kk_data_mng.c
application/klansdk/kk_data_mng.c
+2
-9
application/klansdk/kk_findccu_handle.c
application/klansdk/kk_findccu_handle.c
+6
-1
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+0
-25
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+1
-38
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+0
-8
application/klansdk/kk_lan_sync.h
application/klansdk/kk_lan_sync.h
+1
-1
application/klansdk/kk_login_handle.c
application/klansdk/kk_login_handle.c
+2
-2
application/klansdk/kk_newccu_msg.c
application/klansdk/kk_newccu_msg.c
+0
-18
application/klansdk/kk_newccu_msg.h
application/klansdk/kk_newccu_msg.h
+0
-3
application/klansdk/kk_oldccu_msg.c
application/klansdk/kk_oldccu_msg.c
+2
-30
common/hal/kk_product.h
common/hal/kk_product.h
+2
-2
No files found.
application/kcloud/kcloud_main.c
View file @
80b88e71
...
...
@@ -119,7 +119,7 @@ static int kk_cloud_key_init(void)
pstart
=
key
;
pEnd
=
strstr
(
key
,
"key_"
);
if
(
pEnd
!=
NULL
){
memcpy
(
s_key
,
pEnd
+
4
,
key_len
-
1
-
(
pEnd
-
pstart
+
4
));
memcpy
(
s_key
,
pEnd
+
4
,
key_len
-
(
pEnd
-
pstart
+
4
));
INFO_PRINT
(
"kk_cloud_key_init s_key:%s
\n
"
,
s_key
);
}
else
{
//_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
...
...
application/kcloud/kk_register.c
View file @
80b88e71
...
...
@@ -716,9 +716,9 @@ MQTTAsync kk_mqtt_connect(){
}
return
KK_MQTT_Connect_ex
(
usrname
,
pwd
,
clientId
,
host
,
port
);
}
else
{
return
kk_connect_default
();
return
NULL
;
//
kk_connect_default();
}
}
else
{
return
kk_connect_default
();
return
NULL
;
//
kk_connect_default();
}
}
\ No newline at end of file
application/klansdk/kk_ccu_msg.c
View file @
80b88e71
...
...
@@ -367,10 +367,6 @@ cJSON *map_type_convert(cJSON *s_dataType,cJSON *s_valueRange,cJSON *value,cJSON
return
NULL
;
}
sVrg
=
cJSON_Print
(
s_valueRange
);
dVrg
=
cJSON_Print
(
d_valueRange
);
pVal
=
cJSON_Print
(
value
);
...
...
application/klansdk/kk_data_handle.c
View file @
80b88e71
...
...
@@ -282,7 +282,7 @@ int kk_zb_devs_hw_ack_all(int sockfd)
_kk_map_dev_mutex_unlock
();
_kk_zb_devs_hw_ack
(
sockfd
,
array
);
return
-
1
;
return
0
;
}
cJSON
*
kk_zb_dev_hw_info_build_by_deviceCode
(
int
sockfd
,
const
char
*
deviceCode
,
int
online
)
//
...
...
application/klansdk/kk_data_mng.c
View file @
80b88e71
...
...
@@ -10,9 +10,6 @@
static
kk_map_dev_ctx
g_map_dev_mgr
=
{
0
};
kk_map_dev_ctx
*
_kk_map_dev_ctx
(
void
)
{
return
&
g_map_dev_mgr
;
...
...
@@ -57,7 +54,6 @@ void kk_map_dev_deinit(void)
list_for_each_entry_safe
(
node
,
n
,
&
ctx
->
dev_list
,
linked_list
,
kk_map_dev_node_t
)
{
if
(
node
!=
NULL
)
{
if
(
node
->
json
){
//printf("[delete cjson] node->json.\n");
cJSON_Delete
(
node
->
json
);
...
...
@@ -70,7 +66,8 @@ void kk_map_dev_deinit(void)
//printf("[remove list] node->linked_list\n");
dlist_del
(
&
node
->
linked_list
);
memset
(
node
,
0
,
sizeof
(
kk_map_dev_node_t
));
free
(
node
);
node
=
NULL
;
}
}
_kk_map_dev_mutex_unlock
();
...
...
@@ -92,9 +89,6 @@ static kk_map_dev_node_t *kk_map_dev_node_create(const char *deviceCode,const ch
return
NULL
;
}
memset
(
node
,
0x0
,
sizeof
(
kk_map_dev_node_t
));
json
=
cJSON_Parse
(
buf
);
if
(
json
==
NULL
){
free
(
buf
);
...
...
@@ -103,7 +97,6 @@ static kk_map_dev_node_t *kk_map_dev_node_create(const char *deviceCode,const ch
return
NULL
;
}
node
->
json
=
json
;
optype
=
cJSON_GetObjectItem
(
json
,
OPEARTETYPE_STRING
);
channel
=
cJSON_GetObjectItem
(
json
,
CHANNEL_STRING
);
...
...
application/klansdk/kk_findccu_handle.c
View file @
80b88e71
...
...
@@ -80,6 +80,7 @@ void *kk_findccu_handle(void *data)
char
*
pStart
=
NULL
,
*
pEnd
=
NULL
;
fd_set
server_fd_set
;
int
yes
=
1
;
int
count
=
0
;
while
(
1
){
sockfd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
bzero
(
&
saddr
,
sizeof
(
saddr
));
...
...
@@ -104,7 +105,11 @@ void *kk_findccu_handle(void *data)
sockfd
=
-
1
;
break
;
}
else
if
(
ret
==
0
){
count
++
;
if
(
count
>
30
){
count
=
0
;
DEBUG_PRINT
(
"UDP receiving timeout......
\n
"
);
}
}
else
{
if
(
FD_ISSET
(
sockfd
,
&
server_fd_set
))
{
...
...
application/klansdk/kk_lan_ctrl.c
View file @
80b88e71
...
...
@@ -390,10 +390,7 @@ int kk_ccu_opcode_handle(cJSON *root)
//execute scene
if
((
requester
!=
NULL
)
&&
(
strcmp
(
requester
->
valuestring
,
HJ_PROFILE
)
==
0
)
&&
(
strcmp
(
opcode
->
valuestring
,
"SWITCH"
)
==
0
)){
msg
=
scene_execute
(
nodeId
->
valuestring
);
kk_ipc_send_json
(
msg
);
return
0
;
...
...
@@ -426,28 +423,6 @@ int kk_ccu_opcode_handle(cJSON *root)
char
*
node_string
(
int
nodeId
)
{
char
*
node
=
(
char
*
)
malloc
(
33
);
memset
(
node
,
0
,
33
);
snprintf
(
node
,
32
,
"%d"
,
nodeId
);
return
node
;
}
...
...
application/klansdk/kk_lan_main.c
View file @
80b88e71
...
...
@@ -109,43 +109,6 @@ static void kk_lan_ccuid_init(void)
#endif
}
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
));
}
#define SYNC_INFO_FLAG 0x01
#define SYNC_INFO_PUSH_FLAG 0x02
static
int
g_sync_flag
;
...
...
@@ -259,7 +222,7 @@ int main(int argc, char* argv[])
}
usleep
(
5
0
);
usleep
(
100
*
100
0
);
}
return
0
;
}
...
...
application/klansdk/kk_lan_sync.c
View file @
80b88e71
...
...
@@ -1123,7 +1123,6 @@ int kk_send_indoorAir_status(cJSON *info,const char *deviceCode)
return
-
1
;
}
cJSON
*
epNum
=
cJSON_GetObjectItem
(
info
,
"epNum"
);
if
(
epNum
==
NULL
){
return
-
1
;
...
...
@@ -1523,13 +1522,6 @@ int kk_create_syncinfo_to_sdk(cJSON *payload,int push)
controllers
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
root
,
"controllers"
,
controllers
);
kk_sync_devices_status_to_sdk
(
root
);
...
...
application/klansdk/kk_lan_sync.h
View file @
80b88e71
...
...
@@ -4,7 +4,7 @@
#include "cJSON.h"
#define MAX_AC_GW_AIR_NUM 5
#define MAX_AC_INDOOR_AIR_NUM
16
#define MAX_AC_INDOOR_AIR_NUM
64
#define AIR_AC_INDOOR_ID_SIZE 8
#define AIR_AC_INDOOR_ROOM_ID_SIZE 24
...
...
application/klansdk/kk_login_handle.c
View file @
80b88e71
...
...
@@ -173,7 +173,7 @@ void *TCPServer()
}
ret
=
select
(
max_fd
+
1
,
&
server_fd_set
,
NULL
,
NULL
,
&
time_out
);
if
(
ret
<=
0
){
//
DEBUG
_PRINT("TCPServer:TCP receiving nothing......\n");
//
INFO
_PRINT("TCPServer:TCP receiving nothing......\n");
//break;
}
else
{
if
(
FD_ISSET
(
Listenfd
,
&
server_fd_set
))
...
...
@@ -196,6 +196,7 @@ void *TCPServer()
if
(
s_ConnInfo
[
i
].
socketfd
!=
-
1
){
if
(
i
==
LISTEN_MAX
-
1
){
DEBUG_PRINT
(
"more then max client!!!
\n
"
);
break
;
}
continue
;
}
else
{
...
...
@@ -203,7 +204,6 @@ void *TCPServer()
s_ConnInfo
[
i
].
socketfd
=
client_fd
;
memcpy
(
s_ConnInfo
[
i
].
ip
,
clientIp
,
strlen
(
clientIp
));
index
=
i
;
printf
(
"index:%d
\n
"
,
index
);
pthread_mutex_unlock
(
&
data_mutex
);
break
;
}
...
...
application/klansdk/kk_newccu_msg.c
View file @
80b88e71
...
...
@@ -66,20 +66,6 @@ cJSON * property_set(const char *productCode,const char *deviceCode,const char *
return
root
;
}
cJSON
*
property_report
(
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
msgId
,
const
char
*
version
,
cJSON
*
params
)
{
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
info
=
property_info_build
(
"/thing/event/{tsl.event.identifier}/post"
,
productCode
,
deviceCode
);
cJSON
*
payload
=
property_payload_build
(
"thing.event.{tsl.event.identifier}.post"
,
msgId
,
version
,
params
);
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
PAYLOAD_STRING
,
payload
);
return
root
;
}
extern
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
cJSON
*
scene_payload_build
(
const
char
*
method
,
const
char
*
msgId
,
cJSON
*
params
)
...
...
@@ -103,8 +89,6 @@ cJSON *scene_payload_build(const char*method,const char *msgId,cJSON *params)
return
payload
;
}
cJSON
*
scene_execute
(
const
char
*
sceneId
)
{
char
msgId
[
32
]
=
{
0
};
...
...
@@ -134,12 +118,10 @@ cJSON * scene_execute(const char *sceneId)
int
kk_ipc_send_json
(
cJSON
*
root
)
{
char
*
msg
;
if
(
root
==
NULL
){
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
return
-
1
;
}
if
(
mutex
==
NULL
){
kk_new_msg_init
();
}
...
...
application/klansdk/kk_newccu_msg.h
View file @
80b88e71
...
...
@@ -6,9 +6,6 @@
cJSON
*
property_info_build
(
const
char
*
msgtype
,
const
char
*
productCode
,
const
char
*
deviceCode
);
cJSON
*
property_payload_build
(
const
char
*
method
,
const
char
*
msgId
,
const
char
*
version
,
cJSON
*
params
);
cJSON
*
property_set
(
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
msgId
,
const
char
*
version
,
cJSON
*
params
);
cJSON
*
property_report
(
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
msgId
,
const
char
*
version
,
cJSON
*
params
);
...
...
application/klansdk/kk_oldccu_msg.c
View file @
80b88e71
...
...
@@ -16,7 +16,6 @@
#include "kk_lan_sync.h"
#include "kk_data_mng.h"
#include "kk_data_handle.h"
cJSON
*
old_ccu_msg_build_json
(
const
char
*
nodeid
,
const
char
*
opcode
,
const
char
*
status
,
cJSON
*
arg
)
{
cJSON
*
root
;
...
...
@@ -24,7 +23,6 @@ cJSON *old_ccu_msg_build_json(const char* nodeid,const char* opcode,const char*
if
(
nodeid
==
NULL
||
opcode
==
NULL
||
arg
==
NULL
)
{
return
NULL
;
}
root
=
cJSON_CreateObject
();
if
(
root
){
cJSON_AddStringToObject
(
root
,
"nodeid"
,
nodeid
);
...
...
@@ -64,26 +62,15 @@ int send_msg_to_module(cJSON *root)
if
(
root
==
NULL
){
return
-
1
;
}
if
((
msg
=
cJSON_Print
(
root
))
!=
NULL
){
//debug_log(LOG_INFO_LEVEL,"[lan->module]\n%s\n",msg);
cJSON_Minify
(
msg
);
kk_send_data_to_sdk
(
msg
);
free
(
msg
);
}
return
0
;
}
cJSON
*
val_conver_new2old
(
cJSON
*
newccuItem
,
cJSON
*
oldccuItem
,
int
syn_type
)
{
cJSON
*
n_value
=
NULL
,
*
n_dataType
=
NULL
,
*
o_dataType
=
NULL
;
...
...
@@ -126,7 +113,6 @@ static int _kk_lan_update_device_status(int nodeId,cJSON *opcode,cJSON *arg,cons
memset
(
nodeBuff
,
0
,
sizeof
(
nodeBuff
));
snprintf
(
nodeBuff
,
32
,
"%d"
,
nodeId
);
memset
(
valBuff
,
0
,
sizeof
(
valBuff
));
if
(
arg
->
type
==
cJSON_String
){
...
...
@@ -251,11 +237,8 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
cJSON
*
n_item
=
NULL
,
*
o_item
=
NULL
;
cJSON
*
o_valueRange
=
NULL
,
*
n_valueRange
=
NULL
;
cJSON
*
o_dataType
=
NULL
,
*
n_dataType
=
NULL
;
cJSON
*
opcode
=
NULL
,
*
channelObj
=
NULL
,
*
epNumObj
=
NULL
;
cJSON
*
n_id
=
NULL
;
int
o_item_size
=
0
,
n_item_size
=
0
;
int
item_size
=
0
;
...
...
@@ -276,8 +259,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
item_size
=
(
n_item_size
>
o_item_size
)
?
o_item_size
:
n_item_size
;
for
(
i
=
0
;
i
<
item_size
;
i
++
){
n_item
=
cJSON_GetArrayItem
(
newccu
,
i
);
...
...
@@ -324,12 +305,11 @@ 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_DEBUG_LEVEL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_DEBUG_LEVEL
,
"[epsAry match
11
] next.
\n
"
);
continue
;
}
if
((
valObj
=
cJSON_GetObjectItem
(
epAryItem
,
n_id
->
valuestring
))
==
NULL
){
debug_log
(
LOG_DEBUG_LEVEL
,
"[epsAry match] next.
\n
"
);
debug_log
(
LOG_DEBUG_LEVEL
,
"[epsAry match
22
] next.
\n
"
);
continue
;
}
else
{
mFlag
=
1
;
...
...
@@ -346,7 +326,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
}
}
if
((
nodeId
=
kk_lan_db_node_get
(
deviceCode
,
channel
))
==-
1
){
debug_log
(
LOG_DEBUG_LEVEL
,
"[err] not find node.
\n
"
);
continue
;
...
...
@@ -357,18 +336,14 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
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
,
devNode
->
syn_opcode
);
//todo :
//cJSON_Delete(args);
}
}
debug_log
(
LOG_EMERG_LEVEL
,
"devNode->channelNum=%d
\n
"
,
devNode
->
channelNum
);
...
...
@@ -377,8 +352,6 @@ static int kk_lan_property_convert(const char *deviceCode,kk_map_dev_node_t *dev
debug_log
(
LOG_EMERG_LEVEL
,
"k=%d
\n
"
,
k
);
_kk_lan_sync_device_status
(
deviceCode
,
devNode
,
k
+
1
);
}
return
0
;
}
...
...
@@ -397,7 +370,6 @@ static int attr_indoorAir_report(cJSON *params,const char *deviceCode)
}
else
{
int
epsize
=
cJSON_GetArraySize
(
epsAry
);
for
(
k
=
0
;
k
<
epsize
;
k
++
){
char
tmpIdx
[
4
]
=
{
0
};
cJSON
*
infoItem
=
cJSON_GetArrayItem
(
epsAry
,
k
);
if
(
infoItem
==
NULL
)
continue
;
...
...
common/hal/kk_product.h
View file @
80b88e71
...
...
@@ -38,8 +38,8 @@
#define KK_DEVICESECRET_PATH "/data/local/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/local/kk/kk_token.txt"
#define KK_DEVICE_MAP_FILE_PATH "/data/local/kk/map/device_%s.json"
#define GET_CCUID_CMD "
getprop ro.ccuinfo"
#define GET_KEY_CMD "
getprop ro.ccuinfo
"
#define GET_CCUID_CMD "
cat /mnt/private/ULI/factory/ccuinfo.txt"//"getprop ro.ccuinfo"//
#define GET_KEY_CMD "
cat /mnt/private/ULI/factory/ccuinfo.txt
"
#define GET_PRODUCTID_CMD "getprop ro.product.ccu.pid"
#define KK_DB_FILE "/data/local/kk/db/kk_database.db"
#define TSL_SUBDEVICE_PATH_FILE "/data/local/kk/tsl/product_%s.json"
...
...
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