Commit 2abbf7f2 authored by 尹佳钦's avatar 尹佳钦

20210816

parents e55b7bf4 52797464
1.1.0
\ No newline at end of file
#!/bin/sh
nanomsg_File="/home/kk/lib/libnanomsg.so.5"
ev_File="/home/kk/lib/libev.so.4"
sqlite_File="/home/kk/lib/libsqlite3.so.0"
run_Dir="/usr/kk"
tsl_Dir="${run_Dir}/tsl"
dev_cfg_Dir="${run_Dir}/dev_config_table"
cd /sbin/
insmod /sbin/ssd1306-revision.ko
/sbin/oled >/dev/null 2>&1 &
sleep 1
if [ ! -d "$run_Dir" ]; then
mkdir ${run_Dir}
fi
if [ ! -d "$tsl_Dir" ]; then
cp -rf /home/kk/tsl ${run_Dir}/
fi
if [ ! -d "$dev_cfg_Dir" ]; then
cp -rf /home/kk/dev_config_table ${run_Dir}
sleep 1
fi
export LD_LIBRARY_PATH=/home/kk/lib
cd /home/kk/lib
if [ ! -f "$nanomsg_File" ]; then
ln -sf /home/kk/lib/libnanomsg.so /lib/libnanomsg.so.5
fi
if [ ! -f "$ev_File" ]; then
ln -sf /home/kk/lib/libev.so /lib/libev.so.4
fi
if [ ! -f "$sqlite_File" ]; then
ln -sf /home/kk/lib/libsqlite3.so /lib/libsqlite3.so.0
fi
CCU_ID=`cat /etc/dropbear/accessory/hj/hj_ccuid`
/sbin/logread -f -r 120.55.149.201 514 -p /var/run/logread.cloud_log.pid -u -h $CCU_ID >/dev/null 2>&1 &
/sbin/logread -f -e "ccu_err_info" -F /etc/dropbear/accessory/hj/err.log -p /var/run/logread.err_log.pid -S 512 >/dev/null 2>&1 &
sleep 1
export LD_LIBRARY_PATH=/home/kk/lib
cd ${run_Dir}
/home/kk/kk_midware >/dev/null 2>&1 &
sleep 1
/home/kk/kcloud >/dev/null 2>&1 &
/home/kk/Z3GatewayHost -f x -p /dev/ttyS0 >/dev/null 2>&1 &
/home/kk/process_check.sh >/dev/null 2>&1 &
cd /sbin
/sbin/logd-check.sh >/dev/null 2>&1 &
sleep 1
ntpd -n -q -d -p stdtime.gov.hk &
exit 0
\ No newline at end of file
......@@ -14,12 +14,13 @@
#define CONNECT_TIMEOUT 3
#define IPSTR "172.25.240.194"
#define PORT 8092
#define GET_KEY_CMD "/usr/sbin/fw_printenv key -n"
typedef enum {
RETURN_FAIL = -1,
RETURN_SUCCESS = 0,
} kk_kcloud_error_code_t;
#define KK_DEVICESECRET_PATH "/data/kk/kk_deviceSecret.txt"
#define KK_TOKEN_PATH "/data/kk/kk_token.txt"
#endif
......@@ -287,6 +287,7 @@ int _kk_sendto_cloud(cJSON *root)
}
#endif
char* out=cJSON_Print(pData);
KK_MQTT_SendMsg(topic,(const char*)out);
free(out);
}
......
......@@ -66,19 +66,28 @@ static int mqtt_start(void)
while(1)
{
usleep(100000L);
count++;
if(count>50)
{
count = 0;
//INFO_PRINT("i am send now\n");
//KK_MQTT_SendMsg(TOPIC,"hello my world",2);
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 rc;
return -1;
}
int kk_start_ccu_register(void);
......@@ -90,11 +99,15 @@ int main(int argc, char* argv[])
/*set the callback to get the device date to cloud*/
KK_Ccuid_init();
kk_ipc_init(IPC_APP2MID,(ipc_cb*)KK_Data_FromDev,NULL,NULL);
kk_info_report_start();
//kk_info_report_start();
again:
rc = kk_start_ccu_register();
if(rc == 0){
rc = mqtt_start();
if(rc < 0){
sleep(2);
goto again;
}
}else{
sleep(2);
goto again;
......
This diff is collapsed.
......@@ -14,8 +14,8 @@ const char KK_URI_SYS_PREFIX_SERVICE[] = "biz/newkk/%s/%s/thing/service/+";
const char KK_URI_SYS_PREFIX_TOPO_CHANGE[] = "biz/newkk/%s/%s/thing/topo/change";
const char KK_URI_SYS_PREFIX_EX[] = "biz/newkk/%s/%s";
const char KK_URI_OTA_PREFIX[] = "ota/device/%s/%s/upgrade";
const char KK_URI_OTA_PROCESS[] = "/ota/device/progress/%s/%s";
const char KK_URI_OTA_INFORM[] = "/ota/device/inform/%s/%s";
const char KK_URI_OTA_PROCESS[] = "ota/device/%s/%s/progress";
const char KK_URI_OTA_REPLY[] = "ota/device/%s/%s/upgrade_reply";
static int s_gw_status = DEVICE_OFFLINE;
int kk_set_gw_status(int status)
......@@ -89,10 +89,10 @@ static int _kk_ccu_topic_subscribe(char productCode[PRODUCT_CODE_LEN],char devic
return -1;
}
//memset(url, 0, url_len);
//snprintf(url, url_len, KK_URI_OTA_PREFIX, productCode,deviceCode);
//INFO_PRINT("ota [%s][%d] URL:%s\n",__FUNCTION__,__LINE__,url);
//res = KK_MQTT_SubTopic(url);
memset(url, 0, url_len);
snprintf(url, url_len, KK_URI_OTA_PREFIX, productCode,deviceCode);
INFO_PRINT("ota URL:%s\n",url);
res = KK_MQTT_SubTopic(url);
memset(url, 0, url_len);
snprintf(url, url_len, KK_URI_SYS_PREFIX_SERVICE, productCode,deviceCode);
......@@ -107,6 +107,11 @@ static int _kk_ccu_topic_subscribe(char productCode[PRODUCT_CODE_LEN],char devic
return res;
}
static int s_ccu_topic_sub = 0;
void KK_reset_sub_flag(void)
{
if(s_ccu_topic_sub)
s_ccu_topic_sub = 0;
}
int KK_CCU_TOPIC_Subscribe(void)
{
char productCode[PRODUCT_CODE_LEN] = {0};
......@@ -147,24 +152,41 @@ static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code,
return 0;
}
static int _kk_utils_topic_ota(_IN_ char* str, _OU_ char **topic)
static int _kk_utils_topic_ota_process(_IN_ char* product_code,_IN_ char* device_code, _OU_ char **topic)
{
int service_name_len = 0;
if (str == NULL ||topic == NULL || *topic != NULL) {
if (product_code == NULL || device_code == NULL ||
topic == NULL || *topic != NULL) {
return -1;
}
service_name_len = strlen(str)+1;
service_name_len = strlen(KK_URI_OTA_PROCESS) + strlen(product_code) + strlen(device_code) +1;
*topic = malloc(service_name_len);
if (*topic == NULL) {
return -1;
}
memset(*topic, 0, service_name_len);
memcpy(*topic,str,service_name_len);
snprintf(*topic, service_name_len, KK_URI_OTA_PROCESS, product_code, device_code);
return 0;
}
static int _kk_utils_topic_upgrade_reply(_IN_ char* product_code,_IN_ char* device_code, _OU_ char **topic)
{
int service_name_len = 0;
if (product_code == NULL || device_code == NULL ||
topic == NULL || *topic != NULL) {
return -1;
}
service_name_len = strlen(KK_URI_OTA_REPLY) + strlen(product_code) + strlen(device_code) +1;
*topic = malloc(service_name_len);
if (*topic == NULL) {
return -1;
}
memset(*topic, 0, service_name_len);
snprintf(*topic, service_name_len, KK_URI_OTA_REPLY, product_code, device_code);
return 0;
}
int KK_Subdev_UnSubscribe_By_DeviceCode(const char *deviceCode,const char *productCode )
{
char *topic = NULL;
......@@ -247,8 +269,11 @@ char* KK_Make_Topic(cJSON *info,cJSON *data)
kk_set_gw_status(DEVICE_ONLINE);
}
}
if(strstr(type->valuestring,"/ota/device/inform") ||strstr(type->valuestring,"/ota/device/progress")){
_kk_utils_topic_ota(type->valuestring,&topic);
if(strstr(type->valuestring,"/thing/event/otaProgress/post")){
_kk_utils_topic_ota_process(product_code->valuestring,device_code->valuestring,&topic);
}
else if(strstr(type->valuestring,"/ota/device/upgrade_reply") != NULL){
_kk_utils_topic_upgrade_reply(product_code->valuestring,device_code->valuestring,&topic);
}
else{
_kk_utils_topic(type->valuestring,product_code->valuestring,device_code->valuestring,&topic);
......
......@@ -22,6 +22,8 @@ static void connlost(void *context, char *cause)
{
ERROR_PRINT("PARAM ERROR\n");
s_mqttStop = 1;
s_cloudStatus = DEVICE_OFFLINE;
KK_Send_CloudState(s_cloudStatus);
return;
}
MQTTAsync client = (MQTTAsync)context;
......@@ -85,7 +87,7 @@ void onSend(void* context, MQTTAsync_successData* response)
INFO_PRINT("Message with token value %d delivery confirmed\n", response->token);
}
extern void KK_reset_sub_flag(void);
void onConnectFailure(void* context, MQTTAsync_failureData* response)
{
s_mqttStop = 1;
......@@ -94,7 +96,7 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
ERROR_PRINT("PARAM ERROR\n");
return;
}
KK_reset_sub_flag();
WARNING_PRINT("Connect failed, rc %d\n", response ? response->code : 0);
}
......@@ -135,6 +137,8 @@ static void onConnectBuild(void *context, char *cause)
//{
//ERROR_PRINT("KK_MQTT_SubTopic ERROR rc = %d\n",rc);
//}
s_cloudStatus = DEVICE_ONLINE;
KK_Send_CloudState(s_cloudStatus);
}
static void onDisConnected(void *context, MQTTProperties* properties,enum MQTTReasonCodes reasonCode)
{
......@@ -200,11 +204,11 @@ MQTTAsync KK_MQTT_Connect(void)
char mac[16]={0};
char token[512] = {0};
char usrname[128] = {0};
fp = fopen("/usr/kk/kk_token.txt", "r");
if(fp != NULL){
fread(token,1,sizeof(token),fp);
fclose(fp);
}
fp = fopen(KK_TOKEN_PATH, "r");
if(fp != NULL){
fread(token,1,sizeof(token),fp);
fclose(fp);
}
HAL_Get_mac(mac);
char ccuid[32] = {0};
KK_Get_ccuid(ccuid);
......@@ -264,7 +268,8 @@ int KK_MQTT_SendMsg(char *topicName,const char *payload)
MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
int rc;
cJSON_Minify(payload);
INFO_PRINT("mqtt send payload :%s.\n",payload);
opts.onSuccess = onOptSuccess;
opts.onFailure = onOptFail;
opts.context = (void*)OPT_SEND;
......@@ -274,8 +279,6 @@ int KK_MQTT_SendMsg(char *topicName,const char *payload)
pubmsg.qos = QOS;
pubmsg.retained = 0;
//cJSON_Minify(payload);
INFO_PRINT("mqtt send payload :%s.\n",payload);
if(s_cloudStatus == DEVICE_OFFLINE){
ERROR_PRINT("Failed to start sendMessage, s_cloudStatus == DEVICE_OFFLINE\n");
return -1;
......
......@@ -127,7 +127,7 @@ static int kk_send_ack(cJSON *root,int sockfd)
strcat(tmpBuf,"!");
strcat(tmpBuf,out);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
INFO_PRINT("tmpBuf:%s\n",tmpBuf);
send(sockfd, tmpBuf, strlen(tmpBuf), 0);
free(out);
free(tmpBuf);
......@@ -207,9 +207,9 @@ static cJSON *kk_zb_dev_hw_info_build(const char *deviceCode,cJSON * productCode
_deviceCode_switchto_mac(deviceCode,mac);
if(online==0){
online_status = 1; //在线
}else if(online==1){
online_status = 2; //离线
}else if(online==1){
online_status = 1; //在线
}else{
online_status = 0; //未知
}
......@@ -358,7 +358,7 @@ int kk_data_handle(cJSON *json,int sockfd)
}
static int kk_parse_syncinfo(cJSON *payload)
{
cJSON *paramStr,*dataStr;
cJSON *dataStr;
cJSON *gwdevices,*subdevices;
cJSON * gwitem,*properties;
cJSON *onlineStatus;
......@@ -375,9 +375,7 @@ static int kk_parse_syncinfo(cJSON *payload)
kk_map_dev_deinit();
paramStr = cJSON_GetObjectItem(payload, DATA_STRING);
if(paramStr == NULL) return -1;
dataStr = cJSON_GetObjectItem(paramStr, DATA_STRING);
dataStr = cJSON_GetObjectItem(payload, DATA_STRING);
if(dataStr == NULL) return -1;
gwdevices = cJSON_GetObjectItem(dataStr, DEVICES_STRING);
if(gwdevices == NULL) return -1;
......@@ -406,7 +404,7 @@ static int kk_parse_syncinfo(cJSON *payload)
kk_map_dev_node_add(deviceCode,productCode,gwdevicecode,onlineStatus->valuestring);
kk_map_dev_node_add(deviceCode,productCode,gwdevicecode,(onlineStatus->valueint==1)?"1":"0");
property_syn_deal(deviceCode,properties);
......@@ -470,6 +468,7 @@ void KK_Data_FromMid(void* str,int len)
if(info==NULL || payload==NULL ||
info->type != cJSON_Object ||payload->type!= cJSON_Object){
cJSON_Delete(json);
return;
}
......@@ -480,7 +479,7 @@ void KK_Data_FromMid(void* str,int len)
if(msgtype == NULL || productCode==NULL || deviceCode==NULL||
msgtype->type != cJSON_String || productCode->type!= cJSON_String||deviceCode->type!= cJSON_String ||
msgtype->valuestring==NULL|| productCode->valuestring==NULL || deviceCode->valuestring==NULL){
cJSON_Delete(json);
return;
}
......@@ -497,13 +496,14 @@ void KK_Data_FromMid(void* str,int len)
arming_status_notify(type);
}
}else{
property_post_deal(deviceCode->valuestring,payload);
//property_post_deal(deviceCode->valuestring,payload);
}
}else if(strstr(msgtype->valuestring,"/thing/topo/delete")!= NULL){
device_delete_sync(payload);
}else if(strstr(msgtype->valuestring,"/thing/status/online")!= NULL){
device_add_sync(payload);
}
cJSON_Delete(json);
}
......
......@@ -53,7 +53,7 @@ static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
strcat(tmpBuf,"!");
strcat(tmpBuf,out);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
INFO_PRINT("tmpBuf:%s\n",tmpBuf);
sendto(sockfd, tmpBuf, strlen(tmpBuf), 0, (struct sockaddr*)addr, sizeof(struct sockaddr_in));
cJSON_Delete(json);
free(out);
......
......@@ -142,7 +142,7 @@ int kk_ccu_opcode_handle(cJSON *root)
if(nodeId==NULL||opcode==NULL||arg==NULL ){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return;
return -1;
}
if(requester!=NULL){
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ int kk_send_data_to_sdk(char *buf)
strcat(tmpBuf,"!");
strcat(tmpBuf,buf);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
INFO_PRINT("tmpBuf:%s\n",tmpBuf);
for(i = 0; i < LISTEN_MAX; i++){
if(s_ConnInfo[i].socketfd != -1){
send(s_ConnInfo[i].socketfd, tmpBuf, strlen(tmpBuf), 0);
......@@ -119,7 +119,7 @@ void *TCP_Analyzer(void *pPara)
}
else
{
printf("TCP_Analyzer:%s,%d\n",Buf,(int)Size);
DEBUG_PRINT("TCP_Analyzer:%s,%d\n",Buf,(int)Size);
_kk_handle_data(Buf,s_ConnInfo[index].socketfd);
printf("[%s][%d] TCP_Analyzer end.\n",__FUNCTION__,__LINE__);
}
......
......@@ -119,7 +119,7 @@ int kk_ipc_send_json(cJSON *root)
cJSON_Minify(msg);
kk_ipc_send(IPC_APP2MID, msg, strlen(msg)+1);
free(msg);
cJSON_Delete(root);
return 0;
}
......
......@@ -3,5 +3,7 @@
#define KK_CCU_VERSION "1.1.0"
#define KK_VERSION_FILE_PATH "/app/ccuApps/VERSION"
#endif
......@@ -200,7 +200,7 @@ int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type,char* chlMark, char* i
case IPC_PLAT2MID: {
//创建2个通道 pipe和pub/sub
char addr[30] = {0};
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
loop_ctrl->ba.n = nn_socket(AF_SP, NN_PUSH);
if (loop_ctrl->ba.n < 0) {
ERROR_PRINT("loop_ctrl->ba.n =%d \r\n",loop_ctrl->ba.n);
......@@ -214,9 +214,8 @@ int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type,char* chlMark, char* i
}
sprintf(addr, GW2CCU_PIPE, ip);
printf("---------addr:%s\n",addr);
if (nn_connect(loop_ctrl->ba.n, addr) < 0) {//pipe
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
ERROR_PRINT("nn_connect error ---2\r\n");
return -1;
}
//订阅
......@@ -230,9 +229,8 @@ int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type,char* chlMark, char* i
memset(addr,0, sizeof(addr));
sprintf(addr, GW2CCU_PUBSUB, ip);
printf("---------addr:%s\n",addr);
if (nn_connect(loop_ctrl->ab.n, addr) < 0) {//sub
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
ERROR_PRINT("nn_connect error ---3\r\n");
return -1;
}
......
......@@ -30,6 +30,8 @@
#include "kk_product.h"
#include "ccu_ver.h"
#include "com_api.h"
#include "kk_log.h"
char g_product_type[PRODUCT_TYPE_LEN]={0};
char g_product_code[PRODUCT_CODE_LEN]={0};
......@@ -163,6 +165,15 @@ time_t HAL_GetTime_s(char *outStr)
return t;
}
long long HAL_GetTime_ms()
{
struct timeval begin;
gettimeofday(&begin,NULL);
long long nowTime = (long long)begin.tv_sec * 1000 + (long long)begin.tv_usec / 1000;
return nowTime;
}
char *HAL_GetTimeStr(_IN_ char *buf, _IN_ int len)
{
......@@ -288,16 +299,6 @@ int HAL_GetDevice_Code(_OU_ char *dev_code)
dev_code[strlen(KK_CCU_ID)] = '\0';
return strlen(KK_CCU_ID);
}
int HAL_GetVersion(_OU_ char *version)
{
strncpy(version, KK_CCU_VERSION, strlen(KK_CCU_VERSION));
version[strlen(KK_CCU_VERSION)] = '\0';
return strlen(KK_CCU_VERSION);
}
/*
* This need to be same with app version as in uOTA module (ota_version.h)
......
LIBSO_TARGET := libkk_hal.so
\ No newline at end of file
LIBSO_TARGET := libkk_hal.so
CFLAGS += -I$(TOP_DIR)/common/api
\ No newline at end of file
......@@ -19,6 +19,7 @@ void HAL_SleepMs(_IN_ uint32_t ms);
uint32_t HAL_Get_IP(char ip_str[NETWORK_ADDR_LEN], const char *ifname);
time_t HAL_GetTime(void);
time_t HAL_GetTime_s(char *outStr);
long long HAL_GetTime_ms();
int HAL_Snprintf(_IN_ char *str, const int len, const char *fmt, ...);
int HAL_Vsnprintf(_IN_ char *str, _IN_ const int len, _IN_ const char *format, va_list ap);
void *HAL_MutexCreate(void);
......
......@@ -28,16 +28,24 @@
#define MAC_ADDR_LEN (17+1)
#define SN_ADDR_LEN (32+1)
#define PRODUCT_TPYE "kk"
#define CCU_LAN "eth1"
#define KK_CCU_ID "CCU_77771"
#define KK_CCU_ID "CCU_77770"
#define KK_CCU_PRODUCTID "ccu_n12"
#define KK_GW_PRODUCTID "gateway_2"
#define KK_CCU_RANDOM "0000000000"
#define KK_CCU_NAME "NEW_CCU"
#define KK_DEVICE_MAP_FILE_PATH "/usr/kk/map/device_%s.json"
#define GET_CCUID_CMD "/usr/sbin/fw_printenv uuid -n"
#define KK_DEVICE_MAP_FILE_PATH "/data/kk/map/device_%s.json"
#define GET_CCUID_CMD "fw_printenv uuid -n"
#define GET_KEY_CMD "fw_printenv key -n"
#define KK_DB_FILE "/data/kk/kk_database.db"
#define TSL_SUBDEVICE_PATH_FILE "/data/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/data/kk/tsl/gateway_%s.json"
#define TSL_CCU_PATH_FILE "/data/kk/tsl/ccu_%s.json"
#define TSL_SCENE_PATH_FILE "/data/kk/tsl/ccu_%s_scene.json"
#define OTA_IMG_PATH "/data/OTA/"
#define OTA_IMG_FILE "/data/OTA/app_squashfs.img"
#define OTA_IMG_FILE_MD5 "/data/OTA/app_squashfs.img.md5"
enum {
DEVICE_OFFLINE = 0,
DEVICE_ONLINE,
......
......@@ -6,9 +6,9 @@
#include "cJSON.h"
#include "kk_dm_api.h"
#include "kk_dm_msg.h"
#include <curl/curl.h>
#include "com_api.h"
#include "kk_log.h"
static dm_ota_ctx_t g_dm_ota_ctx;
......@@ -168,20 +168,190 @@ int dm_ota_get_ota_handle(void **handle)
return SUCCESS_RETURN;
}
enum{
OTA_STATE_DOWNLOAD_ING = 1,
OTA_STATE_DOWNLOAD_FAIL,
OTA_STATE_DOWNLOAD_OK,
OTA_STATE_FIRMWARE_TRANSFER,
OTA_STATE_FIRMWARE_OK,
OTA_STATE_UPGRADE_OK,
OTA_STATE_UPGRADE_FAIL,
};
static char *s_url = NULL;
int kk_publishProgress(int process,int state)
{
char productCode[PRODUCT_CODE_LEN] = {0};
char ccuID[PRODUCT_CODE_LEN] = {0};
char msgId[MSG_MAX_LEN] = {0};
HAL_GetProduct_Code(productCode);
HAL_Get_ccuid(ccuID);
iotx_report_id(msgId);
cJSON *info = cJSON_CreateObject();
cJSON_AddStringToObject(info, MSG_TYPE_STR, "/thing/event/otaProgress/post");
cJSON_AddStringToObject(info, MSG_DEVICE_CODE_STR, ccuID);
cJSON_AddStringToObject(info, MSG_PRODUCT_CODE_STR, productCode);
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);
cJSON_AddStringToObject(payload, "identifier", "otaProgress");
cJSON_AddStringToObject(payload, "method", "thing.event.otaProgress.post");
cJSON *params = cJSON_CreateObject();
cJSON_AddStringToObject(params, "productId", productCode);
cJSON_AddNumberToObject(params, "state", state);
cJSON_AddNumberToObject(params, "process", process);
cJSON_AddItemToObject(payload, "params", params);
char *payload11=cJSON_Print(payload);
kk_sendData2app(infff,payload11,0);
free(payload11);
free(infff);
cJSON_Delete(payload);
cJSON_Delete(info);
return 0;
}
size_t receive_data(void *buffer, size_t size, size_t nmemb, FILE *file){
size_t r_size = fwrite(buffer, size, nmemb, file);;
return r_size;
}
int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
#if 1
char processBuf[12] = {0};
//printf("progress_callback clientp:%s,dltotal:%g,dlnow:%g,ultotal:%g,ulnow:%g\n",clientp,dltotal,dlnow,ultotal,ulnow);
if(dlnow > 0){
int process = (int)dlnow*100.0/dltotal;
if(process % 10 == 0){
//sprintf(processBuf,"%d",process);
INFO_PRINT("progress_callback ,process:%d\n",process);
kk_publishProgress(process,OTA_STATE_DOWNLOAD_ING);
//lua_event_notify((char*)"ota_process",(char*)"process", processBuf);
}
}
#endif
return 0;
}
void dm_ota_start(char *url)
{
int res = 0;
char *progress_data = "* ";
CURL* curl = curl_easy_init();
if (NULL == curl){
return ;
}
FILE *file = fopen(OTA_IMG_FILE,"w");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, receive_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_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION , progress_callback);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, progress_data);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 3000);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180);
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){
kk_publishProgress(0,OTA_STATE_DOWNLOAD_FAIL);
INFO_PRINT("curl_easy_perform error,res:%d\n",res);
}
curl_easy_cleanup(curl);
fclose(file);
}
void dm_ota_start_MD5(char *url)
{
int res = 0;
char *md5_url = malloc(strlen(url)+10);
if(md5_url == NULL){
return;
}
memset(md5_url,0x0,strlen(url)+10);
sprintf(md5_url,"%s.md5",url);
CURL* curl = curl_easy_init();
if (NULL == curl){
free(md5_url);
return ;
}
printf("--------->url md5:%s\n",md5_url);
FILE *file = fopen(OTA_IMG_FILE_MD5,"w");
curl_easy_setopt(curl, CURLOPT_URL, md5_url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, receive_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_NOPROGRESS, 0);
//curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION , progress_callback);
//curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, progress_data);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 3000);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180);
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){
INFO_PRINT("curl_easy_perform error,res:%d\n",res);
kk_publishProgress(0,OTA_STATE_DOWNLOAD_FAIL);
}
curl_easy_cleanup(curl);
fclose(file);
free(md5_url);
}
void dm_ota_handle(void *data){
printf("dm_ota_handle ================== [%s]\n",(char*)data);
cJSON *json,*info_root,*info;
cJSON *typeJson;
cJSON *json,*url,*info;
cJSON *params;
cJSON *payload;
cJSON *product_type,*device_code;
json=cJSON_Parse(data);
if (json == NULL) {
printf("Error before: [%s]\n","cJSON_Parse");
return;
}
printf("------------------------------5\n");
payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR);
if(payload != NULL){
params = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
if(params == NULL){
return;
}
printf("------------------------------2\n");
url = cJSON_GetObjectItem(params, "url");
if(url == NULL){
return;
}
INFO_PRINT("OTA URL :%s\n",url->valuestring);
if(s_url != NULL){
free(s_url);
s_url = NULL;
}
s_url = malloc(strlen(url->valuestring)+10);
if(s_url == NULL){
return;
}
memset(s_url,0x0,strlen(url->valuestring)+10);
strcpy(s_url,url->valuestring);
dm_ota_start(s_url);
dm_ota_start_MD5(s_url);
system("sync");
kk_publishProgress(100,OTA_STATE_DOWNLOAD_OK);
char CMD[128] = {0};
sprintf(CMD,"/app/ccuApps/upgrade %s %s",OTA_IMG_FILE,OTA_IMG_FILE_MD5);
INFO_PRINT("------------------------->CMD:%s\n",CMD);
system(CMD);
sleep(1);
kk_publishProgress(100,OTA_STATE_UPGRADE_OK);
sleep(2);
system("reboot -f");
}
#if 0
info_root = cJSON_GetObjectItem(json, MSG_INFO_STR);
info = cJSON_Parse(info_root->valuestring);
typeJson = cJSON_GetObjectItem(info, MSG_TYPE_STR);
......@@ -202,8 +372,9 @@ void dm_ota_handle(void *data){
}else {
printf("invaild ota type: [%d]\n", atoi(typeJson->valuestring));
}
#endif
cJSON_Delete(json);
cJSON_Delete(info);
//cJSON_Delete(info);
}
int dm_ota_check(void* payload, int len, iotx_ota_topic_types_t type){
......@@ -230,6 +401,7 @@ int dm_ota_yield(int timeout_ms)
if (dm_queue_msg_next3(&data) == SUCCESS_RETURN) {
//dm_queue_msg_t *msg = (dm_queue_msg_t *)data;
printf("dm_ota_yield call \n");
printf("------------------------------4\n");
dm_ota_handle(data);
free(data);
......
......@@ -355,10 +355,11 @@ void kk_dm_ota_report_version(_IN_ int devid, char *version){
}
void kk_dm_ota_send(void *data, int len){
dm_queue_msg_insert3(data);
//dm_queue_msg_insert3(data);
if (data != NULL){
void* buf = malloc(len);
memcpy(buf, data, len);
printf("------------------------------1\n");
int res = dm_queue_msg_insert3((void *)buf);
if (res != SUCCESS_RETURN) {
free(buf);
......
......@@ -469,7 +469,15 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp)
if(search_node->hb_timeout == 0){
search_node->hb_timeout = DEFAULT_HEARTBEAT_TIMEOUT;
}
if((timestamp - search_node->timestamp) >= search_node->hb_timeout/*search_node->hb_timeout*/){
if(search_node->devid == KK_DM_DEVICE_CCU_DEVICEID){
continue;
}
//printf("[%s][%d]search_node->productCode:%s\n",__FUNCTION__,__LINE__,search_node->productCode);
//printf("[%s][%d]search_node->hb_timeout:%d\n",__FUNCTION__,__LINE__,search_node->hb_timeout);
//printf("[%s][%d]search_node->isOffline:%d\n",__FUNCTION__,__LINE__,search_node->isOffline);
//printf("[%s][%d]search_node->timestamp:%d\n",__FUNCTION__,__LINE__,search_node->timestamp);
//printf("[%s][%d]timestamp:%d\n",__FUNCTION__,__LINE__,timestamp);
if((timestamp - search_node->timestamp) >= search_node->hb_timeout){
if(search_node->isOffline != KK_DEV_OFFLINE){
dm_mgr_set_dev_onoffline(search_node,1);
}
......@@ -670,9 +678,15 @@ static int _dm_mgr_upstream_service_assemble(_IN_ char* msgid, _IN_ int devid,
static unsigned int g_report_id = 1;
int iotx_report_id(void)
int iotx_report_id(char *msgId)
{
return g_report_id++;
if(msgId == NULL){
return INVALID_PARAMETER;
}
//char timerStr[16] = {0};
//HAL_GetTime_ms();
sprintf(msgId,"6c0645c4-f6d6-46b2-b11e-%lld",HAL_GetTime_ms());
return SUCCESS_RETURN;
}
int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_ int payload_len,_IN_ int isAsync)
......@@ -686,7 +700,8 @@ int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_
}
memset(&request, 0, sizeof(dm_msg_request_t));
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
res = _dm_mgr_upstream_request_assemble(msgId, devid, "property",
payload, payload_len, (char*)DM_URI_THING_EVENT_PROPERTY_POST_METHOD, &request);
if (res != SUCCESS_RETURN) {
......@@ -715,7 +730,8 @@ int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_
return INVALID_PARAMETER;
}
memset(&request, 0, sizeof(dm_msg_request_t));
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
res = _dm_mgr_upstream_request_assemble(msgId, devid,identifier,
payload, payload_len, method, &request);
if (res != SUCCESS_RETURN) {
......@@ -773,7 +789,9 @@ int dm_mgr_upstream_thing_service_post(_IN_ int devid, _IN_ char *identifier, _I
return INVALID_PARAMETER;
}
memset(&request, 0, sizeof(dm_msg_request_t));
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
res = _dm_mgr_upstream_service_assemble(msgId, devid,identifier,
payload, payload_len, method, &request);
if (res != SUCCESS_RETURN) {
......@@ -901,7 +919,9 @@ int dm_mgr_upstream_thing_sub_register(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
/* Get Dev ID */
......@@ -958,7 +978,9 @@ int dm_mgr_upstream_thing_sub_unregister(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1016,7 +1038,9 @@ int dm_mgr_upstream_thing_topo_add(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1073,7 +1097,9 @@ int dm_mgr_upstream_thing_topo_delete(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1117,7 +1143,9 @@ int dm_mgr_upstream_thing_topo_get(void)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1171,7 +1199,8 @@ int dm_mgr_upstream_thing_list_found(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1221,7 +1250,8 @@ int dm_mgr_ccu_status_cloud(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1259,6 +1289,7 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
#if 0
if(strlen(node->fatherDeviceCode) > 0){
res = dm_mgr_get_device_by_devicecode(node->fatherDeviceCode,&gw_node);
if (res != SUCCESS_RETURN) {
......@@ -1268,7 +1299,9 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
}else{
}else
#endif
{
memcpy(request.productCode,node->productCode,strlen(node->productCode));
memcpy(request.deviceCode,node->deviceCode,strlen(node->deviceCode));
}
......@@ -1285,7 +1318,8 @@ int dm_mgr_upstream_status_online(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1322,16 +1356,17 @@ int dm_mgr_upstream_status_offline(_IN_ int devid)
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
if(strlen(node->fatherDeviceCode) > 0){
res = dm_mgr_get_device_by_devicecode(node->fatherDeviceCode,&gw_node);
if (res != SUCCESS_RETURN) {
ERROR_PRINT("ERROR [%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
}
memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
//if(strlen(node->fatherDeviceCode) > 0){
//res = dm_mgr_get_device_by_devicecode(node->fatherDeviceCode,&gw_node);
//if (res != SUCCESS_RETURN) {
//ERROR_PRINT("ERROR [%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
//return FAIL_RETURN;
//}
//memcpy(request.productCode,gw_node->productCode,strlen(gw_node->productCode));
//memcpy(request.deviceCode,gw_node->deviceCode,strlen(gw_node->deviceCode));
}else{
//}else
{
memcpy(request.productCode,node->productCode,strlen(node->productCode));
memcpy(request.deviceCode,node->deviceCode,strlen(node->deviceCode));
}
......@@ -1345,7 +1380,8 @@ int dm_mgr_upstream_status_offline(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1400,7 +1436,8 @@ int dm_mgr_upstream_combine_login(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1454,7 +1491,8 @@ int dm_mgr_upstream_combine_logout(_IN_ int devid)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1507,7 +1545,8 @@ int dm_mgr_ota_report_version(_IN_ int devid, char *version)
}
/* Get Msg ID */
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
memcpy(request.msgid,msgId,strlen(msgId));
......@@ -1551,7 +1590,7 @@ int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN])
return FAIL_RETURN;
}
INFO_PRINT("dm_mgr_subdev_delete deviceCode:%s\n",deviceCode);
kk_scene_deleteall_panel_scene_info(deviceCode);//如果是情景面板,删除对应信息
/*房间信息中删除对应的设备*/
kk_room_dev_remove(deviceCode,NULL);
......
......@@ -95,7 +95,7 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp);
int dm_mgr_get_devId_by_devicecode(_IN_ char deviceCode[DEVICE_CODE_MAXLEN],_OU_ int *devid);
int dm_mgr_init(void);
int dm_mgr_deinit(void);
int iotx_report_id(void);
int iotx_report_id(char *msgId);
int dm_mgr_upstream_thing_property_post(_IN_ int devid, _IN_ char *payload, _IN_ int payload_len,_IN_ int isAsync);
int dm_mgr_upstream_thing_event_post(_IN_ int devid, _IN_ char *identifier, _IN_ int identifier_len, _IN_ char *method,
_IN_ char *payload, _IN_ int payload_len);
......
......@@ -296,13 +296,14 @@ int dm_msg_status_cloud(_IN_ char productCode[PRODUCT_CODE_MAXLEN],
}
const char DM_MSG_COMBINE_STATUS_ONLINE_METHOD[] DM_READ_ONLY = "thing.status.online";
const char DM_MSG_COMBINE_STATUS_ONLINE[] DM_READ_ONLY =
"{\"deviceCode\":\"%s\"}";
"{\"deviceCode\":\"%s\",\"ccuCode\":\"%s\"}";
int dm_msg_status_online(_IN_ char productCode[PRODUCT_CODE_MAXLEN],
_IN_ char deviceCode[DEVICE_CODE_MAXLEN], _OU_ dm_msg_request_t *request)
{
char *params = NULL;
int params_len = 0;
char timestamp[DM_UTILS_UINT64_STRLEN] = {0};
char ccuid[32] = {0};
if (request == NULL ||
deviceCode == NULL || productCode == NULL ||
......@@ -316,17 +317,18 @@ int dm_msg_status_online(_IN_ char productCode[PRODUCT_CODE_MAXLEN],
HAL_Snprintf(timestamp, DM_UTILS_UINT64_STRLEN, "%d", HAL_GetTime());
/* dm_log_debug("Time Stamp: %s", timestamp); */
HAL_Get_ccuid(ccuid);
/* Params */
request->method = (char *)DM_MSG_COMBINE_STATUS_ONLINE_METHOD;
params_len = strlen(DM_MSG_COMBINE_STATUS_ONLINE) + strlen(deviceCode) + 1;
params_len = strlen(DM_MSG_COMBINE_STATUS_ONLINE) + strlen(deviceCode)+strlen(ccuid) + 1;
params = malloc(params_len);
if (params == NULL) {
return DM_MEMORY_NOT_ENOUGH;
}
memset(params, 0, params_len);
HAL_Snprintf(params, params_len, DM_MSG_COMBINE_STATUS_ONLINE,deviceCode);
HAL_Snprintf(params, params_len, DM_MSG_COMBINE_STATUS_ONLINE,deviceCode,ccuid);
request->params = params;
request->params_len = strlen(request->params);
......@@ -336,13 +338,14 @@ int dm_msg_status_online(_IN_ char productCode[PRODUCT_CODE_MAXLEN],
const char DM_MSG_COMBINE_STATUS_OFFLINE_METHOD[] DM_READ_ONLY = "thing.status.offline";
const char DM_MSG_COMBINE_STATUS_OFFLINE[] DM_READ_ONLY =
"{\"deviceCode\":\"%s\"}";
"{\"deviceCode\":\"%s\",\"ccuCode\":\"%s\"}";
int dm_msg_status_offline(_IN_ char productCode[PRODUCT_CODE_MAXLEN],
_IN_ char deviceCode[DEVICE_CODE_MAXLEN], _OU_ dm_msg_request_t *request)
{
char *params = NULL;
int params_len = 0;
char timestamp[DM_UTILS_UINT64_STRLEN] = {0};
char ccuid[32] = {0};
if (request == NULL ||
deviceCode == NULL || productCode == NULL ||
......@@ -356,17 +359,18 @@ int dm_msg_status_offline(_IN_ char productCode[PRODUCT_CODE_MAXLEN],
HAL_Snprintf(timestamp, DM_UTILS_UINT64_STRLEN, "%d", HAL_GetTime());
/* dm_log_debug("Time Stamp: %s", timestamp); */
HAL_Get_ccuid(ccuid);
/* Params */
request->method = (char *)DM_MSG_COMBINE_STATUS_OFFLINE_METHOD;
params_len = strlen(DM_MSG_COMBINE_STATUS_OFFLINE) + strlen(deviceCode) + 1;
params_len = strlen(DM_MSG_COMBINE_STATUS_OFFLINE) + strlen(deviceCode)+ strlen(ccuid) + 1;
params = malloc(params_len);
if (params == NULL) {
return DM_MEMORY_NOT_ENOUGH;
}
memset(params, 0, params_len);
HAL_Snprintf(params, params_len, DM_MSG_COMBINE_STATUS_OFFLINE,deviceCode);
HAL_Snprintf(params, params_len, DM_MSG_COMBINE_STATUS_OFFLINE,deviceCode,ccuid);
request->params = params;
request->params_len = strlen(request->params);
......@@ -903,7 +907,6 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
}
if(msgId != NULL){
dm_mgr_upstream_thing_event_post_ex(node->devid, (char*)identifier, strlen(identifier), method, payload, strlen(payload),msgId);
}else
{
dm_mgr_upstream_thing_event_post(node->devid, identifier, strlen(identifier), method, payload, strlen(payload));
......@@ -1091,7 +1094,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
//memset(propertiesbuf[0],0x0,sizeof(propertiesbuf[0]));
//memcpy(propertiesbuf[0],property->identifier,strlen(property->identifier));
//printf("propertiesbuf[0]:%s,num:%d\n",propertiesbuf[0],num);
epNumInt = 1;
//epNumInt = 1;
}
propertyItem = cJSON_GetObjectItem(params, property->identifier);
if(propertyItem != NULL){
......@@ -1275,7 +1278,8 @@ int kk_msg_execute_property_set(const char *productCode,const char *deviceCode,c
return MEMORY_NOT_ENOUGH;
}
memset(payload, 0, payload_len);
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
snprintf(payload, payload_len, DM_MSG_REQUEST, msgId,
DM_MSG_VERSION, params,HAL_GetTime(), method);
......@@ -1347,7 +1351,8 @@ int kk_msg_execute_property_get(dm_mgr_dev_node_t *node)
return MEMORY_NOT_ENOUGH;
}
memset(payload, 0, payload_len);
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
snprintf(payload, payload_len, DM_MSG_REQUEST, msgId,
DM_MSG_VERSION, paramS,HAL_GetTime(), method);
cJSON *root=cJSON_CreateObject();
......@@ -1427,7 +1432,8 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
return MEMORY_NOT_ENOUGH;
}
memset(payload, 0, payload_len);
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
snprintf(payload, payload_len, DM_MSG_REQUEST, msgId,
DM_MSG_VERSION, params,HAL_GetTime(), method);
......@@ -1477,7 +1483,8 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
return MEMORY_NOT_ENOUGH;
}
memset(payload, 0, payload_len);
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
snprintf(payload, payload_len, DM_MSG_REQUEST, msgId,
DM_MSG_VERSION, params,HAL_GetTime(), method);
......@@ -1526,7 +1533,9 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
return MEMORY_NOT_ENOUGH;
}
memset(payload, 0, payload_len);
sprintf(msgId,"%d",iotx_report_id());
iotx_report_id(msgId);
//sprintf(msgId,"%d",iotx_report_id());
//sprintf(msgId,"%d",iotx_report_id());
snprintf(payload, payload_len, DM_MSG_REQUEST, msgId,
DM_MSG_VERSION, params,HAL_GetTime(), method);
......
......@@ -48,7 +48,7 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_ONLINE_TOPIC_REPLY "/thing/status/online_reply"
#define KK_THING_SERVICE_PROPERTY_SET "/thing/service/property/set"
#define KK_THING_SERVICE_PROPERTY_GET "/thing/service/property/get"
#define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade"
#define KK_THING_OTA_DEVICE_UPGRADE "/thing/service/upgrade"
#define KK_THING_CLOUDSTATE_MSG "/thing/ccu/cloudstate_reply"
#define KK_THING_TOPO_ADD_MSG "/thing/topo/add"
#define KK_THING_TOPO_BATCH_ADD_MSG "/thing/topo/batch_add"
......@@ -91,6 +91,10 @@ const char DM_MSG_INFO[] DM_READ_ONLY;
#define KK_THING_EVENT_MESSAGE "/thing/event/"
#define KK_THING_SERVICE_GETGUARDSENSORS "/thing/service/getGuardSensors"
#define KK_THING_EVENT_POST "/post"
#define KK_THING_SERVICE_BINDSCENE "/thing/service/bindScene"
#define KK_THING_SERVICE_UNBINDSBUTTTON "/thing/service/unbindButton"
#define KK_THING_SERVICE_ACTIVEBUTTON "/thing/service/activeButton"
#define KK_THING_SERVICE_GETCCUVERSION "/thing/service/getCCUVersion"
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],
......
......@@ -356,7 +356,7 @@ int dm_queue_msg_insert3(void *data)
INIT_LIST_HEAD(&node->linked_list);
ctx->msg_list3.size++;
list_add_tail(&node->linked_list, &ctx->msg_list3.message_list);
printf("------------------------------2\n");
_dm_queue_unlock3();
return SUCCESS_RETURN;
}
......@@ -383,7 +383,7 @@ int dm_queue_msg_next3(void **data)
*data = node->data;
free(node);
printf("------------------------------3\n");
_dm_queue_unlock3();
return SUCCESS_RETURN;
}
......
This diff is collapsed.
......@@ -107,7 +107,7 @@ static int kk_subDev_db_Init(void)
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
static int _kk_load_subDevice(void)
int kk_load_subDevice(void)
{
const char *searchCmd = "select * from SubDeviceInfo;";
sqlite3_stmt *stmt;
......@@ -177,7 +177,7 @@ int kk_subDb_init(void)
ERROR_PRINT("[%s][%d]kk_wlist_db_Init FAIL!!!\n",__FUNCTION__,__LINE__);
}
_kk_load_subDevice();
//_kk_load_subDevice();
return SUCCESS_RETURN;
}
/************************************************************
......@@ -548,7 +548,27 @@ int kk_subDev_check_scene_support(const char *deviceCode)
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_subDev_set_action_by_productType(const char *productType,const char *sceneId,const char *propertyName,const char *propertyValue,const char *type)
typedef struct{
char *type;
char *maptype;
}productype_map_s;
static productype_map_s producTypeMap[] = {
{"CURTAIN","curtain"},
{"WINDOW","actuator"},
{"LIGHT","switch"},
{"LIGHT_STRIP","colorDimmableLight"},
{"LIGHT_DIMMER","lightPanel"},
{"SOCKET","outlet"},
{"AC_IndoorUnit","air"},
{"FLOOR_HEATING","floorHeating"},
{"FRESH_AIR","airConditioning"},
{"AIR_SWITCH","airSwitch"},
};
int kk_get_product_type_table_size(void)
{
return sizeof(producTypeMap)/sizeof(productype_map_s);
}
int kk_subDev_set_action_by_productType(const char *productType,const char *sceneId,const char *propertyName,const char *propertyValue,const char *type,int delay)
{
int res = 0;
sqlite3_stmt *stmt;
......@@ -562,25 +582,29 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
kk_tsl_data_t *property = NULL;
int k = 0,count = 0;
char typeArray[10][32] = {0};
int size = 0;
char *pStart = NULL;
if(productType == NULL){
ERROR_PRINT("ERROR [%s][%d]\n",__FUNCTION__,__LINE__);
return INVALID_PARAMETER;
}
INFO_PRINT("kk_subDev_set_action_by_productType called!!!\n");
if(!strcmp(productType,"CURTAIN")){
memcpy(typeArray[0],"curtain",strlen("curtain"));
count = 1;
}
else if(!strcmp(productType,"LIGHT")){
memcpy(typeArray[0],"switch",strlen("switch"));
memcpy(typeArray[1],"light",strlen("light"));
count = 2;
}
else{
INFO_PRINT("kk_subDev_set_action_by_productType wrong type!!!\n");
size = kk_get_product_type_table_size();
//printf("---------------------------->size:%d\n",size);
for(k = 0; k < size; k++){
//printf("---------------------------->producTypeMap[k].type:%s\n",producTypeMap[k].type);
if(!strcmp(productType,producTypeMap[k].type)){
memcpy(typeArray[count],producTypeMap[k].maptype,strlen(producTypeMap[k].maptype));
//printf("---------------------------->producTypeMap[k].maptype:%s\n",producTypeMap[k].maptype);
count++;
if(count >= 10){
break;
}
}
}
for(k = 0; k < count; k++){
//printf("---------------------------->typeArray[k]:%s\n",typeArray[k]);
sqlCmd = sqlite3_mprintf(searchCmd,typeArray[k]); //curtain type
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
//INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
......@@ -596,33 +620,42 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
else{
gw_support_scene = 0;
}
if(!strcmp(typeArray[k],"switch")){
for(idx = 0; idx < node->dev_shadow->property_number; idx++){
property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx);
if(property == NULL){
continue;
}
if(strstr(property->identifier,"PowerSwitch") != NULL){
if(gw_support_scene){
kk_scene_action_detail_t info = {0};
memcpy(info.deviceCode,node->deviceCode,strlen(node->deviceCode));
memcpy(info.propertyName,property->identifier,strlen(property->identifier));
memcpy(info.propertyValue,propertyValue,strlen(propertyValue));
//if(!strcmp(typeArray[k],"switch")){
for(idx = 0; idx < node->dev_shadow->property_number; idx++){
property = (kk_tsl_data_t *)(node->dev_shadow->properties + idx);
if(property == NULL){
continue;
}
if(strstr(property->identifier,propertyName) != NULL){
if(gw_support_scene){
kk_scene_action_detail_t info = {0};
memcpy(info.deviceCode,node->deviceCode,strlen(node->deviceCode));
memcpy(info.propertyName,property->identifier,strlen(property->identifier));
memcpy(info.propertyValue,propertyValue,strlen(propertyValue));
//printf("------------------->property->identifier:%s\n",property->identifier);
pStart = strstr(property->identifier,"_");
if(pStart != NULL){
//printf("------------------->num:%s\n",pStart+1);
info.epNum = atoi(pStart+1);
}else{
info.epNum = 1;
info.delay = 0;
kk_scene_action_add(node->fatherDeviceCode,sceneId,info);
}
res = kk_scene_insert_scene_action(type,node->deviceCode,1,
property->identifier,propertyValue,0,sceneId,node->fatherDeviceCode);
if(res != SUCCESS_RETURN){
INFO_PRINT("kk_subDev_set_action_by_productType fail!!!\n");
//return res;
continue;
}
info.delay = delay;
kk_scene_action_add(node->fatherDeviceCode,sceneId,info);
res = kk_scene_insert_scene_action(type,node->deviceCode,info.epNum,
property->identifier,propertyValue,info.delay,sceneId,node->fatherDeviceCode);
if(res != SUCCESS_RETURN){
INFO_PRINT("kk_subDev_set_action_by_productType fail!!!\n");
//return res;
continue;
}
}
}
}
}
//}
#if 0
else{
if(gw_support_scene){
kk_scene_action_detail_t info = {0};
......@@ -641,6 +674,7 @@ int kk_subDev_set_action_by_productType(const char *productType,const char *scen
continue;
}
}
#endif
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
......
......@@ -20,9 +20,10 @@ int kk_subDev_send_property_get_from_db(void);
int kk_subDev_send_property_get(const char *fatherDeviceCode);
int kk_subDev_check_scene_support(const char *deviceCode);
int kk_subDev_set_action_by_productType(const char *productType,const char *sceneId,const char *propertyName,const char *propertyValue,const char *type);
int kk_subDev_set_action_by_productType(const char *productType,const char *sceneId,const char *propertyName,const char *propertyValue,const char *type,int delay);
int kk_subDev_update_offline(int isOffline,const char *deviceCode);
int kk_subDev_getSensors_reply(SensorType_t*list);
int kk_load_subDevice(void);
enum{
DB_SUB_IDX = 0,
DB_SUB_ONLINE,
......
This diff is collapsed.
......@@ -11,7 +11,7 @@ CFLAGS += -I$(TOP_DIR)/common/sqlite
CFLAGS += -I$(TOP_DIR)/src/tsl/tsl_handle
LDFLAGS += -lapi_com -liot_cjson -lkk_tsl
LDFLAGS += -lm -lkk_hal
LDFLAGS += -lsqlite -ldl
LDFLAGS += -lsqlite -ldl -lcurl
ifeq ($(CONFIG_MODEL),x86)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_ubuntu -lanl
......
......@@ -38,6 +38,7 @@
#include "kk_history_db.h"
#include "kk_scene_handle.h"
#include "dm_ota.h"
#include "ccu_ver.h"
int g_timezone = 8;
char * g_filerToPlatTable[] =
{
......@@ -60,8 +61,36 @@ char * g_filerToPlatTable[] =
(char *){KK_THING_SERVICE_DELETESCENC},
(char *){KK_THING_SERVICE_NEGATIVE},
(char *){KK_THING_SERVICE_SYNCINFO},
(char *){KK_THING_SERVICE_BINDSCENE},
(char *){KK_THING_SERVICE_UNBINDSBUTTTON},
(char *){KK_THING_SERVICE_ACTIVEBUTTON},
};
static char s_ccuid[DEVICE_CODE_LEN] = {0};
static char s_Version[VERSION_MAXLEN] = {0};
static void HAL_Ccuid_version(void)
{
FILE *fp;
if(!(fp = fopen(KK_VERSION_FILE_PATH,"r")))
{
ERROR_PRINT("can't open the file tslPath:%s\n",KK_VERSION_FILE_PATH);
return ;
}
fread(s_Version, 1, VERSION_MAXLEN, fp);
if(strlen(s_Version) == 0){
strncpy(s_Version, KK_CCU_VERSION, strlen(KK_CCU_VERSION));
}
INFO_PRINT("HAL_Ccuid_version version:%s!!!\n",s_Version);
fclose(fp);
return;
}
int HAL_GetVersion(_OU_ char *version)
{
strncpy(version, s_Version, strlen(s_Version));
version[strlen(s_Version)] = '\0';
return strlen(s_Version);
}
int HAL_Get_ccuid(_OU_ char *device_code)
{
strncpy(device_code, s_ccuid, strlen(s_ccuid));
......@@ -237,6 +266,7 @@ static int kk_property_set_data_check(cJSON * payload,const char *deviceCode){
continue;
}
//printf("----------------->property->identifier:%s\n",property->identifier);
memset(propertiesTmp,0x0,sizeof(propertiesTmp));
memcpy(propertiesTmp,property->identifier,strlen(property->identifier));
split(propertiesTmp,"_",propertiesbuf,&num);
if(num == 2){
......@@ -614,7 +644,9 @@ void kk_platMsg_handle(void* data, char* chalMark){
if (chalMark != NULL){
dm_mgr_update_timestamp_by_devicecode(chalMark,HAL_Uptimes());
}
dm_mgr_update_timestamp_by_devicecode(info_dcode->valuestring,HAL_Uptimes());
if(strcmp(msgType->valuestring,"/thing/service/property/get_reply") != 0){
dm_mgr_update_timestamp_by_devicecode(info_dcode->valuestring,HAL_Uptimes());
}
if (strcmp(msgType->valuestring, KK_THING_TOPO_ADD_MSG)==0){
jsonPay = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
......@@ -717,6 +749,16 @@ void kk_platMsg_handle(void* data, char* chalMark){
if(strcmp(node->productType ,"sensor") == 0){
sensorDev = 1;
}
if(strcmp(msgType->valuestring, "/thing/event/SceneRecall/post") == 0){
char btnId[16] = {0};
cJSON *buttonId = cJSON_GetObjectItem(jsonPay, "SceneNum");
if(buttonId == NULL || buttonId->type != cJSON_Number){
ERROR_PRINT("DATA ERROR!!!\n");
goto error;
}
sprintf(btnId,"%d",buttonId->valueint);
kk_scene_execute_quickpanel(btnId,info_dcode->valuestring);
}
INFO_PRINT("kk_platMsg_handle event post enters \n");
for(idx = 0; idx < node->dev_shadow->event_number; idx++){
eventItem = node->dev_shadow->events + idx;
......@@ -1135,7 +1177,7 @@ void *ccu_property_monitor(void *args)
return NULL;
}
sqlite3 *g_kk_pDb;
#define KK_DB_FILE "/usr/kk/kk_database.db"
/************************************************************
*功能描述:主机数据库句柄创建
......@@ -1171,6 +1213,7 @@ int main(const int argc, const char **argv)
open("midware",LOG_PID,LOG_USER);
memset(mid_ctx, 0, sizeof(mid_ctx_t));
HAL_Ccuid_version();
HAL_Ccuid_init();
kk_sqlite_init();
kk_tsl_api_init();
......
......@@ -162,6 +162,21 @@ int kk_scene_db_init(void)
_kk_scene_unlock();
return FAIL_RETURN;
}
//情景面板场景关联
const char *pPanelScene = "CREATE TABLE IF NOT EXISTS QuickPanelScene( \
buttonId varchar(255), \
bindType INTEGER, \
deviceCode varchar(255), \
sceneId varchar(255) UNIQUE)";
if (sqlite3_exec(ctx->pDb, pPanelScene, NULL, NULL, &pcErr) != SQLITE_OK)
{
ERROR_PRINT("Error creating table (%s)\n", pcErr);
sqlite3_free(pcErr);
//eUtils_LockUnlock(&sLock);
_kk_scene_unlock();
return FAIL_RETURN;
}
_kk_scene_unlock();
return SUCCESS_RETURN;
......@@ -234,6 +249,121 @@ int kk_scene_insert_scene_info(const char* roomId,const char* sceneName,int scen
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 添加情景面板信息到数据库
*输入参数: name:场景名称
enable: 1,使能;0,不使能
sceneType:场景类型
sceneId:场景Id
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_scene_insert_panel_scene_info(int bindType,char *buttonId,char *deviceCode,const char* sceneId)
{
int res = 0;
kk_scene_ctx_t *ctx = _kk_scene_get_ctx();
char *sqlCmd = NULL;
char *zErrMsg = 0;
const char *insertCmd = "insert into QuickPanelScene (buttonId,bindType,deviceCode,sceneId) \
values ('%s','%d','%s','%s');";
_kk_scene_lock();
sqlCmd = sqlite3_mprintf(insertCmd,buttonId,bindType,deviceCode,sceneId);
res = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( res != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
sqlite3_free(sqlCmd);
_kk_scene_unlock();
return FAIL_RETURN;
}
sqlite3_free(sqlCmd);
_kk_scene_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 取消关联
*输入参数: name:场景名称
enable: 1,使能;0,不使能
sceneType:场景类型
sceneId:场景Id
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_scene_delete_panel_scene_info(char *buttonId,char *deviceCode)
{
int res = 0;
kk_scene_ctx_t *ctx = _kk_scene_get_ctx();
char *sqlCmd = NULL;
sqlite3_stmt *stmt;
char *zErrMsg = 0;
char *pSceneId = NULL;
int bindType = 0;
const char *selectCmd = "select * from QuickPanelScene WHERE deviceCode = '%s' and buttonId = '%s';";
sqlCmd = sqlite3_mprintf(selectCmd,deviceCode,buttonId);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
pSceneId = (char*)sqlite3_column_text(stmt, DB_QUICKPANEL_SCENEID);
bindType = sqlite3_column_int(stmt, DB_QUICKPANEL_BINDTYPE);
if(bindType == 4){
kk_scene_delete_scene_action(pSceneId,0);
}else if(bindType == 2 || bindType == 3){
kk_scene_delete_scene_action(pSceneId,1);
}
kk_scene_delete_quickpanel_info(buttonId,deviceCode);
break;
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 取消所有关联
*输入参数: name:场景名称
enable: 1,使能;0,不使能
sceneType:场景类型
sceneId:场景Id
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_scene_deleteall_panel_scene_info(char *deviceCode)
{
int res = 0;
kk_scene_ctx_t *ctx = _kk_scene_get_ctx();
char *sqlCmd = NULL;
sqlite3_stmt *stmt;
char *zErrMsg = 0;
char *pSceneId = NULL;
char *buttonId = NULL;
int bindType = 0;
const char *selectCmd = "select * from QuickPanelScene WHERE deviceCode = '%s';";
sqlCmd = sqlite3_mprintf(selectCmd,deviceCode);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
pSceneId = (char*)sqlite3_column_text(stmt, DB_QUICKPANEL_SCENEID);
bindType = sqlite3_column_int(stmt, DB_QUICKPANEL_BINDTYPE);
buttonId = (char*)sqlite3_column_text(stmt, DB_QUICKPANEL_BUTTONID);
if(bindType == 4){
kk_scene_delete_scene_action(pSceneId,0);
}else if(bindType == 2 || bindType == 3){
kk_scene_delete_scene_action(pSceneId,1);
}
kk_scene_delete_quickpanel_info(buttonId,deviceCode);
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 检查场景触发是否已经存在
*输入参数: deviceCode:设备deviceCode
epNum: 设备路数
......@@ -257,10 +387,10 @@ static int kk_scene_check_trigger_exist(const char* deviceCode,int epNum,const c
char *dbcompareType =NULL;
char *dbsceneId =NULL;
const char *selectCmd = "select * from SceneTriggerInfo WHERE deviceCode = '%s' and propertyName = '%s';";
const char *selectCmd = "select * from SceneTriggerInfo WHERE deviceCode = '%s' and propertyName = '%s' and epNum = '%d';";
_kk_scene_lock();
sqlCmd = sqlite3_mprintf(selectCmd,deviceCode,propertyName);
sqlCmd = sqlite3_mprintf(selectCmd,deviceCode,propertyName,epNum);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
dbepNum = sqlite3_column_int(stmt, DB_SCENETRIGGER_EPNUM);
......@@ -304,6 +434,20 @@ int kk_scene_insert_scene_trigger(const char* type,const char* deviceCode,int ep
char *zErrMsg = 0;
/*此触发条件已经存在*/
if(kk_scene_check_trigger_exist(deviceCode,epNum,propertyName,compareType,compareValue,sceneId)){
sqlCmd = sqlite3_mprintf("UPDATE SceneTriggerInfo SET isAnd=%d WHERE deviceCode = '%s' and propertyName = '%s' and epNum = '%d' and sceneId= '%s';",isAnd,deviceCode,propertyName,epNum,sceneId);
printf("sqlCmd=%s\n",sqlCmd);
res = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( res != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
sqlite3_free(sqlCmd);
_kk_scene_unlock();
return FAIL_RETURN;
}
sqlite3_free(sqlCmd);
_kk_scene_unlock();
return SUCCESS_RETURN;
}
const char *insertCmd = "insert into SceneTriggerInfo (type, deviceCode,epNum,propertyName,compareType,compareValue,sceneId,isAnd) \
......@@ -516,6 +660,35 @@ int kk_scene_insert_scene_action(const char* type,const char* deviceCode,int epN
}
/************************************************************
*功能描述: 从数据库删除情景面板的基本数据
*输入参数: sceneId:场景Id
*输出参数: 无
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_scene_delete_quickpanel_info(char *buttonId,char* deviceCode)
{
int res = 0;
kk_scene_ctx_t *ctx = _kk_scene_get_ctx();
char *sqlCmd = NULL;
char *zErrMsg = 0;
const char *deleteCmd = "delete from QuickPanelScene where buttonId = '%s' and deviceCode = '%s';";
_kk_scene_lock();
sqlCmd = sqlite3_mprintf(deleteCmd,buttonId,deviceCode);
res = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( res != SQLITE_OK ){
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
sqlite3_free(sqlCmd);
_kk_scene_unlock();
return FAIL_RETURN;
}
sqlite3_free(sqlCmd);
_kk_scene_unlock();
return SUCCESS_RETURN;
}
/************************************************************
*功能描述: 从数据库删除场景的基本数据
*输入参数: sceneId:场景Id
*输出参数: 无
......
......@@ -68,6 +68,13 @@ enum{
DB_SCENEINVOKESERVICE_SCENEID,
DB_SCENEINVOKESERVICE_args,
};
enum{
DB_QUICKPANEL_BUTTONID = 0,
DB_QUICKPANEL_BINDTYPE,
DB_QUICKPANEL_DEVICECODE,
DB_QUICKPANEL_SCENEID,
};
int kk_scene_delete_scene_timing(const char *sceneId);
int kk_scene_delete_scene_condition(const char *sceneId);
int kk_scene_delete_scene_trigger(const char *sceneId);
......@@ -86,5 +93,10 @@ int kk_scene_insert_scene_condition(const char* type,int startTime,int endTime,i
const char* compareType,const char* compareValue,const char* sceneId,int isAnd);
int kk_scene_insert_scene_info(const char* roomName,const char* name,int sceneType,int enable,const char* sceneId);
int kk_scene_update_scene_enable(int enable,const char *sceneId);
int kk_scene_db_init(void);
int kk_scene_db_init(void);
int kk_scene_insert_panel_scene_info(int bindType,char *buttonId,char *deviceCode,const char* sceneId);
int kk_scene_delete_quickpanel_info(char *buttonId,char* deviceCode);
int kk_scene_delete_panel_scene_info(char *buttonId,char *deviceCode);
int kk_scene_deleteall_panel_scene_info(char *deviceCode);
#endif
......@@ -453,7 +453,7 @@ int kk_scene_action_add(const char *gwdeviceCode,const char *sceneId,kk_scene_ac
*************************************************************/
int kk_scene_delete_send_to_gw(const char *sceneId)
{
char gwdevice[][DEVICE_CODE_MAXLEN] = {0};
char gwdevice[5][DEVICE_CODE_MAXLEN] = {0};
sqlite3_stmt *stmt;
char *sqlCmd = NULL;
char *gwdeviceCode = NULL;
......@@ -644,6 +644,7 @@ int kk_scene_parse_scene_trigger(const cJSON* str,const char *sceneId)
if(type == NULL) return FAIL_RETURN;
if(!strcmp("trigger/thing/property",type->valuestring)){
printf("---------------->isAnd=0\n");
res = kk_scene_parse_trigger_detail(type->valuestring,item,sceneId,0);
if(res != SUCCESS_RETURN){
ERROR_PRINT("kk_scene_parse_scene_trigger fail!!!\n");
......@@ -859,6 +860,7 @@ int kk_scene_parse_scene_condition(const cJSON* str,const char *sceneId)
}
}
else if(!strcmp("trigger/thing/property",type->valuestring)){
printf("---------------->isAnd=1\n");
kk_scene_parse_trigger_detail(type->valuestring,item,sceneId,1);
}
else{
......@@ -941,8 +943,11 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
if(propertyValue == NULL) return FAIL_RETURN;
productType = cJSON_GetObjectItem(item,MSG_PRODUCT_TYPE_STR);
if(productType != NULL){
delay = cJSON_GetObjectItem(item,MSG_SCENE_DELAY);
if(delay == NULL) return FAIL_RETURN;
int idelay = delay->valueint;
kk_subDev_set_action_by_productType(productType->valuestring,sceneId,propertyName->valuestring,
propertyValue->valuestring,type->valuestring);
propertyValue->valuestring,type->valuestring,idelay);
}
else{
deviceCode = cJSON_GetObjectItem(item,MSG_DEVICE_CODE_STR);
......@@ -1052,12 +1057,13 @@ int kk_scene_parse_scene_muticontrol(const cJSON* str,const char *sceneId,int is
}
cJSON_AddItemToArray(array,arrayParam);
//break;
kk_scene_insert_scene_action(type->valuestring,deviceCode->valuestring,atoi(epNum->valuestring),
"","",0,sceneId,node->fatherDeviceCode);
}
item = item->next;
}
res = kk_scene_insert_scene_action(type->valuestring,deviceCode->valuestring,0,
"","",0,sceneId,node->fatherDeviceCode);
kk_scene_muticontrol_info_send(array,node->fatherDeviceCode,sceneId,isUpdate);
return SUCCESS_RETURN;
......@@ -1099,14 +1105,15 @@ int kk_scene_parse_addscene(const cJSON* args,char *sceneId,int isUpdate,const c
dm_msg_scene_event_post(MSG_SCENE_ADDNOTIFICATION,pSceneShadow,msgId);
}
}
char roomIdStr[32] = {0};
snprintf(roomIdStr,32,"%d",room_id->valueint);
res = kk_scene_insert_scene_info(roomIdStr,name->valuestring,sceneType->valueint,enable->valueint,sceneId);
/*多控直接下发给网关处理*/
if(enable->valueint == 1 && sceneType->valueint == DB_SCENETYPE_MUTICONTROL){
kk_scene_parse_scene_muticontrol(args,sceneId,isUpdate);
}
else{
char roomIdStr[32] = {0};
snprintf(roomIdStr,32,"%d",room_id->valueint);
res = kk_scene_insert_scene_info(roomIdStr,name->valuestring,sceneType->valueint,enable->valueint,sceneId);
if(res != SUCCESS_RETURN){
INFO_PRINT("kk_scene_insert_scene_info fail!!!\n");
return res;
......@@ -1197,6 +1204,34 @@ int kk_scene_get_scene_info(const char* sceneId,int *sceneType,int *enable)
return res;
}
/************************************************************
*功能描述:从数据库获取情景信息
*输入参数:sceneId:对应场景Id;
*输出参数:sceneType:场景类型
enable:场景是否使能
*返 回 值: 0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_scene_get_quickpanel_info(const char* buttonId,char *deviceCode,char *sceneId,int *bindType)
{
kk_scene_ctx_t *ctx = _kk_scene_get_ctx();
sqlite3_stmt *stmt;
int res = FAIL_RETURN;
char *pSceneId = NULL;
char *sqlCmd = NULL;
sqlCmd = sqlite3_mprintf("select * from QuickPanelScene where buttonId = '%s' and deviceCode = '%s'",buttonId,deviceCode);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
pSceneId = sqlite3_column_text(stmt, DB_QUICKPANEL_SCENEID);
*bindType = sqlite3_column_int(stmt, DB_QUICKPANEL_BINDTYPE);
memcpy(sceneId,pSceneId,strlen(pSceneId));
res = SUCCESS_RETURN;
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return res;
}
/************************************************************
*功能描述:通过时间获取星期
*输入参数:t:当前时间
*输出参数:无
......@@ -2022,7 +2057,9 @@ void kk_scene_execute_event_post(const char* sceneId,const char *msgId)
return;
}
if(msgId == NULL){
sprintf(msgIdbuf,"%d",iotx_report_id());
//sprintf(msgIdbuf,"%d",iotx_report_id());
iotx_report_id(msgIdbuf);
//sprintf(msgId,"%d",iotx_report_id());
}
else
{
......@@ -2035,3 +2072,51 @@ void kk_scene_execute_event_post(const char* sceneId,const char *msgId)
}
}
static int kk_quickpanel_pro_get(const char* sceneId,char *propertyValue)
{
int res = FAIL_RETURN;
char *sqlCmd = NULL;
char *pPropertyValue = NULL;
sqlite3_stmt *stmt;
kk_scene_ctx_t *ctx = _kk_scene_get_ctx();
sqlCmd = sqlite3_mprintf("select * from SceneActionInfo WHERE sceneId = '%s'",sceneId);
sqlite3_prepare_v2(ctx->pDb, sqlCmd, strlen(sqlCmd), &stmt, NULL);
while(sqlite3_step(stmt) == SQLITE_ROW){
pPropertyValue = (char*)sqlite3_column_text(stmt,DB_SCENEACTION_PROPERTYVALUE);
memcpy(propertyValue,pPropertyValue,strlen(pPropertyValue));
}
sqlite3_finalize(stmt);
sqlite3_free(sqlCmd);
return res;
}
/************************************************************
*功能描述:情景面板执行
*输入参数:buttonId:Id
*输出参数:无
*返 回 值:0:成功;其他:失败
*其他说明:
*************************************************************/
int kk_scene_execute_quickpanel(const char *buttonId,char *deviceCode)
{
int res = 0;
int bindType = 0;
char sceneId[32] = {0};
if(buttonId == NULL || deviceCode == NULL){
return INVALID_PARAMETER;
}
res = kk_scene_get_quickpanel_info(buttonId,deviceCode,sceneId,&bindType);
if(res == SUCCESS_RETURN ){
if(bindType == 4){
char provalue[4] = {0};
kk_quickpanel_pro_get(sceneId,provalue);
kk_service_arming_set(provalue);
}else{
kk_scene_execute_action(sceneId,NULL);
}
}
INFO_PRINT("[%d]kk_scene_execute_quickpanel called!!!\n",__LINE__);
return res;
}
\ No newline at end of file
......@@ -6,11 +6,6 @@
#include "kk_log.h"
#include "kk_tsl_parse.h"
#define TSL_SUBDEVICE_PATH_FILE "/usr/kk/tsl/product_%s.json"
#define TSL_GATEWAY_PATH_FILE "/usr/kk/tsl/gateway_%s.json"
#define TSL_CCU_PATH_FILE "/usr/kk/tsl/ccu_%s.json"
#define TSL_SCENE_PATH_FILE "/usr/kk/tsl/ccu_%s_scene.json"
char* kk_load_json(const char *productCode,int type)
{
FILE *fp;
......
This diff is collapsed.
#!/bin/sh
nanomsg_File="/app/ccuApps/lib/libnanomsg.so.5"
ev_File="/app/ccuApps/lib/libev.so.4"
sqlite_File="/app/ccuApps/lib/libsqlite3.so.0"
run_Dir="/data/kk"
tsl_Dir="${run_Dir}/tsl"
#dev_cfg_Dir="${run_Dir}/dev_config_table"
#cd /sbin/
#insmod /sbin/ssd1306-revision.ko
#/sbin/oled >/dev/null 2>&1 &
#sleep 1
if [ ! -d "$run_Dir" ]; then
mkdir ${run_Dir}
fi
if [ ! -d "$tsl_Dir" ]; then
cp -rf /app/ccuApps/tsl ${run_Dir}/
fi
cd /app/ccuApps/lib
if [ ! -f "$nanomsg_File" ]; then
ln -sf /app/ccuApps/lib/libnanomsg.so /lib/libnanomsg.so.5
fi
if [ ! -f "$ev_File" ]; then
ln -sf /app/ccuApps/lib/libev.so /lib/libev.so.4
fi
if [ ! -f "$sqlite_File" ]; then
ln -sf /app/ccuApps/lib/libsqlite3.so /lib/libsqlite3.so.0
fi
export LD_LIBRARY_PATH=/app/ccuApps/lib
/app/ccuApps/bin/kk_midware &
sleep 3
/app/ccuApps/bin/kk_cloud &
sleep 1
#/home/kk/process_check.sh >/dev/null 2>&1 &
/app/ccuApps/bin/smarthome_z3gw_nx5 -r1 -l3 --device-def=/app/ccuApps/kk_device_def.json --db=/data/kk/kk_z3gw.db --uart=/dev/ttyS1&
sleep 1
ntpd -n -q -d -p stdtime.gov.hk &
exit 0
\ No newline at end of file
{
"productCode":"3024",
"operateType":"3",
"channel":3,
"newccu":[
{
"identifier":"PowerSwitch",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"1",
"valueRange":[0,1],
"value": 0
},
{
"identifier":"PowerSwitch",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"2",
"valueRange":[0,1],
"value": 0
},
{
"identifier":"PowerSwitch",
"opcodemap":"SWITCH",
"dataType":"int",
"channel":"3",
"valueRange":[0,1],
"value": 0
}
],
"oldccu":[
{
"opcode":"SWITCH",
"identifiermap":"PowerSwitch",
"dataType":"map",
"channel":"1",
"valueRange":["OFF","ON"]
},
{
"opcode":"SWITCH",
"identifiermap":"PowerSwitch",
"dataType":"map",
"channel":"2",
"valueRange":["OFF","ON"]
},
{
"opcode":"SWITCH",
"identifiermap":"PowerSwitch",
"dataType":"map",
"channel":"3",
"valueRange":["OFF","ON"]
}
]
}
\ No newline at end of file
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
nanomsg_File="/home/kk/lib/libnanomsg.so.5"
ev_File="/home/kk/lib/libev.so.4"
cd /sbin/
insmod /sbin/ssd1306-revision.ko
/sbin/oled >/dev/null 2>&1 &
sleep 1
export LD_LIBRARY_PATH=/home/kk/lib
cd /home/kk/lib
if [ ! -f "$nanomsg_File" ]; then
ln libnanomsg.so libnanomsg.so.5
fi
if [ ! -f "$ev_File" ]; then
ln libev.so libev.so.4
fi
CCU_ID=`cat /etc/dropbear/accessory/hj/hj_ccuid`
/sbin/logread -f -r 120.55.149.201 514 -p /var/run/logread.cloud_log.pid -u -h $CCU_ID >/dev/null 2>&1 &
/sbin/logread -f -e "ccu_err_info" -F /etc/dropbear/accessory/hj/err.log -p /var/run/logread.err_log.pid -S 512 >/dev/null 2>&1 &
sleep 1
/home/kk/run.sh >/dev/null 2>&1 &
sleep 10
/home/kk/process_check.sh >/dev/null 2>&1 &
cd /sbin
/sbin/logd-check.sh >/dev/null 2>&1 &
sleep 1
ntpd -n -q -d -p stdtime.gov.hk &
exit 0
......@@ -208,15 +208,20 @@ package:
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)/onboot.sh $(TOP_DIR)/$(releaseDir)/
cp -rf $(TOP_DIR)/VERSION $(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/
ifeq ($(CONFIG_MODEL),ubuntu)
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_ubuntu.so $(TOP_DIR)/$(releaseDir)/lib/libnanomsg.so.5
cp -rf $(TOP_DIR)/common/ev/libev_ubuntu.so $(TOP_DIR)/$(releaseDir)/lib
else ifeq ($(CONFIG_MODEL),nx5)
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_nx5.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/ev/libev_nx5.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_nx5.so $(TOP_DIR)/$(releaseDir)/lib/libnanomsg.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)/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)/upgrade $(TOP_DIR)/$(releaseDir)/
else
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/ev/libev.so $(TOP_DIR)/$(releaseDir)/lib
......
{
"schema": "https://iot-ap.ikonke.com/model/product_1002.json",
"productType": "switch",
"profile": {
"heartbeat": "3000",
"productCode": "1002",
"productName": "铂金系列一路灯控"
},
"services": [{
"outputData": [],
"identifier": "set",
"inputData": [{
"identifier": "PowerSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关"
}],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置"
}, {
"outputData": [{
"identifier": "PowerSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关"
}],
"identifier": "get",
"inputData": ["PowerSwitch"],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}, {
"outputData": [],
"identifier": "negativeProperty",
"inputData": [{
"identifier": "PropertyName",
"dataType": {
"specs": {
"length": "50"
},
"type": "text"
},
"name": "属性名字"
}],
"method": "thing.service.negativeProperty",
"name": "negativeProperty",
"required": true,
"callType": "async",
"desc": "属性值取反"
}],
"properties": [{
"identifier": "PowerSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关",
"accessMode": "rw",
"required": true
}],
"events": [{
"outputData": [{
"identifier": "PowerSwitch",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关"
}],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}]
}
\ No newline at end of file
{
"schema": "https://iot-ap.ikonke.com/model/product_1003.json",
"productType": "switch",
"profile": {
"heartbeat": "3000",
"productCode": "1003",
"productName": "铂金系列二路灯控"
},
"services": [{
"outputData": [],
"identifier": "set",
"inputData": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路"
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路"
}],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置"
}, {
"outputData": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路"
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路"
}],
"identifier": "get",
"inputData": ["PowerSwitch_1", "PowerSwitch_2"],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}, {
"outputData": [],
"identifier": "negativeProperty",
"inputData": [{
"identifier": "PropertyName",
"dataType": {
"specs": {
"length": "50"
},
"type": "text"
},
"name": "属性名字"
}],
"method": "thing.service.negativeProperty",
"name": "negativeProperty",
"required": true,
"callType": "async",
"desc": "属性值取反"
}],
"properties": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路",
"accessMode": "rw",
"required": true
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路",
"accessMode": "rw",
"required": true
}],
"events": [{
"outputData": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路"
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路"
}],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}]
}
\ No newline at end of file
{
"schema": "https://iot-ap.ikonke.com/model/product_1004.json",
"productType": "switch",
"profile": {
"heartbeat": "3000",
"productCode": "1004",
"productName": "铂金系列三路灯控 "
},
"services": [{
"outputData": [],
"identifier": "set",
"inputData": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路"
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路"
}, {
"identifier": "PowerSwitch_3",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关3路"
}],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置"
}, {
"outputData": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路"
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路"
}, {
"identifier": "PowerSwitch_3",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关3路"
}],
"identifier": "get",
"inputData": ["PowerSwitch_1", "PowerSwitch_2", "PowerSwitch_3"],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}, {
"outputData": [],
"identifier": "negativeProperty",
"inputData": [{
"identifier": "PropertyName",
"dataType": {
"specs": {
"length": "50"
},
"type": "text"
},
"name": "属性名字"
}],
"method": "thing.service.negativeProperty",
"name": "negativeProperty",
"required": true,
"callType": "async",
"desc": "属性值取反"
}],
"properties": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路",
"accessMode": "rw",
"required": true
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路",
"accessMode": "rw",
"required": true
}, {
"identifier": "PowerSwitch_3",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关3路",
"accessMode": "rw",
"required": true
}],
"events": [{
"outputData": [{
"identifier": "PowerSwitch_1",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关1路"
}, {
"identifier": "PowerSwitch_2",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关2路"
}, {
"identifier": "PowerSwitch_3",
"dataType": {
"specs": {
"0": "关闭",
"1": "打开"
},
"type": "bool"
},
"name": "电源开关3路"
}],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}]
}
\ No newline at end of file
{
"schema": "https://iot-ap.ikonke.com/model/product_1007.json",
"productType": "curtain",
"profile": {
"heartbeat": "3000",
"productCode": "1007",
"productName": "铂金系列推窗面板"
},
"services": [{
"outputData": [],
"identifier": "set",
"inputData": [{
"identifier": "OperationMode",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "enum"
},
"name": "推窗器操作模式"
}],
"method": "thing.service.property.set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置"
}, {
"outputData": [{
"identifier": "OperationMode",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "enum"
},
"name": "推窗器操作模式"
}],
"identifier": "get",
"inputData": ["OperationMode"],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}],
"properties": [{
"identifier": "OperationMode",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "enum"
},
"name": "推窗器操作模式",
"accessMode": "rw",
"required": true
}],
"events": [{
"outputData": [{
"identifier": "OperationMode",
"dataType": {
"specs": {
"0": "关闭",
"1": "开启"
},
"type": "enum"
},
"name": "推窗器操作模式"
}],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}]
}
\ No newline at end of file
{
"schema": "https://iot-ap.ikonke.com/model/product_1008.json",
"productType": "sensor",
"profile": {
"heartbeat": "3000",
"productCode": "1008",
"productName": "铂金系列长供电SOS"
},
"services": [{
"outputData": [{
"identifier": "SosState",
"name": "紧急按钮状态",
"dataType": {
"type": "enum",
"specs": {
"0": "关闭",
"1": "打开"
}
}
}, {
"identifier": "Battery",
"name": "电池电量",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
}, {
"identifier": "DismantleState",
"name": "拆卸状态",
"dataType": {
"type": "enum",
"specs": {
"0": "正常",
"1": "被拆卸"
}
}
}],
"identifier": "get",
"inputData": ["SosState", "Battery", "DismantleState"],
"method": "thing.service.property.get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取"
}],
"properties": [{
"identifier": "SosState",
"name": "门磁状态",
"accessMode": "r",
"required": true,
"dataType": {
"type": "enum",
"specs": {
"0": "关闭",
"1": "打开"
}
}
}, {
"identifier": "Battery",
"name": "电池电量",
"accessMode": "r",
"required": false,
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
}, {
"identifier": "DismantleState",
"name": "拆卸状态",
"accessMode": "r",
"required": false,
"dataType": {
"type": "enum",
"specs": {
"0": "正常",
"1": "被拆卸"
}
}
}],
"events": [{
"outputData": [{
"identifier": "SosState",
"name": "门磁状态",
"dataType": {
"type": "enum",
"specs": {
"0": "关闭",
"1": "打开"
}
}
}, {
"identifier": "Battery",
"name": "电池电量",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
}, {
"identifier": "DismantleState",
"name": "拆卸状态",
"dataType": {
"type": "enum",
"specs": {
"0": "正常",
"1": "被拆卸"
}
}
}],
"identifier": "property",
"method": "thing.event.property.post",
"name": "property",
"type": "info",
"required": true,
"desc": "属性上报"
}, {
"outputData": [{
"identifier": "SosState",
"name": "门磁状态",
"dataType": {
"type": "enum",
"specs": {
"0": "关闭",
"1": "打开"
}
}
}],
"identifier": "sosAlarm",
"method": "thing.event.sosAlarm.post",
"name": "sosAlarm",
"type": "alarm",
"required": true,
"desc": "紧急按钮告警"
}, {
"outputData": [{
"identifier": "Battery",
"name": "电池电量",
"dataType": {
"type": "double",
"specs": {
"min": "0",
"max": "100",
"unit": "%",
"unitName": "百分比",
"step": "0.01"
}
}
}],
"identifier": "BatteryAlarm",
"method": "thing.event.BatteryAlarm.post",
"name": "BatteryAlarm",
"type": "alarm",
"required": true,
"desc": "低电量告警"
}, {
"identifier": "TamperAlarm",
"name": "防撬报警",
"type": "alert",
"required": true,
"method": "thing.event.TamperAlarm.post",
"outputData": [{
"identifier": "DismantleState",
"name": "拆卸状态",
"dataType": {
"type": "enum",
"specs": {
"0": "正常",
"1": "被拆卸"
}
}
}]
}]
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"schema": "https://iot-ap.ikonke.com/model/product_1028.json",
"productType": "controller",
"profile": {
"heartbeat": "3000",
"productCode": "1028",
"productName": "断水面板(电磁水阀控制器)"
},
"services": [
{
"identifier": "set",
"name": "set",
"required": true,
"callType": "async",
"desc": "属性设置",
"method": "thing.service.property.set",
"inputData": [
{
"identifier": "PowerSwitch",
"name": "电源开关",
"dataType": {
"type": "bool",
"specs": {
"0": "关闭",
"1": "开启"
}
}
}
],
"outputData": []
},
{
"identifier": "get",
"name": "get",
"required": true,
"callType": "async",
"desc": "属性获取",
"method": "thing.service.property.get",
"inputData": [],
"outputData": []
}
],
"properties": [
{
"identifier": "PowerSwitch",
"name": "电源开关",
"accessMode": "w",
"required": true,
"dataType": {
"type": "bool",
"specs": {
"0": "关闭",
"1": "开启"
}
}
}
],
"events": [
{
"identifier": "post",
"name": "post",
"type": "info",
"required": true,
"desc": "属性上报",
"method": "thing.event.property.post",
"outputData": [
{
"identifier": "PowerSwitch",
"name": "电源开关",
"dataType": {
"type": "bool",
"specs": {
"0": "关闭",
"1": "开启"
}
}
}
]
}
]
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -93,7 +93,7 @@
{
"outputData": [
{
"identifier": "SceneId",
"identifier": "SceneNum",
"dataType": {
"specs": {
"1": "场景1",
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3014.json",
"productType": "scene",
"version": "1",
"version": "1.0",
"profile": {
"heartbeat": "1200",
"productCode": "3014",
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3015.json",
"productType": "sensor",
"version": "1",
"version": "1.0",
"profile": {
"heartbeat": "300",
"productCode": "3015",
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3016.json",
"productType": "sensor",
"version": "1",
"version": "1.0",
"profile": {
"heartbeat": "1200",
"productCode": "3016",
......
......@@ -5,7 +5,7 @@
"profile": {
"heartbeat": "300",
"productCode": "3028",
"productName": "肖邦系列.白色零火线调光面板Z3S(KONKE)"
"productName": "肖邦系列.零火线调光面板Z3S(KONKE)"
},
"services": [
{
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3029.json",
"productType": "floorHeating",
"version": "1.0",
"profile": {
"heartbeat": "300",
"productCode": "3029",
"productName": "肖邦系列.白色水地暖面板Z3S(KONKE)"
"productName": "肖邦系列.水地暖面板Z3S(KONKE)"
},
"services": [
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"schema": "https://iot-ap.ikonke.com/model/product_3046.json",
"productType": "scene",
"version": "1",
"version": "1.0",
"profile": {
"heartbeat": "7200",
"productCode": "3046",
......
{
"schema": "https://iot-ap.ikonke.com/model/product_3048.json",
"productType": "sensor",
"version": "1",
"version": "1.0",
"profile": {
"heartbeat": "7200",
"productCode": "3048",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"schema":"https://iot-ap.ikonke.com/model/product_3078.json",
"productType":"switch",
"version": "1.0",
"version": "1",
"profile":{
"heartbeat":"300",
"productCode":"3078",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment