Commit d86c9183 authored by 黄振令's avatar 黄振令

【修改内容】1. 把zlog的接口放在公共部分;2. 修改midware和app部分打印

【提交人】huang.zhenling
parent 3ba78763
......@@ -63,7 +63,7 @@ int main(int argc, char* argv[])
int rc = 0;
//KK_Data_Hdl_Init();
kk_zlog_init();
kk_zlog_init("kcloud");
/*set the callback to get the device date to cloud*/
HAL_SetProduct_Type(PRODUCT_TPYE);
......
......@@ -5,7 +5,8 @@
#include "kk_product.h"
#include "cJSON.h"
#include "com_api.h"
#include "kcloud_log.h"
#include "kk_log.h"
const char KK_URI_SYS_PREFIX[] = "/sys/%s/%s/#";
const char KK_URI_SYS_PREFIX_EX[] = "/sys/%s/%s/";
......
#ifndef _MQTT_API_H_
#define _MQTT_API_H_
#include "MQTTAsync.h"
#include "kcloud_log.h"
#include "kk_log.h"
#include "kcloud_config.h"
extern void KK_Data_FromDev(void* str,int len);
......
//=========kk=============
#include "com_api.h"
#include "kk_log.h"
#define APP2MID "ipc:///tmp/app2mid.ipc"
#define PLAT2MID "ipc:///tmp/plat2mid.ipc"
......@@ -31,7 +33,7 @@ pthread_t g_pTh = NULL;
static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
{
printf("watcher_cb !! \r\n\r\n");
INFO_PRINT("watcher_cb !! ");
void *user_data = ev_userdata(loop);
Bloop_ctrl_t *loop_ctrl = (Bloop_ctrl_t *)w->data;
uint8_t *dat = NULL;
......@@ -39,7 +41,7 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
if (bytes <= 0) {
return;
}
printf("watcher_cb:%s recived\r\n\r\n", (char *)dat);
INFO_PRINT("watcher_cb:%s recived\r\n\r\n", (char *)dat);
//for test ipc connect or not
if (loop_ctrl->isconnect == 0 ){
loop_ctrl->isconnect =1;
......@@ -69,7 +71,7 @@ void __loop_init(Bloop_ctrl_t *loop_ctrl, struct ev_loop* loop)
int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type)
{
loop_ctrl->ba.n = nn_socket(AF_SP, NN_PAIR);
printf("__nanomsg_init loop_ctrl->ba.n=%d \r\n",loop_ctrl->ba.n);
INFO_PRINT("__nanomsg_init loop_ctrl->ba.n=%d \r\n",loop_ctrl->ba.n);
if (loop_ctrl->ba.n < 0) {
return -1;
}
......@@ -118,7 +120,7 @@ int __nanomsg_init(Bloop_ctrl_t *loop_ctrl, ipc_type type)
*
==================================*/
void loop_thread(void *arg){
printf("loop_thread start!\r\n");
INFO_PRINT("loop_thread start!\r\n");
ev_run (gloop, 0);
}
......@@ -134,13 +136,13 @@ int kk_ipc_init(ipc_type type, ipc_cb cb)
}
if(loop_ctrl->cb != NULL){
printf("middleware to platform ipc has been inited!\r\n");
WARNING_PRINT("middleware to platform ipc has been inited!\r\n");
return -1;
}
if (__nanomsg_init(loop_ctrl, type) < 0) {
printf("nanomsg init failed\r\n");
ERROR_PRINT("nanomsg init failed\r\n");
return -1;
}
......@@ -148,7 +150,7 @@ int kk_ipc_init(ipc_type type, ipc_cb cb)
if (gloop == NULL){
gloop = ev_loop_new(EVBACKEND_EPOLL);
if (NULL == gloop) {
printf("create loop failed\r\n");
ERROR_PRINT("create loop failed\r\n");
return -1;
}
......@@ -156,7 +158,7 @@ int kk_ipc_init(ipc_type type, ipc_cb cb)
__loop_init(loop_ctrl, gloop);
if (g_pTh ==NULL && 0 != pthread_create(&g_pTh, NULL, loop_thread, NULL)) {
printf("create pthread failed\r\n");
ERROR_PRINT("create pthread failed\r\n");
return -1;
}
......@@ -174,7 +176,7 @@ int kk_ipc_dinit(ipc_type type)
}else if (Mloop_ctrl.type == type){
loop_ctrl = &Mloop_ctrl;
}else{
printf("kk_ipc_dinit failed, no ipc need destroy!\r\n");
ERROR_PRINT("kk_ipc_dinit failed, no ipc need destroy!\r\n");
return -1;
}
......
#include "kcloud_log.h"
#include "kk_log.h"
zlog_category_t *g_zlogC;
int kk_zlog_init(void)
int kk_zlog_init(char* module)
{
int rc;
rc = zlog_init("test.conf");
rc = zlog_init("zlog.conf");
if (rc) {
printf("init failed\n");
......@@ -13,7 +13,7 @@ int kk_zlog_init(void)
}
g_zlogC = zlog_get_category("my_kcloud");
g_zlogC = zlog_get_category(module);
if (!g_zlogC) {
printf("get cat fail\n");
......
......@@ -8,7 +8,7 @@ extern zlog_category_t *g_zlogC;
#define ERROR_PRINT(info,...) zlog_error(g_zlogC, info, ##__VA_ARGS__)
#define WARNING_PRINT(info,...) zlog_warn(g_zlogC, info, ##__VA_ARGS__)
int kk_zlog_init(void);
int kk_zlog_init(char *module);
#endif
......@@ -9,6 +9,7 @@
#include "kk_dm_mng.h"
#include "com_api.h"
#include "dm_ota.h"
#include "kk_log.h"
static dm_api_ctx_t g_dm_api_ctx;
......@@ -156,7 +157,7 @@ void iotx_dm_dispatch(void)
//printf("iotx_dm_dispatch time=%d \n", HAL_UptimeMs());
if (dm_queue_msg_next(&data) == SUCCESS_RETURN) {
//dm_queue_msg_t *msg = (dm_queue_msg_t *)data;
printf("dm_queue_msg_next call \n");
INFO_PRINT("dm_queue_msg_next call \n");
if (ctx->event_callback) {
ctx->event_callback(1, data);
}
......@@ -303,10 +304,10 @@ int iotx_dm_subscribe(_IN_ int devid)
free(buf);
}else{
printf("\n [%d][%s] malloc faild kk_ipc_send \n", __LINE__, __FUNCTION__);
ERROR_PRINT("\n [%d][%s] malloc faild kk_ipc_send \n", __LINE__, __FUNCTION__);
return FAIL_RETURN;
}
printf("\n [%d][%s] [%d] send app to subscribe mqtt \n", __LINE__, __FUNCTION__, HAL_UptimeMs());
INFO_PRINT("\n [%d][%s] [%d] send app to subscribe mqtt \n", __LINE__, __FUNCTION__, HAL_UptimeMs());
......
......@@ -7,6 +7,8 @@
#include "kk_tsl_load.h"
#include "iot_export_linkkit.h"
#include "kk_product.h"
#include "kk_log.h"
//const char DM_URI_SYS_PREFIX[] DM_READ_ONLY = "/sys/%s/%s/";
......@@ -55,7 +57,7 @@ int dm_mgr_search_dev_by_devid(_IN_ int devid, _OU_ dm_mgr_dev_node_t **node)
}
}
printf("Device Not Found, devid: %d", devid);
ERROR_PRINT("Device Not Found, devid: %d", devid);
return FAIL_RETURN;
}
static int _dm_mgr_search_dev_by_pkdn(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
......@@ -77,7 +79,7 @@ static int _dm_mgr_search_dev_by_pkdn(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
}
}
printf("Device Not Found, Product Key: %s, Device Name: %s", product_key, device_name);
ERROR_PRINT("Device Not Found, Product Key: %s, Device Name: %s", product_key, device_name);
return FAIL_RETURN;
}
static int _dm_mgr_next_devid(void)
......@@ -100,7 +102,7 @@ static int _dm_init_tsl_params(int devId)
res = kk_tsl_set_value(kk_tsl_set_property_value,devId,KK_TSL_GATAWAY_VERSION_IDENTIFIER,NULL,version);
if(res != SUCCESS_RETURN)
{
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
/*******set IP*************/
......@@ -108,7 +110,7 @@ static int _dm_init_tsl_params(int devId)
res = kk_tsl_set_value(kk_tsl_set_property_value,devId,KK_TSL_GATAWAY_IP_IDENTIFIER,NULL,s_IP);
if(res != SUCCESS_RETURN)
{
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
/*******set MAC*************/
......@@ -116,7 +118,7 @@ static int _dm_init_tsl_params(int devId)
res = kk_tsl_set_value(kk_tsl_set_property_value,devId,KK_TSL_GATAWAY_MAC_IDENTIFIER,NULL,s_mac);
if(res != SUCCESS_RETURN)
{
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
/*******set port*************/
......@@ -124,7 +126,7 @@ static int _dm_init_tsl_params(int devId)
res = kk_tsl_set_value(kk_tsl_set_property_value,devId,KK_TSL_GATAWAY_PORT_IDENTIFIER,&port,NULL);
if(res != SUCCESS_RETURN)
{
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
/*******set sn*************/
......@@ -132,7 +134,7 @@ static int _dm_init_tsl_params(int devId)
res = kk_tsl_set_value(kk_tsl_set_property_value,devId,KK_TSL_GATAWAY_SN_IDENTIFIER,NULL,s_SN);
if(res != SUCCESS_RETURN)
{
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
return res;
}
......@@ -298,7 +300,7 @@ int dm_mgr_get_device_by_mac(_IN_ char device_mac[DEVICE_MAC_MAXLEN], _OU_ dm_mg
}
}
printf("Device Not Found, device_mac: %s\n", device_mac);
ERROR_PRINT("Device Not Found, device_mac: %s\n", device_mac);
return FAIL_RETURN;
}
......@@ -1003,7 +1005,7 @@ int dm_mgr_subdev_create(_IN_ char product_key[PRODUCT_KEY_MAXLEN],
res = dm_mgr_device_create(KK_DM_DEVICE_SUBDEV,product_key,device_name,device_secret,device_mac, devid);
if(TSL_ALREADY_EXIST == res)
{
printf("SUBDEV ALREADY EXIST!!!\n");
ERROR_PRINT("SUBDEV ALREADY EXIST!!!\n");
}
return res;
}
......@@ -5,6 +5,7 @@
#include "lite-cjson.h"
#include "cJSON.h"
#include "com_api.h"
#include "kk_log.h"
const char DM_MSG_REQUEST[] DM_READ_ONLY = "{\"msgId\":\"%d\",\"version\":\"%s\",\"params\":%.*s,\"method\":\"%s\"}";
......@@ -450,7 +451,7 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
memset(&lite, 0, sizeof(lite_cjson_t));
res = lite_cjson_parse(payload, payload_len, &lite);
if (res < SUCCESS_RETURN) {
printf("Wrong JSON Format, Payload: %s", payload);
ERROR_PRINT("Wrong JSON Format, Payload: %s", payload);
free(req_info);
free(payload);
return FAIL_RETURN;
......@@ -458,7 +459,7 @@ int dm_msg_request (_IN_ dm_msg_request_t *request)
memset(&lite, 0, sizeof(lite_cjson_t));
res = lite_cjson_parse(req_info, req_info_len, &lite);
if (res < SUCCESS_RETURN) {
printf("Wrong JSON Format, Payload: %s", req_info_len);
ERROR_PRINT("Wrong JSON Format, Payload: %s", req_info_len);
free(req_info);
free(payload);
return FAIL_RETURN;
......@@ -482,11 +483,10 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
char *uri = NULL, *payload = NULL;
lite_cjson_t lite;
char *res_info = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if (request == NULL || response == NULL || data == NULL || data_len <= 0) {
return INVALID_PARAMETER;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
/* Response Payload */
payload_len = strlen(DM_MSG_RESPONSE_WITH_DATA) + request->id.value_length + DM_UTILS_UINT32_STRLEN + data_len + 1;
......@@ -495,7 +495,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
free(uri);
return MEMORY_NOT_ENOUGH;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
memset(payload, 0, payload_len);
snprintf(payload, payload_len, DM_MSG_RESPONSE_WITH_DATA,
request->id.value_length, request->id.value, response->code, data_len, data);
......@@ -506,7 +506,7 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
free(payload);
return MEMORY_NOT_ENOUGH;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
memset(res_info, 0, res_info_len);
snprintf(res_info, res_info_len, DM_MSG_INFO, response->msgtype,
response->product_key, response->device_name,response->identity);
......@@ -515,22 +515,20 @@ int dm_msg_response(_IN_ kk_msg_request_payload_t *request, _IN_ kk_msg_response
memset(&lite, 0, sizeof(lite_cjson_t));
res = lite_cjson_parse(payload, payload_len, &lite);
if (res < SUCCESS_RETURN) {
printf("Wrong JSON Format, URI: %s, Payload: %s", uri, payload);
ERROR_PRINT("Wrong JSON Format, URI: %s, Payload: %s", uri, payload);
free(uri);
free(payload);
return FAIL_RETURN;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
memset(&lite, 0, sizeof(lite_cjson_t));
res = lite_cjson_parse(res_info, res_info_len, &lite);
if (res < SUCCESS_RETURN) {
printf("Wrong JSON Format, Payload: %s", res_info_len);
ERROR_PRINT("Wrong JSON Format, Payload: %s", res_info_len);
free(res_info);
free(payload);
return FAIL_RETURN;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
//dm_client_publish(uri, (unsigned char *)payload, strlen(payload), NULL);
kk_sendData2app(res_info, payload);
......@@ -555,18 +553,18 @@ int dm_msg_response_parse(_IN_ char *payload, _IN_ int payload_len, _OU_ dm_msg_
&response->code) != SUCCESS_RETURN ||
kk_utils_json_object_item(&lite, DM_MSG_KEY_DATA, strlen(DM_MSG_KEY_DATA), cJSON_Invalid,
&response->data) != SUCCESS_RETURN) {
printf("Current Request parse faild \n");
ERROR_PRINT("Current Request parse faild \n");
return FAIL_RETURN;
}
printf("Current Request Message ID: %.*s", response->id.value_length, response->id.value);
printf("Current Request Message Code: %d", response->code.value_int);
printf("Current Request Message Data: %.*s", response->data.value_length, response->data.value);
INFO_PRINT("Current Request Message ID: %.*s", response->id.value_length, response->id.value);
INFO_PRINT("Current Request Message Code: %d", response->code.value_int);
INFO_PRINT("Current Request Message Data: %.*s", response->data.value_length, response->data.value);
memset(&lite_message, 0, sizeof(lite_cjson_t));
if (kk_utils_json_object_item(&lite, DM_MSG_KEY_MESSAGE, strlen(DM_MSG_KEY_MESSAGE), cJSON_Invalid,
&response->message) == SUCCESS_RETURN) {
printf("Current Request Message Desc: %.*s", response->message.value_length, response->message.value);
INFO_PRINT("Current Request Message Desc: %.*s", response->message.value_length, response->message.value);
}
return SUCCESS_RETURN;
......@@ -591,10 +589,10 @@ static int dm_msg_request_parse(_IN_ char *payload, _IN_ int payload_len, _OU_ k
return FAIL_RETURN;
}
printf("Current Request Message ID: %.*s", request->id.value_length, request->id.value);
printf("Current Request Message Version: %.*s", request->version.value_length, request->version.value);
printf("Current Request Message Method: %.*s", request->method.value_length, request->method.value);
printf("Current Request Message Params: %.*s", request->params.value_length, request->params.value);
INFO_PRINT("Current Request Message ID: %.*s", request->id.value_length, request->id.value);
INFO_PRINT("Current Request Message Version: %.*s", request->version.value_length, request->version.value);
INFO_PRINT("Current Request Message Method: %.*s", request->method.value_length, request->method.value);
INFO_PRINT("Current Request Message Params: %.*s", request->params.value_length, request->params.value);
return SUCCESS_RETURN;
}
......@@ -611,19 +609,16 @@ int dm_msg_thing_property_set_reply(char product_type[PRODUCT_KEY_MAXLEN], char
memset(&request, 0, sizeof(kk_msg_request_payload_t));
memset(&response, 0, sizeof(kk_msg_response_t));
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
res = dm_mgr_search_device_by_pkdn(product_type, device_name, &devid);
if (res < SUCCESS_RETURN) {
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
ERROR_PRINT("dm_mgr_search_device_by_pkdn failed");
return res;
}
res = dm_msg_request_parse((char *)payload, payload_len, &request);
if (res < SUCCESS_RETURN) {
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
ERROR_PRINT("dm_msg_request_parse failed");
return res ;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
/* Response */
response.msgtype = MSG_SETREPLY;
......
......@@ -9,7 +9,7 @@
#include "kk_dm_msg.h"
#include "kk_dm_api.h"
#include "com_api.h"
#include "kk_log.h"
#define IOTX_LINKKIT_KEY_ID "id"
......@@ -35,9 +35,9 @@
#define IOTX_LINKKIT_KEY_DATA "data"
#define IOTX_LINKKIT_SYNC_DEFAULT_TIMEOUT_MS 10000
#define dm_log_err printf
#define dm_log_debug printf
#define dm_log_info printf
#define dm_log_err ERROR_PRINT
#define dm_log_debug WARNING_PRINT
#define dm_log_info INFO_PRINT
......@@ -124,7 +124,7 @@ static int _iotx_linkkit_upstream_sync_callback_list_insert(int msgid, void *sem
list_for_each_entry(search_node, &ctx->upstream_sync_callback_list, linked_list,
iotx_linkkit_upstream_sync_callback_node_t) {
if (search_node->msgid == msgid) {
printf("Message Already Exist: %d", msgid);
WARNING_PRINT("Message Already Exist: %d", msgid);
return FAIL_RETURN;
}
}
......@@ -140,7 +140,7 @@ static int _iotx_linkkit_upstream_sync_callback_list_insert(int msgid, void *sem
INIT_LIST_HEAD(&search_node->linked_list);
list_add(&search_node->linked_list, &ctx->upstream_sync_callback_list);
printf("New Message, msgid: %d", msgid);
INFO_PRINT("New Message, msgid: %d", msgid);
*node = search_node;
return SUCCESS_RETURN;
......@@ -154,7 +154,7 @@ static int _iotx_linkkit_upstream_sync_callback_list_remove(int msgid)
list_for_each_entry(search_node, &ctx->upstream_sync_callback_list, linked_list,
iotx_linkkit_upstream_sync_callback_node_t) {
if (search_node->msgid == msgid) {
printf("Message Found: %d, Delete It \n", msgid);
INFO_PRINT("Message Found: %d, Delete It \n", msgid);
HAL_SemaphoreDestroy(search_node->semaphore);
list_del(&search_node->linked_list);
free(search_node);
......@@ -178,14 +178,12 @@ int _iotx_linkkit_upstream_sync_callback_list_search(int msgid,
list_for_each_entry(search_node, &ctx->upstream_sync_callback_list, linked_list,
iotx_linkkit_upstream_sync_callback_node_t) {
printf("allan search_node->msgid=%d \n",search_node->msgid);
if (search_node->msgid == msgid) {
dm_log_debug("Sync Message Found: %d", msgid);
*node = search_node;
return SUCCESS_RETURN;
}
}
printf("----------------------allan search_node->msgid=%d \n",search_node->msgid);
return FAIL_RETURN;
}
......@@ -206,13 +204,13 @@ static void _iotx_linkkit_upstream_sync_callback_list_destroy(void)
static void _iotx_linkkit_upstream_callback_remove(int msgid, int code)
{
printf("_iotx_linkkit_upstream_callback_remove : [%d] ,code= %d \n",msgid, code );
INFO_PRINT("_iotx_linkkit_upstream_callback_remove : [%d] ,code= %d \n",msgid, code );
int res = 0;
iotx_linkkit_upstream_sync_callback_node_t *sync_node = NULL;
res = _iotx_linkkit_upstream_sync_callback_list_search(msgid, &sync_node);
if (res == SUCCESS_RETURN) {
sync_node->code = (code == IOTX_DM_ERR_CODE_SUCCESS) ? (SUCCESS_RETURN) : (FAIL_RETURN);
printf("Sync Message %d Result: %d", msgid, sync_node->code);
INFO_PRINT("Sync Message %d Result: %d", msgid, sync_node->code);
HAL_SemaphorePost(sync_node->semaphore);
}
}
......@@ -227,7 +225,7 @@ static void _iotx_linkkit_upstream_callback_remove(int msgid, int code)
static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{
printf("_iotx_linkkit_event_callback ================== [%s]\n",data);
INFO_PRINT("_iotx_linkkit_event_callback ================== [%s]\n",data);
char *out;
int res = 0;
cJSON *json;
......@@ -236,7 +234,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
kk_msg_type_t msgType;
json=cJSON_Parse(data);
if (json == NULL) {
printf("Error before: [%s]\n","cJSON_Parse");
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
return;
}
info_root = cJSON_GetObjectItem(json, MSG_INFO_STR);
......@@ -248,7 +246,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
if (msgType == MSG_REGISTER_REPLY){
//====todo======
//get devicececret and save it
printf(" topic:register_reply \n");
INFO_PRINT(" topic:register_reply \n");
dm_msg_response_payload_t response;
res = dm_msg_response_parse((char *)payload->valuestring, strlen(payload->valuestring)+1, &response);
if (res != SUCCESS_RETURN) {
......@@ -262,7 +260,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
}else if (msgType == MSG_TOPOADD_REPLY){
//====todo======
//
printf(" topic:add_reply \n");
INFO_PRINT(" topic:add_reply \n");
dm_msg_response_payload_t response;
res = dm_msg_response_parse((char *)payload->valuestring, strlen(payload->valuestring)+1, &response);
if (res != SUCCESS_RETURN) {
......@@ -276,7 +274,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
}else if (msgType == MSG_LOGIN_REPLY){
//====todo======
//
printf(" topic:login_reply \n");
INFO_PRINT(" topic:login_reply \n");
dm_msg_response_payload_t response;
res = dm_msg_response_parse((char *)payload->valuestring, strlen(payload->valuestring)+1, &response);
if (res != SUCCESS_RETURN) {
......@@ -287,17 +285,17 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_callback_remove(atoi(response.id.value), response.code.value_int);
_iotx_linkkit_upstream_mutex_unlock();
}else if (msgType == MSG_PROPERTYSET){
printf("property set reply \n");
INFO_PRINT("property set reply \n");
cJSON *product_type = cJSON_GetObjectItem(info, MSG_PRODUCT_TYPE_STR);
cJSON *device_name = cJSON_GetObjectItem(info, MSG_DEVICE_NAME_STR);
dm_msg_thing_property_set_reply(product_type->valuestring, device_name->valuestring,payload->valuestring, strlen(payload->valuestring), NULL);
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}else if (msgType == MSG_OTA_UPGRADE){
printf("ota upgrade... \n");
INFO_PRINT("ota upgrade... \n");
kk_dm_ota_send(data, strlen(data)+1);
}else{
printf("Error 222222222222222 \n");
INFO_PRINT("Error 222222222222222 \n");
}
......@@ -1662,10 +1660,10 @@ int kk_mid_subdev_add(char product_key[PRODUCT_KEY_MAXLEN], char device_name[DEV
res = dm_mgr_subdev_create(product_key,device_name,device_secret,device_mac,&devid);
if (res != SUCCESS_RETURN) {
printf("subdev create Failed\n");
ERROR_PRINT("subdev create Failed\n");
return FAIL_RETURN;
}
printf("subdev open susseed, devid = %d\n", devid);
INFO_PRINT("subdev open susseed, devid = %d\n", devid);
res = kk_subDev_insert_db(0,product_key,device_name,device_secret,device_mac);
if (res != SUCCESS_RETURN) {
......
#include <stdio.h>
#include "kk_tsl_api.h"
#include "kk_sub_db.h"
#include "sqlite3.h"
#include "kk_log.h"
#define KK_SUB_DB_FILE "subDevice.db"
typedef struct {
......@@ -42,11 +43,11 @@ static int kk_subDev_db_Init(void)
if (sqlite3_open_v2(KK_SUB_DB_FILE, &ctx->pDb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) != SQLITE_OK)
{
printf("Error initialising linkage database (%s)", sqlite3_errmsg(ctx->pDb));
ERROR_PRINT("Error initialising linkage database (%s)", sqlite3_errmsg(ctx->pDb));
_kk_subDb_unlock();
return FAIL_RETURN;
}
printf("sub db Database opened\n");
INFO_PRINT("sub db Database opened\n");
{
const char *pSubDevTable = "CREATE TABLE IF NOT EXISTS SubDeviceInfo(idx INTEGER,isOnline INTEGER,product_type varchar(33), device_name varchar(33), device_secret varchar(33),device_mac varchar(17))";
......@@ -56,7 +57,7 @@ static int kk_subDev_db_Init(void)
if (sqlite3_exec(ctx->pDb, pSubDevTable, NULL, NULL, &pcErr) != SQLITE_OK)
{
printf("Error creating table (%s)\n", pcErr);
ERROR_PRINT("Error creating table (%s)\n", pcErr);
sqlite3_free(pcErr);
//eUtils_LockUnlock(&sLock);
_kk_subDb_unlock();
......@@ -78,14 +79,14 @@ static int _kk_load_subDevice(void)
int res = 0;
_kk_subDb_lock();
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
printf("_kk_load_subDevice total_column = %d\n", sqlite3_column_count(stmt));
INFO_PRINT("_kk_load_subDevice total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
res = dm_mgr_subdev_create(sqlite3_column_text(stmt, 2),sqlite3_column_text(stmt, 3),sqlite3_column_text(stmt, 4),
sqlite3_column_text(stmt, 5),&devId);
if(res != SUCCESS_RETURN){
printf("[%s][%d]dm_mgr_subdev_create FAIL!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d]dm_mgr_subdev_create FAIL!!!\n",__FUNCTION__,__LINE__);
}
else{
ctx->subDevNum++;
......@@ -112,7 +113,7 @@ int kk_subDb_init(void)
res = kk_subDev_db_Init();
if(res != SUCCESS_RETURN){
printf("[%s][%d]kk_wlist_db_Init FAIL!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d]kk_wlist_db_Init FAIL!!!\n",__FUNCTION__,__LINE__);
}
_kk_load_subDevice();
......@@ -127,7 +128,7 @@ static int _kk_check_subDev_exist(const char* device_mac)
const char *searchCmd = "select * from SubDeviceInfo;";
_kk_subDb_lock();
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
printf("total_column = %d\n", sqlite3_column_count(stmt));
INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
pmac = sqlite3_column_text(stmt, 5);
if(!strcmp(device_mac,pmac))
......@@ -136,7 +137,7 @@ static int _kk_check_subDev_exist(const char* device_mac)
break;
}
}
printf("\n");
INFO_PRINT("\n");
sqlite3_finalize(stmt);
_kk_subDb_unlock();
return isExist;
......@@ -157,7 +158,7 @@ int kk_subDev_insert_db(int isOnline,char product_type[PRODUCT_KEY_MAXLEN],char
if(_kk_check_subDev_exist((const char*)device_mac) == 1)
{
printf("[%s][%d] DATA ALREADY EXIST!!!\n",__FUNCTION__,__LINE__);
WARNING_PRINT("[%s][%d] DATA ALREADY EXIST!!!\n",__FUNCTION__,__LINE__);
return SUCCESS_RETURN;
}
_kk_subDb_lock();
......@@ -165,10 +166,10 @@ int kk_subDev_insert_db(int isOnline,char product_type[PRODUCT_KEY_MAXLEN],char
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
printf("SQL error: %s\n", zErrMsg);
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
printf("sub device insert data successfully\n");
INFO_PRINT("sub device insert data successfully\n");
}
sqlite3_free(sqlCmd);
ctx->subDevNum++;
......@@ -186,13 +187,13 @@ int kk_subDev_delete_byMac(char device_mac[DEVICE_MAC_MAXLEN])
_kk_subDb_lock();
sqlCmd = sqlite3_mprintf(deleteCmd,device_mac);
printf("Table delete data sqlCmd:%s\n",sqlCmd);
INFO_PRINT("Table delete data sqlCmd:%s\n",sqlCmd);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
printf("SQL error: %s\n", zErrMsg);
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
printf("Table delete data successfully\n");
INFO_PRINT("Table delete data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_subDb_unlock();
......@@ -209,13 +210,13 @@ int kk_subDev_update_online(int isOnline,const char *device_mac)
_kk_subDb_lock();
sqlCmd = sqlite3_mprintf("UPDATE SubDeviceInfo SET isOnline=%d WHERE device_mac=%s",isOnline,device_mac);
printf("kk_subDev_update_online sqlCmd:%s\n",sqlCmd);
INFO_PRINT("kk_subDev_update_online sqlCmd:%s\n",sqlCmd);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
printf("SQL error: %s\n", zErrMsg);
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
printf("Table updata data successfully\n");
INFO_PRINT("Table updata data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_subDb_unlock();
......
......@@ -3,6 +3,8 @@
#include "kk_tsl_api.h"
#include "kk_wlist_mng.h"
#include "sqlite3.h"
#include "kk_log.h"
#define KK_TSL_GATAWAY_ADDWHITELIST_IDENTIFIER "addWhiteList"
#define KK_TSL_GATAWAY_WHITELISTDEVICE_IDENTIFIER "Devices"
......@@ -49,11 +51,11 @@ static int kk_wlist_db_Init(void)
if (sqlite3_open_v2(KK_WLIST_DB_FILE, &ctx->pDb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) != SQLITE_OK)
{
printf("Error initialising linkage database (%s)", sqlite3_errmsg(ctx->pDb));
ERROR_PRINT("Error initialising linkage database (%s)", sqlite3_errmsg(ctx->pDb));
_kk_wlist_unlock();
return FAIL_RETURN;
}
printf("wlist Database opened\n");
INFO_PRINT("wlist Database opened\n");
{
const char *pwListTable = "CREATE TABLE IF NOT EXISTS WhiteList(idx INTEGER, deviceMac varchar(17),productId varchar(33), deviceSN varchar(33), deviceId varchar(33))";
......@@ -63,7 +65,7 @@ static int kk_wlist_db_Init(void)
if (sqlite3_exec(ctx->pDb, pwListTable, NULL, NULL, &pcErr) != SQLITE_OK)
{
printf("Error creating table (%s)\n", pcErr);
ERROR_PRINT("Error creating table (%s)\n", pcErr);
sqlite3_free(pcErr);
//eUtils_LockUnlock(&sLock);
_kk_wlist_unlock();
......@@ -84,7 +86,7 @@ static int _kk_check_exist(const char* device_mac)
kk_wlist_ctx_t *ctx = _kk_wlist_get_ctx();
const char *searchCmd = "select * from WhiteList;";
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
printf("total_column = %d\n", sqlite3_column_count(stmt));
INFO_PRINT("total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
pmac = sqlite3_column_text(stmt, 1);
if(!strcmp(device_mac,pmac))
......@@ -93,7 +95,7 @@ static int _kk_check_exist(const char* device_mac)
break;
}
}
printf("\n");
INFO_PRINT("\n");
sqlite3_finalize(stmt);
return isExist;
......@@ -115,10 +117,10 @@ static int kk_wlist_insert_db(int index,char device_mac[DEVICE_MAC_MAXLEN],char
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
printf("SQL error: %s\n", zErrMsg);
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
printf("Table insert data successfully\n");
INFO_PRINT("Table insert data successfully\n");
}
sqlite3_free(sqlCmd);
_kk_wlist_unlock();
......@@ -135,13 +137,13 @@ static int _kk_wlist_delete_db_byMac(char device_mac[DEVICE_MAC_MAXLEN])
_kk_wlist_lock();
sqlCmd = sqlite3_mprintf( deleteCmd,device_mac);
printf("Table delete data sqlCmd:%s\n",sqlCmd);
INFO_PRINT("Table delete data sqlCmd:%s\n",sqlCmd);
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
printf("SQL error: %s\n", zErrMsg);
ERROR_PRINT("SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}else{
printf("Table delete data successfully\n");
INFO_PRINT("Table delete data successfully\n");
}
sqlite3_free(sqlCmd);
......@@ -155,7 +157,7 @@ int kk_wlist_status_open(int isOpen)
kk_wlist_ctx_t *ctx = _kk_wlist_get_ctx();
res = kk_tsl_set_value(kk_tsl_set_property_value,0,KK_TSL_GATAWAY_WHITELIST_IDENTIFIER,&isOpen,NULL);
if(res != SUCCESS_RETURN){
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
}
ctx->isOpened = 1;
......@@ -173,7 +175,7 @@ int kk_load_wlist(void)
}
sqlite3_prepare_v2(ctx->pDb, searchCmd, strlen(searchCmd), &stmt, NULL);
printf("kk_load_wlist total_column = %d\n", sqlite3_column_count(stmt));
INFO_PRINT("kk_load_wlist total_column = %d\n", sqlite3_column_count(stmt));
while(sqlite3_step(stmt) == SQLITE_ROW){
memset(&wlist,0x0,sizeof(kk_wlist_dev_t));
strcpy(wlist.device_mac,sqlite3_column_text(stmt, 1));
......@@ -201,7 +203,7 @@ int kk_wlist_init(void)
res = kk_wlist_db_Init();
if(res != SUCCESS_RETURN){
printf("[%s][%d]kk_wlist_db_Init FAIL!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d]kk_wlist_db_Init FAIL!!!\n",__FUNCTION__,__LINE__);
}
kk_load_wlist();
......@@ -214,7 +216,7 @@ int kk_set_wlist_byIdx(int idx,kk_wlist_dev_t * wlist_dev)
char identifier_name[64] = {0};
if(wlist_dev == NULL)
{
printf("[%s][%d] wlist_dev == NULL!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] wlist_dev == NULL!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
_kk_wlist_lock();
......@@ -248,7 +250,7 @@ int kk_set_wlist_byIdx(int idx,kk_wlist_dev_t * wlist_dev)
fail_return:
_kk_wlist_unlock();
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
INFO_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
}
......@@ -259,22 +261,22 @@ int kk_add_wlist(kk_wlist_dev_t *wlist_dev)
kk_wlist_ctx_t *ctx = _kk_wlist_get_ctx();
int res = 0;
if(ctx->isOpened != 1){
printf("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
if(ctx->wlistNum >= 512){
printf("[%s][%d] WHITELIST FULL!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] WHITELIST FULL!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
if(wlist_dev == NULL){
printf("[%s][%d] wlist_dev == NULL!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] wlist_dev == NULL!!!\n",__FUNCTION__,__LINE__);
return INVALID_PARAMETER;
}
if(_kk_check_exist(wlist_dev->device_mac) == 1)
{
printf("[%s][%d] DATA ALREADY EXIST!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] DATA ALREADY EXIST!!!\n",__FUNCTION__,__LINE__);
return SUCCESS_RETURN;
}
res = kk_wlist_insert_db(ctx->wlistNum,wlist_dev->device_mac,wlist_dev->product_id,wlist_dev->device_sn,wlist_dev->device_id);
......@@ -288,7 +290,7 @@ int kk_get_wlist_num(void)
kk_wlist_ctx_t *ctx = _kk_wlist_get_ctx();
if(ctx->isOpened != 1)
{
printf("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
return ctx->wlistNum;
......@@ -340,7 +342,7 @@ int kk_getwlist_ByIdx(int idx,kk_wlist_dev_t* wlist_dev)
fail_return:
_kk_wlist_unlock();
printf("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
INFO_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
return FAIL_RETURN;
}
......@@ -353,12 +355,12 @@ int kk_get_wlistIdx_byMac(const char* device_mac)
int idx = 0,findIdx = 0;
if(ctx->isOpened != 1)
{
printf("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
if(idx >= 512)
{
printf("[%s][%d]Invalid idx!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d]Invalid idx!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
......@@ -374,7 +376,7 @@ int kk_get_wlistIdx_byMac(const char* device_mac)
if(!strcmp(device_mac,pmac))
{
findIdx = idx;
printf("[%s][%d]find the delete index\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d]find the delete index\n",__FUNCTION__,__LINE__);
_kk_wlist_unlock();
return findIdx;
}
......@@ -396,7 +398,7 @@ static int _kk_delete_wlist_byIdx(int idx)
if(idx >= 512)
{
printf("[%s][%d]Invalid idx!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d]Invalid idx!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
......@@ -419,7 +421,7 @@ int kk_delete_wlist_byMac(const char* device_mac)
int findIdx = 0;
if(ctx->isOpened != 1)
{
printf("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
ERROR_PRINT("[%s][%d] PLEASE OPNE THE WHITELIST FUNCTION FIRST!!!\n",__FUNCTION__,__LINE__);
return FAIL_RETURN;
}
......
......@@ -15,6 +15,7 @@
#include "kk_product.h"
#include "kk_tsl_common.h"
#include "kk_dm_api.h"
#include "kk_log.h"
......@@ -112,7 +113,7 @@ void kk_platMsg_handle(void* data){
json=cJSON_Parse(data);
if (!json) {
printf("Error before: [%s]\n","cJSON_Parse");
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
}
else{
method = cJSON_GetObjectItem(json, "method");
......@@ -123,15 +124,15 @@ void kk_platMsg_handle(void* data){
proType = cJSON_GetObjectItem(jsonPay, "productType");
proCode = cJSON_GetObjectItem(jsonPay, "productCode");
printf("productType productCode mac: [%s][%s] [%s] \n",proType->valuestring, proCode->valuestring, mac->valuestring);
INFO_PRINT("productType productCode mac: [%s][%s] [%s] \n",proType->valuestring, proCode->valuestring, mac->valuestring);
kk_mid_subdev_add(proType->valuestring,proCode->valuestring,"", mac->valuestring);
}else if (method != NULL && mac != NULL){
printf("save property and send to cloud \n");
INFO_PRINT("save property and send to cloud \n");
kk_tsl_property_set_byMac(mac->valuestring, data, strlen(data)+1);
}else{
printf("kk_platMsg_handle data: don't handle it [%s]\n",data);
INFO_PRINT("kk_platMsg_handle data: don't handle it [%s]\n",data);
//kk_tsl_service_property_set(topic->valuestring, payload->valuestring, strlen(payload->valuestring), NULL);
}
......@@ -148,7 +149,7 @@ void kk_platMsg_dispatch(void)
if (dm_queue_msg_next2(&data) == SUCCESS_RETURN) {
//dm_queue_msg_t *msg = (dm_queue_msg_t *)data;
printf("kk_handle_platMsg_dispatch get call \n");
INFO_PRINT("kk_handle_platMsg_dispatch get call \n");
if (kk_platMsg_handle) {
kk_platMsg_handle( data);
}
......@@ -230,8 +231,8 @@ int main(const int argc, const char **argv)
int res = 0;
mid_ctx_t *mid_ctx = kk_mid_get_ctx();
kk_zlog_init("midware");
memset(mid_ctx, 0, sizeof(mid_ctx_t));
kk_set_product_info();
......@@ -257,14 +258,14 @@ int main(const int argc, const char **argv)
mid_ctx->g_mid_dispatch_thread_running = 1;
res = pthread_create(&mid_ctx->g_mid_dispatch_thread, NULL, mid_dispatch_yield, NULL);
if (res < 0) {
printf("HAL_ThreadCreate Failed\n");
ERROR_PRINT("HAL_ThreadCreate 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);
if (res < 0) {
printf("HAL_ThreadCreate Failed\n");
ERROR_PRINT("HAL_ThreadCreate Failed\n");
IOT_Linkkit_Close(mid_ctx->master_devid);
return -1;
}
......
......@@ -3,6 +3,8 @@
#include "kk_tsl_load.h"
#include "kk_dm_mng.h"
#include "kk_dm_msg.h"
#include "kk_log.h"
typedef enum {
KK_MSG_PROPERTY_SET,
......@@ -299,7 +301,7 @@ static int _kk_msg_set_numberOrStr(kk_msg_set_type_t type, int devid, char *key,
}
break;
default:
printf("Unkonwn Number Type");
ERROR_PRINT("Unkonwn Number Type");
break;
}
......@@ -483,10 +485,10 @@ static int _kk_msg_request_parse(_IN_ char *payload, _IN_ int payload_len, _OU_
return FAIL_RETURN;
}
printf("Current Request Message ID: %.*s", request->id.value_length, request->id.value);
printf("Current Request Message Version: %.*s", request->version.value_length, request->version.value);
printf("Current Request Message Method: %.*s", request->method.value_length, request->method.value);
printf("Current Request Message Params: %.*s", request->params.value_length, request->params.value);
INFO_PRINT("Current Request Message ID: %.*s", request->id.value_length, request->id.value);
INFO_PRINT("Current Request Message Version: %.*s", request->version.value_length, request->version.value);
INFO_PRINT("Current Request Message Method: %.*s", request->method.value_length, request->method.value);
INFO_PRINT("Current Request Message Params: %.*s", request->params.value_length, request->params.value);
return SUCCESS_RETURN;
}
......@@ -1114,7 +1116,7 @@ int kk_tsl_get_value(kk_tsl_get_t method_get, int devId, const char *identifier,
kk_tsl_api_ctx_t *kk_tsl_api_ctx = _kk_tsl_api_get_ctx();
if ( identifier == NULL || (value == NULL && value_str == NULL)) {
printf("Invalid Parameter");
ERROR_PRINT("Invalid Parameter");
return FAIL_RETURN;
}
......@@ -1140,7 +1142,7 @@ int kk_tsl_get_value(kk_tsl_get_t method_get, int devId, const char *identifier,
}
break;
default: {
printf("Invalid Parameter");
ERROR_PRINT("Invalid Parameter");
res = FAIL_RETURN;
}
break;
......@@ -1164,7 +1166,7 @@ int kk_tsl_set_value(kk_tsl_set_t set, int devId, const char *identifier,
kk_tsl_api_ctx_t *kk_tsl_api_ctx = _kk_tsl_api_get_ctx();
if ( identifier == NULL || (value == NULL && value_str == NULL)) {
printf("Invalid Parameter");
ERROR_PRINT("Invalid Parameter");
return FAIL_RETURN;
}
......@@ -1186,7 +1188,7 @@ int kk_tsl_set_value(kk_tsl_set_t set, int devId, const char *identifier,
}
break;
default: {
printf("Invalid Parameter");
ERROR_PRINT("Invalid Parameter");
res = FAIL_RETURN;
}
break;
......@@ -1479,7 +1481,7 @@ static int kk_tsl_post_property_end(_IN_ void *handle)
free(dapi_property);
return MEMORY_NOT_ENOUGH;
}
printf("Post Payload, Length: %d, Payload: %s\n", strlen(payload), payload);
INFO_PRINT("Post Payload, Length: %d, Payload: %s\n", strlen(payload), payload);
res = dm_mgr_upstream_thing_property_post(dapi_property->devid, payload, strlen(payload));
lite_cjson_delete(dapi_property->lite);
free(dapi_property);
......@@ -1512,7 +1514,7 @@ int kk_tsl_post_property(int devId, const char *property_identifier)
_kk_tsl_api_unlock();
return FAIL_RETURN;
}
printf("\n[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_tsl_api_unlock();
return SUCCESS_RETURN;
}
......@@ -1636,7 +1638,7 @@ static int _kk_tsl_post_event(_IN_ int devid, _IN_ char *identifier, _IN_ int id
return MEMORY_NOT_ENOUGH;
}
printf("\nCurrent Event Post Payload, Length: %d, Payload: %s\n", strlen(payload), payload);
INFO_PRINT("\nCurrent Event Post Payload, Length: %d, Payload: %s\n", strlen(payload), payload);
res = kk_tsl_get_event_by_identifier(devid, identifier, &event);
if (res != SUCCESS_RETURN) {
......@@ -1650,7 +1652,7 @@ static int _kk_tsl_post_event(_IN_ int devid, _IN_ char *identifier, _IN_ int id
return FAIL_RETURN;
}
printf("Current Event Method: %s", method);
INFO_PRINT("Current Event Method: %s", method);
res = dm_mgr_upstream_thing_event_post(devid, identifier, identifier_len, method, payload, strlen(payload));
......@@ -1713,7 +1715,7 @@ static int _kk_tsl_send_service_response(_IN_ int devid, _IN_ int msgid, _IN_ io
return MEMORY_NOT_ENOUGH;
}
printf("Current Service Response Payload, Length: %d, Payload: %s", strlen(payload), payload);
INFO_PRINT("Current Service Response Payload, Length: %d, Payload: %s", strlen(payload), payload);
res = dm_mgr_deprecated_upstream_thing_service_response(devid, msgid, code, identifier, identifier_len, payload,
strlen(payload));
......@@ -1729,7 +1731,7 @@ int kk_tsl_post_service(int devId, const char *service_identifier, int response_
kk_tsl_api_ctx_t *kk_tsl_api_ctx = _kk_tsl_api_get_ctx();
if (service_identifier == NULL) {
printf("Invalid Parameter");
ERROR_PRINT("Invalid Parameter");
return FAIL_RETURN;
}
......
......@@ -2,6 +2,8 @@
#include <string.h>
#include <stdio.h>
#include "kk_tsl_common.h"
#include "kk_log.h"
#define TSL_PATH_FILE "/home/tsl/%s.json"
char* kk_load_json(const char *product_type)
......@@ -19,20 +21,20 @@ char* kk_load_json(const char *product_type)
}
memset(tslPath,0x0,path_len);
snprintf(tslPath,path_len,TSL_PATH_FILE,product_type);
printf("\n[%s][%d]tslPath:%s!!!\n",__FUNCTION__,__LINE__,tslPath);
INFO_PRINT("\n[%s][%d]tslPath:%s!!!\n",__FUNCTION__,__LINE__,tslPath);
if(!(fp = fopen(tslPath,"a+")))
{
printf("can't open the file account.txt\n");
ERROR_PRINT("can't open the file account.txt\n");
free(tslPath);
return NULL;
}
fseek(fp, 0L, SEEK_END);
filesize = ftell(fp);
printf("filesize :%d\n",filesize);
INFO_PRINT("filesize :%d\n",filesize);
buf = malloc(filesize+1);
if(buf == NULL)
{
printf("MALLOC FAIL!!!\n");
ERROR_PRINT("MALLOC FAIL!!!\n");
free(tslPath);
return NULL;
......
......@@ -30,7 +30,7 @@ normal = "%d %m%n"
[rules]
my_.INFO >stdout; normal
*.INFO >stdout; normal
*.* "/home/kk/share/%c.log", 1MB*2; normal
......
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