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
62c805fd
Commit
62c805fd
authored
Nov 26, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】1,增加3A认证;2,增加MOORE屏接入支持
【提交人】陈伟灿
parent
f810862d
Changes
44
Show whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
1945 additions
and
212 deletions
+1945
-212
application/kcloud/iot.mk
application/kcloud/iot.mk
+5
-2
application/kcloud/kcloud_config.h
application/kcloud/kcloud_config.h
+2
-0
application/kcloud/kcloud_data_handle.c
application/kcloud/kcloud_data_handle.c
+4
-1
application/kcloud/kcloud_main.c
application/kcloud/kcloud_main.c
+95
-1
application/kcloud/kk_info_report.c
application/kcloud/kk_info_report.c
+3
-1
application/kcloud/kk_register.c
application/kcloud/kk_register.c
+296
-8
application/kcloud/kk_topic_mng.c
application/kcloud/kk_topic_mng.c
+7
-6
application/kcloud/mqtt_api.c
application/kcloud/mqtt_api.c
+41
-1
application/kcloud/mqtt_api.h
application/kcloud/mqtt_api.h
+1
-0
application/klansdk/iot.mk
application/klansdk/iot.mk
+4
-1
application/klansdk/kk_data_handle.c
application/klansdk/kk_data_handle.c
+91
-6
application/klansdk/kk_findccu_handle.h
application/klansdk/kk_findccu_handle.h
+1
-1
application/klansdk/kk_lan_ctrl.c
application/klansdk/kk_lan_ctrl.c
+50
-7
application/klansdk/kk_lan_main.c
application/klansdk/kk_lan_main.c
+23
-3
application/klansdk/kk_lan_sync.c
application/klansdk/kk_lan_sync.c
+7
-7
application/klansdk/kk_newccu_msg.c
application/klansdk/kk_newccu_msg.c
+8
-7
application/klansdk/kk_opcode.h
application/klansdk/kk_opcode.h
+1
-1
common/api/com_api.h
common/api/com_api.h
+9
-5
common/hal/HAL_OS_linux.c
common/hal/HAL_OS_linux.c
+0
-21
common/hal/kk_hal.h
common/hal/kk_hal.h
+1
-2
common/hal/kk_product.h
common/hal/kk_product.h
+6
-3
midware/midware/dm/dm_ota.c
midware/midware/dm/dm_ota.c
+2
-2
midware/midware/dm/kk_dm_mng.c
midware/midware/dm/kk_dm_mng.c
+25
-1
midware/midware/dm/kk_dm_mng.h
midware/midware/dm/kk_dm_mng.h
+3
-2
midware/midware/dm/kk_dm_msg.h
midware/midware/dm/kk_dm_msg.h
+13
-0
midware/midware/dm/kk_linkkit.c
midware/midware/dm/kk_linkkit.c
+385
-44
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+178
-2
midware/midware/dm/kk_property_db.h
midware/midware/dm/kk_property_db.h
+12
-0
midware/midware/dm/kk_sub_db.c
midware/midware/dm/kk_sub_db.c
+282
-26
midware/midware/dm/kk_sub_db.h
midware/midware/dm/kk_sub_db.h
+28
-1
midware/midware/dm/kk_sync_data.c
midware/midware/dm/kk_sync_data.c
+53
-9
midware/midware/iot.mk
midware/midware/iot.mk
+5
-2
midware/midware/midware.c
midware/midware/midware.c
+42
-4
midware/midware/scene/kk_scene_handle.c
midware/midware/scene/kk_scene_handle.c
+2
-2
nx5_soc_gw/kk_device_def.json
nx5_soc_gw/kk_device_def.json
+248
-1
nx5_soc_gw/smarthome_z3gw_nx5
nx5_soc_gw/smarthome_z3gw_nx5
+0
-0
opcodeMapCfg/device_3094.json
opcodeMapCfg/device_3094.json
+1
-1
script/killall.sh
script/killall.sh
+0
-0
script/onboot.sh
script/onboot.sh
+2
-2
script/process_check.sh
script/process_check.sh
+1
-1
testgit.txt
testgit.txt
+0
-0
tools/board/config.alios.esp8266
tools/board/config.alios.esp8266
+0
-22
tools/build-rules/_rules-top.mk
tools/build-rules/_rules-top.mk
+7
-5
tsl/version
tsl/version
+1
-1
No files found.
application/kcloud/iot.mk
View file @
62c805fd
...
@@ -14,13 +14,16 @@ ifeq ($(CONFIG_MODEL),x86)
...
@@ -14,13 +14,16 @@ ifeq ($(CONFIG_MODEL),x86)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_ubuntu
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_ubuntu
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_ubuntu
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_ubuntu
else
ifeq
($(CONFIG_MODEL),nx5)
else
ifeq
($(CONFIG_MODEL),nx5)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_nx5
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_nx5
-lcurl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_nx5
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_nx5
else
ifeq
($(CONFIG_MODEL),8197)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_8197
-lubacktrace
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_8197
else
else
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev
endif
endif
LDFLAGS
+=
-liot_cjson
-liot_mqtt
-ldl
-lm
-l
anl
-l
kk_hal
LDFLAGS
+=
-liot_cjson
-liot_mqtt
-ldl
-lm
-lkk_hal
application/kcloud/kcloud_config.h
View file @
62c805fd
...
@@ -22,5 +22,7 @@ typedef enum {
...
@@ -22,5 +22,7 @@ typedef enum {
#define MQTT_AUTH_HOST_NAME "test.dev.nj-ikonke.site"
#define MQTT_AUTH_HOST_NAME "test.dev.nj-ikonke.site"
int
KK_Get_ccuid
(
char
*
device_code
);
int
KK_Get_ccuid
(
char
*
device_code
);
int
kk_check_config_file
(
char
*
path
,
char
**
config
);
int
kk_cloud_get_pid
(
char
*
productId
);
#endif
#endif
application/kcloud/kcloud_data_handle.c
View file @
62c805fd
...
@@ -199,6 +199,9 @@ char * g_filerToCloudTable[] =
...
@@ -199,6 +199,9 @@ char * g_filerToCloudTable[] =
(
char
*
){
"/thing/service/delAlarm_reply"
},
(
char
*
){
"/thing/service/delAlarm_reply"
},
(
char
*
){
"/thing/service/syncinfo_reply"
},
(
char
*
){
"/thing/service/syncinfo_reply"
},
(
char
*
){
"/thing/service/syncinfopush_reply"
},
(
char
*
){
"/thing/service/syncinfopush_reply"
},
(
char
*
){
"/thing/service/clientReport_reply"
},
(
char
*
){
"/thing/service/clientOnlinePush"
},
(
char
*
){
"/thing/service/getClientInfo_reply"
},
};
};
/************************************************************
/************************************************************
*功能描述:过滤不需要下发给网关的消息
*功能描述:过滤不需要下发给网关的消息
...
...
application/kcloud/kcloud_main.c
View file @
62c805fd
...
@@ -58,6 +58,28 @@ static int KK_Ccuid_init(void)
...
@@ -58,6 +58,28 @@ static int KK_Ccuid_init(void)
}
}
return
0
;
return
0
;
}
}
char
s_pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
static
int
kk_cloud_pid_init
(
void
)
{
char
pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
int
pid_len
=
0
;
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
pid
,
sizeof
(
pid
),
&
pid_len
);
if
(
pid_len
>
0
&&
pid_len
<=
PRODUCT_CODE_LEN
){
memcpy
(
s_pid
,
pid
,
pid_len
-
1
);
INFO_PRINT
(
"s_pid:%s
\n
"
,
s_pid
);
}
else
{
return
-
1
;
}
return
0
;
}
int
kk_cloud_get_pid
(
char
*
productId
)
{
strncpy
(
productId
,
s_pid
,
strlen
(
s_pid
));
printf
(
"kk_cloud_get_pid:%s
\n
"
,
s_pid
);
return
strlen
(
s_pid
);
}
static
int
mqtt_start
(
void
)
static
int
mqtt_start
(
void
)
{
{
int
count
=
0
;
int
count
=
0
;
...
@@ -94,9 +116,55 @@ static int mqtt_start(void)
...
@@ -94,9 +116,55 @@ static int mqtt_start(void)
MQTTAsync_destroy
(
&
mqttClient
);
MQTTAsync_destroy
(
&
mqttClient
);
return
-
1
;
return
-
1
;
}
extern
MQTTAsync
kk_mqtt_connect
();
extern
MQTTAsync
kk_connect_default
(
void
);
static
int
mqtt_start_ex
(
int
isdefault
)
{
int
count
=
0
;
MQTTAsync
mqttClient
;
int
rc
=
0
;
if
(
isdefault
){
mqttClient
=
kk_connect_default
();
}
else
{
mqttClient
=
kk_mqtt_connect
();
}
if
(
mqttClient
==
NULL
){
WARNING_PRINT
(
"KK_MQTT_Connect FAIL!!!
\n
"
);
return
-
1
;
}
while
(
1
)
{
usleep
(
100000L
);
if
(
kk_get_cloud_status
()
==
0
){
//printf("------------------------------>count:%d\n",count);
count
++
;
if
(
count
>
500
)
{
count
=
0
;
WARNING_PRINT
(
"---------------------------------->CONNECT FAIL!!!
\n
"
);
break
;
//INFO_PRINT("i am send now\n");
//KK_MQTT_SendMsg(TOPIC,"hello my world",2);
}
}
else
{
if
(
count
>
0
){
count
=
0
;
}
}
//INFO_PRINT(" %s \n",testStr);
}
INFO_PRINT
(
"MQTTAsync_destroy
\n
"
);
MQTTAsync_destroy
(
&
mqttClient
);
return
-
1
;
}
}
int
kk_start_ccu_register
(
void
);
int
kk_start_ccu_register
(
void
);
extern
int
kk_info_report_start
(
void
);
extern
int
kk_info_report_start
(
void
);
extern
int
kk_dl_config
();
extern
int
kk_register_auth_get
();
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
rc
=
0
;
int
rc
=
0
;
...
@@ -107,8 +175,34 @@ int main(int argc, char* argv[])
...
@@ -107,8 +175,34 @@ int main(int argc, char* argv[])
ERROR_PRINT
(
"CCUID GET FAIL!!!!!!!!!!!
\n
"
);
ERROR_PRINT
(
"CCUID GET FAIL!!!!!!!!!!!
\n
"
);
return
0
;
return
0
;
}
}
kk_cloud_pid_init
();
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
kk_ipc_init
(
IPC_APP2MID
,(
ipc_cb
*
)
KK_Data_FromDev
,
NULL
,
NULL
);
//kk_info_report_start();
//kk_info_report_start();
//
#if 1
kk_dl_config
();
again:
rc
=
kk_register_auth_get
();
if
(
rc
==
0
){
rc
=
mqtt_start_ex
(
0
);
if
(
rc
<
0
){
kk_write_disconnect_flag
();
sleep
(
2
);
goto
again
;
}
}
else
if
(
rc
==
-
2
){
rc
=
mqtt_start_ex
(
1
);
if
(
rc
<
0
){
kk_write_disconnect_flag
();
sleep
(
2
);
goto
again
;
}
}
else
{
kk_write_disconnect_flag
();
sleep
(
2
);
goto
again
;
}
#else
again:
again:
rc
=
kk_start_ccu_register
();
rc
=
kk_start_ccu_register
();
if
(
rc
==
0
){
if
(
rc
==
0
){
...
@@ -123,6 +217,6 @@ again:
...
@@ -123,6 +217,6 @@ again:
sleep
(
2
);
sleep
(
2
);
goto
again
;
goto
again
;
}
}
#endif
return
rc
;
return
rc
;
}
}
application/kcloud/kk_info_report.c
View file @
62c805fd
...
@@ -41,12 +41,14 @@ static int kk_info_get(char *str)
...
@@ -41,12 +41,14 @@ static int kk_info_get(char *str)
char
version
[
VERSION_MAXLEN
]
=
{
0
};
char
version
[
VERSION_MAXLEN
]
=
{
0
};
char
*
str_tmp
=
NULL
;
char
*
str_tmp
=
NULL
;
char
ccuid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
pid
[
32
]
=
{
0
};
if
(
str
==
NULL
){
if
(
str
==
NULL
){
return
-
1
;
return
-
1
;
}
}
//HAL_GetVersion(version);
//HAL_GetVersion(version);
KK_Get_ccuid
(
ccuid
);
KK_Get_ccuid
(
ccuid
);
kk_cloud_get_pid
(
pid
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
root
=
cJSON_CreateObject
();
if
(
root
)
if
(
root
)
{
{
...
@@ -100,7 +102,7 @@ static int kk_info_get(char *str)
...
@@ -100,7 +102,7 @@ static int kk_info_get(char *str)
if
(
qr_code
)
if
(
qr_code
)
{
{
char
qrcodeStr
[
256
]
=
{
0
};
char
qrcodeStr
[
256
]
=
{
0
};
sprintf
(
qrcodeStr
,
"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB"
,
KK_CCU_PRODUCTID
,
&
ccuid
[
4
]);
sprintf
(
qrcodeStr
,
"KONKE-CCU:%s:%s:BBE3C5A5FC1FDB6CA1A386AB321D02AB"
,
pid
,
&
ccuid
[
4
]);
cJSON_AddItemToObject
(
args
,
"qr_code"
,
qr_code
);
cJSON_AddItemToObject
(
args
,
"qr_code"
,
qr_code
);
cJSON_AddStringToObject
(
qr_code
,
"string"
,
qrcodeStr
);
cJSON_AddStringToObject
(
qr_code
,
"string"
,
qrcodeStr
);
cJSON_AddBoolToObject
(
qr_code
,
"show"
,
1
);
cJSON_AddBoolToObject
(
qr_code
,
"show"
,
1
);
...
...
application/kcloud/kk_register.c
View file @
62c805fd
...
@@ -17,18 +17,40 @@
...
@@ -17,18 +17,40 @@
#include "kk_product.h"
#include "kk_product.h"
#include "kcloud_config.h"
#include "kcloud_config.h"
#include "infra_sha256.h"
#include "infra_sha256.h"
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <netinet/tcp.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "kk_log.h"
#include "kk_log.h"
#include <curl/curl.h>
#include "MQTTAsync.h"
#include "mqtt_api.h"
#define BUFSIZE 1024
#define BUFSIZE 1024
#define PRODUCTSECRET "123456"
#define PRODUCTSECRET "123456"
static
int
isIpV4Addr
(
const
char
*
ipAddr
)
{
int
ip_part_1
=
0
;
int
ip_part_2
=
0
;
int
ip_part_3
=
0
;
int
ip_part_4
=
0
;
char
end_char
=
0
;
if
((
NULL
==
ipAddr
)
||
(
0
==
strlen
(
ipAddr
))){
return
-
1
;
}
if
(
4
==
sscanf
(
ipAddr
,
"%d.%d.%d.%d%c"
,
&
ip_part_1
,
&
ip_part_2
,
&
ip_part_3
,
&
ip_part_4
,
&
end_char
)){
if
((
ip_part_1
>=
0
)
&&
(
ip_part_1
<=
255
)
&&
(
ip_part_2
>=
0
)
&&
(
ip_part_2
<=
255
)
&&
(
ip_part_3
>=
0
)
&&
(
ip_part_3
<=
255
)
&&
(
ip_part_4
>=
0
)
&&
(
ip_part_4
<=
255
)
){
return
0
;
}
}
return
-
1
;
}
int
kk_execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
)
int
kk_execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
)
{
{
if
(
cmd
==
NULL
||
buf
==
NULL
||
buf_len
==
0
)
if
(
cmd
==
NULL
||
buf
==
NULL
||
buf_len
==
0
)
...
@@ -209,7 +231,6 @@ static char * kk_create_register_info()
...
@@ -209,7 +231,6 @@ static char * kk_create_register_info()
{
{
cJSON
*
root
;
cJSON
*
root
;
char
*
out
=
NULL
;
char
*
out
=
NULL
;
char
*
productCode
=
KK_CCU_PRODUCTID
;
char
*
signSource
,
*
base64Out
=
NULL
;
char
*
signSource
,
*
base64Out
=
NULL
;
char
mac
[
16
]
=
{
0
};
char
mac
[
16
]
=
{
0
};
char
ramdonId
[
16
]
=
{
0
};
char
ramdonId
[
16
]
=
{
0
};
...
@@ -217,15 +238,17 @@ static char * kk_create_register_info()
...
@@ -217,15 +238,17 @@ static char * kk_create_register_info()
char
sign_hex_str
[
65
]
=
{
0
};
char
sign_hex_str
[
65
]
=
{
0
};
uint8_t
productSecret
[
64
]
=
{
0
};
uint8_t
productSecret
[
64
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
pid
[
32
]
=
{
0
};
int
productSecret_len
=
0
;
int
productSecret_len
=
0
;
char
keyTmp
[
64
]
=
{
0
};
char
keyTmp
[
64
]
=
{
0
};
root
=
cJSON_CreateObject
();
root
=
cJSON_CreateObject
();
HAL_Get_mac
(
mac
);
HAL_Get_mac
(
mac
);
HAL_GetTime_s
(
ramdonId
);
HAL_GetTime_s
(
ramdonId
);
KK_Get_ccuid
(
ccuid
);
KK_Get_ccuid
(
ccuid
);
kk_cloud_get_pid
(
pid
);
cJSON_AddStringToObject
(
root
,
"deviceCode"
,
ccuid
);
cJSON_AddStringToObject
(
root
,
"deviceCode"
,
ccuid
);
cJSON_AddStringToObject
(
root
,
"productCode"
,
p
roductCode
);
cJSON_AddStringToObject
(
root
,
"productCode"
,
p
id
);
signSource
=
kk_dictionary_order
(
ccuid
,
p
roductCode
,
KK_CCU_RANDOM
);
signSource
=
kk_dictionary_order
(
ccuid
,
p
id
,
KK_CCU_RANDOM
);
HAL_Execel_cmd
(
GET_KEY_CMD
,(
char
*
)
productSecret
,
sizeof
(
productSecret
),
&
productSecret_len
);
HAL_Execel_cmd
(
GET_KEY_CMD
,(
char
*
)
productSecret
,
sizeof
(
productSecret
),
&
productSecret_len
);
if
(
productSecret_len
==
0
){
if
(
productSecret_len
==
0
){
utils_hmac_sha256
((
const
uint8_t
*
)
signSource
,
strlen
(
signSource
),
(
const
uint8_t
*
)
PRODUCTSECRET
,
strlen
(
PRODUCTSECRET
),
sign_hex
);
utils_hmac_sha256
((
const
uint8_t
*
)
signSource
,
strlen
(
signSource
),
(
const
uint8_t
*
)
PRODUCTSECRET
,
strlen
(
PRODUCTSECRET
),
sign_hex
);
...
@@ -264,12 +287,14 @@ static char * kk_create_get_jwt_info()
...
@@ -264,12 +287,14 @@ static char * kk_create_get_jwt_info()
char
timestamp
[
16
]
=
{
0
};
char
timestamp
[
16
]
=
{
0
};
char
deviceSecret
[
64
]
=
{
0
};
char
deviceSecret
[
64
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
pid
[
32
]
=
{
0
};
HAL_GetTime_s
(
timestamp
);
HAL_GetTime_s
(
timestamp
);
KK_Get_ccuid
(
ccuid
);
KK_Get_ccuid
(
ccuid
);
kk_cloud_get_pid
(
pid
);
sprintf
(
g_clientId
,
CLIENTID
,
ccuid
,
timestamp
);
sprintf
(
g_clientId
,
CLIENTID
,
ccuid
,
timestamp
);
root
=
cJSON_CreateObject
();
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"deviceCode"
,
ccuid
);
cJSON_AddStringToObject
(
root
,
"deviceCode"
,
ccuid
);
cJSON_AddStringToObject
(
root
,
"productCode"
,
KK_CCU_PRODUCTID
);
cJSON_AddStringToObject
(
root
,
"productCode"
,
pid
);
cJSON_AddStringToObject
(
root
,
"clientId"
,
g_clientId
);
cJSON_AddStringToObject
(
root
,
"clientId"
,
g_clientId
);
fp
=
fopen
(
KK_DEVICESECRET_PATH
,
"r"
);
fp
=
fopen
(
KK_DEVICESECRET_PATH
,
"r"
);
if
(
fp
!=
NULL
){
if
(
fp
!=
NULL
){
...
@@ -436,3 +461,266 @@ int kk_start_ccu_register(void)
...
@@ -436,3 +461,266 @@ int kk_start_ccu_register(void)
close
(
sockfd
);
close
(
sockfd
);
return
-
1
;
return
-
1
;
}
}
static
int
_kk_parse_auth_dl_host
(
cJSON
*
authInfo
,
char
*
url
){
if
(
authInfo
==
NULL
||
url
==
NULL
){
return
-
1
;
}
cJSON
*
host
=
cJSON_GetObjectItem
(
authInfo
,
"host"
);
cJSON
*
proto
=
cJSON_GetObjectItem
(
authInfo
,
"proto"
);
cJSON
*
port
=
cJSON_GetObjectItem
(
authInfo
,
"port"
);
if
(
host
!=
NULL
&&
proto
!=
NULL
&&
port
!=
NULL
){
sprintf
(
url
,
"%s://%s:%d/auth-server/1.0/ccu_std/auth"
,
proto
->
valuestring
,
host
->
valuestring
,
port
->
valueint
);
INFO_PRINT
(
"%s
\n
"
,
url
);
return
0
;
}
return
-
1
;
}
static
int
_kk_get_auth_dl_host
(
char
*
buf
,
char
*
url
){
cJSON
*
authInfo
=
NULL
;
if
(
buf
==
NULL
||
url
==
NULL
){
return
-
1
;
}
cJSON
*
configObj
=
cJSON_Parse
(
buf
);
if
(
configObj
==
NULL
){
return
-
2
;
}
cJSON
*
data
=
cJSON_GetObjectItem
(
configObj
,
"data"
);
if
(
data
==
NULL
){
authInfo
=
cJSON_GetObjectItem
(
configObj
,
"mqtt_auth_entry"
);
}
else
{
authInfo
=
cJSON_GetObjectItem
(
data
,
"mqtt_auth_entry"
);
}
_kk_parse_auth_dl_host
(
authInfo
,
url
);
cJSON_Delete
(
configObj
);
return
0
;
}
static
int
s_getAuthSize
=
0
;
size_t
receive_auth_data
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
FILE
*
file
){
INFO_PRINT
(
"buffer:%s
\n
"
,
buffer
);
size_t
s_getAuthSize
=
fwrite
(
buffer
,
size
,
nmemb
,
file
);
return
s_getAuthSize
;
}
static
int
_kk_auth_param_get
(
char
*
param
){
char
productId
[
32
]
=
{
0
};
char
key
[
128
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
int
productid_len
=
0
;
int
key_len
=
0
;
if
(
param
==
NULL
){
return
-
1
;
}
KK_Get_ccuid
(
ccuid
);
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
productId
,
sizeof
(
productId
),
&
productid_len
);
productId
[
productid_len
-
1
]
=
'\0'
;
HAL_Execel_cmd
(
GET_KEY_CMD
,(
char
*
)
key
,
sizeof
(
key
),
&
key_len
);
key
[
key_len
-
1
]
=
'\0'
;
sprintf
(
param
,
"{
\"
username
\"
:
\"
%s
\"
,
\"
password
\"
:
\"
%s
\"
,
\"
productid
\"
:
\"
%s
\"
}"
,
ccuid
,
key
,
productId
);
//sprintf(param, "{\"username\":\"%s\",\"password\":\"%s\",\"productid\":\"%s\"}",
//"CCU_17199", "AD4C58175AC4029B9B63EC88656FE61D", "ccu_n12");
INFO_PRINT
(
"param:%s
\n
"
,
param
);
return
0
;
}
int
kk_register_auth_get
(){
int
ret
=
0
;
char
*
configData
=
NULL
;
char
url
[
512
]
=
{
0
};
char
param
[
512
]
=
{
0
};
FILE
*
file
;
int
defaultFlag
=
0
;
CURLcode
res
;
static
int
s_count
=
0
;
CURL
*
curl
;
ret
=
kk_check_config_file
(
KK_CONFIG_FILE_PATH
,
&
configData
);
defaultCon:
if
(
ret
!=
0
){
defaultFlag
=
1
;
ret
=
kk_check_config_file
(
KK_DEFAULT_CONFIG_FILE_PATH
,
&
configData
);
}
if
(
ret
==
0
){
ret
=
_kk_get_auth_dl_host
(
configData
,
url
);
if
(
ret
==
-
2
&&
defaultFlag
==
0
){
goto
defaultCon
;
}
if
(
ret
==
0
){
again:
s_count
++
;
curl
=
curl_easy_init
();
if
(
NULL
==
curl
){
if
(
configData
!=
NULL
){
free
(
configData
);
configData
=
NULL
;
}
return
-
1
;
}
_kk_auth_param_get
(
param
);
file
=
fopen
(
KK_AUTH_CONFIG_FILE_PATH
,
"w+"
);
curl_easy_setopt
(
curl
,
CURLOPT_CUSTOMREQUEST
,
"POST"
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
);
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
param
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
receive_auth_data
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
(
void
*
)
file
);
curl_easy_setopt
(
curl
,
CURLOPT_SSL_VERIFYPEER
,
0
);
curl_easy_setopt
(
curl
,
CURLOPT_SSL_VERIFYHOST
,
0
);
curl_easy_setopt
(
curl
,
CURLOPT_NOSIGNAL
,
1
);
curl_easy_setopt
(
curl
,
CURLOPT_CONNECTTIMEOUT_MS
,
3000
);
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT
,
100
);
curl_easy_setopt
(
curl
,
CURLOPT_FOLLOWLOCATION
,
1
);
//支持服务器跳转
curl_easy_setopt
(
curl
,
CURLOPT_TCP_KEEPALIVE
,
1L
);
// enable TCP keep-alive for this transfer
curl_easy_setopt
(
curl
,
CURLOPT_TCP_KEEPIDLE
,
120L
);
// keep-alive idle time to 120 seconds
curl_easy_setopt
(
curl
,
CURLOPT_TCP_KEEPINTVL
,
60L
);
// interval time between keep-alive probes: 60 seconds
res
=
curl_easy_perform
(
curl
);
if
(
res
!=
CURLE_OK
){
curl_easy_cleanup
(
curl
);
fclose
(
file
);
if
(
configData
!=
NULL
){
free
(
configData
);
configData
=
NULL
;
}
if
(
s_count
<
3
){
sleep
(
2
);
goto
again
;
}
else
{
return
-
2
;
}
}
curl_easy_cleanup
(
curl
);
fclose
(
file
);
}
}
if
(
configData
!=
NULL
){
free
(
configData
);
configData
=
NULL
;
}
return
0
;
}
static
int
_kk_parse_mq_info
(
char
*
data
,
char
*
mqhost
,
char
*
mqport
,
char
*
mqclientId
,
char
*
mqpwd
,
char
*
mqusr
){
cJSON
*
configObj
=
NULL
;
char
tmpIP
[
17
]
=
{
0
};
if
(
data
==
NULL
){
return
-
1
;
}
configObj
=
cJSON_Parse
(
data
);
if
(
configObj
==
NULL
){
return
-
1
;
}
cJSON
*
authdata
=
cJSON_GetObjectItem
(
configObj
,
"data"
);
if
(
authdata
==
NULL
)
{
cJSON_Delete
(
configObj
);
return
-
1
;}
cJSON
*
hostJson
=
cJSON_GetObjectItem
(
authdata
,
"host"
);
if
(
hostJson
==
NULL
)
{
cJSON_Delete
(
configObj
);
return
-
1
;}
if
(
isIpV4Addr
(
hostJson
->
valuestring
)
!=
0
){
struct
hostent
*
host
=
gethostbyname
(
hostJson
->
valuestring
);
if
(
NULL
==
host
){
ERROR_PRINT
(
"gethostbyname h_errno
\n
"
);
cJSON_Delete
(
configObj
);
return
-
1
;
}
memcpy
(
tmpIP
,
inet_ntoa
(
*
(
struct
in_addr
*
)(
host
->
h_addr_list
[
0
])),
strlen
(
inet_ntoa
(
*
(
struct
in_addr
*
)(
host
->
h_addr_list
[
0
]))));
}
else
{
memcpy
(
tmpIP
,
hostJson
->
valuestring
,
strlen
(
hostJson
->
valuestring
));
}
cJSON
*
port
=
cJSON_GetObjectItem
(
authdata
,
"port"
);
if
(
port
==
NULL
)
{
cJSON_Delete
(
configObj
);
return
-
1
;}
cJSON
*
clientId
=
cJSON_GetObjectItem
(
authdata
,
"clientId"
);
if
(
clientId
==
NULL
)
{
cJSON_Delete
(
configObj
);
return
-
1
;}
cJSON
*
password
=
cJSON_GetObjectItem
(
authdata
,
"password"
);
if
(
password
==
NULL
)
{
cJSON_Delete
(
configObj
);
return
-
1
;}
cJSON
*
username
=
cJSON_GetObjectItem
(
authdata
,
"username"
);
if
(
username
==
NULL
)
{
cJSON_Delete
(
configObj
);
return
-
1
;}
strncpy
(
mqhost
,
tmpIP
,
strlen
(
tmpIP
));
strncpy
(
mqport
,
port
->
valuestring
,
strlen
(
port
->
valuestring
));
strncpy
(
mqclientId
,
clientId
->
valuestring
,
strlen
(
clientId
->
valuestring
));
strncpy
(
mqpwd
,
password
->
valuestring
,
strlen
(
password
->
valuestring
));
strncpy
(
mqusr
,
username
->
valuestring
,
strlen
(
username
->
valuestring
));
cJSON_Delete
(
configObj
);
return
0
;
}
MQTTAsync
kk_connect_default
(
void
)
{
int
ret
=
0
;
char
*
configData
=
NULL
;
char
tmpIP
[
17
]
=
{
0
};
char
key
[
128
]
=
{
0
};
char
usrname
[
32
]
=
{
0
};
char
clientId
[
128
]
=
{
0
};
int
key_len
=
0
;
char
portStr
[
16
]
=
{
0
};
KK_Get_ccuid
(
usrname
);
HAL_Execel_cmd
(
GET_KEY_CMD
,(
char
*
)
key
,
sizeof
(
key
),
&
key_len
);
key
[
key_len
-
1
]
=
'\0'
;
ret
=
kk_check_config_file
(
KK_DEFAULT_CONFIG_FILE_PATH
,
&
configData
);
cJSON
*
configObj
=
cJSON_Parse
(
configData
);
if
(
configObj
==
NULL
){
goto
error
;
}
cJSON
*
mqttentry
=
cJSON_GetObjectItem
(
configObj
,
"mqtt_entry"
);
if
(
mqttentry
==
NULL
)
goto
error
;
cJSON
*
hostJson
=
cJSON_GetObjectItem
(
mqttentry
,
"host"
);
if
(
hostJson
==
NULL
)
goto
error
;
cJSON
*
port
=
cJSON_GetObjectItem
(
mqttentry
,
"port"
);
if
(
port
==
NULL
)
goto
error
;
cJSON
*
proto
=
cJSON_GetObjectItem
(
mqttentry
,
"proto"
);
if
(
proto
==
NULL
)
goto
error
;
if
(
isIpV4Addr
(
hostJson
->
valuestring
)
!=
0
){
struct
hostent
*
host
=
gethostbyname
(
hostJson
->
valuestring
);
if
(
NULL
==
host
){
INFO_PRINT
(
"gethostbyname h_errno
\n
"
);
goto
error
;
}
memcpy
(
tmpIP
,
inet_ntoa
(
*
(
struct
in_addr
*
)(
host
->
h_addr_list
[
0
])),
strlen
(
inet_ntoa
(
*
(
struct
in_addr
*
)(
host
->
h_addr_list
[
0
]))));
}
else
{
memcpy
(
tmpIP
,
hostJson
->
valuestring
,
strlen
(
hostJson
->
valuestring
));
}
sprintf
(
clientId
,
"GID_CCU@KONKE@CCU_STD@%s@1"
,
usrname
);
if
(
configObj
!=
NULL
){
cJSON_Delete
(
configObj
);
}
if
(
configData
!=
NULL
){
free
(
configData
);
configData
=
NULL
;
}
sprintf
(
portStr
,
"%d"
,
port
->
valueint
);
return
KK_MQTT_Connect_ex
(
usrname
,
key
,
clientId
,
tmpIP
,
portStr
);
error:
if
(
configObj
!=
NULL
){
cJSON_Delete
(
configObj
);
}
if
(
configData
!=
NULL
){
free
(
configData
);
configData
=
NULL
;
}
return
NULL
;
}
MQTTAsync
kk_mqtt_connect
(){
char
*
configData
=
NULL
;
char
host
[
128
]
=
{
0
};
char
port
[
8
]
=
{
0
};
char
pwd
[
512
]
=
{
0
};
char
usrname
[
32
]
=
{
0
};
char
clientId
[
128
]
=
{
0
};
int
ret
=
0
;
int
defaultFlag
=
0
;
cJSON
*
configObj
=
NULL
;
ret
=
kk_check_config_file
(
KK_AUTH_CONFIG_FILE_PATH
,
&
configData
);
if
(
ret
==
0
){
//defaultFlag = 1;
//ret = kk_check_config_file(KK_DEFAULT_CONFIG_FILE_PATH,&configData);
ret
=
_kk_parse_mq_info
(
configData
,
host
,
port
,
clientId
,
pwd
,
usrname
);
if
(
ret
==
0
){
if
(
configData
!=
NULL
){
free
(
configData
);
configData
=
NULL
;
}
return
KK_MQTT_Connect_ex
(
usrname
,
pwd
,
clientId
,
host
,
port
);
}
else
{
return
kk_connect_default
();
}
}
else
{
return
kk_connect_default
();
}
}
\ No newline at end of file
application/kcloud/kk_topic_mng.c
View file @
62c805fd
...
@@ -114,17 +114,17 @@ void KK_reset_sub_flag(void)
...
@@ -114,17 +114,17 @@ void KK_reset_sub_flag(void)
}
}
int
KK_CCU_TOPIC_Subscribe
(
void
)
int
KK_CCU_TOPIC_Subscribe
(
void
)
{
{
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
if
(
s_ccu_topic_sub
==
1
){
if
(
s_ccu_topic_sub
==
1
){
INFO_PRINT
(
"[%s][%d] already Subscribe
\n
"
,
__FUNCTION__
,
__LINE__
);
INFO_PRINT
(
"[%s][%d] already Subscribe
\n
"
,
__FUNCTION__
,
__LINE__
);
//return -1;
//return -1;
}
}
char
ccuid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
KK_Get_ccuid
(
ccuid
);
KK_Get_ccuid
(
ccuid
);
char
pid
[
32
]
=
{
0
};
kk_cloud_get_pid
(
pid
);
s_ccu_topic_sub
=
1
;
s_ccu_topic_sub
=
1
;
HAL_GetProduct_Code
(
productCode
);
return
_kk_ccu_topic_subscribe
(
p
roductCode
,
ccuid
);
return
_kk_ccu_topic_subscribe
(
p
id
,
ccuid
);
}
}
static
int
_kk_utils_topic
(
_IN_
const
char
*
name
,
_IN_
char
*
product_code
,
static
int
_kk_utils_topic
(
_IN_
const
char
*
name
,
_IN_
char
*
product_code
,
...
@@ -241,8 +241,9 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
...
@@ -241,8 +241,9 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
{
{
cJSON
*
type
,
*
product_code
,
*
device_code
;
cJSON
*
type
,
*
product_code
,
*
device_code
;
char
*
topic
=
NULL
;
char
*
topic
=
NULL
;
char
pid
[
32
]
=
{
0
};
//root=cJSON_Parse((char*)info->valuestring);
//root=cJSON_Parse((char*)info->valuestring);
kk_cloud_get_pid
(
pid
);
type
=
cJSON_GetObjectItem
(
info
,
MSG_TYPE_STR
);
type
=
cJSON_GetObjectItem
(
info
,
MSG_TYPE_STR
);
if
(
type
==
NULL
){
if
(
type
==
NULL
){
goto
errorreturn
;
goto
errorreturn
;
...
@@ -256,7 +257,7 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
...
@@ -256,7 +257,7 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
if
(
device_code
==
NULL
){
if
(
device_code
==
NULL
){
goto
errorreturn
;
goto
errorreturn
;
}
}
if
((
!
strcmp
(
product_code
->
valuestring
,
"15"
)
||
!
strcmp
(
product_code
->
valuestring
,
KK_CCU_PRODUCTID
))
&&
\
if
((
!
strcmp
(
product_code
->
valuestring
,
pid
))
&&
\
(
strstr
(
type
->
valuestring
,
"thing/status/online"
)
!=
NULL
)){
(
strstr
(
type
->
valuestring
,
"thing/status/online"
)
!=
NULL
)){
KK_CCU_TOPIC_Subscribe
();
KK_CCU_TOPIC_Subscribe
();
}
}
...
...
application/kcloud/mqtt_api.c
View file @
62c805fd
...
@@ -232,8 +232,10 @@ MQTTAsync KK_MQTT_Connect(void)
...
@@ -232,8 +232,10 @@ MQTTAsync KK_MQTT_Connect(void)
}
}
HAL_Get_mac
(
mac
);
HAL_Get_mac
(
mac
);
char
ccuid
[
32
]
=
{
0
};
char
ccuid
[
32
]
=
{
0
};
char
pid
[
32
]
=
{
0
};
KK_Get_ccuid
(
ccuid
);
KK_Get_ccuid
(
ccuid
);
sprintf
(
usrname
,
"%s.%s"
,
ccuid
,
KK_CCU_PRODUCTID
);
kk_cloud_get_pid
(
pid
);
sprintf
(
usrname
,
"%s.%s"
,
ccuid
,
pid
);
INFO_PRINT
(
"cliendid:%s,usrname:%s
\n
"
,
g_clientId
,
usrname
);
INFO_PRINT
(
"cliendid:%s,usrname:%s
\n
"
,
g_clientId
,
usrname
);
INFO_PRINT
(
"------------>token:%s
\n
"
,
token
);
INFO_PRINT
(
"------------>token:%s
\n
"
,
token
);
sprintf
(
temp_address
,
"tcp://%s:1983"
,
s_ServerIp
);
sprintf
(
temp_address
,
"tcp://%s:1983"
,
s_ServerIp
);
...
@@ -266,7 +268,45 @@ MQTTAsync KK_MQTT_Connect(void)
...
@@ -266,7 +268,45 @@ MQTTAsync KK_MQTT_Connect(void)
}
}
return
s_Client
;
return
s_Client
;
}
}
MQTTAsync
KK_MQTT_Connect_ex
(
char
*
usrname
,
char
*
pwd
,
char
*
cliendId
,
char
*
host
,
char
*
port
)
{
int
rc
=
0
;
char
temp_address
[
256
]
=
{
0
};
FILE
*
fp
;
MQTTAsync_createOptions
opts
=
MQTTAsync_createOptions_initializer
;
MQTTAsync_connectOptions
conn_opts
=
MQTTAsync_connectOptions_initializer
;
MQTTAsync_setTraceCallback
(
mqttTraceCallback
);
opts
.
MQTTVersion
=
MQTTVERSION_3_1_1
;
sprintf
(
temp_address
,
"tcp://%s:%s"
,
host
,
port
);
INFO_PRINT
(
"------------>temp_address:%s
\n
"
,
temp_address
);
if
((
rc
=
MQTTAsync_createWithOptions
(
&
s_Client
,
temp_address
,
cliendId
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
,
&
opts
))
!=
MQTTASYNC_SUCCESS
)
{
ERROR_PRINT
(
"Failed to create client object, return code %d
\n
"
,
rc
);
return
NULL
;
}
/*Set the mqtt callback*/
mqtt_set_callbacks
();
conn_opts
.
keepAliveInterval
=
30
;
conn_opts
.
connectTimeout
=
CONNECT_TIMEOUT
;
conn_opts
.
automaticReconnect
=
AUTO_CONN
;
conn_opts
.
minRetryInterval
=
1
;
conn_opts
.
maxRetryInterval
=
32
;
//conn_opts.username = USRNAME;
//conn_opts.password = PASSWORD;
conn_opts
.
username
=
usrname
;
conn_opts
.
password
=
pwd
;
conn_opts
.
cleansession
=
1
;
conn_opts
.
onSuccess
=
onConnect
;
conn_opts
.
onFailure
=
onConnectFailure
;
conn_opts
.
context
=
s_Client
;
if
((
rc
=
MQTTAsync_connect
(
s_Client
,
&
conn_opts
))
!=
MQTTASYNC_SUCCESS
)
{
ERROR_PRINT
(
"Failed to start connect, return code %d
\n
"
,
rc
);
return
NULL
;
}
return
s_Client
;
}
int
KK_MQTT_SubTopic
(
char
*
topicName
)
int
KK_MQTT_SubTopic
(
char
*
topicName
)
{
{
INFO_PRINT
(
"to subtopic:%s
\n
"
,
topicName
);
INFO_PRINT
(
"to subtopic:%s
\n
"
,
topicName
);
...
...
application/kcloud/mqtt_api.h
View file @
62c805fd
...
@@ -17,5 +17,6 @@ extern int KK_MQTT_UnsubTopic(const char *topicName);
...
@@ -17,5 +17,6 @@ extern int KK_MQTT_UnsubTopic(const char *topicName);
extern
MQTTAsync
KK_MQTT_Connect
(
void
);
extern
MQTTAsync
KK_MQTT_Connect
(
void
);
int
kk_get_cloud_status
(
void
);
int
kk_get_cloud_status
(
void
);
void
kk_write_disconnect_flag
(
void
);
void
kk_write_disconnect_flag
(
void
);
MQTTAsync
KK_MQTT_Connect_ex
(
char
*
usrname
,
char
*
pwd
,
char
*
cliendId
,
char
*
host
,
char
*
port
);
#endif
#endif
application/klansdk/iot.mk
View file @
62c805fd
...
@@ -19,11 +19,14 @@ ifeq ($(CONFIG_MODEL),x86)
...
@@ -19,11 +19,14 @@ ifeq ($(CONFIG_MODEL),x86)
else
ifeq
($(CONFIG_MODEL),nx5)
else
ifeq
($(CONFIG_MODEL),nx5)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_nx5
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_nx5
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_nx5
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_nx5
else
ifeq
($(CONFIG_MODEL),8197)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_8197
-lubacktrace
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_8197
else
else
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev
endif
endif
LDFLAGS
+=
-liot_cjson
-ldl
-lm
-l
anl
-l
kk_hal
LDFLAGS
+=
-liot_cjson
-ldl
-lm
-lkk_hal
application/klansdk/kk_data_handle.c
View file @
62c805fd
...
@@ -384,7 +384,8 @@ int kk_data_handle(cJSON *json,int sockfd)
...
@@ -384,7 +384,8 @@ int kk_data_handle(cJSON *json,int sockfd)
if
(
vol
!=
NULL
){
if
(
vol
!=
NULL
){
kk_voice_control
(
atoi
(
vol
->
valuestring
));
kk_voice_control
(
atoi
(
vol
->
valuestring
));
}
}
}
else
if
(
strcmp
(
opcode
->
valuestring
,
VOICE_SWITCH_CTRL
)
==
0
){
}
else
if
(
strcmp
(
opcode
->
valuestring
,
VOICE_SWITCH_CTRL
)
==
0
){
cJSON
*
onff
=
cJSON_GetObjectItem
(
json
,
"arg"
);
cJSON
*
onff
=
cJSON_GetObjectItem
(
json
,
"arg"
);
int
value
=
0
;
int
value
=
0
;
if
(
onff
!=
NULL
){
if
(
onff
!=
NULL
){
...
@@ -469,9 +470,11 @@ static int kk_parse_syncinfo(cJSON *payload)
...
@@ -469,9 +470,11 @@ static int kk_parse_syncinfo(cJSON *payload)
int
is_ccu_msg
(
cJSON
*
productCode
,
cJSON
*
deviceCode
)
int
is_ccu_msg
(
cJSON
*
productCode
,
cJSON
*
deviceCode
)
{
{
char
ccuid
[
33
]
=
{
0
};
char
ccuid
[
33
]
=
{
0
};
char
pid
[
33
]
=
{
0
};
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_ccuid
(
ccuid
);
if
((
strlen
(
productCode
->
valuestring
)
==
strlen
(
KK_CCU_PRODUCTID
)
&&
kk_lan_get_pid
(
pid
);
!
strcmp
(
productCode
->
valuestring
,
KK_CCU_PRODUCTID
))
&&
if
((
strlen
(
productCode
->
valuestring
)
==
strlen
(
pid
)
&&
!
strcmp
(
productCode
->
valuestring
,
pid
))
&&
(
strlen
(
deviceCode
->
valuestring
)
==
strlen
(
ccuid
)
&&
(
strlen
(
deviceCode
->
valuestring
)
==
strlen
(
ccuid
)
&&
!
strcmp
(
deviceCode
->
valuestring
,
ccuid
))){
!
strcmp
(
deviceCode
->
valuestring
,
ccuid
))){
return
1
;
return
1
;
...
@@ -781,7 +784,82 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
...
@@ -781,7 +784,82 @@ static int kk_lan_scene_handle(cJSON *payload,int isAdd)
}
}
static
int
kk_client_reoprt_reply_handle
(
cJSON
*
payload
)
{
int
nodeId
=
0
;
if
(
payload
==
NULL
){
return
-
1
;
}
cJSON
*
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
if
(
params
==
NULL
){
return
-
1
;
}
cJSON
*
serialId
=
cJSON_GetObjectItem
(
params
,
"serialId"
);
if
(
serialId
==
NULL
){
return
-
1
;
}
cJSON
*
arg
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
arg
,
"serialId"
,
serialId
->
valuestring
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"nodeid"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
"CCU_CLIENT_REPORT"
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddItemToObject
(
root
,
"arg"
,
arg
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
return
0
;
}
static
int
kk_client_online_push_handle
(
cJSON
*
payload
)
{
int
nodeId
=
0
;
if
(
payload
==
NULL
){
return
-
1
;
}
cJSON
*
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
if
(
params
==
NULL
){
return
-
1
;
}
cJSON
*
serialId
=
cJSON_GetObjectItem
(
params
,
"serialId"
);
if
(
serialId
==
NULL
){
return
-
1
;
}
cJSON
*
online
=
cJSON_GetObjectItem
(
params
,
"online"
);
if
(
online
==
NULL
){
return
-
1
;
}
cJSON
*
arg
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
arg
,
"serialId"
,
serialId
->
valuestring
);
cJSON_AddNumberToObject
(
arg
,
"online"
,
online
->
valueint
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"nodeid"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
"CCU_CLIENT_ONLINE_PUSH"
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddItemToObject
(
root
,
"arg"
,
arg
);
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
return
0
;
}
static
int
kk_client_info_push_handle
(
cJSON
*
payload
)
{
int
nodeId
=
0
;
if
(
payload
==
NULL
){
return
-
1
;
}
cJSON
*
params
=
cJSON_GetObjectItem
(
payload
,
"params"
);
if
(
params
==
NULL
){
return
-
1
;
}
char
*
pData
=
cJSON_Print
(
params
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
root
,
"nodeid"
,
"*"
);
cJSON_AddStringToObject
(
root
,
"opcode"
,
"GET_CCU_CLIENT_INFO"
);
cJSON_AddStringToObject
(
root
,
"status"
,
"success"
);
cJSON_AddItemToObject
(
root
,
"arg"
,
cJSON_Parse
(
pData
));
send_msg_to_module
(
root
);
cJSON_Delete
(
root
);
free
(
pData
);
return
0
;
}
void
KK_Data_FromMid
(
void
*
str
,
int
len
)
void
KK_Data_FromMid
(
void
*
str
,
int
len
)
{
{
cJSON
*
json
=
NULL
;
cJSON
*
json
=
NULL
;
...
@@ -869,9 +947,16 @@ void KK_Data_FromMid(void* str,int len)
...
@@ -869,9 +947,16 @@ void KK_Data_FromMid(void* str,int len)
}
else
if
(
strstr
(
msgtype
->
valuestring
,
"/thing/event/deleteSceneNotification/post"
)
!=
NULL
){
}
else
if
(
strstr
(
msgtype
->
valuestring
,
"/thing/event/deleteSceneNotification/post"
)
!=
NULL
){
INFO_PRINT
(
"deleteSceneNotification handle!!!"
);
INFO_PRINT
(
"deleteSceneNotification handle!!!"
);
kk_lan_scene_handle
(
payload
,
0
);
kk_lan_scene_handle
(
payload
,
0
);
}
else
if
(
strstr
(
msgtype
->
valuestring
,
"/thing/service/clientReport_reply"
)
!=
NULL
){
INFO_PRINT
(
"clientReport_reply handle!!!"
);
kk_client_reoprt_reply_handle
(
payload
);
}
else
if
(
strstr
(
msgtype
->
valuestring
,
"/thing/service/clientOnlinePush"
)
!=
NULL
){
INFO_PRINT
(
"clientOnlinePush handle!!!"
);
kk_client_online_push_handle
(
payload
);
}
else
if
(
strstr
(
msgtype
->
valuestring
,
"/thing/service/getClientInfo_reply"
)
!=
NULL
){
INFO_PRINT
(
"getClientInfo_reply handle!!!"
);
kk_client_info_push_handle
(
payload
);
}
}
//
cJSON_Delete
(
json
);
cJSON_Delete
(
json
);
}
}
...
...
application/klansdk/kk_findccu_handle.h
View file @
62c805fd
...
@@ -17,5 +17,5 @@
...
@@ -17,5 +17,5 @@
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
int
kk_findccu_handle_init
(
void
);
int
kk_findccu_handle_init
(
void
);
int
kk_lan_get_pid
(
_OU_
char
*
productId
);
#endif
#endif
\ No newline at end of file
application/klansdk/kk_lan_ctrl.c
View file @
62c805fd
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include "kk_oldccu_msg.h"
#include "kk_oldccu_msg.h"
#include "kk_newccu_msg.h"
#include "kk_newccu_msg.h"
#include "kk_lan_node_db.h"
#include "kk_lan_node_db.h"
#include "kk_findccu_handle.h"
extern
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
extern
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
);
...
@@ -163,7 +163,9 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
...
@@ -163,7 +163,9 @@ cJSON * kk_control_protocol_convert(kk_map_dev_node_t *devNode,int nodeId,cJSON
static
int
kk_guard_ctrl_handle
(
int
status
)
static
int
kk_guard_ctrl_handle
(
int
status
)
{
{
char
ccuid
[
33
]
=
{
0
};
char
ccuid
[
33
]
=
{
0
};
char
pid
[
33
]
=
{
0
};
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_pid
(
pid
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
params
=
cJSON_CreateObject
();
cJSON
*
params
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
params
,
"epNum"
,
"1"
);
cJSON_AddStringToObject
(
params
,
"epNum"
,
"1"
);
...
@@ -174,13 +176,53 @@ static int kk_guard_ctrl_handle(int status)
...
@@ -174,13 +176,53 @@ static int kk_guard_ctrl_handle(int status)
}
else
{
//³··À
}
else
{
//³··À
cJSON_AddStringToObject
(
params
,
"ArmingState"
,
"1"
);
cJSON_AddStringToObject
(
params
,
"ArmingState"
,
"1"
);
}
}
cJSON
*
info
=
property_info_build
(
"/thing/service/property/set"
,
KK_CCU_PRODUCTID
,
ccuid
);
cJSON
*
info
=
property_info_build
(
"/thing/service/property/set"
,
pid
,
ccuid
);
cJSON
*
payload
=
property_payload_build
(
"thing.service.property.set"
,
"1"
,
"v1.0"
,
params
);
cJSON
*
payload
=
property_payload_build
(
"thing.service.property.set"
,
"1"
,
"v1.0"
,
params
);
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
PAYLOAD_STRING
,
payload
);
cJSON_AddItemToObject
(
root
,
PAYLOAD_STRING
,
payload
);
kk_ipc_send_json
(
root
);
kk_ipc_send_json
(
root
);
return
0
;
return
0
;
}
}
static
int
kk_client_report_handle
(
cJSON
*
arg
)
{
char
ccuid
[
33
]
=
{
0
};
char
pid
[
33
]
=
{
0
};
if
(
arg
==
NULL
){
return
-
1
;
}
char
*
pData
=
cJSON_Print
(
arg
);
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_pid
(
pid
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
info
=
property_info_build
(
"/thing/service/clientReport"
,
pid
,
ccuid
);
cJSON
*
payload
=
property_payload_build
(
"thing.service.clientReport"
,
"1"
,
"v1.0"
,
cJSON_Parse
(
pData
));
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
PAYLOAD_STRING
,
payload
);
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
kk_ipc_send_json
(
root
);
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
free
(
pData
);
return
0
;
}
static
int
kk_get_client_info_handle
(
cJSON
*
arg
)
{
char
ccuid
[
33
]
=
{
0
};
char
pid
[
33
]
=
{
0
};
if
(
arg
==
NULL
){
return
-
1
;
}
char
*
pData
=
cJSON_Print
(
arg
);
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_pid
(
pid
);
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
info
=
property_info_build
(
"/thing/service/getClientInfo"
,
pid
,
ccuid
);
cJSON
*
payload
=
property_payload_build
(
"thing.service.getClientInfo"
,
"1"
,
"v1.0"
,
cJSON_Parse
(
pData
));
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
PAYLOAD_STRING
,
payload
);
kk_ipc_send_json
(
root
);
free
(
pData
);
return
0
;
}
static
int
kk_indoorAir_ctrl_handle
(
char
*
epNum
,
cJSON
*
arg
)
static
int
kk_indoorAir_ctrl_handle
(
char
*
epNum
,
cJSON
*
arg
)
{
{
kk_map_dev_node_t
*
dev
=
NULL
;
kk_map_dev_node_t
*
dev
=
NULL
;
...
@@ -310,12 +352,9 @@ int kk_ccu_opcode_handle(cJSON *root)
...
@@ -310,12 +352,9 @@ int kk_ccu_opcode_handle(cJSON *root)
if
(
opcode
==
NULL
||
opcode
->
type
!=
cJSON_String
){
if
(
opcode
==
NULL
||
opcode
->
type
!=
cJSON_String
){
return
-
1
;
return
-
1
;
}
}
if
(
nodeId
==
NULL
||
opcode
==
NULL
||
arg
==
NULL
){
if
(
nodeId
==
NULL
||
opcode
==
NULL
||
arg
==
NULL
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
1
;
return
-
1
;
}
}
if
(
requester
!=
NULL
){
if
(
requester
!=
NULL
){
WARNING_PRINT
(
"[requester]%s
\n
"
,
requester
->
valuestring
);
WARNING_PRINT
(
"[requester]%s
\n
"
,
requester
->
valuestring
);
if
(
strcmp
(
requester
->
valuestring
,
"HJ_CentralAC"
)
==
0
&&
if
(
strcmp
(
requester
->
valuestring
,
"HJ_CentralAC"
)
==
0
&&
...
@@ -337,13 +376,17 @@ int kk_ccu_opcode_handle(cJSON *root)
...
@@ -337,13 +376,17 @@ int kk_ccu_opcode_handle(cJSON *root)
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"DISARMING"
)
==
0
){
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"DISARMING"
)
==
0
){
kk_guard_ctrl_handle
(
1
);
kk_guard_ctrl_handle
(
1
);
return
0
;
return
0
;
}
else
if
(
strcmp
(
opcode
->
valuestring
,
"CCU_CLIENT_REPORT"
)
==
0
){
kk_client_report_handle
(
arg
);
return
0
;
}
else
if
(
strcmp
(
opcode
->
valuestring
,
GET_CCU_CLIENT_INFO
)
==
0
){
kk_get_client_info_handle
(
arg
);
return
0
;
}
}
}
}
}
}
kk_lan_db_deviceCode_get
(
atoi
(
nodeId
->
valuestring
),
deviceCode
);
kk_lan_db_deviceCode_get
(
atoi
(
nodeId
->
valuestring
),
deviceCode
);
//execute scene
//execute scene
if
((
requester
!=
NULL
)
&&
(
strcmp
(
requester
->
valuestring
,
HJ_PROFILE
)
==
0
)
&&
if
((
requester
!=
NULL
)
&&
(
strcmp
(
requester
->
valuestring
,
HJ_PROFILE
)
==
0
)
&&
(
strcmp
(
opcode
->
valuestring
,
"SWITCH"
)
==
0
)){
(
strcmp
(
opcode
->
valuestring
,
"SWITCH"
)
==
0
)){
...
...
application/klansdk/kk_lan_main.c
View file @
62c805fd
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
#include "kk_data_mng.h"
#include "kk_data_mng.h"
#include "kk_lan_debug.h"
#include "kk_lan_debug.h"
extern
char
*
_kk_data_create
(
char
*
msgtype
,
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
param
);
extern
char
*
_kk_data_create
(
char
*
msgtype
,
const
char
*
productCode
,
const
char
*
deviceCode
,
const
char
*
param
);
extern
int
HAL_Execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
);
static
char
s_ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
static
char
s_ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
)
int
kk_lan_get_ccuid
(
_OU_
char
*
device_code
)
...
@@ -51,7 +51,27 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
...
@@ -51,7 +51,27 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
strncpy
(
s_ccuid
,
device_code
,
len
);
strncpy
(
s_ccuid
,
device_code
,
len
);
return
len
;
return
len
;
}
}
extern
int
HAL_Execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
);
char
s_pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
static
int
kk_lan_pid_init
(
void
)
{
char
pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
int
pid_len
=
0
;
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
pid
,
sizeof
(
pid
),
&
pid_len
);
if
(
pid_len
>
0
&&
pid_len
<=
PRODUCT_CODE_LEN
){
memcpy
(
s_pid
,
pid
,
pid_len
-
1
);
INFO_PRINT
(
"s_pid:%s
\n
"
,
s_pid
);
}
else
{
return
-
1
;
}
return
0
;
}
int
kk_lan_get_pid
(
_OU_
char
*
productId
)
{
strncpy
(
productId
,
s_pid
,
strlen
(
s_pid
));
printf
(
"kk_lan_get_ccuid:%s
\n
"
,
s_pid
);
return
strlen
(
s_pid
);
}
static
void
kk_lan_ccuid_init
(
void
)
static
void
kk_lan_ccuid_init
(
void
)
{
{
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
uint8_t
ccuid
[
DEVICE_CODE_LEN
]
=
{
0
};
...
@@ -188,7 +208,7 @@ int main(int argc, char* argv[])
...
@@ -188,7 +208,7 @@ int main(int argc, char* argv[])
//debug_log(LOG_CRITICAL_LEVEL,"[%s]run singleton fail!\n",argv[0]);
//debug_log(LOG_CRITICAL_LEVEL,"[%s]run singleton fail!\n",argv[0]);
//return -1;
//return -1;
//}
//}
kk_lan_pid_init
();
kk_lan_ccuid_init
();
kk_lan_ccuid_init
();
/*set the callback to get the device date to cloud*/
/*set the callback to get the device date to cloud*/
...
...
application/klansdk/kk_lan_sync.c
View file @
62c805fd
...
@@ -811,7 +811,7 @@ int kk_sync_guard_to_sdk(cJSON *root,cJSON *data)
...
@@ -811,7 +811,7 @@ int kk_sync_guard_to_sdk(cJSON *root,cJSON *data)
int
i
,
num
;
int
i
,
num
;
cJSON
*
item
=
NULL
;
cJSON
*
item
=
NULL
;
char
roomIdStr
[
16
]
=
{
0
};
char
roomIdStr
[
16
]
=
{
0
};
RoomIdsAry
=
cJSON_GetObjectItem
(
properties
,
"RoomIds"
);
RoomIdsAry
=
cJSON_GetObjectItem
(
properties
,
"
ccu
RoomIds"
);
if
(
RoomIdsAry
==
NULL
||
RoomIdsAry
->
type
!=
cJSON_Array
){
if
(
RoomIdsAry
==
NULL
||
RoomIdsAry
->
type
!=
cJSON_Array
){
return
-
1
;
return
-
1
;
}
}
...
...
application/klansdk/kk_newccu_msg.c
View file @
62c805fd
#include "kk_log.h"
#include "kk_log.h"
#include "klist.h"
#include "klist.h"
#include "kk_product.h"
#include "kk_product.h"
#include "com_api.h"
#include "com_api.h"
#include "kk_opcode.h"
#include "kk_opcode.h"
#include "kk_lan_ctrl.h"
#include "kk_lan_ctrl.h"
#include "kk_data_mng.h"
#include "kk_data_mng.h"
#include "kk_newccu_msg.h"
#include "kk_newccu_msg.h"
#include "kk_product.h"
#include "kk_product.h"
#include "kk_lan_node_db.h"
#include "kk_lan_node_db.h"
#include "kk_findccu_handle.h"
static
pthread_mutex_t
*
mutex
=
NULL
;
static
pthread_mutex_t
*
mutex
=
NULL
;
int
kk_new_msg_init
(
void
)
int
kk_new_msg_init
(
void
)
...
@@ -89,10 +85,12 @@ extern int kk_lan_get_ccuid(_OU_ char *device_code);
...
@@ -89,10 +85,12 @@ extern int kk_lan_get_ccuid(_OU_ char *device_code);
cJSON
*
scene_payload_build
(
const
char
*
method
,
const
char
*
msgId
,
cJSON
*
params
)
cJSON
*
scene_payload_build
(
const
char
*
method
,
const
char
*
msgId
,
cJSON
*
params
)
{
{
char
ccuid
[
33
]
=
{
0
};
char
ccuid
[
33
]
=
{
0
};
char
pid
[
33
]
=
{
0
};
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON
*
payload
=
cJSON_CreateObject
();
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_ccuid
(
ccuid
);
cJSON_AddStringToObject
(
payload
,
"productCode"
,
KK_CCU_PRODUCTID
);
kk_lan_get_pid
(
pid
);
cJSON_AddStringToObject
(
payload
,
"productCode"
,
pid
);
cJSON_AddStringToObject
(
payload
,
"deviceCode"
,
ccuid
);
cJSON_AddStringToObject
(
payload
,
"deviceCode"
,
ccuid
);
cJSON_AddStringToObject
(
payload
,
"identity"
,
"executeScene"
);
cJSON_AddStringToObject
(
payload
,
"identity"
,
"executeScene"
);
...
@@ -111,16 +109,18 @@ cJSON * scene_execute(const char *sceneId)
...
@@ -111,16 +109,18 @@ cJSON * scene_execute(const char *sceneId)
{
{
char
msgId
[
32
]
=
{
0
};
char
msgId
[
32
]
=
{
0
};
char
ccuid
[
33
]
=
{
0
};
char
ccuid
[
33
]
=
{
0
};
char
pid
[
33
]
=
{
0
};
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
root
=
cJSON_CreateObject
();
cJSON
*
params
=
cJSON_CreateObject
();
cJSON
*
params
=
cJSON_CreateObject
();
cJSON
*
info
,
*
payload
;
cJSON
*
info
,
*
payload
;
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_ccuid
(
ccuid
);
kk_lan_get_pid
(
pid
);
printf
(
"[execute scene]sceneId=%s
\n
"
,
sceneId
);
printf
(
"[execute scene]sceneId=%s
\n
"
,
sceneId
);
kk_lan_get_msg_id_str
(
msgId
,
sizeof
(
msgId
));
kk_lan_get_msg_id_str
(
msgId
,
sizeof
(
msgId
));
cJSON_AddStringToObject
(
params
,
"sceneId"
,
sceneId
);
cJSON_AddStringToObject
(
params
,
"sceneId"
,
sceneId
);
info
=
property_info_build
(
"/thing/service/executeScene"
,
KK_CCU_PRODUCTID
,
ccuid
);
info
=
property_info_build
(
"/thing/service/executeScene"
,
pid
,
ccuid
);
payload
=
scene_payload_build
(
"thing.service.executeScene"
,
msgId
,
params
);
payload
=
scene_payload_build
(
"thing.service.executeScene"
,
msgId
,
params
);
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
cJSON_AddItemToObject
(
root
,
INFO_STRING
,
info
);
...
@@ -136,6 +136,7 @@ int kk_ipc_send_json(cJSON *root)
...
@@ -136,6 +136,7 @@ int kk_ipc_send_json(cJSON *root)
char
*
msg
;
char
*
msg
;
if
(
root
==
NULL
){
if
(
root
==
NULL
){
//printf("----------------------------------------DEBUG-------------------------[%s][%d]\n",__FUNCTION__,__LINE__);
return
-
1
;
return
-
1
;
}
}
...
...
application/klansdk/kk_opcode.h
View file @
62c805fd
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
#define SWITCH_OPCODE "SWITCH"
#define SWITCH_OPCODE "SWITCH"
#define GET_HISTORY_MSG_TYPE "/thing/service/historyAlarm"
#define GET_HISTORY_MSG_TYPE "/thing/service/historyAlarm"
#define DEL_HISTORY_MSG_TYPE "/thing/service/delAlarm"
#define DEL_HISTORY_MSG_TYPE "/thing/service/delAlarm"
#define GET_CCU_CLIENT_INFO "GET_CCU_CLIENT_INFO"
...
...
common/api/com_api.h
View file @
62c805fd
...
@@ -39,10 +39,12 @@ typedef enum {
...
@@ -39,10 +39,12 @@ typedef enum {
#define MSG_INFO_STR "info"
#define MSG_INFO_STR "info"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_DATA_TYPE_STR "dataType"
#define MSG_DATA_TYPE_STR "dataType"
#define MSG_DEVICE_IP "ip"
#define MSG_DEVICE_VERSION "version"
#define MSG_DEVICE_SERIALID "serialId"
#define MSG_DEVICE_DEVICEINFO "deviceInfo"
#define MSG_DEVICE_TYPE "type"
#define MSG_DEVICE_EXPAND "expand"
#define MSG_PARAMS_STR "params"
#define MSG_PARAMS_STR "params"
#define MSG_IOTClOUDSTATE_STR "IOTCloudState"
#define MSG_IOTClOUDSTATE_STR "IOTCloudState"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
...
@@ -52,6 +54,8 @@ typedef enum {
...
@@ -52,6 +54,8 @@ typedef enum {
#define MSG_AREA_ADDROOM_DEVICENAME "name"
#define MSG_AREA_ADDROOM_DEVICENAME "name"
#define MSG_AREA_ADDROOM_ROOMNAME "roomName"
#define MSG_AREA_ADDROOM_ROOMNAME "roomName"
#define MSG_AREA_ROOM_ROOMID "roomId"
#define MSG_AREA_ROOM_ROOMID "roomId"
#define MSG_AREA_ROOM_CCUROOMIDS "ccuRoomIds"
#define MSG_AREA_ROOM_CCUROOMID "ccuRoomId"
#define MSG_AREA_ROOM_EPNUM "epNum"
#define MSG_AREA_ROOM_EPNUM "epNum"
#define MSG_AREA_ROOM_ACTION "action"
#define MSG_AREA_ROOM_ACTION "action"
#define MSG_AREA_ADDROOM_NOTIFICATION "addRoomNotification"
#define MSG_AREA_ADDROOM_NOTIFICATION "addRoomNotification"
...
@@ -111,7 +115,6 @@ typedef enum {
...
@@ -111,7 +115,6 @@ typedef enum {
#define MSG_SCENE_SUPPORT "sceneSupport"
#define MSG_SCENE_SUPPORT "sceneSupport"
#define MSG_SCENE_MSGID "msgId"
#define MSG_SCENE_MSGID "msgId"
#define MSG_SCENE_SCENE_NAME "name"
#define MSG_SCENE_SCENE_NAME "name"
#define MSG_SCENE_ROOM_ID "roomId"
#define MSG_SCENE_ROOM_NAME "roomName"
#define MSG_SCENE_ROOM_NAME "roomName"
#define MSG_SCENE_SCENCTYPE "sceneType"
#define MSG_SCENE_SCENCTYPE "sceneType"
#define MSG_SCENE_ENABLE "enable"
#define MSG_SCENE_ENABLE "enable"
...
@@ -146,6 +149,7 @@ typedef enum {
...
@@ -146,6 +149,7 @@ typedef enum {
#define BUFFER_SIZE 1024
#define BUFFER_SIZE 1024
#define MAX_LISTEN_NUM 10
#define MAX_LISTEN_NUM 10
#define MAX_IP_LEN 16
#define MAX_IP_LEN 16
#define KK_DEVICE_SCREEN_MAX_SUPPORT 8
//#ifndef DEVICE_CODE_LEN
//#ifndef DEVICE_CODE_LEN
//#define DEVICE_CODE_LEN 33
//#define DEVICE_CODE_LEN 33
//#endif
//#endif
...
...
common/hal/HAL_OS_linux.c
View file @
62c805fd
...
@@ -273,27 +273,6 @@ int HAL_SetProduct_Type(_IN_ char *product_type)
...
@@ -273,27 +273,6 @@ int HAL_SetProduct_Type(_IN_ char *product_type)
return
len
;
return
len
;
}
}
int
HAL_SetProduct_Code
(
_IN_
char
*
product_code
)
{
int
len
=
strlen
(
product_code
);
if
(
len
>
PRODUCT_CODE_LEN
)
{
return
-
1
;
}
memset
(
g_product_code
,
0x0
,
PRODUCT_CODE_LEN
);
strncpy
(
g_product_code
,
product_code
,
len
);
return
len
;
}
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
)
{
strncpy
(
product_code
,
KK_CCU_PRODUCTID
,
strlen
(
KK_CCU_PRODUCTID
));
product_code
[
strlen
(
KK_CCU_PRODUCTID
)]
=
'\0'
;
return
strlen
(
KK_CCU_PRODUCTID
);
}
/*
/*
* This need to be same with app version as in uOTA module (ota_version.h)
* This need to be same with app version as in uOTA module (ota_version.h)
...
...
common/hal/kk_hal.h
View file @
62c805fd
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#ifndef __KK_HAL_H__
#ifndef __KK_HAL_H__
#define __KK_HAL_H__
#define __KK_HAL_H__
#include <stdio.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/time.h>
#include <time.h>
#include <time.h>
#include "kk_product.h"
#include "kk_product.h"
...
@@ -42,8 +43,6 @@ int HAL_Get_SN(char sn[SN_ADDR_LEN]);
...
@@ -42,8 +43,6 @@ int HAL_Get_SN(char sn[SN_ADDR_LEN]);
int
HAL_Execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
);
int
HAL_Execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
);
int
HAL_SetProduct_Type
(
_IN_
char
*
product_type
);
int
HAL_SetProduct_Type
(
_IN_
char
*
product_type
);
int
HAL_SetProduct_Code
(
_IN_
char
*
product_code
);
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
);
void
HAL_Firmware_Persistence_Start
(
void
*
fileName
);
void
HAL_Firmware_Persistence_Start
(
void
*
fileName
);
int
HAL_Firmware_Persistence_Write
(
_IN_
char
*
buffer
,
_IN_
uint32_t
length
);
int
HAL_Firmware_Persistence_Write
(
_IN_
char
*
buffer
,
_IN_
uint32_t
length
);
int
HAL_Firmware_Persistence_Stop
(
void
);
int
HAL_Firmware_Persistence_Stop
(
void
);
...
...
common/hal/kk_product.h
View file @
62c805fd
...
@@ -31,13 +31,13 @@
...
@@ -31,13 +31,13 @@
#define PRODUCT_TPYE "kk"
#define PRODUCT_TPYE "kk"
#define CCU_LAN "eth0"
#define CCU_LAN "eth0"
#define KK_CCU_ID "CCU_77771"
#define KK_CCU_ID "CCU_77771"
#define KK_CCU_PRODUCTID "ccu_n12"
#define KK_GW_PRODUCTID "gateway_2"
#define KK_GW_PRODUCTID "gateway_2"
#define KK_CCU_RANDOM "0000000000"
#define KK_CCU_RANDOM "0000000000"
#define KK_CCU_NAME "NEW_CCU"
#define KK_CCU_NAME "NEW_CCU"
#define KK_DEVICE_MAP_FILE_PATH "/data/kk/map/device_%s.json"
#define KK_DEVICE_MAP_FILE_PATH "/data/kk/map/device_%s.json"
#define GET_CCUID_CMD "fw_printenv uuid -n"
#define GET_CCUID_CMD "fw_printenv uuid -n"
#define GET_KEY_CMD "fw_printenv key -n"
#define GET_KEY_CMD "fw_printenv key -n"
#define GET_PRODUCTID_CMD "fw_printenv pid -n"
#define KK_DB_FILE "/data/kk/kk_database.db"
#define KK_DB_FILE "/data/kk/kk_database.db"
#define TSL_SUBDEVICE_PATH_FILE "/data/kk/tsl/product_%s.json"
#define TSL_SUBDEVICE_PATH_FILE "/data/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/data/kk/tsl/gateway_%s.json"
#define TSL_GATEWAY_PATH_FILE "/data/kk/tsl/gateway_%s.json"
...
@@ -48,6 +48,9 @@
...
@@ -48,6 +48,9 @@
#define OTA_IMG_FILE_MD5 "/data/OTA/app_squashfs.img.md5"
#define OTA_IMG_FILE_MD5 "/data/OTA/app_squashfs.img.md5"
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#define KK_CONFIG_FILE_PATH "/data/kk/kk_cloud_conf.json"
#define KK_DEFAULT_CONFIG_FILE_PATH "/app/ccuApps/config/cloud_default_config.json"
#define KK_AUTH_CONFIG_FILE_PATH "/tmp/auth_conf.json"
enum
{
enum
{
DEVICE_OFFLINE
=
0
,
DEVICE_OFFLINE
=
0
,
DEVICE_ONLINE
,
DEVICE_ONLINE
,
...
...
midware/midware/dm/dm_ota.c
View file @
62c805fd
...
@@ -24,7 +24,7 @@ int dm_ota_init(void)
...
@@ -24,7 +24,7 @@ int dm_ota_init(void)
dm_ota_ctx_t
*
ctx
=
_dm_ota_get_ctx
();
dm_ota_ctx_t
*
ctx
=
_dm_ota_get_ctx
();
memset
(
ctx
,
0
,
sizeof
(
dm_ota_ctx_t
));
memset
(
ctx
,
0
,
sizeof
(
dm_ota_ctx_t
));
HAL_GetProduct_Code
(
ctx
->
deviceCode
);
kk_get_pid
(
ctx
->
deviceCode
);
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
...
@@ -186,7 +186,7 @@ int kk_publishProgress(int process,int state)
...
@@ -186,7 +186,7 @@ int kk_publishProgress(int process,int state)
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
productCode
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
ccuID
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
ccuID
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
char
msgId
[
MSG_MAX_LEN
]
=
{
0
};
HAL_GetProduct_Code
(
productCode
);
kk_get_pid
(
productCode
);
HAL_Get_ccuid
(
ccuID
);
HAL_Get_ccuid
(
ccuID
);
iotx_report_id
(
msgId
);
iotx_report_id
(
msgId
);
cJSON
*
info
=
cJSON_CreateObject
();
cJSON
*
info
=
cJSON_CreateObject
();
...
...
midware/midware/dm/kk_dm_mng.c
View file @
62c805fd
...
@@ -594,6 +594,26 @@ static void _dm_mgr_destroy_devlist(void)
...
@@ -594,6 +594,26 @@ static void _dm_mgr_destroy_devlist(void)
free
(
del_node
);
free
(
del_node
);
}
}
}
}
char
s_pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
static
int
kk_pid_init
(
void
)
{
char
pid
[
PRODUCT_CODE_LEN
]
=
{
0
};
int
pid_len
=
0
;
HAL_Execel_cmd
(
GET_PRODUCTID_CMD
,(
char
*
)
pid
,
sizeof
(
pid
),
&
pid_len
);
if
(
pid_len
>
0
&&
pid_len
<=
PRODUCT_CODE_LEN
){
memcpy
(
s_pid
,
pid
,
pid_len
-
1
);
INFO_PRINT
(
"s_pid:%s
\n
"
,
s_pid
);
}
else
{
return
-
1
;
}
return
0
;
}
int
kk_get_pid
(
char
*
productId
)
{
strncpy
(
productId
,
s_pid
,
strlen
(
s_pid
));
printf
(
"kk_lan_get_ccuid:%s
\n
"
,
s_pid
);
return
strlen
(
s_pid
);
}
extern
char
*
kk_sync_get_info
();
extern
char
*
kk_sync_get_info
();
int
dm_mgr_init
(
void
)
int
dm_mgr_init
(
void
)
{
{
...
@@ -614,12 +634,13 @@ int dm_mgr_init(void)
...
@@ -614,12 +634,13 @@ int dm_mgr_init(void)
ctx
->
global_devid
=
1
;
ctx
->
global_devid
=
1
;
kk_property_db_init
();
kk_property_db_init
();
HAL_Get_ccuid
(
ccuid
);
HAL_Get_ccuid
(
ccuid
);
kk_pid_init
();
/* Init Device List */
/* Init Device List */
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
INIT_LIST_HEAD
(
&
ctx
->
dev_list
);
HAL_Get_mac
(
mac
);
HAL_Get_mac
(
mac
);
kk_sync_init
();
kk_sync_init
();
//kk_sync_get_info();
//kk_sync_get_info();
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
KK_DM_CCU_DEVICE_PRODUCT_CODE
,
ccuid
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
res
=
dm_mgr_device_create
(
KK_DM_DEVICE_CCU
,
s_pid
,
ccuid
,
mac
,
""
,
KK_DEV_UNKNOW
,
&
devId
,
&
heartbeat
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
goto
ERROR
;
goto
ERROR
;
}
}
...
@@ -1687,6 +1708,9 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN])
...
@@ -1687,6 +1708,9 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN])
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
kk_subAirSwitch_delete_by_dcode
(
deviceCode
);
kk_subAirSwitch_delete_by_dcode
(
deviceCode
);
}
}
if
(
strcmp
(
node
->
productType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
){
kk_subFreshAir_delete_by_dcode
(
deviceCode
);
}
if
(
node
->
dev_type
==
KK_DM_DEVICE_CCU
){
if
(
node
->
dev_type
==
KK_DM_DEVICE_CCU
){
ERROR_PRINT
(
"ERROR [%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
ERROR_PRINT
(
"ERROR [%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
...
midware/midware/dm/kk_dm_mng.h
View file @
62c805fd
...
@@ -12,11 +12,11 @@
...
@@ -12,11 +12,11 @@
#define KK_MID_SYNC_DEFAULT_TIMEOUT_MS (200)
#define KK_MID_SYNC_DEFAULT_TIMEOUT_MS (200)
#define IDENTIFY_MAXLEN (64 + 1)
#define IDENTIFY_MAXLEN (64 + 1)
#define KK_DM_CCU_DEVICE_PRODUCT_TYPE "ccu"
#define KK_DM_CCU_DEVICE_PRODUCT_TYPE "ccu"
#define KK_DM_CCU_DEVICE_PRODUCT_CODE KK_CCU_PRODUCTID
#define KK_DM_GW_DEVICE_PRODUCT_TYPE "gw"
#define KK_DM_GW_DEVICE_PRODUCT_TYPE "gw"
#define KK_DM_GW_DEVICE_PRODUCT_CODE "2"
#define KK_DM_GW_DEVICE_PRODUCT_CODE "2"
#define KK_DM_AIR_GATEWAY_TYPE "air conditioning gateway"
#define KK_DM_AIR_GATEWAY_TYPE "air conditioning gateway"
#define KK_DM_AIR_SWITCH_GATEWAY_TYPE "airswitch gateway"
#define KK_DM_AIR_SWITCH_GATEWAY_TYPE "airswitch gateway"
#define KK_DM_FRESHAIR_GATEWAY_TYPE "freshAir Gateway"
#define KK_DM_DEVICE_CCU_DEVICEID (0x00)
#define KK_DM_DEVICE_CCU_DEVICEID (0x00)
#define MSG_MAX_LEN (64)
#define MSG_MAX_LEN (64)
...
@@ -124,4 +124,5 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN]);
...
@@ -124,4 +124,5 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN]);
int
dm_msg_thing_property_post_all
(
char
*
deviceCode
);
int
dm_msg_thing_property_post_all
(
char
*
deviceCode
);
int
dm_mgr_get_gw_deviceCode
(
_OU_
dm_mgr_dev_node_t
**
node
);
int
dm_mgr_get_gw_deviceCode
(
_OU_
dm_mgr_dev_node_t
**
node
);
void
dm_mgr_resubscribe
(
void
);
void
dm_mgr_resubscribe
(
void
);
int
kk_get_pid
(
char
*
productId
);
#endif
#endif
midware/midware/dm/kk_dm_msg.h
View file @
62c805fd
...
@@ -120,6 +120,19 @@ typedef struct {
...
@@ -120,6 +120,19 @@ typedef struct {
#define KK_THING_SERVICE_DELETEFLOORS_REPLY "/thing/service/deleteFloors_reply"
#define KK_THING_SERVICE_DELETEFLOORS_REPLY "/thing/service/deleteFloors_reply"
#define KK_THING_SERVICE_UPDATEFLOORS "/thing/service/updateFloors"
#define KK_THING_SERVICE_UPDATEFLOORS "/thing/service/updateFloors"
#define KK_THING_SERVICE_UPDATEFLOORS_REPLY "/thing/service/updateFloors_reply"
#define KK_THING_SERVICE_UPDATEFLOORS_REPLY "/thing/service/updateFloors_reply"
#define KK_THING_SERVICE_CLIENTREPORT "/thing/service/clientReport"
#define KK_THING_SERVICE_CLIENTREPORT_REPLY "/thing/service/clientReport_reply"
#define KK_THING_SERVICE_SPECIALDEVTOROOM "/thing/service/addSpecialDeviceToRoom"
#define KK_THING_SERVICE_SPECIALDEVTOROOM_REPLY "/thing/service/addSpecialDeviceToRoom_reply"
#define KK_THING_SERVICE_RMSPECIALDEVFROMROOM "/thing/service/removeSpecialDeviceFromRoom"
#define KK_THING_SERVICE_RMSPECIALDEVFROM_REPLY "/thing/service/removeSpecialDeviceFromRoom_reply"
#define KK_THING_SERVICE_DELETESPECIALDEV "/thing/service/relieveMooreDevice"
#define KK_THING_SERVICE_DELETESPECIALDEV_REPLY "/thing/service/relieveMooreDevice_reply"
#define KK_THING_SERVICE_GETMOORELIST "/thing/service/getMooreList"
#define KK_THING_SERVICE_GETMOORELIST_REPLY "/thing/service/getMooreList_reply"
#define KK_THING_SERVICE_CLIENTONLINEPUSH "/thing/service/clientOnlinePush"
#define KK_THING_SERVICE_GETCLIENTINFO "/thing/service/getClientInfo"
#define KK_THING_SERVICE_GETCLIENTINFO_REPLY "/thing/service/getClientInfo_reply"
void
kk_sendData2app
(
void
*
info
,
void
*
payload
,
int
isAsync
);
void
kk_sendData2app
(
void
*
info
,
void
*
payload
,
int
isAsync
);
int
dm_msg_thing_sub_register
(
_IN_
char
productCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
int
dm_msg_thing_sub_register
(
_IN_
char
productCode
[
DEVICE_CODE_MAXLEN
],
_IN_
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
...
...
midware/midware/dm/kk_linkkit.c
View file @
62c805fd
...
@@ -481,7 +481,6 @@ static int kk_service_addRoom_handle(const char *deviceCode, cJSON *params,cJSON
...
@@ -481,7 +481,6 @@ static int kk_service_addRoom_handle(const char *deviceCode, cJSON *params,cJSON
return
res
;
return
res
;
}
}
cJSON
*
roomInfoStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
cJSON
*
roomInfoStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
//cJSON *roomIdStr = cJSON_GetObjectItem(params, MSG_AREA_ROOM_ROOMID);
if
(
roomInfoStr
==
NULL
){
if
(
roomInfoStr
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -508,7 +507,7 @@ static int kk_service_updateRoom_handle(const char *deviceCode, cJSON *params,cJ
...
@@ -508,7 +507,7 @@ static int kk_service_updateRoom_handle(const char *deviceCode, cJSON *params,cJ
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
cJSON
*
roomInfoStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
cJSON
*
roomInfoStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
cJSON
*
roomIdStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_ROOMID
);
cJSON
*
roomIdStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
roomInfoStr
==
NULL
||
roomIdStr
==
NULL
){
if
(
roomInfoStr
==
NULL
||
roomIdStr
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -569,7 +568,7 @@ static int kk_service_deleteRoom_handle(cJSON *params)
...
@@ -569,7 +568,7 @@ static int kk_service_deleteRoom_handle(cJSON *params)
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
cJSON
*
roomInfoStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_ROOMID
);
cJSON
*
roomInfoStr
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
roomInfoStr
==
NULL
){
if
(
roomInfoStr
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -603,7 +602,7 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
...
@@ -603,7 +602,7 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
if
(
room_name
==
NULL
){
if
(
room_name
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_ROOMID
);
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
roomId
==
NULL
){
if
(
roomId
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -623,6 +622,8 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
...
@@ -623,6 +622,8 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
isAirGwFlag
=
1
;
isAirGwFlag
=
1
;
}
else
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
}
else
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
isAirGwFlag
=
2
;
isAirGwFlag
=
2
;
}
else
if
(
strcmp
(
node
->
productType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
){
isAirGwFlag
=
3
;
}
}
strcpy
(
epNumStr
,
"1"
);
strcpy
(
epNumStr
,
"1"
);
}
else
{
}
else
{
...
@@ -657,6 +658,19 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
...
@@ -657,6 +658,19 @@ static int kk_service_addDeviceToRoom_handle(cJSON *params)
kk_room_dev_add
(
roomId
->
valuestring
,
room_name
->
valuestring
,
deviceCode
->
valuestring
,
epNumStr
,
name
);
kk_room_dev_add
(
roomId
->
valuestring
,
room_name
->
valuestring
,
deviceCode
->
valuestring
,
epNumStr
,
name
);
}
}
}
}
if
(
strcmp
(
node
->
productType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
&&
isAirGwFlag
==
3
){
int
eplist
[
64
]
=
{
0
};
char
name
[
128
]
=
{
0
};
int
i
=
0
;
int
count
=
kk_subFreshAir_query_epnums
(
deviceCode
->
valuestring
,
eplist
);
for
(
i
=
0
;
i
<
count
;
i
++
){
memset
(
epNumStr
,
0x0
,
sizeof
(
epNumStr
));
memset
(
name
,
0x0
,
sizeof
(
name
));
sprintf
(
epNumStr
,
"%d"
,
eplist
[
i
]);
sprintf
(
name
,
"新风%d"
,
eplist
[
i
]);
kk_room_dev_add
(
roomId
->
valuestring
,
room_name
->
valuestring
,
deviceCode
->
valuestring
,
epNumStr
,
name
);
}
}
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
/************************************************************
/************************************************************
...
@@ -729,12 +743,16 @@ static int kk_service_executeDNDMode_handle(cJSON *params)
...
@@ -729,12 +743,16 @@ static int kk_service_executeDNDMode_handle(cJSON *params)
if
(
params
==
NULL
){
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_ROOMID
);
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
roomId
==
NULL
||
roomId
->
type
!=
cJSON_Number
){
if
(
roomId
==
NULL
||
roomId
->
type
!=
cJSON_Number
){
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
ERROR_PRINT
(
"DATA ERROR!!!
\n
"
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
if
(
roomId
->
type
==
cJSON_Number
){
sprintf
(
roomIdStr
,
"%d"
,
roomId
->
valueint
);
sprintf
(
roomIdStr
,
"%d"
,
roomId
->
valueint
);
}
else
{
strcpy
(
roomIdStr
,
roomId
->
valuestring
);
}
pList
=
kk_get_room_deviceCode
(
roomIdStr
);
pList
=
kk_get_room_deviceCode
(
roomIdStr
);
while
(
pList
!=
NULL
){
while
(
pList
!=
NULL
){
...
@@ -793,7 +811,7 @@ static int kk_service_setFloor_handle(cJSON *params)
...
@@ -793,7 +811,7 @@ static int kk_service_setFloor_handle(cJSON *params)
if
(
rooms
==
NULL
)
return
INVALID_PARAMETER
;
if
(
rooms
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
itemroom
=
rooms
->
child
;
cJSON
*
itemroom
=
rooms
->
child
;
while
(
itemroom
!=
NULL
){
while
(
itemroom
!=
NULL
){
cJSON
*
roomid
=
cJSON_GetObjectItem
(
itemroom
,
MSG_AREA_ROOM_ROOMID
);
cJSON
*
roomid
=
cJSON_GetObjectItem
(
itemroom
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
roomid
==
NULL
){
if
(
roomid
==
NULL
){
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
...
@@ -967,7 +985,327 @@ static int kk_service_getFloor_handle(cJSON *param,cJSON *msgId)
...
@@ -967,7 +985,327 @@ static int kk_service_getFloor_handle(cJSON *param,cJSON *msgId)
kk_free_floor_list
();
kk_free_floor_list
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
/************************************************************
*功能描述:添加屏类设备REPLY
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_addScreen_handle_reply
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
serialId
)
{
if
(
param
==
NULL
||
msgId
==
NULL
||
serialId
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
param
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_CLIENTREPORT_REPLY
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
cJSON
*
paramInfo
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
paramInfo
,
"serialId"
,
serialId
);
cJSON_AddItemToObject
(
payload
,
"params"
,
paramInfo
);
char
*
payload11
=
cJSON_Print
(
payload
);
printf
(
"------------------------------>payload11:%s
\n
"
,
payload11
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:添加屏类设备REPLY
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_client_online_push
(
cJSON
*
param
,
cJSON
*
msgId
,
char
*
serialId
)
{
if
(
param
==
NULL
||
msgId
==
NULL
||
serialId
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
param
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_CLIENTONLINEPUSH
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
cJSON
*
paramInfo
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
paramInfo
,
"serialId"
,
serialId
);
cJSON_AddNumberToObject
(
paramInfo
,
"online"
,
1
);
cJSON_AddItemToObject
(
payload
,
"params"
,
paramInfo
);
char
*
payload11
=
cJSON_Print
(
payload
);
printf
(
"------------------------------>payload11:%s
\n
"
,
payload11
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:添加屏类设备
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_addScreen_handle
(
cJSON
*
info
,
cJSON
*
msgId
,
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
mac
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_MAC
);
if
(
mac
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
ip
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_IP
);
if
(
ip
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
version
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_VERSION
);
if
(
version
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_SERIALID
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
devtype
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_TYPE
);
if
(
devtype
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
expand
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_EXPAND
);
if
(
expand
==
NULL
)
return
INVALID_PARAMETER
;
kk_service_addScreen_handle_reply
(
info
,
msgId
,
serialid
->
valuestring
);
kk_screenDev_insert_db
(
devtype
->
valueint
,
serialid
->
valuestring
,
ip
->
valuestring
,
mac
->
valuestring
,
version
->
valuestring
,
expand
->
valuestring
);
kk_service_client_online_push
(
info
,
msgId
,
serialid
->
valuestring
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:添加屏类到房间
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_addScreenToRoom_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
roomname
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_ROOMNAME
);
if
(
roomname
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_CCUROOMID
);
if
(
roomId
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
name
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ADDROOM_DEVICENAME
);
if
(
name
==
NULL
)
return
INVALID_PARAMETER
;
kk_screenDev_update_room
(
serialid
->
valuestring
,
roomId
->
valuestring
,
roomname
->
valuestring
,
name
->
valuestring
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:删除屏类到房间
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_removeScreenToRoom_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
kk_screenDev_update_room
(
serialid
->
valuestring
,
""
,
""
,
""
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:删除屏类
*输入参数:params:云端下发数据,包含房间号等
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_deleteScreen_handle
(
cJSON
*
params
)
{
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
serialid
=
cJSON_GetObjectItem
(
params
,
MSG_DEVICE_DEVICEINFO
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
kk_screenDev_delete_by_serialId
(
serialid
->
valuestring
);
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:获取屏类列表
*输入参数:params:云端下发数据,包含场景Id等
msgId:消息Id
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_getScreenList_handle
(
cJSON
*
param
,
cJSON
*
msgId
)
{
int
res
=
0
;
int
i
=
0
,
num
=
0
;
ScreenDevInfo_t
*
pList
=
NULL
;
printf
(
"----------------------------------------DEBUG-------------------------[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETER
;
}
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
param
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
}
printf
(
"----------------------------------------DEBUG-------------------------[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_GETMOORELIST_REPLY
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
pList
=
(
ScreenDevInfo_t
*
)
malloc
(
sizeof
(
ScreenDevInfo_t
)
*
KK_DEVICE_SCREEN_MAX_SUPPORT
);
if
(
pList
==
NULL
){
ERROR_PRINT
(
"MALLOC ERROR!!!"
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
free
(
infff
);
return
-
1
;
}
memset
(
pList
,
0x0
,
sizeof
(
ScreenDevInfo_t
)
*
KK_DEVICE_SCREEN_MAX_SUPPORT
);
cJSON
*
paramArray
=
cJSON_CreateArray
();
num
=
kk_get_screenDev_list
(
pList
);
for
(
i
=
0
;
i
<
num
;
i
++
){
cJSON
*
Item
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
Item
,
"deviceType"
,
pList
[
i
].
type
);
cJSON_AddStringToObject
(
Item
,
MSG_DEVICE_SERIALID
,
pList
[
i
].
serialId
);
cJSON_AddStringToObject
(
Item
,
MSG_DEVICE_IP
,
pList
[
i
].
ip
);
cJSON_AddStringToObject
(
Item
,
"deviceName"
,
pList
[
i
].
name
);
cJSON_AddStringToObject
(
Item
,
MSG_DEVICE_VERSION
,
pList
[
i
].
version
);
cJSON_AddStringToObject
(
Item
,
MSG_AREA_ROOM_ROOMID
,
pList
[
i
].
roomid
);
cJSON_AddStringToObject
(
Item
,
MSG_DEVICE_MAC
,
pList
[
i
].
mac
);
cJSON_AddItemToArray
(
paramArray
,
Item
);
}
cJSON_AddItemToObject
(
payload
,
"params"
,
paramArray
);
char
*
payload11
=
cJSON_Print
(
payload
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
free
(
pList
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
res
;
}
/************************************************************
*功能描述:获取指定屏类数据
*输入参数:params:云端下发数据,包含场景Id等
msgId:消息Id
*输出参数:无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
static
int
kk_service_getScreenInfo_handle
(
cJSON
*
inforoot
,
cJSON
*
param
,
cJSON
*
msgId
)
{
int
res
=
0
;
int
i
=
0
,
num
=
0
;
ScreenDevInfo_t
pInfo
=
{
0
};
if
(
param
==
NULL
||
msgId
==
NULL
){
return
INVALID_PARAMETER
;
}
printf
(
"----------------------------------------DEBUG-------------------------[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON
*
serialid
=
cJSON_GetObjectItem
(
param
,
MSG_DEVICE_SERIALID
);
if
(
serialid
==
NULL
)
return
INVALID_PARAMETER
;
cJSON
*
deviceCode
=
cJSON_GetObjectItem
(
inforoot
,
MSG_DEVICE_CODE_STR
);
if
(
deviceCode
==
NULL
){
return
FAIL_RETURN
;
}
cJSON
*
productCode
=
cJSON_GetObjectItem
(
inforoot
,
MSG_PRODUCT_CODE_STR
);
if
(
productCode
==
NULL
){
return
FAIL_RETURN
;
}
printf
(
"----------------------------------------DEBUG-------------------------[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON
*
info
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
info
,
MSG_TYPE_STR
,
KK_THING_SERVICE_GETCLIENTINFO_REPLY
);
cJSON_AddStringToObject
(
info
,
MSG_DEVICE_CODE_STR
,
deviceCode
->
valuestring
);
cJSON_AddStringToObject
(
info
,
MSG_PRODUCT_CODE_STR
,
productCode
->
valuestring
);
char
*
infff
=
cJSON_Print
(
info
);
cJSON
*
payload
=
cJSON_CreateObject
();
cJSON_AddStringToObject
(
payload
,
"desc"
,
"success"
);
cJSON_AddStringToObject
(
payload
,
"version"
,
"1.0"
);
cJSON_AddStringToObject
(
payload
,
"code"
,
"0"
);
cJSON_AddStringToObject
(
payload
,
"msgId"
,
msgId
->
valuestring
);
printf
(
"----------------------------------------DEBUG-------------------------[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON
*
paramInfo
=
cJSON_CreateObject
();
kk_get_screenDev_info
(
&
pInfo
,
serialid
->
valuestring
);
{
cJSON_AddNumberToObject
(
paramInfo
,
"type"
,
pInfo
.
type
);
cJSON_AddStringToObject
(
paramInfo
,
MSG_DEVICE_SERIALID
,
pInfo
.
serialId
);
cJSON_AddStringToObject
(
paramInfo
,
MSG_DEVICE_IP
,
pInfo
.
ip
);
cJSON_AddStringToObject
(
paramInfo
,
"name"
,
pInfo
.
name
);
cJSON_AddStringToObject
(
paramInfo
,
MSG_DEVICE_VERSION
,
pInfo
.
version
);
cJSON_AddStringToObject
(
paramInfo
,
"room_id"
,
pInfo
.
roomid
);
cJSON_AddStringToObject
(
paramInfo
,
MSG_DEVICE_MAC
,
pInfo
.
mac
);
cJSON_AddStringToObject
(
paramInfo
,
"id"
,
pInfo
.
serialId
);
cJSON_AddNumberToObject
(
paramInfo
,
"online"
,
1
);
cJSON
*
expand
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
paramInfo
,
"expand"
,
expand
);
}
printf
(
"----------------------------------------DEBUG-------------------------[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
cJSON_AddItemToObject
(
payload
,
"params"
,
paramInfo
);
char
*
payload11
=
cJSON_Print
(
payload
);
printf
(
"------------------------------>payload11:%s
\n
"
,
payload11
);
kk_sendData2app
(
infff
,
payload11
,
0
);
free
(
payload11
);
free
(
infff
);
cJSON_Delete
(
payload
);
cJSON_Delete
(
info
);
return
res
;
}
/************************************************************
/************************************************************
*功能描述:批量执行房间设备处理
*功能描述:批量执行房间设备处理
*输入参数:params:云端下发数据,包含房间号,productCode等
*输入参数:params:云端下发数据,包含房间号,productCode等
...
@@ -984,7 +1322,7 @@ static int kk_service_executeRoom_handle(cJSON *params)
...
@@ -984,7 +1322,7 @@ static int kk_service_executeRoom_handle(cJSON *params)
if
(
params
==
NULL
){
if
(
params
==
NULL
){
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_ROOMID
);
cJSON
*
roomId
=
cJSON_GetObjectItem
(
params
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
roomId
==
NULL
){
if
(
roomId
==
NULL
){
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
...
@@ -1577,7 +1915,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -1577,7 +1915,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
);
cJSON
*
state
=
cJSON_GetObjectItem
(
paramStr
,
KK_TSL_CCU_ARMINGSTATE_IDENTIFIER
);
if
(
state
!=
NULL
){
if
(
state
!=
NULL
){
cJSON
*
RoomIds
=
cJSON_GetObjectItem
(
paramStr
,
"RoomIds"
);
cJSON
*
RoomIds
=
cJSON_GetObjectItem
(
paramStr
,
MSG_AREA_ROOM_CCUROOMIDS
);
if
(
RoomIds
!=
NULL
){
if
(
RoomIds
!=
NULL
){
kk_room_reset_armingstate
();
kk_room_reset_armingstate
();
int
array_size
=
cJSON_GetArraySize
(
RoomIds
);
int
array_size
=
cJSON_GetArraySize
(
RoomIds
);
...
@@ -1855,6 +2193,44 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
...
@@ -1855,6 +2193,44 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
kk_service_updateFloor_handle
(
paramStr
);
kk_service_updateFloor_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATEFLOORS_REPLY
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_UPDATEFLOORS_REPLY
);
}
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_CLIENTREPORT
)
==
0
){
INFO_PRINT
(
"CLIENTREPORT
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_addScreen_handle
(
info_root
,
msgId
,
paramStr
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_SPECIALDEVTOROOM
)
==
0
){
INFO_PRINT
(
"SPECIALDEV TO ROOM
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_addScreenToRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_SPECIALDEVTOROOM_REPLY
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_RMSPECIALDEVFROMROOM
)
==
0
){
INFO_PRINT
(
"RM SPECIALDEV FROM ROOM
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_removeScreenToRoom_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_RMSPECIALDEVFROM_REPLY
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_DELETESPECIALDEV
)
==
0
){
INFO_PRINT
(
"DELETE SPECIALDEV
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_deleteScreen_handle
(
paramStr
);
kk_service_common_reply
(
info_root
,
msgId
,
KK_THING_SERVICE_DELETESPECIALDEV_REPLY
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_GETMOORELIST
)
==
0
){
INFO_PRINT
(
"SPECIALDEV GETLIST
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
kk_service_getScreenList_handle
(
info_root
,
msgId
);
}
else
if
(
strcmp
(
typeJson
->
valuestring
,
KK_THING_SERVICE_GETCLIENTINFO
)
==
0
){
INFO_PRINT
(
"GETCLIENTINFO
\n
"
);
cJSON
*
msgId
=
cJSON_GetObjectItem
(
payload
,
MSG_COMMON_MSGID
);
cJSON
*
paramStr
=
cJSON_GetObjectItem
(
payload
,
MSG_PARAMS_STR
);
kk_service_getScreenInfo_handle
(
info_root
,
paramStr
,
msgId
);
}
else
{
else
{
INFO_PRINT
(
"Error msgtype!!!
\n
"
);
INFO_PRINT
(
"Error msgtype!!!
\n
"
);
}
}
...
@@ -2176,41 +2552,6 @@ static int _iotx_linkkit_subdev_login(int devid)
...
@@ -2176,41 +2552,6 @@ static int _iotx_linkkit_subdev_login(int devid)
if
(
res
<
SUCCESS_RETURN
)
{
if
(
res
<
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
#ifdef MSG_NEED_RESP
msgid
=
res
;
semaphore
=
HAL_SemaphoreCreate
();
if
(
semaphore
==
NULL
)
{
return
FAIL_RETURN
;
}
_iotx_linkkit_upstream_mutex_lock
();
res
=
_iotx_linkkit_upstream_sync_callback_list_insert
(
msgid
,
semaphore
,
&
node
);
if
(
res
!=
SUCCESS_RETURN
)
{
HAL_SemaphoreDestroy
(
semaphore
);
_iotx_linkkit_upstream_mutex_unlock
();
return
FAIL_RETURN
;
}
_iotx_linkkit_upstream_mutex_unlock
();
res
=
HAL_SemaphoreWait
(
semaphore
,
IOTX_LINKKIT_SYNC_DEFAULT_TIMEOUT_MS
);
if
(
res
<
SUCCESS_RETURN
)
{
_iotx_linkkit_upstream_mutex_lock
();
_iotx_linkkit_upstream_sync_callback_list_remove
(
msgid
);
_iotx_linkkit_upstream_mutex_unlock
();
return
FAIL_RETURN
;
}
_iotx_linkkit_upstream_mutex_lock
();
code
=
node
->
code
;
_iotx_linkkit_upstream_sync_callback_list_remove
(
msgid
);
if
(
code
!=
SUCCESS_RETURN
)
{
_iotx_linkkit_upstream_mutex_unlock
();
return
FAIL_RETURN
;
}
_iotx_linkkit_upstream_mutex_unlock
();
#endif
res
=
iotx_dm_subscribe
(
devid
);
res
=
iotx_dm_subscribe
(
devid
);
if
(
res
!=
SUCCESS_RETURN
)
{
if
(
res
!=
SUCCESS_RETURN
)
{
return
FAIL_RETURN
;
return
FAIL_RETURN
;
...
...
midware/midware/dm/kk_property_db.c
View file @
62c805fd
...
@@ -122,7 +122,6 @@ static int _kk_property_db_Init(void)
...
@@ -122,7 +122,6 @@ static int _kk_property_db_Init(void)
value varchar(33), \
value varchar(33), \
valueType INTEGER, \
valueType INTEGER, \
epNum INTEGER)"
;
epNum INTEGER)"
;
if
(
sqlite3_exec
(
ctx
->
pDb
,
pSubAirSwitchtable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
if
(
sqlite3_exec
(
ctx
->
pDb
,
pSubAirSwitchtable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
{
{
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
...
@@ -131,6 +130,22 @@ static int _kk_property_db_Init(void)
...
@@ -131,6 +130,22 @@ static int _kk_property_db_Init(void)
_kk_property_db_unlock
();
_kk_property_db_unlock
();
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
const
char
*
pSubFreshAirtable
=
"CREATE TABLE IF NOT EXISTS subFreshAirProperties( \
idx INTEGER PRIMARY KEY, \
deviceCode varchar(33), \
identifier varchar(33), \
value varchar(33), \
valueType INTEGER, \
epNum INTEGER)"
;
if
(
sqlite3_exec
(
ctx
->
pDb
,
pSubFreshAirtable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
{
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
sqlite3_free
(
pcErr
);
//eUtils_LockUnlock(&sLock);
_kk_property_db_unlock
();
return
FAIL_RETURN
;
}
//eUtils_LockUnlock(&sLock);
//eUtils_LockUnlock(&sLock);
_kk_property_db_unlock
();
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
...
@@ -504,6 +519,167 @@ int kk_subAirSwitch_db_update_value(const char *deviceCode,const char *identifie
...
@@ -504,6 +519,167 @@ int kk_subAirSwitch_db_update_value(const char *deviceCode,const char *identifie
_kk_property_db_unlock
();
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
static
int
_kk_check_subFreshAir_exist
(
const
char
*
deviceCode
,
const
char
*
identifier
,
int
epNum
)
{
int
isExist
=
0
;
sqlite3_stmt
*
stmt
;
char
*
pDeviceCode
=
NULL
;
char
*
pIdentifier
=
NULL
;
int
epNumDb
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
const
char
*
searchCmd
=
"select * from subFreshAirProperties;"
;
_kk_property_db_lock
();
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pDeviceCode
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SUBFRESHAIR_DEVICECODE
);
pIdentifier
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SUBFRESHAIR_IDENTIFITER
);
epNumDb
=
sqlite3_column_int
(
stmt
,
DB_SUBFRESHAIR_EPNUM
);
if
((
strcmp
(
deviceCode
,
pDeviceCode
)
==
0
)
&&
(
strcmp
(
identifier
,
pIdentifier
)
==
0
)
&&
(
epNumDb
==
epNum
))
{
isExist
=
1
;
break
;
}
}
//INFO_PRINT("\n");
sqlite3_finalize
(
stmt
);
_kk_property_db_unlock
();
return
isExist
;
}
/************************************************************
*功能描述: 插入新风子设备属性到数据库
*输入参数: deviceCode:设备deviceCode
epNum:端点
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:属性的值插入的时候先置空,后续再update
*************************************************************/
int
kk_subFreshAir_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
epNum
)
{
const
char
*
insertCmd
=
"insert into subFreshAirProperties (deviceCode,identifier,value,valueType,epNum) \
values ('%s','%s','%s','%d','%d');"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
if
(
_kk_check_subFreshAir_exist
(
deviceCode
,
identifier
,
epNum
)
==
1
){
return
SUCCESS_RETURN
;
}
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
deviceCode
,
identifier
,
""
,
valuetype
,
epNum
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
//INFO_PRINT("sub device insert data successfully\n");
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述: 查询新风子设备数量
*输入参数: deviceCode:设备deviceCode
epList:端点列表
*输出参数: 子设备个数
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_subFreshAir_query_epnums
(
const
char
*
deviceCode
,
int
epList
[])
{
char
*
sqlCmd
=
NULL
;
//int rc = 0;
//char *zErrMsg = 0;
sqlite3_stmt
*
stmt
;
char
*
valueStr
=
NULL
;
int
count
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
"select * from subFreshAirProperties WHERE deviceCode= '%s' and identifier = '%s'"
,
deviceCode
,
"PowerSwitch"
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
if
(
count
>
32
){
return
count
;
}
epList
[
count
]
=
sqlite3_column_int
(
stmt
,
DB_SUBFRESHAIR_EPNUM
);
printf
(
"epList[count] :%d
\n
"
,
epList
[
count
]);
count
++
;
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
sqlite3_finalize
(
stmt
);
return
count
;
}
/************************************************************
*功能描述:通过deviceCode删除新风子设备
*输入参数: deviceCode:设备deviceCode
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_subFreshAir_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
])
{
const
char
*
deleteCmd
=
"delete from subFreshAirProperties where deviceCode = '%s';"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
deviceCode
);
INFO_PRINT
(
"Table delete data sqlCmd:%s
\n
"
,
sqlCmd
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
INFO_PRINT
(
"Table delete data successfully
\n
"
);
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述: 更新属性值
*输入参数: deviceCode:设备deviceCode
identifier:属性名称
value:属性值
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_subFreshAir_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
,
int
epNum
)
{
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
//if()
sqlCmd
=
sqlite3_mprintf
(
"UPDATE subFreshAirProperties SET value='%s' WHERE (deviceCode= '%s' and epNum = '%d') and (identifier = '%s') "
,
value
,
deviceCode
,
epNum
,
identifier
);
//DEBUG_PRINT("kk_property_db_update_value sqlCmd:%s\n",sqlCmd);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
//DEBUG_PRINT("kk_property_db_update_value successfully\n");
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
/************************************************************
*功能描述: 插入空调内机属性到数据库
*功能描述: 插入空调内机属性到数据库
*输入参数: deviceCode:设备deviceCode
*输入参数: deviceCode:设备deviceCode
...
...
midware/midware/dm/kk_property_db.h
View file @
62c805fd
...
@@ -48,6 +48,14 @@ enum{
...
@@ -48,6 +48,14 @@ enum{
DB_SUBAIRSWITCH_VALUETYPE
,
DB_SUBAIRSWITCH_VALUETYPE
,
DB_SUBAIRSWITCH_EPNUM
DB_SUBAIRSWITCH_EPNUM
};
};
enum
{
DB_SUBFRESHAIR_IDX
=
0
,
DB_SUBFRESHAIR_DEVICECODE
,
DB_SUBFRESHAIR_IDENTIFITER
,
DB_SUBFRESHAIR_VALUE
,
DB_SUBFRESHAIR_VALUETYPE
,
DB_SUBFRESHAIR_EPNUM
};
int
kk_property_db_init
(
void
);
int
kk_property_db_init
(
void
);
int
kk_property_db_get_rawdata
(
const
char
*
identifier
,
const
int
dev_type
,
kk_prop_raw_struct_t
*
raw
,
int
count
);
int
kk_property_db_get_rawdata
(
const
char
*
identifier
,
const
int
dev_type
,
kk_prop_raw_struct_t
*
raw
,
int
count
);
int
kk_property_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
);
int
kk_property_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
);
...
@@ -69,5 +77,9 @@ int kk_subAirSwitch_db_update_value(const char *deviceCode,const char *identifie
...
@@ -69,5 +77,9 @@ int kk_subAirSwitch_db_update_value(const char *deviceCode,const char *identifie
int
kk_subAirSwitch_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_subAirSwitch_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_subAirSwitch_query_epnums
(
const
char
*
deviceCode
,
int
epList
[]);
int
kk_subAirSwitch_query_epnums
(
const
char
*
deviceCode
,
int
epList
[]);
int
kk_subAirSwitch_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
epNum
);
int
kk_subAirSwitch_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
epNum
);
int
kk_subFreshAir_db_insert
(
const
char
*
deviceCode
,
const
char
*
identifier
,
kk_tsl_data_type_e
valuetype
,
int
epNum
);
int
kk_subFreshAir_query_epnums
(
const
char
*
deviceCode
,
int
epList
[]);
int
kk_subFreshAir_delete_by_dcode
(
char
deviceCode
[
DEVICE_CODE_MAXLEN
]);
int
kk_subFreshAir_db_update_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
const
char
*
value
,
int
epNum
);
#endif
#endif
midware/midware/dm/kk_sub_db.c
View file @
62c805fd
...
@@ -67,8 +67,7 @@ static int kk_subDev_db_Init(void)
...
@@ -67,8 +67,7 @@ static int kk_subDev_db_Init(void)
ctx
->
pDb
=
g_kk_pDb
;
ctx
->
pDb
=
g_kk_pDb
;
INFO_PRINT
(
"sub db Database opened
\n
"
);
{
const
char
*
pSubDevTable
=
"CREATE TABLE IF NOT EXISTS SubDeviceInfo( \
const
char
*
pSubDevTable
=
"CREATE TABLE IF NOT EXISTS SubDeviceInfo( \
idx INTEGER, \
idx INTEGER, \
isOffline INTEGER, \
isOffline INTEGER, \
...
@@ -95,8 +94,26 @@ static int kk_subDev_db_Init(void)
...
@@ -95,8 +94,26 @@ static int kk_subDev_db_Init(void)
_kk_subDb_unlock
();
_kk_subDb_unlock
();
return
FAIL_RETURN
;
return
FAIL_RETURN
;
}
}
}
const
char
*
pScreenDevTable
=
"CREATE TABLE IF NOT EXISTS ScreenDeviceInfo( \
idx INTEGER PRIMARY KEY , \
isOffline INTEGER, \
type INTEGER, \
serialId varchar(128), \
deviceIp varchar(32), \
deviceName varchar(128), \
mac varchar(33), \
version varchar(33), \
roomId varchar(33), \
roomName varchar(128), \
expand varchar(256))"
;
if
(
sqlite3_exec
(
ctx
->
pDb
,
pScreenDevTable
,
NULL
,
NULL
,
&
pcErr
)
!=
SQLITE_OK
)
{
ERROR_PRINT
(
"Error creating table (%s)
\n
"
,
pcErr
);
sqlite3_free
(
pcErr
);
return
FAIL_RETURN
;
}
//eUtils_LockUnlock(&sLock);
//eUtils_LockUnlock(&sLock);
_kk_subDb_unlock
();
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
...
@@ -810,3 +827,242 @@ int kk_subDev_getSensors_reply(SensorType_t*list)
...
@@ -810,3 +827,242 @@ int kk_subDev_getSensors_reply(SensorType_t*list)
/************************************************************
*功能描述:检查屏类设备是否有重复
*输入参数:deviceCode:设备deviceCode
*输出参数:无
*返 回 值:1:存在;0:不存在
*其他说明:
*************************************************************/
static
int
_kk_check_screenDev_exist
(
const
char
*
sId
)
{
int
isExist
=
0
;
sqlite3_stmt
*
stmt
;
char
*
serialId
=
NULL
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
const
char
*
searchCmd
=
"select * from ScreenDeviceInfo;"
;
_kk_subDb_lock
();
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
serialId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_SERIALID
);
if
(
!
strcmp
(
sId
,
serialId
))
{
isExist
=
1
;
break
;
}
}
sqlite3_finalize
(
stmt
);
_kk_subDb_unlock
();
return
isExist
;
}
/************************************************************
*功能描述:保存设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_screenDev_insert_db
(
int
devType
,
char
*
serialId
,
\
char
*
ip
,
char
*
mac
,
char
*
version
,
char
*
expand
)
{
const
char
*
insertCmd
=
"insert into ScreenDeviceInfo (isOffline,type,serialId,deviceIp,deviceName,mac,version,roomId,roomName,expand) \
values ('%d','%d','%s','%s','%s','%s','%s','%s','%s','%s');"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
if
(
_kk_check_screenDev_exist
((
const
char
*
)
serialId
)
==
1
)
{
WARNING_PRINT
(
"[%s][%d] DATA ALREADY EXIST!!!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
SUCCESS_RETURN
;
}
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
insertCmd
,
1
,
devType
,
serialId
,
ip
,
"MOOR4C"
,
mac
,
version
,
""
,
""
,
expand
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
//INFO_PRINT("sub device insert data successfully\n");
}
sqlite3_free
(
sqlCmd
);
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:更新设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_screenDev_update_room
(
char
*
serialId
,
char
*
roomid
,
char
*
roomname
,
char
*
name
)
{
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
"UPDATE ScreenDeviceInfo SET roomId= '%s',roomName ='%s',deviceName = '%s' WHERE serialId= '%s'"
,
roomid
,
roomname
,
name
,
serialId
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
INFO_PRINT
(
"Table updata data successfully
\n
"
);
}
sqlite3_free
(
sqlCmd
);
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:删除设备信息到数据库
*输入参数:devType:设备类型
serialId:产品Id
ip:设备ip
mac: mac地址
version:版本号
expand:预留
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_screenDev_delete_by_serialId
(
char
*
serialId
)
{
const
char
*
deleteCmd
=
"delete from ScreenDeviceInfo where serialId = '%s';"
;
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
deleteCmd
,
serialId
);
rc
=
sqlite3_exec
(
ctx
->
pDb
,
sqlCmd
,
NULL
,
NULL
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
ERROR_PRINT
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
else
{
//INFO_PRINT("Table delete data successfully\n");
}
sqlite3_free
(
sqlCmd
);
_kk_subDb_unlock
();
return
SUCCESS_RETURN
;
}
/************************************************************
*功能描述:获取屏类列表
*输入参数:deviceCode:设备deviceCode
isAuth:1,已注册;0,未注册
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_get_screenDev_list
(
ScreenDevInfo_t
*
list
)
{
const
char
*
searchCmd
=
"select * from ScreenDeviceInfo"
;
char
*
zErrMsg
=
0
;
sqlite3_stmt
*
stmt
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
char
*
pSerialId
=
NULL
;
char
*
pIp
=
NULL
;
char
*
pDevName
=
NULL
;
char
*
pMac
=
NULL
;
char
*
pRoomId
=
NULL
;
char
*
pVer
=
NULL
;
int
type
=
0
;
int
count
=
0
;
_kk_subDb_lock
();
sqlite3_prepare_v2
(
ctx
->
pDb
,
searchCmd
,
strlen
(
searchCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pSerialId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_SERIALID
);
pIp
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_IP
);
pDevName
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_NAME
);
pRoomId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_ROOMID
);
pMac
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_MAC
);
pVer
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_VERSION
);
type
=
sqlite3_column_int
(
stmt
,
DB_SCREEN_TYPE
);
//printf("currentValue:%d\n",currentValue);
memcpy
(
list
[
count
].
serialId
,
pSerialId
,
strlen
(
pSerialId
));
memcpy
(
list
[
count
].
ip
,
pIp
,
strlen
(
pIp
));
memcpy
(
list
[
count
].
mac
,
pMac
,
strlen
(
pMac
));
memcpy
(
list
[
count
].
name
,
pDevName
,
strlen
(
pDevName
));
memcpy
(
list
[
count
].
roomid
,
pRoomId
,
strlen
(
pRoomId
));
memcpy
(
list
[
count
].
version
,
pVer
,
strlen
(
pVer
));
list
[
count
].
type
=
type
;
count
++
;
}
sqlite3_finalize
(
stmt
);
_kk_subDb_unlock
();
return
count
;
}
/************************************************************
*功能描述:获取屏类信息
*输入参数:deviceCode:设备deviceCode
isAuth:1,已注册;0,未注册
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int
kk_get_screenDev_info
(
ScreenDevInfo_t
*
devInfo
,
char
*
serialId
)
{
const
char
*
searchCmd
=
"select * from ScreenDeviceInfo where serialId = '%s';"
;
char
*
zErrMsg
=
0
;
sqlite3_stmt
*
stmt
;
kk_subDb_ctx_t
*
ctx
=
_kk_subDb_get_ctx
();
char
*
pSerialId
=
NULL
;
char
*
pIp
=
NULL
;
char
*
pDevName
=
NULL
;
char
*
pMac
=
NULL
;
char
*
pRoomId
=
NULL
;
char
*
pVer
=
NULL
;
int
type
=
0
;
char
*
sqlCmd
=
NULL
;
if
(
devInfo
==
NULL
||
serialId
==
NULL
){
return
-
1
;
}
_kk_subDb_lock
();
sqlCmd
=
sqlite3_mprintf
(
searchCmd
,
serialId
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
pSerialId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_SERIALID
);
pIp
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_IP
);
pDevName
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_NAME
);
pRoomId
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_ROOMID
);
pMac
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_MAC
);
pVer
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SCREEN_VERSION
);
type
=
sqlite3_column_int
(
stmt
,
DB_SCREEN_TYPE
);
//printf("currentValue:%d\n",currentValue);
memcpy
(
devInfo
->
serialId
,
pSerialId
,
strlen
(
pSerialId
));
memcpy
(
devInfo
->
ip
,
pIp
,
strlen
(
pIp
));
memcpy
(
devInfo
->
mac
,
pMac
,
strlen
(
pMac
));
memcpy
(
devInfo
->
name
,
pDevName
,
strlen
(
pDevName
));
memcpy
(
devInfo
->
roomid
,
pRoomId
,
strlen
(
pRoomId
));
memcpy
(
devInfo
->
version
,
pVer
,
strlen
(
pVer
));
devInfo
->
type
=
type
;
break
;
}
sqlite3_finalize
(
stmt
);
_kk_subDb_unlock
();
sqlite3_free
(
sqlCmd
);
return
0
;
}
\ No newline at end of file
midware/midware/dm/kk_sub_db.h
View file @
62c805fd
...
@@ -6,6 +6,15 @@ typedef struct {
...
@@ -6,6 +6,15 @@ typedef struct {
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
int
SensorType
;
int
SensorType
;
}
SensorType_t
;
}
SensorType_t
;
typedef
struct
{
char
ip
[
17
];
char
name
[
128
];
char
serialId
[
128
];
char
roomid
[
32
];
char
version
[
32
];
char
mac
[
32
];
int
type
;
}
ScreenDevInfo_t
;
int
kk_subDb_init
(
void
);
int
kk_subDb_init
(
void
);
int
kk_subDev_insert_db
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
\
int
kk_subDev_insert_db
(
int
devType
,
char
productCode
[
PRODUCT_CODE_MAXLEN
],
\
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
fatherMac
[
DEVICE_MAC_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
version
[
DEVICE_VERSION_MAXLEN
],
int
heartbeat
);
char
deviceCode
[
DEVICE_CODE_MAXLEN
],
char
fatherMac
[
DEVICE_MAC_MAXLEN
],
char
mac
[
DEVICE_MAC_MAXLEN
],
char
version
[
DEVICE_VERSION_MAXLEN
],
int
heartbeat
);
...
@@ -24,6 +33,12 @@ int kk_subDev_update_offline(int isOffline,const char *deviceCode);
...
@@ -24,6 +33,12 @@ int kk_subDev_update_offline(int isOffline,const char *deviceCode);
int
kk_subDev_getSensors_reply
(
SensorType_t
*
list
);
int
kk_subDev_getSensors_reply
(
SensorType_t
*
list
);
int
kk_load_subDevice
(
void
);
int
kk_load_subDevice
(
void
);
int
kk_subDev_check_auth
(
int
devType
);
int
kk_subDev_check_auth
(
int
devType
);
int
kk_screenDev_insert_db
(
int
devType
,
char
*
serialId
,
\
char
*
ip
,
char
*
mac
,
char
*
version
,
char
*
expand
);
int
kk_screenDev_update_room
(
char
*
serialId
,
char
*
roomid
,
char
*
roomname
,
char
*
name
);
int
kk_screenDev_delete_by_serialId
(
char
*
serialId
);
int
kk_get_screenDev_list
(
ScreenDevInfo_t
*
list
);
int
kk_get_screenDev_info
(
ScreenDevInfo_t
*
devInfo
,
char
*
serialId
);
enum
{
enum
{
DB_SUB_IDX
=
0
,
DB_SUB_IDX
=
0
,
DB_SUB_ONLINE
,
DB_SUB_ONLINE
,
...
@@ -38,5 +53,17 @@ enum{
...
@@ -38,5 +53,17 @@ enum{
DB_SUB_PRODUCTTYPE
,
DB_SUB_PRODUCTTYPE
,
DB_SUB_SCENESUPPORT
DB_SUB_SCENESUPPORT
};
};
enum
{
DB_SCREEN_IDX
=
0
,
DB_SCREEN_ONLINE
,
DB_SCREEN_TYPE
,
DB_SCREEN_SERIALID
,
DB_SCREEN_IP
,
DB_SCREEN_NAME
,
DB_SCREEN_MAC
,
DB_SCREEN_VERSION
,
DB_SCREEN_ROOMID
,
DB_SCREEN_ROOMNAME
,
DB_SCREEN_EXPAND
,
};
#endif
#endif
midware/midware/dm/kk_sync_data.c
View file @
62c805fd
...
@@ -106,12 +106,8 @@ static cJSON * kk_get_room_devices(const char *roomId)
...
@@ -106,12 +106,8 @@ static cJSON * kk_get_room_devices(const char *roomId)
}
}
if
(
kk_check_multi_ep_num
(
deviceCode
)){
if
(
kk_check_multi_ep_num
(
deviceCode
)){
cJSON_AddStringToObject
(
dev
,
KK_SYNC_SCENE_EPNUM_STR
,
epNum
);
cJSON_AddStringToObject
(
dev
,
KK_SYNC_SCENE_EPNUM_STR
,
epNum
);
}
else
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_GATEWAY_TYPE
)
==
0
){
}
else
if
(
strcmp
(
node
->
productType
,
KK_DM_AIR_GATEWAY_TYPE
)
==
0
||
strcmp
(
node
->
productType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
){
//if(atoi(epNum) == 1){//epNum为1的是空调网关
// continue;
//}else{
cJSON_AddStringToObject
(
dev
,
KK_SYNC_SCENE_EPNUM_STR
,
epNum
);
cJSON_AddStringToObject
(
dev
,
KK_SYNC_SCENE_EPNUM_STR
,
epNum
);
//}
}
}
cJSON_AddStringToObject
(
dev
,
KK_SYNC_DEVICECODE_STR
,
deviceCode
);
cJSON_AddStringToObject
(
dev
,
KK_SYNC_DEVICECODE_STR
,
deviceCode
);
//cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
//cJSON_AddStringToObject(dev,KK_SYNC_SCENE_EPNUM_STR,epNum);
...
@@ -464,6 +460,53 @@ static cJSON *kk_get_indoor_properties_info(char *deviceCode)
...
@@ -464,6 +460,53 @@ static cJSON *kk_get_indoor_properties_info(char *deviceCode)
sqlite3_finalize
(
stmt
);
sqlite3_finalize
(
stmt
);
return
obj
;
return
obj
;
}
}
static
cJSON
*
kk_get_subfreshair_properties_info
(
char
*
deviceCode
)
{
char
*
sqlCmd
=
NULL
;
//char *zErrMsg = 0;
sqlite3_stmt
*
stmt
;
char
*
propertyStr
=
NULL
;
char
*
valueStr
=
NULL
;
int
valueType
=
0
;
int
eplist
[
65
]
=
{
0
};
int
count
=
0
,
i
=
0
;
char
*
ptr
=
NULL
;
kk_sync_ctx_t
*
ctx
=
_kk_sync_get_ctx
();
if
(
deviceCode
==
NULL
){
return
NULL
;
}
cJSON
*
obj
=
cJSON_CreateObject
();
cJSON
*
eps
=
cJSON_CreateArray
();
count
=
kk_subFreshAir_query_epnums
(
deviceCode
,
eplist
);
for
(
i
=
0
;
i
<
count
;
i
++
){
sqlCmd
=
sqlite3_mprintf
(
"select * from subFreshAirProperties WHERE deviceCode = '%s' and epNum=%d;"
,
deviceCode
,
eplist
[
i
]);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
cJSON
*
propertyItem
=
cJSON_CreateObject
();
cJSON_AddNumberToObject
(
propertyItem
,
"epNum"
,
eplist
[
i
]);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
propertyStr
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SUBFRESHAIR_IDENTIFITER
);
valueType
=
sqlite3_column_int
(
stmt
,
DB_SUBFRESHAIR_VALUETYPE
);
valueStr
=
(
char
*
)
sqlite3_column_text
(
stmt
,
DB_SUBFRESHAIR_VALUE
);
if
(
valueType
==
KK_TSL_DATA_TYPE_TEXT
){
cJSON_AddStringToObject
(
propertyItem
,
propertyStr
,
valueStr
);
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_INT
||
valueType
==
KK_TSL_DATA_TYPE_ENUM
||
valueType
==
KK_TSL_DATA_TYPE_BOOL
){
cJSON_AddNumberToObject
(
propertyItem
,
propertyStr
,
atoi
(
valueStr
));
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_DOUBLE
){
cJSON_AddNumberToObject
(
propertyItem
,
propertyStr
,
atof
(
valueStr
));
}
}
cJSON_AddItemToArray
(
eps
,
propertyItem
);
}
cJSON_AddItemToObject
(
obj
,
"eps"
,
eps
);
cJSON_AddNumberToObject
(
obj
,
"EpTotal"
,
count
);
cJSON_AddNumberToObject
(
obj
,
"CombineDeviceFlag"
,
1
);
sqlite3_free
(
sqlCmd
);
sqlite3_finalize
(
stmt
);
return
obj
;
}
static
cJSON
*
kk_get_properties_info_obj
(
char
*
deviceCode
)
static
cJSON
*
kk_get_properties_info_obj
(
char
*
deviceCode
)
{
{
char
*
sqlCmd
=
NULL
;
char
*
sqlCmd
=
NULL
;
...
@@ -638,8 +681,9 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode)
...
@@ -638,8 +681,9 @@ static int kk_get_sub_devices_info(cJSON *gwdevicesItem,char *deviceCode)
properties
=
kk_get_properties_info
(
subDeviceCode
,
KK_DM_DEVICE_SUBDEV
);
properties
=
kk_get_properties_info
(
subDeviceCode
,
KK_DM_DEVICE_SUBDEV
);
}
else
if
(
strcmp
(
subproductType
,
KK_DM_AIR_GATEWAY_TYPE
)
==
0
){
}
else
if
(
strcmp
(
subproductType
,
KK_DM_AIR_GATEWAY_TYPE
)
==
0
){
properties
=
kk_get_indoor_properties_info
(
subDeviceCode
);
properties
=
kk_get_indoor_properties_info
(
subDeviceCode
);
}
}
else
if
(
strcmp
(
subproductType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
){
else
{
properties
=
kk_get_subfreshair_properties_info
(
subDeviceCode
);
}
else
{
properties
=
kk_get_properties_info_obj
(
subDeviceCode
);
properties
=
kk_get_properties_info_obj
(
subDeviceCode
);
}
}
...
@@ -1202,7 +1246,7 @@ char *kk_sync_get_info()
...
@@ -1202,7 +1246,7 @@ char *kk_sync_get_info()
kk_get_devices_info
(
data
);
kk_get_devices_info
(
data
);
kk_get_scenes_info
(
data
);
kk_get_scenes_info
(
data
);
HAL_Get_ccuid
(
ccu_deviceCode
);
HAL_Get_ccuid
(
ccu_deviceCode
);
HAL_GetProduct_Code
(
ccu_productCode
);
kk_get_pid
(
ccu_productCode
);
HAL_GetVersion
(
version
);
HAL_GetVersion
(
version
);
cJSON_AddStringToObject
(
data
,
KK_SYNC_DEVICECODE_STR
,
ccu_deviceCode
);
cJSON_AddStringToObject
(
data
,
KK_SYNC_DEVICECODE_STR
,
ccu_deviceCode
);
cJSON_AddStringToObject
(
data
,
KK_SYNC_NANE_STR
,
"newccu"
);
cJSON_AddStringToObject
(
data
,
KK_SYNC_NANE_STR
,
"newccu"
);
...
...
midware/midware/iot.mk
View file @
62c805fd
...
@@ -11,14 +11,17 @@ CFLAGS += -I$(TOP_DIR)/common/sqlite
...
@@ -11,14 +11,17 @@ CFLAGS += -I$(TOP_DIR)/common/sqlite
CFLAGS
+=
-I
$(TOP_DIR)
/src/tsl/tsl_handle
CFLAGS
+=
-I
$(TOP_DIR)
/src/tsl/tsl_handle
LDFLAGS
+=
-lapi_com
-liot_cjson
-lkk_tsl
LDFLAGS
+=
-lapi_com
-liot_cjson
-lkk_tsl
LDFLAGS
+=
-lm
-lkk_hal
LDFLAGS
+=
-lm
-lkk_hal
LDFLAGS
+=
-lsqlite
-ldl
-lcurl
LDFLAGS
+=
-lsqlite
-ldl
ifeq
($(CONFIG_MODEL),x86)
ifeq
($(CONFIG_MODEL),x86)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_ubuntu
-lanl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_ubuntu
-lanl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_ubuntu
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_ubuntu
else
ifeq
($(CONFIG_MODEL),nx5)
else
ifeq
($(CONFIG_MODEL),nx5)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_nx5
-lanl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_nx5
-lanl
-lcurl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_nx5
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_nx5
else
ifeq
($(CONFIG_MODEL),8197)
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg_8197
-lubacktrace
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev_8197
else
else
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg
-lanl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/nanomsg
-lnanomsg
-lanl
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev
LDFLAGS
+=
-L
$(TOP_DIR)
/common/ev
-lev
...
...
midware/midware/midware.c
View file @
62c805fd
...
@@ -702,6 +702,8 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
...
@@ -702,6 +702,8 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
1
){
}
else
if
(
type
==
1
){
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
2
){
kk_subFreshAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_FLOAT
||
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_DOUBLE
){
char
valBuf
[
16
]
=
{
0
};
char
valBuf
[
16
]
=
{
0
};
...
@@ -710,15 +712,17 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
...
@@ -710,15 +712,17 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
1
){
}
else
if
(
type
==
1
){
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
else
if
(
type
==
2
){
kk_subFreshAir_db_update_value
(
deviceCode
,
property
->
identifier
,
valBuf
,
epNumInt
);
}
}
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
}
else
if
(
property
->
data_value
.
type
==
KK_TSL_DATA_TYPE_TEXT
){
if
(
type
==
0
){
if
(
type
==
0
){
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
kk_indoorAir_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
}
else
if
(
type
==
1
){
}
else
if
(
type
==
1
){
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
kk_subAirSwitch_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
}
else
if
(
type
==
2
){
kk_subFreshAir_db_update_value
(
deviceCode
,
property
->
identifier
,
propertyItem
->
valuestring
,
epNumInt
);
}
}
}
}
}
}
...
@@ -727,7 +731,7 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
...
@@ -727,7 +731,7 @@ static int kk_subDevice_property_save(cJSON *payload,char *deviceCode,int type)
}
}
return
0
;
return
0
;
}
}
/*type : 0,air condition gw;1,air switch gw*/
/*type : 0,air condition gw;1,air switch gw
;2,fresh air switch
*/
static
int
kk_subDevice_property_handle
(
cJSON
*
info
,
cJSON
*
payload
,
char
*
deviceCode
,
int
type
)
static
int
kk_subDevice_property_handle
(
cJSON
*
info
,
cJSON
*
payload
,
char
*
deviceCode
,
int
type
)
{
{
kk_subDevice_property_save
(
payload
,
deviceCode
,
type
);
kk_subDevice_property_save
(
payload
,
deviceCode
,
type
);
...
@@ -795,6 +799,34 @@ static int kk_subAirSwitch_online_handle(dm_mgr_dev_node_t *node ,char *deviceCo
...
@@ -795,6 +799,34 @@ static int kk_subAirSwitch_online_handle(dm_mgr_dev_node_t *node ,char *deviceCo
}
}
return
0
;
return
0
;
}
}
static
int
kk_subFreshair_online_handle
(
dm_mgr_dev_node_t
*
node
,
char
*
deviceCode
,
int
epNum
)
{
int
idx
=
0
;
int
gwExist
=
0
;
char
roomId
[
32
]
=
{
0
};
char
roomName
[
256
]
=
{
0
};
char
epNumStr
[
10
]
=
{
0
};
kk_tsl_data_t
*
property
=
NULL
;
if
(
node
==
NULL
){
return
-
1
;
}
for
(
idx
=
0
;
idx
<
node
->
dev_shadow
->
property_number
;
idx
++
){
property
=
(
kk_tsl_data_t
*
)(
node
->
dev_shadow
->
properties
+
idx
);
if
(
property
==
NULL
){
continue
;
}
kk_subFreshAir_db_insert
(
deviceCode
,
property
->
identifier
,
property
->
data_value
.
type
,
epNum
);
}
gwExist
=
kk_get_device_roomInfo
(
deviceCode
,
1
,
roomName
,
roomId
);
//获取网关房间信息
if
(
gwExist
){
char
name
[
128
]
=
{
0
};
sprintf
(
name
,
"新风%d"
,
epNum
);
sprintf
(
epNumStr
,
"%d"
,
epNum
);
kk_room_dev_add
(
roomId
,
roomName
,
deviceCode
,
epNumStr
,
name
);
}
return
0
;
}
void
kk_platMsg_handle
(
void
*
data
,
char
*
chalMark
){
void
kk_platMsg_handle
(
void
*
data
,
char
*
chalMark
){
int
res
=
0
;
int
res
=
0
;
cJSON
*
json
;
cJSON
*
json
;
...
@@ -875,6 +907,10 @@ void kk_platMsg_handle(void* data, char* chalMark){
...
@@ -875,6 +907,10 @@ void kk_platMsg_handle(void* data, char* chalMark){
cJSON
*
epNumJson
=
cJSON_GetObjectItem
(
jsonPay
,
"epNum"
);
cJSON
*
epNumJson
=
cJSON_GetObjectItem
(
jsonPay
,
"epNum"
);
if
(
epNumJson
==
NULL
)
goto
error
;
if
(
epNumJson
==
NULL
)
goto
error
;
kk_subAirSwitch_online_handle
(
search_node
,
devCode
->
valuestring
,
epNumJson
->
valueint
);
kk_subAirSwitch_online_handle
(
search_node
,
devCode
->
valuestring
,
epNumJson
->
valueint
);
}
else
if
(
strcmp
(
search_node
->
productType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
){
cJSON
*
epNumJson
=
cJSON_GetObjectItem
(
jsonPay
,
"epNum"
);
if
(
epNumJson
==
NULL
)
goto
error
;
kk_subFreshair_online_handle
(
search_node
,
devCode
->
valuestring
,
epNumJson
->
valueint
);
}
}
}
}
else
if
(
strstr
(
msgType
->
valuestring
,
KK_THING_TOPO_BATCH_ADD_MSG
)
!=
NULL
){
else
if
(
strstr
(
msgType
->
valuestring
,
KK_THING_TOPO_BATCH_ADD_MSG
)
!=
NULL
){
...
@@ -909,6 +945,8 @@ void kk_platMsg_handle(void* data, char* chalMark){
...
@@ -909,6 +945,8 @@ void kk_platMsg_handle(void* data, char* chalMark){
kk_subDevice_property_handle
(
info
,
payload
,
info_dcode
->
valuestring
,
0
);
kk_subDevice_property_handle
(
info
,
payload
,
info_dcode
->
valuestring
,
0
);
}
else
if
(
strcmp
(
search_node
->
productType
,
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
}
else
if
(
strcmp
(
search_node
->
productType
,
KK_DM_AIR_SWITCH_GATEWAY_TYPE
)
==
0
){
kk_subDevice_property_handle
(
info
,
payload
,
info_dcode
->
valuestring
,
1
);
kk_subDevice_property_handle
(
info
,
payload
,
info_dcode
->
valuestring
,
1
);
}
else
if
(
strcmp
(
search_node
->
productType
,
KK_DM_FRESHAIR_GATEWAY_TYPE
)
==
0
){
kk_subDevice_property_handle
(
info
,
payload
,
info_dcode
->
valuestring
,
2
);
}
}
else
{
else
{
/*插座类设备保存功率历史记录*/
/*插座类设备保存功率历史记录*/
...
...
midware/midware/scene/kk_scene_handle.c
View file @
62c805fd
...
@@ -1173,7 +1173,7 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
...
@@ -1173,7 +1173,7 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
propertyValue
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_PROPERTYVALUE
);
propertyValue
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_PROPERTYVALUE
);
if
(
propertyValue
==
NULL
)
return
FAIL_RETURN
;
if
(
propertyValue
==
NULL
)
return
FAIL_RETURN
;
productType
=
cJSON_GetObjectItem
(
item
,
MSG_PRODUCT_TYPE_STR
);
productType
=
cJSON_GetObjectItem
(
item
,
MSG_PRODUCT_TYPE_STR
);
roomId
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ROOM_ROOMID
);
roomId
=
cJSON_GetObjectItem
(
item
,
MSG_AREA_ROOM_
CCU
ROOMID
);
if
(
productType
!=
NULL
){
if
(
productType
!=
NULL
){
delay
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_DELAY
);
delay
=
cJSON_GetObjectItem
(
item
,
MSG_SCENE_DELAY
);
if
(
delay
==
NULL
)
return
FAIL_RETURN
;
if
(
delay
==
NULL
)
return
FAIL_RETURN
;
...
@@ -1349,7 +1349,7 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
...
@@ -1349,7 +1349,7 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
ERROR_PRINT
(
"[%d]kk_scene_parse_addscene fail!!!
\n
"
,
__LINE__
);
ERROR_PRINT
(
"[%d]kk_scene_parse_addscene fail!!!
\n
"
,
__LINE__
);
return
INVALID_PARAMETER
;
return
INVALID_PARAMETER
;
}
}
cJSON
*
room_id
=
cJSON_GetObjectItem
(
args
,
MSG_
SCENE_ROOM_
ID
);
cJSON
*
room_id
=
cJSON_GetObjectItem
(
args
,
MSG_
AREA_ROOM_CCUROOM
ID
);
if
(
room_id
==
NULL
)
if
(
room_id
==
NULL
)
{
{
INFO_PRINT
(
"NOT Contain the room info
\n
"
);
INFO_PRINT
(
"NOT Contain the room info
\n
"
);
...
...
nx5_soc_gw/kk_device_def.json
View file @
62c805fd
...
@@ -1953,7 +1953,7 @@
...
@@ -1953,7 +1953,7 @@
]
]
},
},
{
{
"pid"
:
"0080
0000
"
,
"pid"
:
"0080
3122
"
,
"name"
:
"BL Fresh Air Gateway"
,
"name"
:
"BL Fresh Air Gateway"
,
"type"
:
"ZR"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"ota"
:
true
,
...
@@ -2067,6 +2067,25 @@
...
@@ -2067,6 +2067,25 @@
}
}
]
]
},
},
{
"pid"
:
"01021000"
,
"name"
:
"YY Dimmalbe Light 5W"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3137
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
{
"pid"
:
"01000004"
,
"pid"
:
"01000004"
,
"name"
:
"Four Lamp Control Module"
,
"name"
:
"Four Lamp Control Module"
,
...
@@ -2447,6 +2466,234 @@
...
@@ -2447,6 +2466,234 @@
}
}
]
]
},
},
{
"pid"
:
"01010004"
,
"name"
:
"YY Linear Dimmalbe Light Model G4 With Level"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3166
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010C0002"
,
"name"
:
"YY Linear Dimmalbe Light Model G4 With ColorTemp"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3167
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010C0021"
,
"name"
:
"YY Dimmalbe Light Controler 12W With ColorTemp"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3169
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"01010021"
,
"name"
:
"YY Dimmalbe Light Controler 12W With Level"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3170
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010C0031"
,
"name"
:
"YY Dimmalbe Light Controler 20W With ColorTemp"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3171
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"01010031"
,
"name"
:
"YY Dimmalbe Light Controler 20W With Level"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3172
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010C0041"
,
"name"
:
"YY Dimmalbe Light Controler 8W With ColorTemp"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3173
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"01010041"
,
"name"
:
"YY Dimmalbe Light Controler 8W With Level"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3174
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010C0051"
,
"name"
:
"YY Dimmalbe Light Controler 14W With ColorTemp"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3175
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"01010051"
,
"name"
:
"YY Dimmalbe Light Controler 14W With Level"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3176
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010D0062"
,
"name"
:
"YY RGBCW Light Belt Controller"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3177
,
"productType"
:
"colorDimmableLight"
,
"eps"
:
[
{
"zid"
:
"0102"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
"pid"
:
"010D0061"
,
"name"
:
"YY CW Light Belt Controller"
,
"type"
:
"ZR"
,
"ota"
:
true
,
"b_pid"
:
3178
,
"productType"
:
"lightPanel"
,
"eps"
:
[
{
"zid"
:
"0103"
,
"cluster"
:
{
"client"
:
"0003:0019"
,
"server"
:
"0000:0003:0004:0005:0006:0008:0300"
}
}
]
},
{
{
"pid"
:
"00041002"
,
"pid"
:
"00041002"
,
"name"
:
"XB KeyBord Panel G3"
,
"name"
:
"XB KeyBord Panel G3"
,
...
...
nx5_soc_gw/smarthome_z3gw_nx5
View file @
62c805fd
No preview for this file type
opcodeMapCfg/device_3094.json
View file @
62c805fd
{
{
"productCode"
:
"3094"
,
"productCode"
:
"3094"
,
"operateType"
:
"5
12
"
,
"operateType"
:
"5
01
"
,
"channel"
:
1
,
"channel"
:
1
,
"syn_type"
:
1
,
"syn_type"
:
1
,
"syn_opcode"
:
"DIMMABLE_LIGHT_STATUS"
,
"syn_opcode"
:
"DIMMABLE_LIGHT_STATUS"
,
...
...
killall.sh
→
script/
killall.sh
View file @
62c805fd
File moved
onboot.sh
→
script/
onboot.sh
View file @
62c805fd
...
@@ -88,10 +88,10 @@ $filepath/bin/kk_lan --uart=/dev/ttyS3&
...
@@ -88,10 +88,10 @@ $filepath/bin/kk_lan --uart=/dev/ttyS3&
sleep
2
sleep
2
$filepath
/bin/kk_cloud &
$filepath
/bin/kk_cloud &
sleep
5
sleep
5
$filepath
/bin/smarthome_z3gw_nx5
-r0
-l3
--device-def
=
$filepath
/kk_device_def.json
--db
=
/data/kk/kk_z3gw.db
--uart
=
/dev/ttyS1&
$filepath
/bin/smarthome_z3gw_nx5
-r0
-l3
--device-def
=
$filepath
/
config/
kk_device_def.json
--db
=
/data/kk/kk_z3gw.db
--uart
=
/dev/ttyS1&
sleep
1
sleep
1
if
[
!
-f
/etc/cron.d/ccu
]
;
then
if
[
!
-f
/etc/cron.d/ccu
]
;
then
echo
"*/1 * * * * /app/ccuApps/process_check.sh"
>
/etc/cron.d/ccu
||
{
echo
"ERROR:add ccu crontab rule failed."
;
exit
1
;
}
echo
"*/1 * * * * /app/ccuApps/
script/
process_check.sh"
>
/etc/cron.d/ccu
||
{
echo
"ERROR:add ccu crontab rule failed."
;
exit
1
;
}
fi
fi
/etc/init.d/S90dcron restart
/etc/init.d/S90dcron restart
ntpd
-n
-q
-d
-p
stdtime.gov.hk &
ntpd
-n
-q
-d
-p
stdtime.gov.hk &
...
...
process_check.sh
→
script/
process_check.sh
View file @
62c805fd
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
ccuApps
=
"/app/ccuApps"
ccuApps
=
"/app/ccuApps"
restart_process
()
restart_process
()
{
{
$ccuApps
/killall.sh
$ccuApps
/
script/
killall.sh
$ccuApps
/onboot.sh
$ccuApps
/onboot.sh
}
}
PIDS
=
`
ps|grep kk_midware |grep
-v
grep
|
awk
'{print $1}'
`
PIDS
=
`
ps|grep kk_midware |grep
-v
grep
|
awk
'{print $1}'
`
...
...
testgit.txt
deleted
100644 → 0
View file @
f810862d
File deleted
tools/board/config.alios.esp8266
deleted
100644 → 0
View file @
f810862d
CONFIG_ENV_CFLAGS += \
-DBOARD_ESP8266 -u call_user_start \
-fno-inline-functions \
-ffunction-sections \
-fdata-sections \
-mlongcalls \
-DESPOS_FOR_ESP8266 -Wl,-static \
-DXT_USE_THREAD_SAFE_CLIB=0 \
CONFIG_ENV_CFLAGS += \
-Os \
-DCONFIG_HTTP_AUTH_TIMEOUT=500 \
-DCONFIG_MID_HTTP_TIMEOUT=500 \
-DCONFIG_GUIDER_AUTH_TIMEOUT=500 \
-DCONFIG_MQTT_TX_MAXLEN=640 \
-DCONFIG_MQTT_RX_MAXLEN=1200 \
CONFIG_external_libs/mbedtls :=
CONFIG_tests :=
CROSS_PREFIX := xtensa-lx106-elf-
tools/build-rules/_rules-top.mk
View file @
62c805fd
...
@@ -204,15 +204,17 @@ package:
...
@@ -204,15 +204,17 @@ package:
mkdir
$(releaseDir)
/lib
mkdir
$(releaseDir)
/lib
mkdir
$(releaseDir)
/bin
mkdir
$(releaseDir)
/bin
mkdir
$(releaseDir)
/map
mkdir
$(releaseDir)
/map
mkdir
$(releaseDir)
/config
mkdir
$(releaseDir)
/script
cp
-rf
$(TOP_DIR)
/tsl
$(TOP_DIR)
/
$(releaseDir)
cp
-rf
$(TOP_DIR)
/tsl
$(TOP_DIR)
/
$(releaseDir)
cp
-rf
$(TOP_DIR)
/output/release/lib/
*
.so
$(TOP_DIR)
/
$(releaseDir)
/lib
cp
-rf
$(TOP_DIR)
/output/release/lib/
*
.so
$(TOP_DIR)
/
$(releaseDir)
/lib
cp
-rf
$(TOP_DIR)
/output/release/bin/
*
$(TOP_DIR)
/
$(releaseDir)
/bin
cp
-rf
$(TOP_DIR)
/output/release/bin/
*
$(TOP_DIR)
/
$(releaseDir)
/bin
cp
-rf
$(TOP_DIR)/process_check.sh
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/script/*
$(TOP_DIR)/$(releaseDir)/script
cp
-rf
$(TOP_DIR)/onboot.sh
$(TOP_DIR)/$(releaseDir)/
mv
$(TOP_DIR)/$(releaseDir)/script/onboot.sh
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/killall.sh
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/VERSION
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/VERSION
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/opcodeMapCfg/*
$(TOP_DIR)/$(releaseDir)/map
cp
-rf
$(TOP_DIR)/opcodeMapCfg/*
$(TOP_DIR)/$(releaseDir)/map
cp
-rf
$(TOP_DIR)/config/*
$(TOP_DIR)/$(releaseDir)/config
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_map_table.json $(TOP_DIR)/$(releaseDir)/dev_config_table/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_map_table.json $(TOP_DIR)/$(releaseDir)/dev_config_table/
ifeq
($(CONFIG_MODEL),ubuntu)
ifeq
($(CONFIG_MODEL),ubuntu)
...
@@ -224,7 +226,7 @@ else ifeq ($(CONFIG_MODEL),nx5)
...
@@ -224,7 +226,7 @@ else ifeq ($(CONFIG_MODEL),nx5)
cp
-rf
$(TOP_DIR)/common/ev/libev_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libev.so
cp
-rf
$(TOP_DIR)/common/ev/libev_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libev.so
cp
-rf
$(TOP_DIR)/common/sqlite/libsqlite3_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libsqlite3.so
cp
-rf
$(TOP_DIR)/common/sqlite/libsqlite3_nx5.so
$(TOP_DIR)/$(releaseDir)/lib/libsqlite3.so
cp
-rf
$(TOP_DIR)/nx5_soc_gw/smarthome_z3gw_nx5
$(TOP_DIR)/$(releaseDir)/bin/
cp
-rf
$(TOP_DIR)/nx5_soc_gw/smarthome_z3gw_nx5
$(TOP_DIR)/$(releaseDir)/bin/
cp
-rf
$(TOP_DIR)/nx5_soc_gw/kk_device_def.json
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/nx5_soc_gw/kk_device_def.json
$(TOP_DIR)/$(releaseDir)/
config/
cp
-rf
$(TOP_DIR)/upgrade
$(TOP_DIR)/$(releaseDir)/
cp
-rf
$(TOP_DIR)/upgrade
$(TOP_DIR)/$(releaseDir)/
else
else
cp
-rf
$(TOP_DIR)/common/nanomsg/libnanomsg.so
$(TOP_DIR)/$(releaseDir)/lib
cp
-rf
$(TOP_DIR)/common/nanomsg/libnanomsg.so
$(TOP_DIR)/$(releaseDir)/lib
...
@@ -232,7 +234,7 @@ else
...
@@ -232,7 +234,7 @@ else
cp
-rf
$(TOP_DIR)/common/sqlite/libsqlite3.so
$(TOP_DIR)/$(releaseDir)/lib
cp
-rf
$(TOP_DIR)/common/sqlite/libsqlite3.so
$(TOP_DIR)/$(releaseDir)/lib
endif
endif
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/build/exe/Z3GatewayHost $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/build/exe/Z3GatewayHost $(TOP_DIR)/$(releaseDir)/
fromdos
$(releaseDir)/*.sh
fromdos
$(releaseDir)/
script/
*.sh
echo
$(PWD)
echo
$(PWD)
squashfs
:
package
squashfs
:
package
...
...
tsl/version
View file @
62c805fd
1.1.5
1.1.0
\ No newline at end of file
\ No newline at end of file
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