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

Merge branch 'cwc' into 'master'

Cwc

See merge request chenweican/k-sdk!96
parents 5336a238 be597969
......@@ -27,7 +27,32 @@
#include "com_api.h"
#include "kk_product.h"
//#include "kcloud_log.h"
static char s_ccuid[DEVICE_CODE_LEN] = {0};
int KK_Get_ccuid(_OU_ char *device_code)
{
strncpy(device_code, s_ccuid, strlen(s_ccuid));
printf("HAL_Get_ccuid:%s\n",s_ccuid);
return strlen(s_ccuid);
}
static int _setDevice_Code(_IN_ char *device_code,int len)
{
memset(s_ccuid, 0x0, DEVICE_CODE_LEN);
printf("_setDevice_Code:%s\n",device_code);
strncpy(s_ccuid, device_code, len);
return len;
}
static void KK_Ccuid_init(void)
{
uint8_t ccuid[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);
if(ccuid_len > 0 && ccuid_len <= DEVICE_CODE_LEN){
_setDevice_Code(ccuid,ccuid_len-1);
}else{
_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
}
}
static int mqtt_start(void)
{
int count = 0;
......@@ -63,6 +88,7 @@ int main(int argc, char* argv[])
int rc = 0;
open("kcloud",LOG_PID,LOG_USER);
/*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();
again:
......
......@@ -46,7 +46,7 @@ static int kk_info_get(char *str)
}
HAL_GetVersion(version);
memcpy(ccuid,KK_CCU_ID,strlen(KK_CCU_ID));
KK_Get_ccuid(ccuid);
cJSON *root = cJSON_CreateObject();
if (root)
{
......
......@@ -20,27 +20,7 @@
#define BUFSIZE 1024
#define PRODUCTSECRET "123456"
int kk_execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len)
{
if(cmd == NULL || buf == NULL || buf_len == 0)
{
printf("arg error\n");
return -1;
}
memset(buf,0,buf_len);
FILE *fp = NULL;
fp = popen(cmd,"r");
while(fgets(buf,buf_len,fp)!=NULL){
printf("%s return %s",cmd,buf);
}
pclose (fp);
*ret_len = strlen(buf);
return 0;
}
int kk_parse_deviceSecret(char *info){
FILE *fp;
if(info == NULL){
......@@ -205,14 +185,16 @@ static char * kk_create_register_info()
unsigned char sign_hex[32] = {0};
char sign_hex_str[65] = {0};
uint8_t productSecret[64] = {0};
char ccuid[32] = {0};
int productSecret_len = 0;
root=cJSON_CreateObject();
HAL_Get_mac(mac);
HAL_GetTime_s(ramdonId);
cJSON_AddStringToObject(root, "deviceCode", KK_CCU_ID);
KK_Get_ccuid(ccuid);
cJSON_AddStringToObject(root, "deviceCode", ccuid);
cJSON_AddStringToObject(root, "productCode",productCode);
signSource = kk_dictionary_order(KK_CCU_ID,productCode,KK_CCU_RANDOM);
kk_execel_cmd(GET_KEY_CMD,(char *)productSecret,sizeof(productSecret),&productSecret_len);
signSource = kk_dictionary_order(ccuid,productCode,KK_CCU_RANDOM);
HAL_Execel_cmd(GET_KEY_CMD,(char *)productSecret,sizeof(productSecret),&productSecret_len);
if(productSecret_len == 0){
utils_hmac_sha256((const uint8_t *)signSource, strlen(signSource), (const uint8_t *)PRODUCTSECRET, strlen(PRODUCTSECRET), sign_hex);
}else{
......@@ -247,10 +229,12 @@ static char * kk_create_get_jwt_info()
char *out = NULL;
char timestamp[16] = {0};
char deviceSecret[64] = {0};
char ccuid[32] = {0};
HAL_GetTime_s(timestamp);
sprintf(g_clientId, CLIENTID, KK_CCU_ID,timestamp);
KK_Get_ccuid(ccuid);
sprintf(g_clientId, CLIENTID, ccuid,timestamp);
root=cJSON_CreateObject();
cJSON_AddStringToObject(root, "deviceCode", KK_CCU_ID);
cJSON_AddStringToObject(root, "deviceCode", ccuid);
cJSON_AddStringToObject(root, "productCode",KK_CCU_PRODUCTID);
cJSON_AddStringToObject(root, "clientId",g_clientId);
fp = fopen("/usr/kk/kk_deviceSecret.txt", "r");
......
......@@ -115,10 +115,12 @@ int KK_CCU_TOPIC_Subscribe(void)
INFO_PRINT("[%s][%d] already Subscribe\n",__FUNCTION__,__LINE__);
return -1;
}
char ccuid[32] = {0};
KK_Get_ccuid(ccuid);
s_ccu_topic_sub = 1;
HAL_GetProduct_Code(productCode);
HAL_Get_mac(deviceCode);
return _kk_ccu_topic_subscribe(productCode,KK_CCU_ID);
return _kk_ccu_topic_subscribe(productCode,ccuid);
}
static int _kk_utils_topic(_IN_ const char *name, _IN_ char *product_code,
......
......@@ -206,7 +206,9 @@ MQTTAsync KK_MQTT_Connect(void)
fclose(fp);
}
HAL_Get_mac(mac);
sprintf(usrname, "%s.%s", KK_CCU_ID,KK_CCU_PRODUCTID);
char ccuid[32] = {0};
KK_Get_ccuid(ccuid);
sprintf(usrname, "%s.%s", ccuid,KK_CCU_PRODUCTID);
printf("cliendid:%s,usrname:%s\n",g_clientId,usrname);
printf("------------>token:%s\n",token);
if ((rc = MQTTAsync_createWithOptions(&s_Client, ADDRESS, g_clientId, MQTTCLIENT_PERSISTENCE_NONE, NULL,&opts)) != MQTTASYNC_SUCCESS)
......
......@@ -176,9 +176,11 @@ static int kk_loginccu_ack(cJSON *arg,int sockfd)
if(arg == NULL){
return -1;
}
char ccuid[32] = {0};
kk_lan_get_ccuid(ccuid);
zkid = cJSON_GetObjectItem(arg, ZKID_STRING);
if(zkid != NULL){
if(strstr(KK_CCU_ID,zkid->valuestring) != NULL){
if(strstr(ccuid,zkid->valuestring) != NULL){
root=cJSON_CreateObject();
if(root){
args = cJSON_CreateObject();
......
......@@ -26,12 +26,14 @@ static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
if(addr == NULL || sockfd < 0){
return -1;
}
char ccuid[32] = {0};
kk_lan_get_ccuid(ccuid);
json=cJSON_CreateObject();
if(json){
args = cJSON_CreateObject();
if(args){
cJSON_AddItemToObject(json, "arg", args);
cJSON_AddStringToObject(args, "zkid", KK_CCU_ID);
cJSON_AddStringToObject(args, "zkid", ccuid);
cJSON_AddStringToObject(args, "zk", KK_CCU_NAME);
HAL_Get_IP(s_IP,NULL);
cJSON_AddStringToObject(args, "ip", s_IP);
......
......@@ -28,7 +28,32 @@
//#include "kk_lan_queue.h"
#include "kk_lan_node_db.h"
static char s_ccuid[DEVICE_CODE_LEN] = {0};
int kk_lan_get_ccuid(_OU_ char *device_code)
{
strncpy(device_code, s_ccuid, strlen(s_ccuid));
printf("kk_lan_get_ccuid:%s\n",s_ccuid);
return strlen(s_ccuid);
}
static int _setDevice_Code(_IN_ char *device_code,int len)
{
memset(s_ccuid, 0x0, DEVICE_CODE_LEN);
printf("_setDevice_Code:%s\n",device_code);
strncpy(s_ccuid, device_code, len);
return len;
}
static void kk_lan_ccuid_init(void)
{
uint8_t ccuid[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);
if(ccuid_len > 0 && ccuid_len <= DEVICE_CODE_LEN){
_setDevice_Code(ccuid,ccuid_len-1);
}else{
_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
}
}
static void sig_handler(int sig)
{
printf("Received signal: %d\n", sig);
......@@ -44,6 +69,7 @@ int main(int argc, char* argv[])
int rc = 0;
char *ppp;
open("kk_lan",LOG_PID,LOG_USER);
kk_lan_ccuid_init();
ttttt_test();
kk_scene_build_test();
/*set the callback to get the device date to cloud*/
......
......@@ -81,10 +81,10 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
//ERROR_PRINT("nn_recv failed with error code %d, %s \n", nn_errno(), nn_strerror(nn_errno ()));
return;
}
//INFO_PRINT("watcher_cb:-------------------------\n");
dat_bak = malloc(bytes+1);
if(dat_bak != NULL){
memset(dat_bak,0x0,bytes);
memset(dat_bak,0x0,bytes+1);
memcpy(dat_bak,dat,bytes);
cJSON_Minify((char *)dat_bak);
INFO_PRINT("watcher_cb:%s\n", (char*)dat_bak);
......@@ -125,7 +125,6 @@ void __loop_init(Bloop_ctrl_t *loop_ctrl, struct ev_loop* loop)
loop_ctrl->watcher.data = loop_ctrl;
if (loop_ctrl->type == IPC_PLAT2MID || loop_ctrl->type == IPC_APP2MID){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
ev_io_init (&(loop_ctrl->watcher), watcher_cb, loop_ctrl->ab.s, EV_READ);
}else{
ev_io_init (&(loop_ctrl->watcher), watcher_cb, loop_ctrl->ba.s, EV_READ);
......
#ifndef _LOGDEF_H_
#ifndef _LOGDEF_H_
#define _LOGDEF_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <syslog.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/prctl.h>
#include <sys/time.h>
#include <semaphore.h>
#include <errno.h>
#include <assert.h>
#include <net/if.h> // struct ifreq
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/reboot.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
static int g_enable_printf = 1;
#define LOG_STRING(level) ((level == LOG_EMERG) ? "EMERG " : \
(level == LOG_ALERT) ? "ALERT " : \
(level == LOG_CRIT) ? "CRIT " : \
(level == LOG_ERR) ? "ERR " : \
(level == LOG_WARNING) ? "WARNING " : \
(level == LOG_NOTICE) ? "NOTICE " : \
(level == LOG_INFO) ? "INFO " : \
(level == LOG_DEBUG) ? "DEBUG " : "NONE ")
#define KK_LOG(level,fmt,args...) do {\
time_t t; \
t = time(NULL); \
struct tm ptm; \
memset(&ptm, 0, sizeof(ptm)); \
localtime_r(&t, &ptm); \
syslog(level,"%s %4d-%02d-%02d %02d:%02d:%02d [%s:%d]:" fmt ,LOG_STRING(level), \
ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour,ptm.tm_min, ptm.tm_sec,\
__FILE__,__LINE__,##args);\
if(g_enable_printf == 1){\
printf("%s %4d-%02d-%02d %02d:%02d:%02d [%s:%d]:" fmt ,LOG_STRING(level), \
ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour,ptm.tm_min, \
ptm.tm_sec,__FILE__,__LINE__,##args);\
}}while(0)
#define DEBUG_PRINT(info,args...) do { \
syslog(LOG_DEBUG, "[%s][%d]"info,__FUNCTION__,__LINE__ ,##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#define INFO_PRINT(info,args...) do { \
syslog(LOG_INFO, "[%s][%d]"info,__FUNCTION__,__LINE__ , ##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#define ERROR_PRINT(info,args...) do { \
syslog(LOG_ERR, "[%s][%d]"info,__FUNCTION__,__LINE__ , ##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#define WARNING_PRINT(info,args...) do { \
syslog(LOG_WARNING, "[%s][%d]"info,__FUNCTION__,__LINE__ , ##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#define DEBUG_PRINT(fmt, args...) KK_LOG(LOG_DEBUG, fmt, ##args)
#define INFO_PRINT(fmt, args...) KK_LOG(LOG_INFO, fmt, ##args)
#define ERROR_PRINT(fmt, args...) KK_LOG(LOG_ERR, fmt, ##args)
#define WARNING_PRINT(fmt, args...) KK_LOG(LOG_WARNING, fmt, ##args)
#ifdef __cplusplus
}
#endif
#endif
......@@ -32,10 +32,30 @@
#include "com_api.h"
char g_product_type[PRODUCT_TYPE_LEN]={0};
char g_product_code[PRODUCT_CODE_LEN]={0};
char g_device_code[DEVICE_CODE_LEN] = {0};
#define PLATFORM_WAIT_INFINITE (~0)
int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len)
{
if(cmd == NULL || buf == NULL || buf_len == 0)
{
printf("arg error\n");
return -1;
}
memset(buf,0,buf_len);
FILE *fp = NULL;
fp = popen(cmd,"r");
while(fgets(buf,buf_len,fp)!=NULL){
printf("%s return %s",cmd,buf);
}
pclose (fp);
*ret_len = strlen(buf);
return 0;
}
void *HAL_Malloc(_IN_ uint32_t size)
{
return malloc(size);
......@@ -255,20 +275,6 @@ int HAL_SetProduct_Code(_IN_ char *product_code)
}
int HAL_SetDevice_Code(_IN_ char *device_code)
{
int len = strlen(device_code);
if (len > DEVICE_CODE_LEN) {
return -1;
}
memset(g_device_code, 0x0, DEVICE_CODE_LEN);
strncpy(g_device_code, device_code, len);
return len;
}
int HAL_GetProduct_Code(_OU_ char *product_code)
{
strncpy(product_code, KK_CCU_PRODUCTID, strlen(KK_CCU_PRODUCTID));
......@@ -276,12 +282,8 @@ int HAL_GetProduct_Code(_OU_ char *product_code)
return strlen(KK_CCU_PRODUCTID);
}
int HAL_GetDevice_Code(_OU_ char *device_code)
{
strncpy(device_code, KK_CCU_ID, strlen(KK_CCU_ID));
device_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));
......@@ -747,6 +749,8 @@ uint32_t HAL_Get_IP(char ip_str[NETWORK_ADDR_LEN], const char *ifname)
return ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr.s_addr;
}
#if 0
static kv_file_t *kvfile = NULL;
......
......@@ -37,4 +37,9 @@ void HAL_MutexDestroy(_IN_ void *mutex);
int HAL_GetVersion(_OU_ char *version);
int HAL_Get_mac(char* mac);
int HAL_Get_SN(char sn[SN_ADDR_LEN]);
int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
int HAL_SetProduct_Type(_IN_ char *product_type);
int HAL_SetProduct_Code(_IN_ char *product_code);
int HAL_GetProduct_Code(_OU_ char *product_code);
#endif
......@@ -37,17 +37,13 @@
#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"
enum {
DEVICE_OFFLINE = 0,
DEVICE_ONLINE,
DEVICE_UNKNOW,
};
int HAL_SetProduct_Type(_IN_ char *product_type);
int HAL_SetProduct_Code(_IN_ char *product_code);
int HAL_SetDevice_Code(_IN_ char *device_code);
int HAL_GetProduct_Code(_OU_ char *product_code);
int HAL_GetDevice_Code(_OU_ char *device_code);
......
......@@ -530,7 +530,9 @@ int dm_mgr_init(void)
{
int res = 0;
dm_mgr_ctx *ctx = _dm_mgr_get_ctx();
char mac[DEVICE_MAC_MAXLEN]= {0};
char mac[DEVICE_MAC_MAXLEN]= {0};
char ccuid[32] = {0};
int devId = 0,heartbeat = 0;
memset(ctx, 0, sizeof(dm_mgr_ctx));
......@@ -542,19 +544,19 @@ int dm_mgr_init(void)
/* Init Device Id*/
ctx->global_devid = 1;
kk_property_db_init();
HAL_Get_ccuid(ccuid);
/* Init Device List */
INIT_LIST_HEAD(&ctx->dev_list);
HAL_Get_mac(mac);
kk_sync_init();
//kk_sync_get_info();
res = dm_mgr_device_create(KK_DM_DEVICE_CCU,KK_DM_CCU_DEVICE_PRODUCT_CODE,KK_CCU_ID,mac,"",KK_DEV_UNKNOW,&devId,&heartbeat);
res = dm_mgr_device_create(KK_DM_DEVICE_CCU,KK_DM_CCU_DEVICE_PRODUCT_CODE,ccuid,mac,"",KK_DEV_UNKNOW,&devId,&heartbeat);
if (res != SUCCESS_RETURN) {
goto ERROR;
}
else{
kk_property_db_update(KK_CCU_ID);
kk_property_db_update(ccuid);
}
......@@ -1105,7 +1107,7 @@ int dm_mgr_upstream_thing_topo_get(void)
memset(&request, 0, sizeof(dm_msg_request_t));
request.msgTypeStr = (char*)DM_URI_THING_TOPO_GET;
HAL_GetDevice_Code(request.deviceCode);
HAL_Get_ccuid(request.deviceCode);
res = _dm_mgr_search_dev_by_pkdn(request.deviceCode, &node);
......
......@@ -929,6 +929,7 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
_iotx_linkkit_upstream_mutex_unlock();
}else if (strstr(typeJson->valuestring,KK_THING_SERVICE_PROPERTY_SET)){
INFO_PRINT("property set \n");
char ccuid[32] = {0};
dm_mgr_dev_node_t *node = NULL;
cJSON *paramStr = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
cJSON *state = cJSON_GetObjectItem(paramStr, KK_TSL_CCU_ARMINGSTATE_IDENTIFIER);
......@@ -939,12 +940,14 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
kk_property_db_update(KK_CCU_ID);
HAL_Get_ccuid(ccuid);
kk_property_db_update(ccuid);
//dm_msg_thing_property_set_reply(deviceCode->valuestring,payload_Str, strlen(payload_Str), NULL);
dm_msg_ccu_property_post(node);
}
}else if (strstr(typeJson->valuestring,KK_THING_CLOUDSTATE_MSG)){
INFO_PRINT("cloud state notify \n");
char ccuid[32] = {0};
s_CloudStatusRecv = 1;
cJSON *paramStr = cJSON_GetObjectItem(payload, MSG_PARAMS_STR);
cJSON *state = cJSON_GetObjectItem(paramStr, MSG_IOTClOUDSTATE_STR);
......@@ -963,8 +966,8 @@ static void _iotx_linkkit_event_callback(iotx_dm_event_types_t type, char *data)
{
ERROR_PRINT("[%s][%d] res:%d\n",__FUNCTION__,__LINE__,res);
}
kk_property_db_update(KK_CCU_ID);
HAL_Get_ccuid(ccuid);
kk_property_db_update(ccuid);
if(s_CloudStatus){
node->isOffline = KK_DEV_ONLINE;
......
......@@ -189,7 +189,12 @@ int kk_property_db_insert(const char *deviceCode,const char *identifier,kk_tsl_d
return SUCCESS_RETURN;
}
_kk_property_db_lock();
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"",valuetype,devtype);
//传感器类默认安防等级为离家安防
if(strcmp(identifier,"SensorType") == 0 && devtype == KK_DM_DEVICE_SUBDEV){
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"1",valuetype,devtype);
}else{
sqlCmd = sqlite3_mprintf(insertCmd,deviceCode,identifier,"",valuetype,devtype);
}
rc = sqlite3_exec(ctx->pDb, sqlCmd, NULL, NULL, &zErrMsg);
if( rc != SQLITE_OK ){
......
......@@ -466,7 +466,7 @@ char *kk_sync_get_info()
kk_get_rooms_info(data);
kk_get_devices_info(data);
kk_get_scenes_info(data);
HAL_GetDevice_Code(ccu_deviceCode);
HAL_Get_ccuid(ccu_deviceCode);
HAL_GetProduct_Code(ccu_productCode);
HAL_GetVersion(version);
cJSON_AddStringToObject(data, KK_SYNC_DEVICECODE_STR,ccu_deviceCode);
......
......@@ -61,6 +61,32 @@ char * g_filerToPlatTable[] =
(char *){KK_THING_SERVICE_NEGATIVE},
(char *){KK_THING_SERVICE_SYNCINFO},
};
static char s_ccuid[DEVICE_CODE_LEN] = {0};
int HAL_Get_ccuid(_OU_ char *device_code)
{
strncpy(device_code, s_ccuid, strlen(s_ccuid));
printf("HAL_Get_ccuid:%s\n",s_ccuid);
return strlen(s_ccuid);
}
static int _setDevice_Code(_IN_ char *device_code,int len)
{
memset(s_ccuid, 0x0, DEVICE_CODE_LEN);
printf("_setDevice_Code:%s\n",device_code);
strncpy(s_ccuid, device_code, len);
return len;
}
static void HAL_Ccuid_init(void)
{
uint8_t ccuid[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);
if(ccuid_len > 0 && ccuid_len <= DEVICE_CODE_LEN){
_setDevice_Code(ccuid,ccuid_len-1);
}else{
_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
}
}
/************************************************************
*功能描述:过滤不需要下发给网关的消息
*输入参数:msgtype:消息类型
......@@ -520,7 +546,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
//判断网关还是子设备
if (strcmp(info_dcode->valuestring, devCode->valuestring) == 0){
char ccu_deviceCode[DEVICE_CODE_MAXLEN] = {0};
HAL_GetDevice_Code(ccu_deviceCode);
HAL_Get_ccuid(ccu_deviceCode);
kk_mid_subdev_add(KK_DM_DEVICE_GATEWAY,proCode->valuestring,devCode->valuestring, mac->valuestring,ccu_deviceCode);
cJSON * sceneSupportStr = cJSON_GetObjectItem(jsonPay, MSG_SCENE_SUPPORT);
if(sceneSupportStr != NULL&&!strcmp(sceneSupportStr->valuestring,"1")){
......@@ -963,7 +989,7 @@ void *udp_dispatch_yield(void *args){
memset(mac, 0, sizeof(mac));
memset(szOut, 0, sizeof(szOut));
HAL_Get_IP(host_ip,NULL);
HAL_GetDevice_Code(device_code);
HAL_Get_ccuid(device_code);
// printf("[%s][%d]inet_ntoa(from.sin_addr):%s\n",__FUNCTION__,__LINE__,inet_ntoa(from.sin_addr));
// printf("[%s][%d]host_ip:%s\n",__FUNCTION__,__LINE__,host_ip);
// if(strcmp(inet_ntoa(from.sin_addr),host_ip) == 0){
......@@ -1090,7 +1116,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_init();
kk_sqlite_init();
kk_tsl_api_init();
kk_ipc_init(IPC_MID2APP, mid_cb, NULL, NULL);
......
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