Commit e872556d authored by 陈伟灿's avatar 陈伟灿

Merge branch 'cwc' into 'master'

【修改内容】去warning处理

See merge request chenweican/k-sdk!145
parents 84ab334e 8df7914e
......@@ -358,14 +358,19 @@ int kk_start_ccu_register(void)
INFO_PRINT("send success send %d bytes!\n\n", ret);
}
registerType = 1;
FD_ZERO(&t_set1);
FD_SET(sockfd, &t_set1);
tv.tv_sec= 1;
tv.tv_usec= 0;
h= 0;
while(1){
FD_ZERO(&t_set1);
FD_SET(sockfd, &t_set1);
h = select(sockfd +1, &t_set1, NULL, NULL, &tv);
//if (h == 0) continue;
if (h == 0)
{
INFO_PRINT("kk_register receive nothing\n");
continue;
}
if (h < 0) {
close(sockfd);
return -1;
......
......@@ -111,7 +111,6 @@ void onConnectFailure(void* context, MQTTAsync_failureData* response)
}
KK_reset_sub_flag();
WARNING_PRINT("Connect failed, rc %d\n", response ? response->code : 0);
}
void onConnect(void* context, MQTTAsync_successData* response)
......@@ -278,6 +277,10 @@ int KK_MQTT_SubTopic(char *topicName)
opts.onFailure = onOptFail;
opts.context = (void*)OPT_SUB;
if(s_cloudStatus == DEVICE_OFFLINE){
ERROR_PRINT("Failed to KK_MQTT_SubTopic, s_cloudStatus == DEVICE_OFFLINE\n");
return -1;
}
if ((rc = MQTTAsync_subscribe(s_Client,topicName, QOS, &opts)) != MQTTASYNC_SUCCESS)
{
ERROR_PRINT("Failed to start subscribe, return code:%d.\n", rc);
......@@ -291,7 +294,7 @@ 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);
cJSON_Minify((char*)payload);
INFO_PRINT("mqtt send payload :%s.\n",payload);
opts.onSuccess = onOptSuccess;
opts.onFailure = onOptFail;
......@@ -336,6 +339,10 @@ int KK_MQTT_UnsubTopic(const char *topicName)
opts.onFailure = onOptFail;
opts.context = (void*)OPT_UNSUB;
if(s_cloudStatus == DEVICE_OFFLINE){
ERROR_PRINT("Failed to KK_MQTT_UnsubTopic, s_cloudStatus == DEVICE_OFFLINE\n");
return -1;
}
if ((rc = MQTTAsync_unsubscribe(s_Client,topicName,&opts)) != MQTTASYNC_SUCCESS)
{
ERROR_PRINT("Failed to start unubscribe, return code:%d.\n", rc);
......
......@@ -126,12 +126,7 @@ void kk_sync_info_push(void)
void handler(int signum)
{
printf("[sig]---------------------->signum=%d\n",signum);
if(signum==SIGALRM){
printf("[SIGALRM]\n");
}
debug_log(LOG_CRIT_LEVEL,"[sig]---------------------->signum=%d\n",signum);
if(signum!=17 &&signum!=SIGALRM){
exit(-1);
}
......
#ifndef _KK_CCU_VER_H_
#define _KK_CCU_VER_H_
#define KK_CCU_VERSION "1.1.0"
#define KK_CCU_VERSION "1.3.0"
#define KK_VERSION_FILE_PATH "/app/ccuApps/VERSION"
......
......@@ -22,6 +22,7 @@ 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_Printf(_IN_ const char *fmt, ...);
void *HAL_MutexCreate(void);
void HAL_MutexLock(_IN_ void *mutex);
void HAL_MutexUnlock(_IN_ void *mutex);
......@@ -43,4 +44,11 @@ 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_Code(_IN_ char *product_code);
int HAL_GetProduct_Code(_OU_ char *product_code);
void HAL_Firmware_Persistence_Start(void* fileName);
int HAL_Firmware_Persistence_Write(_IN_ char *buffer, _IN_ uint32_t length);
int HAL_Firmware_Persistence_Stop(void);
void HAL_Reboot(void);
void *HAL_Malloc(_IN_ uint32_t size);
void HAL_Free(_IN_ void *ptr);
int HAL_Get_TimeZone(void);
#endif
......@@ -564,11 +564,13 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
publish.payloadlen = m->publish->payloadlen;
}
publish.MQTTVersion = m->MQTTVersion;
if (publish.MQTTVersion >= MQTTVERSION_5)
if (publish.MQTTVersion >= MQTTVERSION_5){
publish.properties = m->properties;
else
}
else{
Protocol_processPublication(&publish, client, 0); /* only for 3.1.1 and lower */
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
}
#if !defined(NO_PERSISTENCE)
rc += MQTTPersistence_remove(client,
(m->MQTTVersion >= MQTTVERSION_5) ? PERSISTENCE_V5_PUBLISH_RECEIVED : PERSISTENCE_PUBLISH_RECEIVED,
......
......@@ -36,5 +36,6 @@ int kk_get_room_armingstate(const char* roomId);
int kk_get_roomId_by_deviceCode(const char* deviceCode,const char *epNum,char *roomId,int size);
int kk_get_device_roomInfo(const char* deviceCode,int epNum,char *roomName,char *roomId);
int kk_room_reset_armingstate(void);
cJSON *kk_get_roomIds_ary(void);
#endif
......@@ -3,8 +3,10 @@
*/
//#include "../dm/iotx_dm_internal.h"
#include "dm_fota.h"
#include "kk_hal.h"
#include "dm_ota.h"
#include "../ota/ota_api.h"
#include "iotx_ota.h"
#define dm_log_err printf
#define dm_log_debug printf
#define dm_log_info printf
......
......@@ -9,7 +9,9 @@
#include <curl/curl.h>
#include "com_api.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "iotx_ota.h"
#include "kk_dm_queue.h"
static dm_ota_ctx_t g_dm_ota_ctx;
static dm_ota_ctx_t *_dm_ota_get_ctx(void)
......@@ -178,7 +180,7 @@ enum{
OTA_STATE_UPGRADE_FAIL,
};
static char *s_url = NULL;
int HAL_Get_ccuid(_OU_ char *device_code);
int kk_publishProgress(int process,int state)
{
char productCode[PRODUCT_CODE_LEN] = {0};
......
......@@ -6,13 +6,15 @@
#include "kk_dm_api.h"
#include "kk_tsl_common.h"
#include "kk_dm_mng.h"
#include "kk_tsl_api.h"
#include "com_api.h"
#include "dm_ota.h"
#include "kk_log.h"
#include "kk_hal.h"
#include "kk_dm_queue.h"
#include "kk_linkkit.h"
#include "dm_fota.h"
static dm_api_ctx_t g_dm_api_ctx;
static dm_api_ctx_t *_dm_api_get_ctx(void)
......@@ -332,7 +334,7 @@ int iotx_dm_subscribe_node(dm_mgr_dev_node_t *node)
ERROR_PRINT("\n [%d][%s] malloc faild kk_ipc_send \n", __LINE__, __FUNCTION__);
return FAIL_RETURN;
}
INFO_PRINT("\n [%d][%s] [%lu] send app to subscribe mqtt \n", __LINE__, __FUNCTION__, HAL_UptimeMs());
INFO_PRINT("\n [%d][%s] [%llu] send app to subscribe mqtt \n", __LINE__, __FUNCTION__, HAL_UptimeMs());
return SUCCESS_RETURN;
}
......@@ -371,7 +373,7 @@ int iotx_dm_subscribe(_IN_ int devid)
ERROR_PRINT("\n [%d][%s] malloc faild kk_ipc_send \n", __LINE__, __FUNCTION__);
return FAIL_RETURN;
}
INFO_PRINT("\n [%d][%s] [%lu] send app to subscribe mqtt \n", __LINE__, __FUNCTION__, HAL_UptimeMs());
INFO_PRINT("\n [%d][%s] [%llu] send app to subscribe mqtt \n", __LINE__, __FUNCTION__, HAL_UptimeMs());
return SUCCESS_RETURN;
}
......@@ -402,9 +404,9 @@ int kk_dm_get_property_type(const char* deviceCode,const char *key)
if(deviceCode == NULL){
return FAIL_RETURN;
}
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
res = dm_mgr_get_device_by_devicecode((char*)deviceCode, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
return kk_tsl_get_property_type(node->dev_shadow,key);
return kk_tsl_get_property_type(node->dev_shadow,(char*)key);
}
......@@ -7,7 +7,7 @@
#ifndef _KK_DM_API_H_
#define _KK_DM_API_H_
#include "iotx_dm.h"
#include "kk_dm_mng.h"
#define CONFIG_DISPATCH_QUEUE_MAXLEN (50)
......@@ -43,4 +43,5 @@ int iotx_dm_subscribe(_IN_ int devid);
void kk_dm_ota_report_version(_IN_ int devid, char *version);
void kk_dm_ota_send(void *data, int len);
int kk_dm_get_property_type(const char* deviceCode,const char *key);
int iotx_dm_subscribe_node(dm_mgr_dev_node_t *node);
#endif
......@@ -18,6 +18,7 @@
#include "kk_log.h"
#include "kk_tsl_common.h"
#include "kk_dm_mng.h"
#include "kk_dm_msg.h"
#include "kk_hal.h"
/*************************************************************
......@@ -142,7 +143,7 @@ int kk_heartbeat_init(void)
ctx->hearbeat_thread_running = 1;
s_start_time = HAL_Uptimes();
res = pthread_create(&ctx->hearbeat_thread, NULL, kk_heartbeat_yield, NULL);
res = pthread_create((pthread_t *)&ctx->hearbeat_thread, NULL, kk_heartbeat_yield, NULL);
if (res < 0) {
ERROR_PRINT("HAL_ThreadCreate ota Failed\n");
//IOT_Linkkit_Close(mid_ctx->master_devid);
......
......@@ -5,6 +5,7 @@
#include "kk_dm_msg.h"
#include "kk_dm_api.h"
#include "kk_tsl_api.h"
#include "kk_tsl_parse.h"
#include "kk_tsl_load.h"
#include "iot_export_linkkit.h"
#include "kk_product.h"
......@@ -26,7 +27,7 @@ const char DM_URI_REPLY_SUFFIX[] DM_READ_ONLY = "_reply";
const char DM_URI_OTA_DEVICE_INFORM[] DM_READ_ONLY = "/ota/device/inform/%s/%s";
const char DM_URI_THING_EVENT_PROPERTY_POST_METHOD[] DM_READ_ONLY = "thing.event.property.post";
int HAL_Get_ccuid(_OU_ char *device_code);
static dm_mgr_ctx g_dm_mgr = {0};
static dm_mgr_ctx *_dm_mgr_get_ctx(void)
{
......@@ -298,7 +299,7 @@ int dm_mgr_device_create(_IN_ int dev_type,_IN_ char productCode[PRODUCT_CODE_MA
{
int heartbeat = 0;
kk_msg_parse_productType(tsl_str,node->productType);
res = kk_tsl_create(tsl_str,strlen(tsl_str),&node->dev_shadow,&heartbeat,&node->dormancyDev);
res = kk_tsl_create(tsl_str,strlen(tsl_str),&node->dev_shadow,&heartbeat,(int*)&node->dormancyDev);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
......@@ -518,8 +519,8 @@ int dm_mgr_check_heartbeat_timeout(time_t timestamp)
INFO_PRINT("[%s][%d]search_node->productCode:%s\n",__FUNCTION__,__LINE__,search_node->productCode);
INFO_PRINT("[%s][%d]search_node->hb_timeout:%d\n",__FUNCTION__,__LINE__,search_node->hb_timeout);
INFO_PRINT("[%s][%d]search_node->isOffline:%d\n",__FUNCTION__,__LINE__,search_node->isOffline);
INFO_PRINT("[%s][%d]search_node->timestamp:%d\n",__FUNCTION__,__LINE__,search_node->timestamp);
INFO_PRINT("[%s][%d]timestamp:%d\n",__FUNCTION__,__LINE__,timestamp);
INFO_PRINT("[%s][%d]search_node->timestamp:%ld\n",__FUNCTION__,__LINE__,search_node->timestamp);
INFO_PRINT("[%s][%d]timestamp:%ld\n",__FUNCTION__,__LINE__,timestamp);
}
if((timestamp - search_node->timestamp) >= search_node->hb_timeout){
if(search_node->isOffline != KK_DEV_OFFLINE){
......@@ -873,7 +874,7 @@ int dm_mgr_upstream_thing_service_post(_IN_ int devid, _IN_ char *identifier, _I
return res;
}
const char DM_URI_THING_SERVICE_RESPONSE[] = "/thing/service/%.*s_reply";
const char DM_URI_THING_SERVICE_RESPONSE[] = "/thing/service/%s_reply";
static int _kk_mgr_upstream_response_assemble(_IN_ int devid, _IN_ char *msgid, _IN_ int msgid_len,
_IN_ const char *identfy, _IN_ int code, _OU_ kk_msg_request_payload_t *request, _OU_ kk_msg_response_t *response)
{
......
......@@ -122,4 +122,5 @@ int dm_mgr_subdev_create(int devtype,_IN_ char productCode[PRODUCT_CODE_MAXLEN],
int dm_mgr_subdev_delete(_IN_ char deviceCode[DEVICE_CODE_MAXLEN]);
int dm_msg_thing_property_post_all(char *deviceCode);
int dm_mgr_get_gw_deviceCode(_OU_ dm_mgr_dev_node_t **node);
void dm_mgr_resubscribe(void);
#endif
#include "kk_dm_msg.h"
#include "kk_property_db.h"
#include "kk_dm_queue.h"
#include "lite-cjson.h"
#include "kk_hal.h"
......@@ -7,7 +7,7 @@
#include "kk_log.h"
#include "kk_utils.h"
#include "kk_sync_data.h"
int HAL_Get_ccuid(_OU_ char *device_code);
const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%s\",\"version\":\"%s\",\"params\":%s,\"time\":\"%lu\",\"method\":\"%s\"}";
const char DM_MSG_INFO[] DM_READ_ONLY = "{\"msgtype\":\"%s\",\"productCode\":\"%s\",\"deviceCode\":\"%s\"}";
extern void kk_sendData2gw(void* data, int len, char* chalMark);
......@@ -899,7 +899,7 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
}
payload = kk_tsl_get_post_event_str(node->dev_shadow,(char*)identifier,strlen(identifier));
if(payload != NULL){
res = kk_tsl_get_event_by_identifier(node->dev_shadow, identifier, &event);
res = kk_tsl_get_event_by_identifier(node->dev_shadow, (char*)identifier, &event);
if (res != SUCCESS_RETURN) {
free(payload);
ERROR_PRINT("dm_msg_thing_event_post failed\n");
......@@ -916,7 +916,7 @@ int dm_msg_thing_event_post(const char *deviceCode, const char *identifier,const
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));
dm_mgr_upstream_thing_event_post(node->devid, (char*)identifier, strlen(identifier), method, payload, strlen(payload));
}
free(method);
method = NULL;
......@@ -932,9 +932,9 @@ int dm_msg_scene_event_post(const char *identifier,kk_tsl_t *dev_shadow,const ch
void *event = NULL;
char *method = NULL;
payload = kk_tsl_get_post_event_str(dev_shadow,identifier,strlen(identifier));
payload = kk_tsl_get_post_event_str(dev_shadow,(char*)identifier,strlen(identifier));
if(payload != NULL){
res = kk_tsl_get_event_by_identifier(dev_shadow, identifier, &event);
res = kk_tsl_get_event_by_identifier(dev_shadow, (char*)identifier, &event);
if (res != SUCCESS_RETURN) {
free(payload);
return FAIL_RETURN;
......@@ -945,7 +945,7 @@ int dm_msg_scene_event_post(const char *identifier,kk_tsl_t *dev_shadow,const ch
free(payload);
return FAIL_RETURN;
}
dm_mgr_upstream_thing_event_post_ex(KK_DM_DEVICE_CCU_DEVICEID, identifier, strlen(identifier), method, payload, strlen(payload),msgId);
dm_mgr_upstream_thing_event_post_ex(KK_DM_DEVICE_CCU_DEVICEID, (char*)identifier, strlen(identifier), method, payload, strlen(payload),msgId);
free(method);
method = NULL;
free(payload);
......@@ -966,13 +966,13 @@ int dm_msg_thing_service_post(const char *deviceCode, const char *identifier)
return FAIL_RETURN;
}
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
res = dm_mgr_get_device_by_devicecode((char*)deviceCode, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
payload = kk_tsl_get_post_service_str(node->dev_shadow,identifier);
payload = kk_tsl_get_post_service_str(node->dev_shadow,(char*)identifier);
if(payload != NULL){
res = kk_tsl_get_service_by_identifier(node->dev_shadow, identifier, &service);
res = kk_tsl_get_service_by_identifier(node->dev_shadow, (char*)identifier, &service);
if (res != SUCCESS_RETURN) {
free(payload);
return FAIL_RETURN;
......@@ -983,7 +983,7 @@ int dm_msg_thing_service_post(const char *deviceCode, const char *identifier)
free(payload);
return FAIL_RETURN;
}
dm_mgr_upstream_thing_service_post(node->devid, identifier, strlen(identifier),method, payload, strlen(payload));
dm_mgr_upstream_thing_service_post(node->devid, (char*)identifier, strlen(identifier),method, payload, strlen(payload));
free(method);
method = NULL;
free(payload);
......@@ -1192,7 +1192,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
}
else if(current_data->data_value.type == KK_TSL_DATA_TYPE_DOUBLE){
sprintf(tmpValue,"%u",current_data->data_value.value_double);
sprintf(tmpValue,"%f",current_data->data_value.value_double);
kk_property_db_update_value(deviceCode,tmp_identifiers,tmpValue);
_kk_property_handle(&subPropertyInfoBuf,current_data->data_value.type,current_data->identifier,&current_data->data_value.value_double);
......@@ -1216,7 +1216,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
//cJSON_DeleteItemFromObject(params,property->identifier);
}
}
int epIdx[4] = {0};
char epIdx[4] = {0};
for(idx = 0; idx < epNumInt; idx++){
countPro = propertyInfoBuf[idx].num;
memset(epIdx,0x0,sizeof(epIdx));
......@@ -1265,7 +1265,7 @@ int dm_msg_thing_property_post_by_identify(char *deviceCode,cJSON *params)
return SUCCESS_RETURN;
}
int kk_msg_cloud_status_notify(const char *deviceCode,const char *productCode)
int kk_msg_cloud_status_notify(char *deviceCode,const char *productCode)
{
char *method = "thing.service.cloudStatus";
char *req_info = NULL,*payload = NULL;
......@@ -1345,7 +1345,7 @@ int kk_msg_execute_property_set(const char *productCode,const char *deviceCode,c
cJSON_AddItemToObject(root, "info", infoObj);
cJSON_AddItemToObject(root, "payload",payloadObj);
void *buf = cJSON_Print(root);
kk_sendData2gw(buf, strlen(buf), fatherDeviceCode);
kk_sendData2gw(buf, strlen(buf), (char*)fatherDeviceCode);
free(buf);
free(req_info);
free(payload);
......@@ -1466,7 +1466,7 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
method = KK_THING_METHOD_UPDATESCENC;
msgType = KK_THING_SERVICE_UPDATESCENC;
}
res = dm_mgr_get_device_by_devicecode(fatherDeviceCode,&node);
res = dm_mgr_get_device_by_devicecode((char*)fatherDeviceCode,&node);
if (res != SUCCESS_RETURN) {
ERROR_PRINT("ERROR [%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
......@@ -1499,7 +1499,7 @@ int kk_msg_execute_scene_set(const char* params,const char *fatherDeviceCode,int
cJSON_AddItemToObject(root, "info", infoObj);
cJSON_AddItemToObject(root, "payload",payloadObj);
void *buf = cJSON_Print(root);
kk_sendData2gw(buf, strlen(buf), fatherDeviceCode);
kk_sendData2gw(buf, strlen(buf), (char*)fatherDeviceCode);
free(buf);
free(req_info);
free(payload);
......@@ -1517,7 +1517,7 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
char msgId[MSG_MAX_LEN] = {0};
dm_mgr_dev_node_t *node = NULL;
res = dm_mgr_get_device_by_devicecode(fatherDeviceCode,&node);
res = dm_mgr_get_device_by_devicecode((char*)fatherDeviceCode,&node);
if (res != SUCCESS_RETURN) {
ERROR_PRINT("ERROR [%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
......@@ -1550,7 +1550,7 @@ int kk_msg_execute_scene_action(const char* params,const char *fatherDeviceCode)
cJSON_AddItemToObject(root, "info", infoObj);
cJSON_AddItemToObject(root, "payload",payloadObj);
void *buf = cJSON_Print(root);
kk_sendData2gw(buf, strlen(buf), fatherDeviceCode);
kk_sendData2gw(buf, strlen(buf), (char*)fatherDeviceCode);
free(buf);
free(req_info);
free(payload);
......@@ -1567,7 +1567,7 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
char msgId[MSG_MAX_LEN] = {0};
dm_mgr_dev_node_t *node = NULL;
res = dm_mgr_get_device_by_devicecode(fatherDeviceCode,&node);
res = dm_mgr_get_device_by_devicecode((char*)fatherDeviceCode,&node);
if (res != SUCCESS_RETURN) {
ERROR_PRINT("ERROR [%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
......@@ -1600,9 +1600,8 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
cJSON* payloadObj = cJSON_Parse(payload);
cJSON_AddItemToObject(root, "info", infoObj);
cJSON_AddItemToObject(root, "payload",payloadObj);
void *buf = cJSON_Print(root);
printf("----------------->buf:%s\n",buf);
kk_sendData2gw(buf, strlen(buf), fatherDeviceCode);
char *buf = cJSON_Print(root);
kk_sendData2gw(buf, strlen(buf), (char*)fatherDeviceCode);
free(buf);
free(req_info);
free(payload);
......
......@@ -153,7 +153,8 @@ int kk_msg_execute_scene_delete(const char* params,const char *fatherDeviceCode)
int dm_msg_thing_syncinfo_reply(void);
int dm_msg_thing_syncinfopush_reply(void);
void kk_split(char *src,const char *separator,char **dest,int *num);
int kk_msg_cloud_status_notify(const char *deviceCode,const char *productCode);
int kk_msg_cloud_status_notify(char *deviceCode,const char *productCode);
int dm_msg_thing_syncdeviceinfo_reply(cJSON *msgId);
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
......
......@@ -54,7 +54,7 @@
#define dm_log_debug WARNING_PRINT
#define dm_log_info INFO_PRINT
int HAL_Get_ccuid(_OU_ char *device_code);
extern void kk_sendData2gw(void* data, int len, char* chalMark);
static int s_gateway_add_flag = 0;
......@@ -1218,6 +1218,7 @@ int kk_service_arming_set(char *state)
kk_property_db_update(node->deviceCode);
//dm_msg_thing_property_set_reply(deviceCode->valuestring,payload_Str, strlen(payload_Str), NULL);
dm_msg_ccu_property_post(node);
return res;
}
/************************************************************
*功能描述:收到云端数据后的回调处理
......
......@@ -12,4 +12,5 @@ void IOT_Linkkit_Yield(int timeout_ms);
int IOT_Linkkit_Close(int devid);
int kk_mid_subdev_add(int devType, char productCode[PRODUCT_CODE_MAXLEN], char deviceCode[DEVICE_CODE_MAXLEN],char mac[DEVICE_MAC_MAXLEN],char fatherDeviceCode[DEVICE_CODE_MAXLEN]);
int kk_mid_subdev_batch_add( char productCode[PRODUCT_CODE_MAXLEN], char deviceCode[DEVICE_CODE_MAXLEN],char mac[DEVICE_MAC_MAXLEN],char fatherDeviceCode[DEVICE_CODE_MAXLEN]);
int kk_service_arming_set(char *state);
#endif
......@@ -244,7 +244,7 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
_kk_property_db_lock();
//传感器类默认安防等级为离家安防
if(strcmp(identifier,"SensorType") == 0 && devtype == KK_DM_DEVICE_SUBDEV){
res = dm_mgr_get_device_by_devicecode(deviceCode, &node);
res = dm_mgr_get_device_by_devicecode((char*)deviceCode, &node);
if (res != SUCCESS_RETURN) {
return FAIL_RETURN;
}
......
......@@ -44,7 +44,6 @@ 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_update_value(const char *deviceCode,const char *identifier,const char* value);
int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_data_type_e valuetype,int devtype);
int kk_property_db_update_value(const char *deviceCode,const char *identifier,const char* value);
int kk_property_db_get_value_directly(const char *deviceCode,const char *identifier,char* value);
int kk_property_db_get_value(const char *deviceCode,const char *identifier,void* value);
int kk_property_db_update(const char *deviceCode);
......@@ -57,5 +56,6 @@ int kk_indoorAir_db_insert(const char *deviceCode,const char *identifier,kk_tsl_
int kk_indoorAir_db_update_value(const char *deviceCode,const char *identifier,const char* value,int epNum);
int kk_indoorAir_query_epnums(const char *deviceCode,int epList[]);
int kk_check_property_exist(const char* deviceCode,const char* identifier);
int kk_indoorAir_delete_by_dcode(char deviceCode[DEVICE_CODE_MAXLEN]);
#endif
......@@ -650,7 +650,7 @@ static int _kk_indoor_air_handle(char* deviceCode, char *sceneId, char *property
}
return 0;
}
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_set_action_by_productType(char *productType,char *sceneId,char *propertyName,char *propertyValue,char *type,int delay)
{
int res = 0;
sqlite3_stmt *stmt;
......
......@@ -19,7 +19,7 @@ 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 delay);
int kk_subDev_set_action_by_productType(char *productType,char *sceneId,char *propertyName,char *propertyValue,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);
......
......@@ -23,6 +23,8 @@
#include "kk_area_handle.h"
#include "kk_sub_db.h"
#include "kk_hal.h"
#include "kk_dm_msg.h"
#include "kk_linkkit.h"
extern sqlite3 *g_kk_pDb;
static int kk_check_multi_ep_num(char *deviceCode);
......@@ -217,7 +219,7 @@ static int kk_check_multi_ep_num(char *deviceCode)
propertyStr = (char*)sqlite3_column_text(stmt, DB_IDENTIFITER);
char *propertiesbuf[64] = {0};
int num = 0;
split(propertyStr,"_",propertiesbuf,&num);
kk_split(propertyStr,"_",propertiesbuf,&num);
if(num>=2){
return 1;
}
......@@ -352,7 +354,7 @@ static cJSON *kk_get_properties_info(char *deviceCode,int devType)
//printf("[%s][%d]\n",__FUNCTION__,__LINE__);
char *propertiesbuf[64] = {0};
int num = 0;
split(propertyStr,"_",propertiesbuf,&num);
kk_split(propertyStr,"_",propertiesbuf,&num);
if(num==2){
if(strcmp(propertiesbuf[1],"1") == 0){
if(propertyItem1 == NULL){
......@@ -462,7 +464,7 @@ static cJSON *kk_get_indoor_properties_info(char *deviceCode)
sqlite3_finalize(stmt);
return obj;
}
static int kk_get_properties_info_obj(char *deviceCode)
static cJSON * kk_get_properties_info_obj(char *deviceCode)
{
char *sqlCmd = NULL;
int num = 0;
......@@ -779,7 +781,7 @@ static int kk_get_panel_scenes_actions_info(cJSON *actionItem,int id)
char *propertiesbuf[64] = {0};
int num = 0;
split(propertyName,"_",propertiesbuf,&num);
kk_split(propertyName,"_",propertiesbuf,&num);
if(num==2){
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_PROPERTYNAME_STR, propertiesbuf[0]);
}else{
......@@ -844,7 +846,7 @@ static int kk_get_scenes_actions_info(cJSON *actionArray,int id)
char *propertiesbuf[64] = {0};
int num = 0;
split(propertyName,"_",propertiesbuf,&num);
kk_split(propertyName,"_",propertiesbuf,&num);
if(num==2){
cJSON_AddStringToObject(actionItem, KK_SYNC_SCENE_PROPERTYNAME_STR, propertiesbuf[0]);
cJSON_AddNumberToObject(actionItem, KK_SYNC_SCENE_EPNUM_STR, atoi(propertiesbuf[1]));
......@@ -900,6 +902,7 @@ static int kk_build_repeatday_string(int repeatday,char *repeatStr,int size)
if(pos>0){
repeatStr[pos-1] = '\0';
}
return 0;
}
int kk_is_trigger_timing(char *sceneId)
......@@ -1185,6 +1188,7 @@ static int kk_get_ccu_properties(cJSON *property)
*返 回 值:1:存在;0:不存在
*其他说明:
*************************************************************/
int HAL_Get_ccuid(_OU_ char *device_code);
char *kk_sync_get_info()
{
char *out = NULL;
......
......@@ -182,16 +182,16 @@ cJSON * kk_history_get_sensor_info(void)
cJSON * arrayObj = cJSON_CreateArray();
while(sqlite3_step(stmt) == SQLITE_ROW){
cJSON *infoItem = cJSON_CreateObject();
pDeviceCode = (const char*)sqlite3_column_text(stmt, DB_SENSOR_DEVICECODE);
pDeviceCode = (char*)sqlite3_column_text(stmt, DB_SENSOR_DEVICECODE);
dm_mgr_dev_node_t *search_node = NULL;
res = dm_mgr_get_device_by_devicecode(pDeviceCode,&search_node);
if (res < 0) {
continue;
}
cJSON_AddStringToObject(infoItem, "productCode", search_node->productCode);
pident = (const char*)sqlite3_column_text(stmt, DB_SENSOR_IDENTIFIER);
pident = (char*)sqlite3_column_text(stmt, DB_SENSOR_IDENTIFIER);
cJSON_AddStringToObject(infoItem, "identifier", pident);
pValue = (const char*)sqlite3_column_text(stmt, DB_SENSOR_VALUE);
pValue = (char*)sqlite3_column_text(stmt, DB_SENSOR_VALUE);
cJSON_AddStringToObject(infoItem, "value", pValue);
rtime = sqlite3_column_int(stmt, DB_SENSOR_RECORDTIME);
cJSON_AddNumberToObject(infoItem, "alarm_time", rtime);
......
......@@ -102,8 +102,8 @@ static int _setDevice_Code(_IN_ char *device_code,int len)
}
static int HAL_Ccuid_init(void)
{
uint8_t ccuid[DEVICE_CODE_LEN] = {0};
uint8_t ccuidTmp[DEVICE_CODE_LEN] = {0};
char ccuid[DEVICE_CODE_LEN] = {0};
char ccuidTmp[DEVICE_CODE_LEN] = {0};
int ccuid_len = 0;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)ccuid,sizeof(ccuid),&ccuid_len);
printf("GET_CCUID_CMD:%s\n",ccuid);
......@@ -1390,14 +1390,14 @@ int main(const int argc, const char **argv)
g_timezone = HAL_Get_TimeZone();
mid_ctx->g_mid_dispatch_thread_running = 1;
res = pthread_create(&mid_ctx->g_mid_dispatch_thread, NULL, mid_dispatch_yield, NULL);
res = pthread_create((pthread_t *)&mid_ctx->g_mid_dispatch_thread, NULL, mid_dispatch_yield, NULL);
if (res < 0) {
ERROR_PRINT("HAL_ThreadCreate mid Failed\n");
//IOT_Linkkit_Close(mid_ctx->master_devid);
return -1;
}
mid_ctx->g_ota_dispatch_thread_running = 1;
res = pthread_create(&mid_ctx->g_ota_dispatch_thread, NULL, ota_dispatch_yield, NULL);
res = pthread_create((pthread_t *)&mid_ctx->g_ota_dispatch_thread, NULL, ota_dispatch_yield, NULL);
if (res < 0) {
ERROR_PRINT("HAL_ThreadCreate ota Failed\n");
//IOT_Linkkit_Close(mid_ctx->master_devid);
......@@ -1405,7 +1405,7 @@ int main(const int argc, const char **argv)
}
// recv gateway add cmd and ack to gateway
res = pthread_create(&mid_ctx->g_udp_dispatch_thread, NULL, udp_dispatch_yield, NULL);
res = pthread_create((pthread_t *)&mid_ctx->g_udp_dispatch_thread, NULL, udp_dispatch_yield, NULL);
if (res < 0) {
ERROR_PRINT("HAL_ThreadCreate udp Failed\n");
//IOT_Linkkit_Close(mid_ctx->master_devid);
......@@ -1413,7 +1413,7 @@ int main(const int argc, const char **argv)
}
mid_ctx->g_ccuProChg_dispatch_thread_running = 1;
res = pthread_create(&mid_ctx->g_ccuProChg_dispatch_thread, NULL, ccu_property_monitor, NULL);
res = pthread_create((pthread_t *)&mid_ctx->g_ccuProChg_dispatch_thread, NULL, ccu_property_monitor, NULL);
if (res < 0) {
ERROR_PRINT("HAL_ThreadCreate Failed\n");
return -1;
......
......@@ -2,9 +2,9 @@
*
*/
#include "iotx_ota_internal.h"
#include "com_api.h"
#include "cJSON.h"
#include "iotx_ota.h"
#include "kk_dm_msg.h"
......
......@@ -4,12 +4,13 @@
#ifndef __IOTX_OTA_H__
#define __IOTX_OTA_H__
#include "iotx_ota_internal.h"
int iotx_ota_get_config(void *handle, const char *configScope, const char *getType,
const char *attributeKeys);
int iotx_req_image(void *handle, const char *version);
int ota_callback(void *pcontext, const char *msg, uint32_t msg_len, iotx_ota_topic_types_t type);
#endif /* #ifndef __IOTX_OTA_H__ */
......@@ -15,6 +15,7 @@
#include "infra_sha256.h"
#include "infra_json_parser.h"
#include "ota_api.h"
#include "kk_hal.h"
//#include "iotx_ota_config.h"
//#include "ota_wrapper.h"
......
......@@ -17,11 +17,13 @@
#include "kk_scene_db.h"
#include "kk_sub_db.h"
#include "kk_tsl_load.h"
#include "kk_tsl_parse.h"
#include "kk_dm_api.h"
#include "kk_dm_msg.h"
#include "kk_property_db.h"
#include "kk_hal.h"
#include "kk_log.h"
#include "kk_linkkit.h"
#include <time.h>
......@@ -111,7 +113,7 @@ static int kk_scene_tsl_load(void)
tsl_str = kk_load_json("15", KK_DEVICE_TSL_TYPE);
if(tsl_str != NULL)
{
res = kk_tsl_create(tsl_str,strlen(tsl_str),&s_scene_shadow,&heartTime,&isDormancyDev);
res = kk_tsl_create(tsl_str,strlen(tsl_str),&s_scene_shadow,&heartTime,(int*)&isDormancyDev);
free(tsl_str);
if(res != 0){
return FAIL_RETURN;
......@@ -972,13 +974,13 @@ int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdat
if(delay == NULL) return FAIL_RETURN;
int idelay = delay->valueint;
if(propertyValue->type==cJSON_String){
kk_subDev_set_action_by_productType(productType->valuestring,sceneId,propertyName->valuestring,
kk_subDev_set_action_by_productType(productType->valuestring,(char*)sceneId,propertyName->valuestring,
propertyValue->valuestring,type->valuestring,idelay);
}else{
printf("1111\r\n");
char *str = cJSON_PrintUnformatted(propertyValue);
printf("222\r\n");
kk_subDev_set_action_by_productType(productType->valuestring,sceneId,propertyName->valuestring,
kk_subDev_set_action_by_productType(productType->valuestring,(char*)sceneId,propertyName->valuestring,
str,type->valuestring,idelay);
printf("333\r\n");
free(str);
......@@ -1283,7 +1285,7 @@ int kk_scene_get_quickpanel_info(const char* buttonId,char *deviceCode,char *sce
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);
pSceneId = (char*)sqlite3_column_text(stmt, DB_QUICKPANEL_SCENEID);
*bindType = sqlite3_column_int(stmt, DB_QUICKPANEL_BINDTYPE);
memcpy(sceneId,pSceneId,strlen(pSceneId));
res = SUCCESS_RETURN;
......@@ -1387,6 +1389,7 @@ static time_t kk_scene_creat_new_starttime(time_t starttime,time_t current)
static time_t kk_scene_creat_timer_starttime(int week,int starttime,time_t current)
{
time_t newTime = 0;
time_t res = 0;
char curWeek = 0;
int startNew = 0;
int i = 0;
......@@ -1407,17 +1410,18 @@ static time_t kk_scene_creat_timer_starttime(int week,int starttime,time_t curre
}
if(curWeek & week){
newTime = current + 86400*i;
return kk_scene_creat_new_starttime(startNew,newTime);
res = kk_scene_creat_new_starttime(startNew,newTime);
}else{
return kk_scene_creat_new_starttime(startNew,current);
res = kk_scene_creat_new_starttime(startNew,current);
}
}
}
else
{
return kk_scene_creat_new_starttime(startNew,current);
res = kk_scene_creat_new_starttime(startNew,current);
}
return res;
}
/************************************************************
......@@ -1805,7 +1809,7 @@ static int kk_scene_start_action(const char *deviceCode,const char *propertyName
memcpy(actionInfo->propertyValue,valueS,strlen(valueS));
if(delay == 0){
if(strcmp(propertyName,"ArmingState") == 0){
kk_service_arming_set(valueS);
kk_service_arming_set((char*)valueS);
}else{
kk_scene_send_action_msg(actionInfo);
}
......
......@@ -82,5 +82,7 @@ int kk_scene_parse_updatescene(const cJSON* arg,char *sceneId);
int kk_scene_parse_deletescene(char *sceneId);
int kk_scene_delete_send_to_gw(const char *sceneId);
int kk_scene_parse_scene_action(const cJSON* str,const char *sceneId,int isUpdate);
int kk_scene_execute_quickpanel(const char *buttonId,char *deviceCode);
int kk_scene_action_add(const char *gwdeviceCode,const char *sceneId,kk_scene_action_detail_t detail);
#endif
......@@ -41,7 +41,7 @@ typedef struct kk_timer_list{
} kk_timer_info_t;
static kk_timer_info_t *p_timer_info_list = NULL;
int kk_del_expired_timer_from_list(uint64_t current);
static kk_timer_ctx_t s_kk_timer_ctx = {NULL,NULL,0,0};
static kk_timer_ctx_t *_kk_timer_get_ctx(void)
......@@ -98,7 +98,7 @@ int kk_timer_init(void)
if (ctx->mutex == NULL) {
return FAIL_RETURN;
}
res = pthread_create(&ctx->s_timer_thread, NULL, kk_timer_yield, NULL);
res = pthread_create((pthread_t *)&ctx->s_timer_thread, NULL, kk_timer_yield, NULL);
if (res < 0) {
ERROR_PRINT("HAL_ThreadCreate mid Failed\n");
//IOT_Linkkit_Close(mid_ctx->master_devid);
......
......@@ -42,7 +42,7 @@ extern "C" {
#define _IN_OPT_
#endif
#define NETWORK_ADDR_LEN (16)
//#define NETWORK_ADDR_LEN (16)
#define HAL_MAC_LEN (17 + 1) /* MAC地址的长度 */
#define STR_SHORT_LEN (32)
#ifndef ETH_ALEN
......
......@@ -100,4 +100,5 @@ int kk_tsl_get_event_by_identifier(_IN_ kk_tsl_t *dev_shadow, _IN_ char *identif
int kk_tsl_get_event_method(_IN_ void *event, _OU_ char **method);
int kk_tsl_get_service_by_identifier(_IN_ kk_tsl_t *dev_shadow, _IN_ char *identifier, _OU_ void **service);
int kk_tsl_get_service_method(_IN_ void *service, _OU_ char **method);
void kk_tsl_destroy(_IN_ kk_tsl_t **shadow);
#endif
......@@ -53,11 +53,15 @@ fi
if [ ! -d "$tsl_Dir" ]; then
cp -rf $filepath/tsl ${run_Dir}/
else
if [ ! -f "${run_Dir}/tsl/version" ]; then
cp -rf $filepath/tsl ${run_Dir}/
else
defaultVer=`cat ${filepath}/tsl/version`
curVer=`cat ${run_Dir}/tsl/version`
if [ $defaultVer != $curVer ]; then
cp -rf $filepath/tsl ${run_Dir}/
fi
fi
fi
#if [ ! -d "$map_Dir" ]; then
cp -rf $filepath/map ${run_Dir}/
......
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