Commit 8fcfbe3a authored by 陈伟灿's avatar 陈伟灿

Merge branch 'yjq' into 'master'

20210713:问题

See merge request chenweican/k-sdk!88
parents 3533b5b2 8fd421e1
......@@ -8,8 +8,11 @@ CFLAGS += -I$(TOP_DIR)/common/api
CFLAGS += -I$(TOP_DIR)/common/json
CFLAGS += -I$(TOP_DIR)/common/nanomsg/include
CFLAGS += -I$(TOP_DIR)/common/ev/include
CFLAGS += -I$(TOP_DIR)/common/sqlite
LDFLAGS += -lkk_tsl
LDFLAGS += -lapi_com
LDFLAGS += -lsqlite -ldl
ifeq ($(CONFIG_MODEL),x86)
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -lnanomsg_ubuntu
LDFLAGS += -L$(TOP_DIR)/common/ev -lev_ubuntu
......
......@@ -15,60 +15,62 @@
#include "kk_opcode.h"
#include "com_api.h"
#include "kk_data_mng.h"
#include "kk_lan_ctrl.h"
const char DM_MSG_TO_MIDDWARE[] = "{\"msgtype\":\"%s\",\"productCode\":\"%s\",\"deviceCode\":\"%s\"}";
char *strrpl(char *in, char *out, int outlen, char *src, char *dst)
{
char *p = in;
unsigned int len = outlen - 1;
// 这几段检查参数合法性
if((NULL == src) || (NULL == dst) || (NULL == in) || (NULL == out))
{
return NULL;
}
if((strcmp(in, "") == 0) || (strcmp(src, "") == 0))
{
return NULL;
}
if(outlen <= 0)
{
return NULL;
}
while((*p != '\0') && (len > 0))
{
if(strncmp(p, src, strlen(src)) != 0)
{
int n = strlen(out);
char *p = in;
unsigned int len = outlen - 1;
// 这几段检查参数合法性
if((NULL == src) || (NULL == dst) || (NULL == in) || (NULL == out))
{
return NULL;
}
if((strcmp(in, "") == 0) || (strcmp(src, "") == 0))
{
return NULL;
}
if(outlen <= 0)
{
return NULL;
}
while((*p != '\0') && (len > 0))
{
if(strncmp(p, src, strlen(src)) != 0)
{
int n = strlen(out);
out[n] = *p;
out[n + 1] = '\0';
out[n] = *p;
out[n + 1] = '\0';
p++;
len--;
}
else
{
strcat(out, dst);
p += strlen(src);
len -= strlen(dst);
}
}
return out;
p++;
len--;
}
else
{
strcat(out, dst);
p += strlen(src);
len -= strlen(dst);
}
}
return out;
}
static char * _kk_data_create(char *msgtype,const char *productCode,const char *deviceCode,const char *param)
{
cJSON *root;
cJSON *payload;
cJSON* infoObj;
cJSON *payload;
cJSON* infoObj;
char *out;
char *infoStr = NULL;
int infoStr_len = 0;
int res = 0;
char method[128] = {0};
char method[128] = {0};
strrpl(msgtype+1,method,sizeof(method),"/",".");
printf("method:%s\n",method);
strrpl(msgtype+1,method,sizeof(method),"/",".");
printf("method:%s\n",method);
infoStr_len = strlen(DM_MSG_TO_MIDDWARE)+strlen(productCode)+strlen(deviceCode)+strlen(msgtype)+10;
infoStr = malloc(infoStr_len);
if(infoStr == NULL){
......@@ -79,17 +81,17 @@ static char * _kk_data_create(char *msgtype,const char *productCode,const char *
snprintf(infoStr,infoStr_len,DM_MSG_TO_MIDDWARE,msgtype,productCode,deviceCode);
root=cJSON_CreateObject();
infoObj = cJSON_Parse(infoStr);
cJSON_AddItemToObject(root, MSG_INFO_STR, infoObj);
payload = cJSON_CreateObject();
if(payload){
cJSON_AddItemToObject(root, MSG_PAYLOAD_STR, payload);
cJSON_AddStringToObject(payload, "msgId", "*");
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "method", method);
cJSON_AddStringToObject(payload, "params", param);
}
infoObj = cJSON_Parse(infoStr);
cJSON_AddItemToObject(root, MSG_INFO_STR, infoObj);
payload = cJSON_CreateObject();
if(payload){
cJSON_AddItemToObject(root, MSG_PAYLOAD_STR, payload);
cJSON_AddStringToObject(payload, "msgId", "*");
cJSON_AddStringToObject(payload, "version", "1.0");
cJSON_AddStringToObject(payload, "method", method);
cJSON_AddStringToObject(payload, "params", param);
}
out=cJSON_Print(root);
cJSON_Minify(out);
cJSON_Delete(root);
......@@ -99,319 +101,506 @@ static char * _kk_data_create(char *msgtype,const char *productCode,const char *
return out;
//free(out); /* Print to text, Delete the cJSON, print it, release the string. */
}
static void kk_handle_sync_info(void)
void kk_handle_sync_info(void)
{
char *send_data = NULL;
send_data = _kk_data_create(SYNC_MSG_TYPE,"*","*","*");
if(send_data == NULL){
char *send_data = NULL;
send_data = _kk_data_create(SYNC_MSG_TYPE,"*","*","*");
if(send_data == NULL){
return;
}
printf("kk_ipc_send........%s \n",send_data);
kk_ipc_send(IPC_APP2MID, send_data, strlen(send_data)+1);
free(send_data);
}
static int kk_send_ack(cJSON *root,int sockfd)
{
char *out = NULL;
char *tmpBuf = NULL;
out=cJSON_Print(root);
cJSON_Minify((char*)out);
tmpBuf = calloc(strlen(out) + 4,1);
if(tmpBuf == NULL){
cJSON_Delete(root);
free(out);
return -1;
}
strcat(tmpBuf,"!");
strcat(tmpBuf,out);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
send(sockfd, tmpBuf, strlen(tmpBuf), 0);
cJSON_Delete(root);
free(out);
free(tmpBuf);
return 0;
char *out = NULL;
char *tmpBuf = NULL;
out=cJSON_Print(root);
cJSON_Minify((char*)out);
tmpBuf = calloc(strlen(out) + 4,1);
if(tmpBuf == NULL){
free(out);
return -1;
}
strcat(tmpBuf,"!");
strcat(tmpBuf,out);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
send(sockfd, tmpBuf, strlen(tmpBuf), 0);
free(out);
free(tmpBuf);
return 0;
}
static int _kk_send_data_to_sdk(char *nodeid,char *opcode,char *arg)
static int _kk_send_data_to_sdk(char *nodeid,char *opcode,cJSON *arg)
{
cJSON *root;
char *out = NULL;
root=cJSON_CreateObject();
if(root){
cJSON_AddStringToObject(root, "nodeid", nodeid);
cJSON_AddStringToObject(root, "opcode", opcode);
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddStringToObject(root, "arg", arg);
out=cJSON_Print(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("out:%s\n",out);
cJSON_Minify((char*)out);
kk_send_data_to_sdk(out);
}
free(arg);
cJSON_Delete(root);
return 0;
cJSON *root;
char *out = NULL;
root=cJSON_CreateObject();
if(root){
cJSON_AddStringToObject(root, "nodeid", nodeid);
cJSON_AddStringToObject(root, "opcode", opcode);
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddItemToObject(root,"arg",arg);
out=cJSON_Print(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("out:%s\n",out);
cJSON_Minify((char*)out);
kk_send_data_to_sdk(out);
}
cJSON_Delete(root);
return 0;
}
static int kk_heartbeat_ack(int sockfd)
{
cJSON *root;
root=cJSON_CreateObject();
if(root){
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", HEARTBEAT_OPCODE);
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddStringToObject(root, "arg", "*");
kk_send_ack(root,sockfd);
}
cJSON_Delete(root);
return 0;
cJSON *root;
root=cJSON_CreateObject();
if(root){
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", HEARTBEAT_OPCODE);
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddStringToObject(root, "arg", "*");
kk_send_ack(root,sockfd);
}
cJSON_Delete(root);
return 0;
}
static int kk_loginccu_ack(cJSON *arg,int sockfd)
{
cJSON *zkid;
cJSON *root;
cJSON *args;
char *out = NULL;
char *tmpBuf = NULL;
if(arg == NULL){
return -1;
}
zkid = cJSON_GetObjectItem(arg, ZKID_STRING);
if(zkid != NULL){
if(strstr(KK_CCU_ID,zkid->valuestring) != NULL){
root=cJSON_CreateObject();
if(root){
args = cJSON_CreateObject();
if(args){
cJSON_AddItemToObject(root, "arg", args);
cJSON_AddStringToObject(args, "error_code", "0");
cJSON_AddStringToObject(args, "seq", "");
cJSON_AddStringToObject(args, "zkid", zkid->valuestring);
}
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", LOGIN_OPCODE);
cJSON_AddStringToObject(root, "status", "success");
kk_send_ack(root,sockfd);
}
cJSON_Delete(root);
}
}else{
ERROR_PRINT("data error...\n");
return -1;
}
return 0;
cJSON *zkid;
cJSON *root;
cJSON *args;
char *out = NULL;
char *tmpBuf = NULL;
if(arg == NULL){
return -1;
}
zkid = cJSON_GetObjectItem(arg, ZKID_STRING);
if(zkid != NULL){
if(strstr(KK_CCU_ID,zkid->valuestring) != NULL){
root=cJSON_CreateObject();
if(root){
args = cJSON_CreateObject();
if(args){
cJSON_AddItemToObject(root, "arg", args);
cJSON_AddStringToObject(args, "error_code", "0");
cJSON_AddStringToObject(args, "seq", "");
cJSON_AddStringToObject(args, "zkid", zkid->valuestring);
}
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", LOGIN_OPCODE);
cJSON_AddStringToObject(root, "status", "success");
kk_send_ack(root,sockfd);
}
cJSON_Delete(root);
}
}else{
ERROR_PRINT("data error...\n");
return -1;
}
return 0;
}
int kk_data_handle(cJSON *json,int sockfd)
//构建hw信息
static cJSON *kk_zb_dev_hw_info_build(const char *deviceCode,cJSON * productCode,cJSON * online,const char *hw_ver,const char *sw_ver)
{
cJSON *opcode;
cJSON *arg;
opcode = cJSON_GetObjectItem(json, OPCODE_STRING);
if(opcode != NULL){
if(strcmp(opcode->valuestring,LOGIN_OPCODE) == 0){
arg = cJSON_GetObjectItem(json, ARG_STRING);
kk_loginccu_ack(arg,sockfd);
}else if(strcmp(opcode->valuestring,HEARTBEAT_OPCODE) == 0){
kk_heartbeat_ack(sockfd);
}else if(strcmp(opcode->valuestring,SYNC_OPCODE) == 0){
kk_handle_sync_info();
}
}
return 0;
cJSON *item;
char mac[32] = {0};
int online_status = 0;
int pid;
if(mac==NULL){
return NULL;
}
item = cJSON_CreateObject();
if(item){
if(hw_ver!=NULL){
cJSON_AddStringToObject(item, "hardware_version", hw_ver);
}else{
cJSON_AddStringToObject(item, "hardware_version", "");
}
_deviceCode_switchto_mac(deviceCode,mac);
if(online==0){
online_status = 1; //在线
}else if(online==1){
online_status = 2; //离线
}else{
online_status = 0; //未知
}
pid = atoi(productCode);
cJSON_AddStringToObject(item, "mac", mac);
cJSON_AddNumberToObject(item, "online_status",online_status);
cJSON_AddNumberToObject(item, "product_id", pid);
if(hw_ver!=NULL){
cJSON_AddStringToObject(item, "version", sw_ver);
}else{
cJSON_AddStringToObject(item, "version", "");
}
}
return item;
}
static void _kk_zb_devs_hw_ack(int sockfd,cJSON *arg)
{
cJSON *root;
root=cJSON_CreateObject();
if(root){
cJSON_AddStringToObject(root, "nodeid", "*");
cJSON_AddStringToObject(root, "opcode", GET_ZB_DEVS_HW_INFO_OPCODE);
cJSON_AddStringToObject(root, "status", "success");
cJSON_AddItemToObject(root, "arg", arg);
kk_send_ack(root,sockfd);
}
cJSON_Delete(root);
}
int kk_zb_devs_hw_ack_all(int sockfd)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
kk_map_dev_node_t *search_node = NULL;
cJSON *array = cJSON_CreateArray();
cJSON *item;
list_for_each_entry(search_node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if((item = kk_zb_dev_hw_info_build(search_node->deviceCode,search_node->productCode,search_node->online_status,NULL,NULL))!=NULL){
cJSON_AddItemToArray(array,item);
}
}
_kk_zb_devs_hw_ack(sockfd,array);
return -1;
}
int kk_zb_dev_hw_info_build_by_deviceCode(int sockfd,const char *deviceCode)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
kk_map_dev_node_t *search_node = NULL;
cJSON *item;
unsigned char online_status = 0;
int pid =-1;
list_for_each_entry(search_node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if ( (strlen(search_node->deviceCode) == strlen(deviceCode)) &&
(memcmp(search_node->deviceCode, deviceCode, strlen(deviceCode)) == 0)) {
item = kk_zb_dev_hw_info_build(search_node->deviceCode,search_node->productCode,search_node->online_status,NULL,NULL);
return item;
}
}
return NULL;
}
static void kk_zb_devs_hw_ack(int sockfd,cJSON *conditions)
{
int i,size;
cJSON *type;
cJSON *arg;
char devCode[33] ={0};
type = cJSON_GetObjectItem(conditions,"condition_type");
if(type==NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_zb_devs_hw_ack_all(sockfd);
}else{
if(strcmp(type->valuestring,"dev_list")){
WARNING_PRINT("[type err]%s,%s\n",type->valuestring,"dev_list");
return ;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
arg = cJSON_GetObjectItem(conditions,"condition_arg");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
size = cJSON_GetArraySize(arg);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *qMac;
cJSON *item;
cJSON *array = cJSON_CreateArray();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
for(i=0;i<size;i++){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
qMac=cJSON_GetArrayItem(arg,1);
if(mac_switchto_deviceCode(qMac->valuestring,devCode)==0){
if((item=kk_zb_dev_hw_info_build_by_deviceCode(sockfd,devCode))!=NULL){
cJSON_AddItemToArray(array,item);
}
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_zb_devs_hw_ack(sockfd,array);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
}
return 0;
}
int kk_data_handle(cJSON *json,int sockfd)
{
cJSON *opcode;
cJSON *arg;
opcode = cJSON_GetObjectItem(json, OPCODE_STRING);
if(opcode != NULL){
if(strcmp(opcode->valuestring,LOGIN_OPCODE) == 0){
arg = cJSON_GetObjectItem(json, ARG_STRING);
kk_loginccu_ack(arg,sockfd);
}else if(strcmp(opcode->valuestring,HEARTBEAT_OPCODE) == 0){
kk_heartbeat_ack(sockfd);
}else if(strcmp(opcode->valuestring,SYNC_OPCODE) == 0){
kk_handle_sync_info();
}else if(strcmp(opcode->valuestring,GET_ZB_DEVS_HW_INFO_OPCODE) == 0){
cJSON *conditions = cJSON_GetObjectItem(json, OPCODE_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_zb_devs_hw_ack(sockfd,conditions);
}else{
kk_ccu_opcode_handle(json);
}
}
return 0;
}
static int kk_parse_syncinfo(cJSON *payload)
{
cJSON *paramStr,*dataStr;
cJSON *gwdevices,*subdevices;
cJSON * gwitem,*properties;
char *gwdevicecode;
char *deviceCode,*productCode;
char *identifier,*valuetype;
cJSON * subitem;
cJSON * newccuItem;
cJSON *valuejson;
int value;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_map_dev_node_t *node = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
paramStr = cJSON_GetObjectItem(payload, DATA_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(paramStr == NULL) return -1;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
dataStr = cJSON_GetObjectItem(paramStr, DATA_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(dataStr == NULL) return -1;
gwdevices = cJSON_GetObjectItem(dataStr, DEVICES_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(gwdevices == NULL) return -1;
gwitem = gwdevices->child;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
while(gwitem != NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
subdevices = cJSON_GetObjectItem(gwitem,DEVICES_STRING);
gwdevicecode = cJSON_GetObjectItem(gwitem,MSG_DEVICE_CODE_STR)->valuestring;
if(subdevices != NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
subitem = subdevices->child;
while(subitem != NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
deviceCode = cJSON_GetObjectItem(subitem,MSG_DEVICE_CODE_STR)->valuestring;
productCode = cJSON_GetObjectItem(subitem,MSG_PRODUCT_CODE_STR)->valuestring;
properties = cJSON_GetObjectItem(subitem,MSG_PROPERTIES_STR);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node = kk_map_dev_add(deviceCode,productCode,gwdevicecode);
if(node != NULL && node->newccu != NULL){
newccuItem = node->newccu->child;
while(newccuItem != NULL){
identifier = cJSON_GetObjectItem(newccuItem,MSG_INDENTIFIER_STR)->valuestring;
valuetype = cJSON_GetObjectItem(newccuItem,MSG_INDENTIFIER_STR)->valuestring;
valuejson = cJSON_GetObjectItem(properties,identifier);
if(valuejson != NULL){
if(strcmp(valuetype,"bool") == 0 || strcmp(valuetype,"int") == 0){
value = valuejson->valueint;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_map_dev_update_int_value(node,identifier,value);
}
}
newccuItem = newccuItem->next;
}
}
subitem = subitem->next;
}
}
gwitem = gwitem->next;
}
return 0;
cJSON *paramStr,*dataStr;
cJSON *gwdevices,*subdevices;
cJSON * gwitem,*properties;
cJSON *onlineStatus;
char *gwdevicecode;
char *deviceCode,*productCode;
char *identifier,*valuetype;
cJSON * subitem;
cJSON * newccuItem;
cJSON *valuejson;
int value;
printf("\n\n\n00000000000000000000000000000000000000\n\n\n");
kk_map_dev_deinit();
printf("\n\n\n11111111111111111111111111111111111\n\n\n");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_map_dev_node_t *node = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
paramStr = cJSON_GetObjectItem(payload, DATA_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(paramStr == NULL) return -1;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
dataStr = cJSON_GetObjectItem(paramStr, DATA_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(dataStr == NULL) return -1;
gwdevices = cJSON_GetObjectItem(dataStr, DEVICES_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(gwdevices == NULL) return -1;
gwitem = gwdevices->child;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("\n\n222222222222222222222222222222222\n\n\n");
while(gwitem != NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
subdevices = cJSON_GetObjectItem(gwitem,DEVICES_STRING);
gwdevicecode = cJSON_GetObjectItem(gwitem,MSG_DEVICE_CODE_STR)->valuestring;
if(subdevices != NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
subitem = subdevices->child;
while(subitem != NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
deviceCode = cJSON_GetObjectItem(subitem,MSG_DEVICE_CODE_STR)->valuestring;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
productCode = cJSON_GetObjectItem(subitem,MSG_PRODUCT_CODE_STR)->valuestring;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
onlineStatus = cJSON_GetObjectItem(subitem,MSG_ONLINE_STATUS_STR);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
properties = cJSON_GetObjectItem(subitem,MSG_PROPERTIES_STR);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node = kk_map_dev_add(deviceCode,productCode,gwdevicecode,onlineStatus->valuestring);
property_syn_deal(deviceCode,properties);
subitem = subitem->next;
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
gwitem = gwitem->next;
}
printf("\n\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n\n\n");
return 0;
}
static int kk_create_floors_to_sdk(cJSON *root)
{
cJSON *floors = cJSON_CreateArray();
cJSON *floorItem = cJSON_CreateObject();
cJSON_AddStringToObject(floorItem, "floor_icon", "");
cJSON_AddStringToObject(floorItem, "floor_pos", "1");
cJSON_AddStringToObject(floorItem, "id", "1");
cJSON_AddStringToObject(floorItem, "name", "一楼");
cJSON_AddItemToArray(floors, floorItem);
cJSON_AddItemToObject(root, "floors", floors);
return 0;
cJSON *floors = cJSON_CreateArray();
cJSON *floorItem = cJSON_CreateObject();
cJSON_AddStringToObject(floorItem, "floor_icon", "");
cJSON_AddStringToObject(floorItem, "floor_pos", "1");
cJSON_AddStringToObject(floorItem, "id", "1");
cJSON_AddStringToObject(floorItem, "name", "一楼");
cJSON_AddItemToArray(floors, floorItem);
cJSON_AddItemToObject(root, "floors", floors);
return 0;
}
static int kk_create_roominfo_to_sdk(cJSON *root)
{
cJSON *rooms = cJSON_CreateArray();
cJSON *roomsItem = cJSON_CreateObject();
cJSON *room_status;
cJSON_AddStringToObject(roomsItem, "floor_id", "1");
cJSON_AddStringToObject(roomsItem, "id", "1");
cJSON_AddStringToObject(roomsItem, "room_icon", "");
cJSON_AddStringToObject(roomsItem, "name", "卧室");
room_status = cJSON_CreateObject();
cJSON_AddItemToObject(roomsItem, "room_status", room_status);
cJSON_AddItemToArray(rooms, roomsItem);
cJSON_AddItemToObject(root, "rooms", rooms);
return 0;
cJSON *rooms = cJSON_CreateArray();
cJSON *roomsItem = cJSON_CreateObject();
cJSON *room_status;
cJSON_AddStringToObject(roomsItem, "floor_id", "1");
cJSON_AddStringToObject(roomsItem, "id", "1");
cJSON_AddStringToObject(roomsItem, "room_icon", "");
cJSON_AddStringToObject(roomsItem, "name", "卧室");
room_status = cJSON_CreateObject();
cJSON_AddItemToObject(roomsItem, "room_status", room_status);
cJSON_AddItemToArray(rooms, roomsItem);
cJSON_AddItemToObject(root, "rooms", rooms);
return 0;
}
static int kk_create_scene_to_sdk(cJSON *root)
{
cJSON *scenes = cJSON_CreateArray();
cJSON_AddItemToObject(root, "scenes", scenes);
return 0;
cJSON *scenes = cJSON_CreateArray();
cJSON_AddItemToObject(root, "scenes", scenes);
return 0;
}
int kk_create_syncinfo_to_sdk(void)
{
cJSON *air_box_devices;
cJSON *alarms;
cJSON *ccu_link_status;
cJSON *link_arg;
cJSON *ccu_version;
cJSON *central_ac_gws;
cJSON *central_ac_indoorunits;
cJSON *cnwise_music_controllers;
cJSON *code_lib_controllers;
cJSON *controllers;
cJSON *expand_rules;
cJSON *group;
cJSON *guard;
cJSON *gw_version;
char *out = NULL;
cJSON *root=cJSON_CreateObject();
cJSON *aiks_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "aiks_controllers", aiks_controllers);
air_box_devices = cJSON_CreateArray();
cJSON_AddItemToObject(root, "air_box_devices", air_box_devices);
alarms = cJSON_CreateArray();
cJSON_AddItemToObject(root, "alarms", alarms);
ccu_link_status = cJSON_CreateObject();
link_arg = cJSON_CreateObject();
cJSON_AddItemToObject(ccu_link_status, "link_arg", link_arg);
cJSON_AddStringToObject(ccu_link_status, "link_type", "broadband_net");
cJSON_AddItemToObject(root, "ccu_link_status", ccu_link_status);
ccu_version = cJSON_CreateObject();
cJSON_AddStringToObject(ccu_version, "cur_ccu_version", "1.0.0");
cJSON_AddStringToObject(ccu_version, "downloaded_ccu_version", "1.0.0");
cJSON_AddItemToObject(root, "ccu_version", ccu_version);
central_ac_gws = cJSON_CreateArray();
cJSON_AddItemToObject(root, "central_ac_gws", central_ac_gws);
central_ac_indoorunits = cJSON_CreateArray();
cJSON_AddItemToObject(root, "central_ac_indoorunits", central_ac_indoorunits);
cnwise_music_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "cnwise_music_controllers", cnwise_music_controllers);
code_lib_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "code_lib_controllers", code_lib_controllers);
controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "controllers", controllers);
kk_create_devicestatus_to_sdk(root);
kk_create_devices_to_sdk(root);
#if 1
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
expand_rules = cJSON_CreateArray();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "expand_rules", expand_rules);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_create_floors_to_sdk(root);
group = cJSON_CreateArray();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "group", group);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
guard = cJSON_CreateObject();
cJSON_AddItemToObject(root, "guard", guard);
gw_version = cJSON_CreateObject();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "gw_version", gw_version);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_create_roominfo_to_sdk(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_create_scene_to_sdk(root);
#endif
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
out=cJSON_Print(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("out:%s\n",out);
cJSON_Minify((char*)out);
_kk_send_data_to_sdk("*","*",out);
return 0;
cJSON *air_box_devices;
cJSON *alarms;
cJSON *ccu_link_status;
cJSON *link_arg;
cJSON *ccu_version;
cJSON *central_ac_gws;
cJSON *central_ac_indoorunits;
cJSON *cnwise_music_controllers;
cJSON *code_lib_controllers;
cJSON *controllers;
cJSON *expand_rules;
cJSON *group;
cJSON *guard;
cJSON *gw_version;
char *out = NULL;
cJSON *root=cJSON_CreateObject();
cJSON *aiks_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "aiks_controllers", aiks_controllers);
air_box_devices = cJSON_CreateArray();
cJSON_AddItemToObject(root, "air_box_devices", air_box_devices);
alarms = cJSON_CreateArray();
cJSON_AddItemToObject(root, "alarms", alarms);
ccu_link_status = cJSON_CreateObject();
link_arg = cJSON_CreateObject();
cJSON_AddItemToObject(ccu_link_status, "link_arg", link_arg);
cJSON_AddStringToObject(ccu_link_status, "link_type", "broadband_net");
cJSON_AddItemToObject(root, "ccu_link_status", ccu_link_status);
ccu_version = cJSON_CreateObject();
cJSON_AddStringToObject(ccu_version, "cur_ccu_version", "1.0.0");
cJSON_AddStringToObject(ccu_version, "downloaded_ccu_version", "1.0.0");
cJSON_AddItemToObject(root, "ccu_version", ccu_version);
central_ac_gws = cJSON_CreateArray();
cJSON_AddItemToObject(root, "central_ac_gws", central_ac_gws);
central_ac_indoorunits = cJSON_CreateArray();
cJSON_AddItemToObject(root, "central_ac_indoorunits", central_ac_indoorunits);
cnwise_music_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "cnwise_music_controllers", cnwise_music_controllers);
code_lib_controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "code_lib_controllers", code_lib_controllers);
controllers = cJSON_CreateArray();
cJSON_AddItemToObject(root, "controllers", controllers);
kk_create_devicestatus_to_sdk(root);
kk_create_devices_to_sdk(root);
#if 1
expand_rules = cJSON_CreateArray();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "expand_rules", expand_rules);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_create_floors_to_sdk(root);
group = cJSON_CreateArray();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "group", group);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
guard = cJSON_CreateObject();
cJSON_AddItemToObject(root, "guard", guard);
gw_version = cJSON_CreateObject();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddItemToObject(root, "gw_version", gw_version);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_create_roominfo_to_sdk(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_create_scene_to_sdk(root);
#endif
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
out=cJSON_Print(root);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("out:%s\n",out);
_kk_send_data_to_sdk("*","SYNC_INFO",root);
return 0;
}
void KK_Data_FromMid(void* str,int len)
{
cJSON *json;
cJSON *info_root;
cJSON *payload,*typeJson;
cJSON *json;
cJSON *info_root;
cJSON *payload,*typeJson;
cJSON *deviceCode;
printf("str:%s\n",str);
printf("[midware->lan]:%s\n",str);
json = cJSON_Parse(str);
if(json == NULL){
return;
}
info_root = cJSON_GetObjectItem(json, MSG_INFO_STR);
json = cJSON_Parse(str);
if(json == NULL){
return;
}
info_root = cJSON_GetObjectItem(json, MSG_INFO_STR);
if(info_root == NULL) return;
payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR);
if(payload == NULL) return;
payload = cJSON_GetObjectItem(json, MSG_PAYLOAD_STR);
if(payload == NULL) return;
deviceCode= cJSON_GetObjectItem(info_root, MSG_DEVICE_CODE_STR);
if(deviceCode == NULL) return;
typeJson = cJSON_GetObjectItem(info_root, MSG_TYPE_STR);
if(typeJson == NULL) return;
if (strstr(typeJson->valuestring,SYNC_MSG_TYPE_REPLY) != NULL){
kk_parse_syncinfo(payload);
kk_create_syncinfo_to_sdk();
}
}
\ No newline at end of file
if (strstr(typeJson->valuestring,SYNC_MSG_TYPE_REPLY) != NULL){
kk_parse_syncinfo(payload);
kk_create_syncinfo_to_sdk();
printf("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");
}else if((typeJson->valuestring,"/thing/event/property/post")!= NULL){
property_post_deal(deviceCode->valuestring,payload);
}
}
......@@ -3,270 +3,400 @@
#include <stdlib.h>
#include <string.h>
#include "kk_data_mng.h"
#include "kk_lan_node_db.h"
static kk_map_dev_ctx g_map_dev_mgr = {0};
static kk_map_dev_ctx *_kk_map_dev_ctx(void)
kk_map_dev_ctx *_kk_map_dev_ctx(void)
{
return &g_map_dev_mgr;
return &g_map_dev_mgr;
}
static void _kk_map_dev_mutex_lock(void)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
if (ctx->mutex) {
kk_MutexLock(ctx->mutex);
}
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
if (ctx->mutex) {
kk_MutexLock(ctx->mutex);
}
}
static void _kk_map_dev_mutex_unlock(void)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
if (ctx->mutex) {
kk_MutexUnLock(ctx->mutex);
}
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
if (ctx->mutex) {
kk_MutexUnLock(ctx->mutex);
}
}
int kk_map_dev_init(void)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
memset(ctx, 0, sizeof(kk_map_dev_ctx));
ctx->mutex = kk_MutexCreate();
if (ctx->mutex == NULL) {
return -1;
}
INIT_LIST_HEAD(&ctx->dev_list);
return 0;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
memset(ctx, 0, sizeof(kk_map_dev_ctx));
ctx->mutex = kk_MutexCreate();
if (ctx->mutex == NULL) {
return -1;
}
INIT_LIST_HEAD(&ctx->dev_list);
return 0;
}
void kk_map_dev_deinit(void)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
kk_map_dev_node_t *node = NULL;
kk_map_dev_node_t *n = NULL;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
list_for_each_entry_safe(node,n,&ctx->dev_list, linked_list, kk_map_dev_node_t) {
printf("[remove list] node->linked_list000000000\n");
if (node != NULL) {
_kk_map_dev_mutex_lock();
if(node->json){
printf("[delete cjson] node->json.\n");
cJSON_Delete(node->json);
}
if(node->syn_opcode) {
printf("[free] node->syn_opcode.\n");
free(node->syn_opcode);
}
printf("[remove list] node->linked_list\n");
dlist_del(&node->linked_list);
memset(node,0,sizeof(kk_map_dev_node_t));
_kk_map_dev_mutex_unlock();
}
}
}
static int kk_open_cfg_file(char *deviceCode,kk_map_dev_node_t *node)
{
char path[128] = {0};
unsigned int filesize;
FILE *fp;
char *buf = NULL;
cJSON *json = NULL;
cJSON *optype = NULL;
sprintf(path,KK_DEVICE_MAP_FILE_PATH,deviceCode);
printf("kk_open_cfg_file path:%s\n",path);
char path[128] = {0};
unsigned int filesize;
FILE *fp;
char *buf = NULL;
cJSON *json = NULL;
cJSON *optype = NULL;
cJSON *syn_type = NULL;
sprintf(path,KK_DEVICE_MAP_FILE_PATH,deviceCode);
printf("kk_open_cfg_file path:%s\n",path);
if(!(fp = fopen(path,"r")))
{
ERROR_PRINT("can't open the file tslPath:%s\n",path);
return -1;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
fseek(fp, 0L, SEEK_END);
filesize = ftell(fp);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
fseek(fp, 0L, SEEK_END);
filesize = ftell(fp);
buf = malloc(filesize+1);
if(buf == NULL)
{
ERROR_PRINT("MALLOC FAIL!!!\n");
fclose(fp);
fclose(fp);
return -1;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
memset(buf,0x0,filesize+1);
fseek(fp, 0L, SEEK_SET);
fread(buf, 1, filesize, fp);
printf("buf:%s\n",buf);
json = cJSON_Parse(buf);
if(json == NULL){
ERROR_PRINT("cJSON_Parse FAIL!!!\n");
free(buf);
fclose(fp);
fread(buf, 1, filesize, fp);
printf("buf:%s\n",buf);
json = cJSON_Parse(buf);
if(json == NULL){
ERROR_PRINT("cJSON_Parse FAIL!!!\n");
free(buf);
fclose(fp);
return -1;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
optype = cJSON_GetObjectItem(json, OPEARTETYPE_STRING);
if(optype != NULL){
memcpy(node->opearteType,optype->valuestring,strlen(optype->valuestring));
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node->channelNum = cJSON_GetObjectItem(json, CHANNEL_STRING)->valueint;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node->newccu = cJSON_GetObjectItem(json, NEWCCU_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node->oldccu = cJSON_GetObjectItem(json, OLDCCU_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(node->newccu == NULL || node->oldccu == NULL){
ERROR_PRINT("cJSON_Parse DATA FAIL!!!\n");
free(buf);
fclose(fp);
}
node->json = json;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
optype = cJSON_GetObjectItem(json, OPEARTETYPE_STRING);
if(optype != NULL){
memcpy(node->opearteType,optype->valuestring,strlen(optype->valuestring));
}
syn_type = cJSON_GetObjectItem(json, "syn_type");
if(syn_type){
cJSON *syn_opcode = cJSON_GetObjectItem(json, "syn_opcode");
node->syn_type = syn_type->valueint;
node->syn_opcode= (char *)malloc(strlen(syn_opcode->valuestring)+1);
memset(node->syn_opcode,0,strlen(node->syn_opcode)+1);
memcpy(node->syn_opcode,syn_opcode->valuestring,strlen(syn_opcode->valuestring));
}
printf("[%s][%d]node->syn_type=%d****************\n",__FUNCTION__,__LINE__,node->syn_type);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node->channelNum = cJSON_GetObjectItem(json, CHANNEL_STRING)->valueint;
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node->newccu = cJSON_GetObjectItem(json, NEWCCU_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node->oldccu = cJSON_GetObjectItem(json, OLDCCU_STRING);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(node->newccu == NULL || node->oldccu == NULL){
ERROR_PRINT("cJSON_Parse DATA FAIL!!!\n");
free(buf);
fclose(fp);
return -1;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
free(buf);
fclose(fp);
return 0;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
free(buf);
fclose(fp);
return 0;
}
static int kk_creater_nodeid(char *deviceCode,char *channel,char *nodeId)
int kk_creater_nodeid(char *deviceCode,int channel,char *nodeId)
{
if(deviceCode == NULL || channel == NULL || nodeId == NULL){
return -1;
}
strcat(nodeId,deviceCode);
strcat(nodeId,"_");
strcat(nodeId,channel);
printf("nodeId:%s\n",nodeId);
return 0;
static int next = 1;
int node=-1;
if(deviceCode == NULL || channel == NULL || nodeId == NULL){
printf("bbb\n");
return -1;
}
printf("aaa\n");
printf("channel=%d\n",channel);
printf("deviceCode=%s\n",deviceCode);
printf(",,,,\n");
//INFO_PRINT("-------------->deviceCode=%s,channel=%d\n",deviceCode,channel);
printf("aaa-1\n");
if(kk_check_lan_node_exist(deviceCode,channel)){
printf("aaa-2\n");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
node = kk_lan_db_node_get(deviceCode,channel);
}else{
printf("aaa-3\n");
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
while(kk_check_lan_node(next)){
++next;
}
INFO_PRINT("#################next=%d\n",next);
if(0==kk_lan_db_node_insert(deviceCode,channel,next)){
node=next;
}
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("aaa-44,node=%d\n",node);
sprintf(nodeId,"%d",node);
printf("aaa-4\n");
//INFO_PRINT("[node]deviceCode=%s,channel=%d,node=%d,nodeId=%s\n",deviceCode,channel,node,nodeId);
return 0;
}
/******************************************
*从映射表中获取组件所需的值
*******************************************/
static char* kk_value_int_map_string(char *opcodemap,kk_map_dev_node_t *node,int idx)
{
if(opcodemap == NULL || node == NULL){
return -1;
}
cJSON * oldccuItem = node->oldccu->child;
while(oldccuItem != NULL){
char *opcode = cJSON_GetObjectItem(oldccuItem,OPCODE_STRING)->valuestring;
char *dataType = cJSON_GetObjectItem(oldccuItem,DATATYPE_STRING)->valuestring;
if(strcmp(opcode,opcodemap) == 0){
cJSON *range = cJSON_GetObjectItem(oldccuItem,VALUERANGE_STRING);
if(range != NULL){
cJSON * pSub = cJSON_GetArrayItem(range, idx);
if(pSub != NULL){
if(strcmp(dataType,"string") == 0){
return pSub->valuestring;
}
}
}
}
}
return "";
if(opcodemap == NULL || node == NULL){
return -1;
}
cJSON * oldccuItem = node->oldccu->child;
while(oldccuItem != NULL){
char *opcode = cJSON_GetObjectItem(oldccuItem,OPCODE_STRING)->valuestring;
char *dataType = cJSON_GetObjectItem(oldccuItem,DATATYPE_STRING)->valuestring;
if(strcmp(opcode,opcodemap) == 0){
cJSON *range = cJSON_GetObjectItem(oldccuItem,VALUERANGE_STRING);
if(range != NULL){
cJSON * pSub = cJSON_GetArrayItem(range, idx);
if(pSub != NULL){
if(strcmp(dataType,"string") == 0){
return pSub->valuestring;
}
}
}
}
}
return "";
}
int kk_get_int_value_idx(cJSON * range,int val)
{
int i = 0;
int array_size = cJSON_GetArraySize (range);
for(i = 0; i < array_size; i++){
cJSON * pSub = cJSON_GetArrayItem(range, i);
if(pSub != NULL && (pSub->valueint == val)){
return i;
}
}
return -1;
}
static int kk_get_int_value_idx(cJSON * range,int val)
int mac_switchto_deviceCode(char *mac,char * deviceCode)
{
int i = 0;
int array_size = cJSON_GetArraySize (range);
for(i = 0; i < array_size; i++){
cJSON * pSub = cJSON_GetArrayItem(range, i);
if(pSub != NULL && pSub->valueint == val){
return i;
}
}
return -1;
char mac_bak[33] = {0};
int i, j;
int len = strlen(mac);
if(len!=23)
return -1;
for(i=0; i < len; i++) /*将串s拷贝至串t*/
mac_bak[i]=mac[i];
mac_bak[i]='\0';
for(i=0,j=0; i < len; i++){
if((i+1)%3==0&&i!=0){
continue;
}
deviceCode[j++] =mac_bak[i];
}
deviceCode[j]='\0'; /*在串s结尾加结束标志*/
return 0;
}
static int _deviceCode_switchto_mac(char * deviceCode,char *mac)
int _deviceCode_switchto_mac(char * deviceCode,char *mac)
{
char deviceCode_bak[33] = {0};
int i, j;
int len = strlen(deviceCode);
for(i=0; i < len; i++) /*将串s拷贝至串t*/
deviceCode_bak[i]=deviceCode[i];
deviceCode_bak[i]='\0';
for(i=0,j=0; i < len; i++){
if( i % 2 == 0 && i != 0)
{
mac[j++]=':';
mac[j++]=deviceCode_bak[i];
}
else
{
mac[j++]=deviceCode_bak[i];
}
}
mac[j]='\0'; /*在串s结尾加结束标志*/
return 0;
char deviceCode_bak[33] = {0};
int i, j;
int len = strlen(deviceCode);
for(i=0; i < len; i++) /*将串s拷贝至串t*/
deviceCode_bak[i]=deviceCode[i];
deviceCode_bak[i]='\0';
for(i=0,j=0; i < len; i++){
if( i % 2 == 0 && i != 0)
{
mac[j++]=':';
mac[j++]=deviceCode_bak[i];
}
else
{
mac[j++]=deviceCode_bak[i];
}
}
mac[j]='\0'; /*在串s结尾加结束标志*/
return 0;
}
int kk_create_devices_to_sdk(cJSON *root)
{
kk_map_dev_node_t *node = NULL;
char nodeid[32] = {0};
char channel[4] = {0};
char gwmac[32] = {0};
char submac[32] = {0};
int idx = 1;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
cJSON *devices = cJSON_CreateArray();
list_for_each_entry(node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if (node != NULL) {
for(idx = 1; idx <= node->channelNum; idx++){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *subdevicesItem = cJSON_CreateObject();
sprintf(channel,"%d",idx);
cJSON_AddStringToObject(subdevicesItem, CHANNEL_STRING, channel);
cJSON_AddStringToObject(subdevicesItem, DEVICE_FIELD_STRING, "");
cJSON_AddStringToObject(subdevicesItem, DEVICE_FIELD_IDNDEX_STRING, "1");
cJSON_AddStringToObject(subdevicesItem, DEVICE_ICON_STRING, "");
cJSON_AddStringToObject(subdevicesItem, DEVICE_POS_STRING, "1");
_deviceCode_switchto_mac(node->gwDeviceCode,gwmac);
printf("gwmac:%s\n",gwmac);
cJSON_AddStringToObject(subdevicesItem, GW_MAC_STRING, gwmac);
_deviceCode_switchto_mac(node->deviceCode,submac);
cJSON_AddStringToObject(subdevicesItem, MAC_STRING, submac);
cJSON_AddStringToObject(subdevicesItem, NAME_STRING, "默认灯");
memset(nodeid,0x0,sizeof(nodeid));
kk_creater_nodeid(node->deviceCode,channel,nodeid);
cJSON_AddStringToObject(subdevicesItem, NODEID_STRING, nodeid);
cJSON_AddStringToObject(subdevicesItem, OPERATE_TYPE_STRING, node->opearteType);
cJSON_AddStringToObject(subdevicesItem, ROOM_ID_STRING, "1");
cJSON_AddItemToArray(devices, subdevicesItem);
}
kk_map_dev_node_t *node = NULL;
char nodeid[32] = {0};
char gwmac[32] = {0};
char submac[32] = {0};
char channel[4];
int idx = 1;
}
}
cJSON_AddItemToObject(root, DEVICES_STRING, devices);
return 0;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
cJSON *devices = cJSON_CreateArray();
list_for_each_entry(node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if (node != NULL) {
for(idx = 1; idx <= node->channelNum; idx++){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON *subdevicesItem = cJSON_CreateObject();
sprintf(channel,"%d",idx);
cJSON_AddStringToObject(subdevicesItem, CHANNEL_STRING, channel);
cJSON_AddStringToObject(subdevicesItem, DEVICE_FIELD_STRING, "");
cJSON_AddStringToObject(subdevicesItem, DEVICE_FIELD_IDNDEX_STRING, "1");
cJSON_AddStringToObject(subdevicesItem, DEVICE_ICON_STRING, "");
cJSON_AddStringToObject(subdevicesItem, DEVICE_POS_STRING, "1");
_deviceCode_switchto_mac(node->gwDeviceCode,gwmac);
printf("gwmac:%s\n",gwmac);
cJSON_AddStringToObject(subdevicesItem, GW_MAC_STRING, gwmac);
_deviceCode_switchto_mac(node->deviceCode,submac);
cJSON_AddStringToObject(subdevicesItem, MAC_STRING, submac);
//todo name字段
cJSON_AddStringToObject(subdevicesItem, NAME_STRING, "默认灯");
memset(nodeid,0x0,sizeof(nodeid));
kk_creater_nodeid(node->deviceCode,idx,nodeid);
cJSON_AddStringToObject(subdevicesItem, NODEID_STRING, nodeid);
cJSON_AddStringToObject(subdevicesItem, OPERATE_TYPE_STRING, node->opearteType);
cJSON_AddStringToObject(subdevicesItem, ROOM_ID_STRING, "1");
cJSON_AddItemToArray(devices, subdevicesItem);
}
}
}
cJSON_AddItemToObject(root, DEVICES_STRING, devices);
return 0;
}
char *double_value_string(double val)
{
char *value = (char *)malloc(33);
memset(value,0,33);
snprintf(value,32,"%6f",val);
return value;
}
int kk_create_devicestatus_to_sdk(cJSON *root)
{
kk_map_dev_node_t *node = NULL;
char nodeid[32] = {0};
char indxId[4] = {0};
int idx = 1;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
cJSON *device_status = cJSON_CreateArray();
#if 1
list_for_each_entry(node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if (node != NULL) {
cJSON * newccuItem = node->newccu->child;
while(newccuItem != NULL){
cJSON *subdevicesItem = cJSON_CreateObject();
memset(nodeid,0x0,sizeof(nodeid));
char *opcodemap = cJSON_GetObjectItem(newccuItem,OPCODEMAP_STRING)->valuestring;
char *channel = cJSON_GetObjectItem(newccuItem,CHANNEL_STRING)->valuestring;
char *dataType = cJSON_GetObjectItem(newccuItem,DATATYPE_STRING)->valuestring;
cJSON *range = cJSON_GetObjectItem(newccuItem,VALUERANGE_STRING);
kk_creater_nodeid(node->deviceCode,channel,nodeid);
cJSON_AddStringToObject(subdevicesItem, OPCODE_STRING, opcodemap);
cJSON_AddStringToObject(subdevicesItem, NODEID_STRING, nodeid);
sprintf(indxId,"%d",idx++);
cJSON_AddStringToObject(subdevicesItem, "index", indxId);
if(strcmp(dataType,"int") == 0){
int value = cJSON_GetObjectItem(newccuItem,VALUE_STRING)->valueint;
if(range != NULL){
int index = kk_get_int_value_idx(range,value);
cJSON_AddStringToObject(subdevicesItem, "arg", kk_value_int_map_string(opcodemap,node,index));
}
}
cJSON_AddItemToArray(device_status, subdevicesItem);
newccuItem = newccuItem->next;
}
}
}
#endif
cJSON_AddItemToObject(root, DEVICE_STATUS_STRING, device_status);
return 0;
kk_map_dev_node_t *node = NULL;
char nodeid[32] = {0};
char indxId[4] = {0};
int idx = 1;
int syn_type = 0;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
cJSON *device_status = cJSON_CreateArray();
cJSON *args;
cJSON *sub_device;
list_for_each_entry(node, &ctx->dev_list, linked_list, kk_map_dev_node_t){
if(node->syn_type==1){
kk_creater_nodeid(node->deviceCode,1,nodeid);
if((args = kk_devicestatus_build(node))!=NULL){
sub_device=old_ccu_msg_build_json_node_int(atoi(nodeid),node->syn_opcode,NULL,args);
if(sub_device){
cJSON_AddItemToArray(device_status,sub_device);
}
}
}else{
kk_devicestatus_build_aaa(device_status,node);
}
}
cJSON_AddItemToObject(root, DEVICE_STATUS_STRING, device_status);
return 0;
}
int kk_map_dev_update_int_value(kk_map_dev_node_t *node,char *identifier,int val)
{
int ret = 0;
int ret = 0;
if(node != NULL && node->newccu != NULL){
cJSON * newccuItem = node->newccu->child;
while(newccuItem != NULL){
char *identifier_tmp = cJSON_GetObjectItem(newccuItem,MSG_INDENTIFIER_STR)->valuestring;
if(strcmp(identifier_tmp,identifier) == 0){
cJSON_ReplaceItemInObject(newccuItem, "value", cJSON_CreateNumber(val));
break;
}
newccuItem = newccuItem->next;
}
}
return 0;
if(node != NULL && node->newccu != NULL){
cJSON * newccuItem = node->newccu->child;
while(newccuItem != NULL){
char *identifier_tmp = cJSON_GetObjectItem(newccuItem,MSG_INDENTIFIER_STR)->valuestring;
if(strcmp(identifier_tmp,identifier) == 0){
cJSON_ReplaceItemInObject(newccuItem, "value", cJSON_CreateNumber(val));
break;
}
newccuItem = newccuItem->next;
}
}
return 0;
}
int kk_map_dev_update_int_value_by_devicecode(char *deviceCode,char *identifier,int val)
{
......@@ -291,6 +421,7 @@ int kk_map_dev_update_int_value_by_devicecode(char *deviceCode,char *identifier,
return 0;
}
int kk_map_dev_search_by_deviceCode(char *deviceCode, kk_map_dev_node_t **node)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
......@@ -307,33 +438,101 @@ int kk_map_dev_search_by_deviceCode(char *deviceCode, kk_map_dev_node_t **node)
}
}
ERROR_PRINT("Device Not Found, deviceCode: %s", deviceCode);
return -1;
ERROR_PRINT("Device Not Found, deviceCode: %s\n", deviceCode);
return -1;
}
kk_map_dev_node_t *kk_map_dev_add(char *deviceCode,char *productCode,char *gwdeviceCode)
kk_map_dev_node_t *kk_map_dev_add(char *deviceCode,char *productCode,char *gwdeviceCode,char *onlineStatus)
{
#if 1
kk_map_dev_node_t *node = NULL;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
#if 1
kk_map_dev_node_t *node = NULL;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
node = malloc(sizeof(kk_map_dev_node_t));
if (node == NULL) {
return NULL;
}
printf("----------------------------------------->%s\n",onlineStatus);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_map_dev_mutex_lock();
printf("[%s][%d]%d\n",__FUNCTION__,__LINE__,onlineStatus);
memset(node,0x0,sizeof(kk_map_dev_node_t));
printf("[%s][%d]%d\n",__FUNCTION__,__LINE__,onlineStatus);
memcpy(node->gwDeviceCode,gwdeviceCode,strlen(gwdeviceCode));
printf("[%s][%d]%d\n",__FUNCTION__,__LINE__,onlineStatus);
memcpy(node->deviceCode,deviceCode,strlen(deviceCode));
printf("[%s][%d]%d\n",__FUNCTION__,__LINE__,onlineStatus);
memcpy(node->productCode,productCode,strlen(productCode));
printf("[%s][%d]%d\n",__FUNCTION__,__LINE__,onlineStatus);
if(onlineStatus){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[%s][%d]%d\n",__FUNCTION__,__LINE__,onlineStatus);
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(strcmp(onlineStatus,"1")==0){
node->online_status=1;
}else{
node->online_status=0;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_open_cfg_file(productCode,node);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
INIT_LIST_HEAD(&node->linked_list);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("#55,%d\n",node);
list_add_tail(&node->linked_list, &ctx->dev_list);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_map_dev_mutex_unlock();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return node;
#endif
}
/*
int get_productCode_by_deviceCode(const char *deviceCode)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
kk_map_dev_node_t *search_node = NULL;
list_for_each_entry(search_node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
if ( (strlen(search_node->deviceCode) == strlen(deviceCode)) &&
(memcmp(search_node->deviceCode, deviceCode, strlen(deviceCode)) == 0)) {
item = kk_zb_dev_hw_info_build(search_node->deviceCode,search_node->productCode,search_node->online_status,NULL,NULL);
return item;
}
}
return NULL;
}
*/
node = malloc(sizeof(kk_map_dev_node_t));
if (node == NULL) {
return NULL;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_map_dev_mutex_lock();
memset(node,0x0,sizeof(kk_map_dev_node_t));
memcpy(node->gwDeviceCode,gwdeviceCode,strlen(gwdeviceCode));
memcpy(node->deviceCode,deviceCode,strlen(deviceCode));
memcpy(node->productCode,productCode,strlen(productCode));
kk_open_cfg_file(productCode,node);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
INIT_LIST_HEAD(&node->linked_list);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
list_add_tail(&node->linked_list, &ctx->dev_list);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
_kk_map_dev_mutex_unlock();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return node;
#endif
}
\ No newline at end of file
......@@ -8,22 +8,32 @@
#include "com_api.h"
#include "kk_opcode.h"
typedef struct {
cJSON *newccu;
cJSON *oldccu;
int channelNum;
char gwDeviceCode[DEVICE_CODE_LEN];
char productCode[PRODUCT_CODE_LEN];
char deviceCode[DEVICE_CODE_LEN];
char opearteType[8];
struct list_head linked_list;
cJSON *json;
cJSON *newccu;
cJSON *oldccu;
unsigned char online_status;
int channelNum;
int syn_type;
char *syn_opcode;
char gwDeviceCode[DEVICE_CODE_LEN];
char productCode[PRODUCT_CODE_LEN];
char deviceCode[DEVICE_CODE_LEN];
char opearteType[8];
struct list_head linked_list;
} kk_map_dev_node_t;
typedef struct {
void *mutex;
struct list_head dev_list;
void *mutex;
struct list_head dev_list;
} kk_map_dev_ctx;
kk_map_dev_node_t *kk_map_dev_add(char *deviceCode,char *productCode,char *gwdeviceCode);
kk_map_dev_node_t *kk_map_dev_add(char *deviceCode,char *productCode,char *gwdeviceCode,char *onlineStatus);
int kk_create_devicestatus_to_sdk(cJSON *root);
int kk_create_devices_to_sdk(cJSON *root);
int _deviceCode_switchto_mac(char * deviceCode,char *mac);
int mac_switchto_deviceCode(char *mac,char * deviceCode);
kk_map_dev_ctx *_kk_map_dev_ctx(void);
#endif
\ No newline at end of file
......@@ -18,46 +18,46 @@
#include "cJSON.h"
static int kk_findccu_ack(int sockfd,struct sockaddr_in *addr){
cJSON *json = NULL,*args = NULL;
cJSON *ccu = NULL;
char *out = NULL;
char *tmpBuf = NULL;
char s_IP[NETWORK_ADDR_LEN] = {0};
if(addr == NULL || sockfd < 0){
return -1;
}
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, "zk", KK_CCU_NAME);
HAL_Get_IP(s_IP,NULL);
cJSON_AddStringToObject(args, "ip", s_IP);
cJSON_AddBoolToObject(args, "ssl", FALSE);
}
cJSON_AddStringToObject(json, "nodeid", "*");
cJSON_AddStringToObject(json, "opcode", FINDCCU_OPCODE);
cJSON_AddStringToObject(json, "status", "success");
out=cJSON_Print(json);
cJSON_Minify((char*)out);
tmpBuf = calloc(strlen(out) + 4,1);
if(tmpBuf == NULL){
cJSON_Delete(json);
free(out);
return -1;
}
strcat(tmpBuf,"!");
strcat(tmpBuf,out);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
sendto(sockfd, tmpBuf, strlen(tmpBuf), 0, (struct sockaddr*)addr, sizeof(struct sockaddr_in));
cJSON_Delete(json);
free(out);
free(tmpBuf);
}
return 0;
cJSON *json = NULL,*args = NULL;
cJSON *ccu = NULL;
char *out = NULL;
char *tmpBuf = NULL;
char s_IP[NETWORK_ADDR_LEN] = {0};
if(addr == NULL || sockfd < 0){
return -1;
}
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, "zk", KK_CCU_NAME);
HAL_Get_IP(s_IP,NULL);
cJSON_AddStringToObject(args, "ip", s_IP);
cJSON_AddBoolToObject(args, "ssl", FALSE);
}
cJSON_AddStringToObject(json, "nodeid", "*");
cJSON_AddStringToObject(json, "opcode", FINDCCU_OPCODE);
cJSON_AddStringToObject(json, "status", "success");
out=cJSON_Print(json);
cJSON_Minify((char*)out);
tmpBuf = calloc(strlen(out) + 4,1);
if(tmpBuf == NULL){
cJSON_Delete(json);
free(out);
return -1;
}
strcat(tmpBuf,"!");
strcat(tmpBuf,out);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
sendto(sockfd, tmpBuf, strlen(tmpBuf), 0, (struct sockaddr*)addr, sizeof(struct sockaddr_in));
cJSON_Delete(json);
free(out);
free(tmpBuf);
}
return 0;
}
void *kk_findccu_handle(void *data)
{
......@@ -65,73 +65,73 @@ void *kk_findccu_handle(void *data)
struct sockaddr_in saddr;
int r;
char recvline[1025] = {0};
char recvline_tmp[1025] = {0};
char recvline_tmp[1025] = {0};
struct sockaddr_in presaddr;
socklen_t len;
cJSON *json;
cJSON *opcode;
char *pStart = NULL,*pEnd = NULL;
cJSON *json;
cJSON *opcode;
char *pStart = NULL,*pEnd = NULL;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
bzero(&saddr, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
saddr.sin_port = htons(FINDCCU_LOCAL_PORT);
if(bind(sockfd, (struct sockaddr*)&saddr, sizeof(saddr)) == -1)
{
ERROR_PRINT("bind error...\n");
}
if(bind(sockfd, (struct sockaddr*)&saddr, sizeof(saddr)) == -1)
{
ERROR_PRINT("bind error...\n");
}
while (1)
{
r = recvfrom(sockfd, recvline, sizeof(recvline), 0 , (struct sockaddr*)&presaddr, &len);
if (r <= 0){
WARNING_PRINT("read error....\n");
WARNING_PRINT("read error....\n");
}else{
DEBUG_PRINT("findccu recmsg: %s\n", recvline);
pStart = strstr(recvline, "!");
pEnd = strstr(recvline, "$");
if(pStart != NULL && pEnd != NULL){
memset(recvline_tmp,0x0,sizeof(recvline_tmp));
memcpy(recvline_tmp,pStart+1,(pEnd - pStart - 1));
json=cJSON_Parse(recvline_tmp);
if (!json) {
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
}else{
opcode = cJSON_GetObjectItem(json, OPCODE_STRING);
if(opcode != NULL){
if(strcmp(opcode->valuestring,FINDCCU_OPCODE) == 0){
kk_findccu_ack(sockfd,&presaddr);
}
}
cJSON_Delete(json);
}
}else{
WARNING_PRINT("data error....\n");
}
}
DEBUG_PRINT("findccu recmsg: %s\n", recvline);
pStart = strstr(recvline, "!");
pEnd = strstr(recvline, "$");
if(pStart != NULL && pEnd != NULL){
memset(recvline_tmp,0x0,sizeof(recvline_tmp));
memcpy(recvline_tmp,pStart+1,(pEnd - pStart - 1));
json=cJSON_Parse(recvline_tmp);
if (!json) {
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
}else{
opcode = cJSON_GetObjectItem(json, OPCODE_STRING);
if(opcode != NULL){
if(strcmp(opcode->valuestring,FINDCCU_OPCODE) == 0){
kk_findccu_ack(sockfd,&presaddr);
}
}
cJSON_Delete(json);
}
}else{
WARNING_PRINT("data error....\n");
}
}
}
return NULL;
return NULL;
}
int kk_findccu_handle_init(void)
{
int rc = 0;
size_t s = 1500;
pthread_t findccu_thread_handle;
pthread_attr_t findccu_thread_attr;
//pthread_mutex_init(&s_data_mutex, NULL);
/*创建线程*/
pthread_attr_init(&findccu_thread_attr);
pthread_attr_setstacksize(&findccu_thread_attr, s);
pthread_attr_setdetachstate(&findccu_thread_attr, PTHREAD_CREATE_DETACHED);
rc = pthread_create(&findccu_thread_handle, &findccu_thread_attr, kk_findccu_handle, (void *)NULL); //收数据
if (rc)
{
WARNING_PRINT("Error : unable to create thread udp_recv \r\n");
return -1;
}
pthread_attr_destroy(&findccu_thread_attr);
return 0;
int rc = 0;
size_t s = 1500;
pthread_t findccu_thread_handle;
pthread_attr_t findccu_thread_attr;
//pthread_mutex_init(&s_data_mutex, NULL);
/*创建线程*/
pthread_attr_init(&findccu_thread_attr);
pthread_attr_setstacksize(&findccu_thread_attr, s);
pthread_attr_setdetachstate(&findccu_thread_attr, PTHREAD_CREATE_DETACHED);
rc = pthread_create(&findccu_thread_handle, &findccu_thread_attr, kk_findccu_handle, (void *)NULL); //收数据
if (rc)
{
WARNING_PRINT("Error : unable to create thread udp_recv \r\n");
return -1;
}
pthread_attr_destroy(&findccu_thread_attr);
return 0;
}
\ No newline at end of file
......@@ -24,18 +24,40 @@
#include "kk_findccu_handle.h"
#include "kk_login_handle.h"
#include "kk_data_handle.h"
//#include "kcloud_log.h"
//#include "kk_lan_queue.h"
#include "kk_lan_node_db.h"
static void sig_handler(int sig)
{
printf("Received signal: %d\n", sig);
abort();
}
int main(int argc, char* argv[])
{
int rc = 0;
char *ppp;
open("kk_lan",LOG_PID,LOG_USER);
/*set the callback to get the device date to cloud*/
kk_ipc_init(IPC_APP2MID,(ipc_cb*)KK_Data_FromMid,NULL,NULL);
kk_findccu_handle_init();
kk_map_dev_init();
kk_login_init();
struct sigaction sig = {0};
sig.sa_handler = sig_handler;
sig.sa_flags = 0;
for(int i=0;i<31;i++){
//sigaction(i, &sig, NULL);
}
//lan_queue_init();
kk_lan_db_node_init();
kk_handle_sync_info();
while(1){
//count++;
//if(count == 10){
......
......@@ -18,8 +18,8 @@
#define BUF_SIZE 1500
typedef struct {
int socketfd;
char ip[18];
int socketfd;
char ip[18];
} kk_clientInfo_t;
static kk_clientInfo_t s_ConnInfo[LISTEN_MAX] = {0};
static pthread_mutex_t data_mutex;
......@@ -27,47 +27,50 @@ fd_set fds;
int kk_send_data_to_sdk(char *buf)
{
char *tmpBuf = NULL;
int i = 0;
tmpBuf = calloc(strlen(buf) + 4,1);
if(tmpBuf == NULL){
return -1;
}
strcat(tmpBuf,"!");
strcat(tmpBuf,buf);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
for(i = 0; i < LISTEN_MAX; i++){
if(s_ConnInfo[i].socketfd != -1){
send(s_ConnInfo[i].socketfd, tmpBuf, strlen(tmpBuf), 0);
}
}
free(buf);
free(tmpBuf);
return 0;
char *tmpBuf = NULL;
int i = 0;
tmpBuf = calloc(strlen(buf) + 4,1);
if(tmpBuf == NULL){
return -1;
}
strcat(tmpBuf,"!");
strcat(tmpBuf,buf);
strcat(tmpBuf,"$");
printf("tmpBuf:%s\n",tmpBuf);
for(i = 0; i < LISTEN_MAX; i++){
if(s_ConnInfo[i].socketfd != -1){
send(s_ConnInfo[i].socketfd, tmpBuf, strlen(tmpBuf), 0);
}
}
free(tmpBuf);
return 0;
}
static int _kk_handle_data(char *buf,int sockfd){
char *pStart = NULL,*pEnd = NULL;
char tmpBuf[BUF_SIZE] = {0};
cJSON *json;
if(buf == NULL){
return -1;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
pStart = strstr(buf, "!");
pEnd = strstr(buf, "$");
if(pStart != NULL && pEnd != NULL){
memset(tmpBuf,0x0,sizeof(tmpBuf));
memcpy(tmpBuf,pStart+1,(pEnd - pStart - 1));
}
json=cJSON_Parse(tmpBuf);
if (!json) {
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_data_handle(json,sockfd);
cJSON_Delete(json);
}
char *pStart = NULL,*pEnd = NULL;
char tmpBuf[BUF_SIZE] = {0};
cJSON *json;
if(buf == NULL){
return -1;
}
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
pStart = strstr(buf, "!");
pEnd = strstr(buf, "$");
if(pStart != NULL && pEnd != NULL){
memset(tmpBuf,0x0,sizeof(tmpBuf));
memcpy(tmpBuf,pStart+1,(pEnd - pStart - 1));
}
json=cJSON_Parse(tmpBuf);
if (!json) {
WARNING_PRINT("Error before: [%s]\n","cJSON_Parse");
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
kk_data_handle(json,sockfd);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_Delete(json);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
}
}
static void PrintMesg(int i , char buf[])
......@@ -77,198 +80,200 @@ static void PrintMesg(int i , char buf[])
void *TCP_Analyzer(void *pPara)
{
char Buf[BUF_SIZE] = {0};
ssize_t Size = 0;
int index = 0;
unsigned char *pReceiveData = NULL;
int ReceiveLen = 0;
char Buf[BUF_SIZE] = {0};
ssize_t Size = 0;
int index = 0;
unsigned char *pReceiveData = NULL;
int ReceiveLen = 0;
if (NULL == pPara)
{
ERROR_PRINT("TCP_Analyzer: TCP_Analyzer Failed!\n");
return NULL;
}
if (NULL == pPara)
{
ERROR_PRINT("TCP_Analyzer: TCP_Analyzer Failed!\n");
return NULL;
}
index = *(int *)pPara;
printf("index:%d\n",*(int *)pPara);
if(index < 0 || index >= LISTEN_MAX)
{
ERROR_PRINT("TCP_Analyzer:Get pConnfd Failed \n" );
return NULL;
}
index = *(int *)pPara;
printf("index:%d\n",*(int *)pPara);
if(index < 0 || index >= LISTEN_MAX)
{
ERROR_PRINT("TCP_Analyzer:Get pConnfd Failed \n" );
return NULL;
}
while(1)
{
memset(Buf, '\0', sizeof(Buf));
Size = read(s_ConnInfo[index].socketfd, Buf,sizeof(Buf) );
if (Size <= 0) //没有接收到数据,关闭描述符,释放在TCPServer申请的空间
{
ERROR_PRINT("TCP_Analyzer:remote client close:%d\n",s_ConnInfo[index].socketfd );
pthread_mutex_lock(&data_mutex);
close(s_ConnInfo[index].socketfd);
s_ConnInfo[index].socketfd = -1;
memset(s_ConnInfo[index].ip,0x0,sizeof(s_ConnInfo[index].ip));
pthread_mutex_unlock(&data_mutex);
while(1)
{
memset(Buf, '\0', sizeof(Buf));
Size = read(s_ConnInfo[index].socketfd, Buf,sizeof(Buf) );
if (Size <= 0) //没有接收到数据,关闭描述符,释放在TCPServer申请的空间
{
ERROR_PRINT("TCP_Analyzer:remote client close:%d\n",s_ConnInfo[index].socketfd );
pthread_mutex_lock(&data_mutex);
close(s_ConnInfo[index].socketfd);
s_ConnInfo[index].socketfd = -1;
memset(s_ConnInfo[index].ip,0x0,sizeof(s_ConnInfo[index].ip));
pthread_mutex_unlock(&data_mutex);
return NULL;
}
else
{
printf("TCP_Analyzer:%s,%d\n",Buf,(int)Size);
_kk_handle_data(Buf,s_ConnInfo[index].socketfd);
}
}
return NULL;
return NULL;
}
else
{
printf("TCP_Analyzer:%s,%d\n",Buf,(int)Size);
_kk_handle_data(Buf,s_ConnInfo[index].socketfd);
printf("[%s][%d] TCP_Analyzer end.\n",__FUNCTION__,__LINE__);
}
}
return NULL;
}
static int kk_check_is_connect(char *ip){
int i = 0;
if(ip == NULL){
return -1;
}
for(i = 0; i < LISTEN_MAX; i ++){
if(s_ConnInfo[i].socketfd != -1 && strcmp(s_ConnInfo[i].ip,ip) == 0){
return 1;
}
}
return 0;
int i = 0;
if(ip == NULL){
return -1;
}
for(i = 0; i < LISTEN_MAX; i ++){
if(s_ConnInfo[i].socketfd != -1 && strcmp(s_ConnInfo[i].ip,ip) == 0){
return 1;
}
}
return 0;
}
void *TCPServer()
{
pthread_t threadID = 0;
struct sockaddr_in Server;
struct sockaddr_in Client;
int Listenfd = 0;
int i = 0;
int j = 0;
int yes = 1;
int index = 0;
int Connfd = 0;
int ret = 0;
char clientIp[18] = {0};
socklen_t len = 0;
//char logMessage[128] = {0};
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_t threadID = 0;
struct sockaddr_in Server;
struct sockaddr_in Client;
int Listenfd = 0;
int i = 0;
int j = 0;
int yes = 1;
int index = 0;
int Connfd = 0;
int ret = 0;
char clientIp[18] = {0};
socklen_t len = 0;
//char logMessage[128] = {0};
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
Listenfd = socket(AF_INET, SOCK_STREAM, 0);
if (Listenfd < 0)
{
perror("socket");
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
DEBUG_PRINT("TCPServer:create socket success\n");
setsockopt(Listenfd, SOL_SOCKET, SO_REUSEADDR, &yes ,sizeof(int));// 允许IP地址复用
bzero(&Server, sizeof(Server));
Server.sin_family = AF_INET;
Server.sin_port = htons(SERVER_LISTEN_PORT);
Server.sin_addr.s_addr = htonl(INADDR_ANY);
Listenfd = socket(AF_INET, SOCK_STREAM, 0);
if (Listenfd < 0)
{
perror("socket");
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
DEBUG_PRINT("TCPServer:create socket success\n");
setsockopt(Listenfd, SOL_SOCKET, SO_REUSEADDR, &yes ,sizeof(int));// 允许IP地址复用
bzero(&Server, sizeof(Server));
Server.sin_family = AF_INET;
Server.sin_port = htons(SERVER_LISTEN_PORT);
Server.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(Listenfd, (struct sockaddr*)&Server, sizeof(Server)) < 0)
{
perror("bind");
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
DEBUG_PRINT("TCPServer:bind socket success\n");
if (bind(Listenfd, (struct sockaddr*)&Server, sizeof(Server)) < 0)
{
perror("bind");
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
DEBUG_PRINT("TCPServer:bind socket success\n");
if (listen(Listenfd, LISTEN_MAX) < 0)
{
perror("listen");
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
DEBUG_PRINT("TCPServer:listen socket success\n");
if (listen(Listenfd, LISTEN_MAX) < 0)
{
perror("listen");
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
DEBUG_PRINT("TCPServer:listen socket success\n");
while (1)
{
//index = -1;
FD_ZERO(&fds);//描述符集合初始化
while (1)
{
//index = -1;
FD_ZERO(&fds);//描述符集合初始化
FD_SET(Listenfd,&fds);
struct timeval timeout = {1, 0};
ret = select(Listenfd + 1, &fds,NULL, NULL, &timeout );
if(ret <= 0){
DEBUG_PRINT("TCPServer:TCP receiving nothing......\n");
//break;
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if (FD_ISSET(Listenfd, &fds))
{
len = sizeof(Client);
bzero(&Client, len);
Connfd = accept(Listenfd, (struct sockaddr*)&Client,&len );
printf("addr:%s\n",inet_ntoa(Client.sin_addr));
printf("[%s][%d]Connfd:%d\n",__FUNCTION__,__LINE__,Connfd);
//若有新的连接
if (Connfd != -1)
{
memset(clientIp,0x0,sizeof(clientIp));
strcpy(clientIp,inet_ntoa(Client.sin_addr));
if(kk_check_is_connect(clientIp) == 1){
DEBUG_PRINT("already connect!!!\n");
continue;
}
for(i = 0; i < LISTEN_MAX; i ++){
if(s_ConnInfo[i].socketfd != -1){
if(i == 4){
DEBUG_PRINT("more then max client!!!\n");
}
continue;
}else{
pthread_mutex_lock(&data_mutex);
s_ConnInfo[i].socketfd = Connfd;
memcpy(s_ConnInfo[i].ip,clientIp,strlen(clientIp));
index = i;
printf("index:%d\n",index);
pthread_mutex_unlock(&data_mutex);
break;
}
}
ret = pthread_create(&threadID, &attr, TCP_Analyzer, &index);
if(0 != ret)
{
DEBUG_PRINT("TCPServer: TCP_Analyzer build Fail!\n");
FD_CLR(Listenfd, &fds);// 清除 fds中相应的文件描述符
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
FD_SET(Listenfd,&fds);
struct timeval timeout = {1, 0};
ret = select(Listenfd + 1, &fds,NULL, NULL, &timeout );
if(ret <= 0){
DEBUG_PRINT("TCPServer:TCP receiving nothing......\n");
//break;
}else{
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if (FD_ISSET(Listenfd, &fds))
{
len = sizeof(Client);
bzero(&Client, len);
Connfd = accept(Listenfd, (struct sockaddr*)&Client,&len );
printf("addr:%s\n",inet_ntoa(Client.sin_addr));
printf("[%s][%d]Connfd:%d\n",__FUNCTION__,__LINE__,Connfd);
//若有新的连接
if (Connfd != -1)
{
memset(clientIp,0x0,sizeof(clientIp));
strcpy(clientIp,inet_ntoa(Client.sin_addr));
if(kk_check_is_connect(clientIp) == 1){
DEBUG_PRINT("already connect!!!\n");
continue;
}
for(i = 0; i < LISTEN_MAX; i ++){
if(s_ConnInfo[i].socketfd != -1){
if(i == LISTEN_MAX-1){
DEBUG_PRINT("more then max client!!!\n");
}
continue;
}else{
pthread_mutex_lock(&data_mutex);
s_ConnInfo[i].socketfd = Connfd;
memcpy(s_ConnInfo[i].ip,clientIp,strlen(clientIp));
index = i;
printf("index:%d\n",index);
pthread_mutex_unlock(&data_mutex);
break;
}
}
ret = pthread_create(&threadID, &attr, TCP_Analyzer, &index);
if(0 != ret)
{
DEBUG_PRINT("TCPServer: TCP_Analyzer build Fail!\n");
FD_CLR(Listenfd, &fds);// 清除 fds中相应的文件描述符
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
}
}
}
}
}
}
}
FD_CLR(Listenfd, &fds);// 清除 fds中相应的文件描述符
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
FD_CLR(Listenfd, &fds);// 清除 fds中相应的文件描述符
close(Listenfd);
pthread_attr_destroy(&attr);//线程属性销毁
return NULL;
}
int kk_login_init()
{
int ret = 0;
int i = 0;
pthread_t threadID = 0;
int ret = 0;
int i = 0;
pthread_t threadID = 0;
DEBUG_PRINT("kk_login_init Init OK!\n");
for(i = 0; i < LISTEN_MAX; i ++){
s_ConnInfo[i].socketfd = -1;
memset(s_ConnInfo[i].ip,0x0,sizeof(s_ConnInfo[i].ip));
}
DEBUG_PRINT("kk_login_init Init OK!\n");
for(i = 0; i < LISTEN_MAX; i ++){
s_ConnInfo[i].socketfd = -1;
memset(s_ConnInfo[i].ip,0x0,sizeof(s_ConnInfo[i].ip));
}
if (pthread_mutex_init(&data_mutex, NULL) != 0) {
ERROR_PRINT("pthread_mutex_init kk_login_init err\n");
return -1;
}
ret = pthread_create(&threadID, NULL, TCPServer, NULL);
if(0 != ret)
{
ERROR_PRINT("TCPServer: TCPServer build Fail!\n");
return -1;
}
return 0;
return -1;
}
ret = pthread_create(&threadID, NULL, TCPServer, NULL);
if(0 != ret)
{
ERROR_PRINT("TCPServer: TCPServer build Fail!\n");
return -1;
}
return 0;
}
......@@ -16,10 +16,21 @@
#define OPEARTETYPE_STRING "operateType"
#define NEWCCU_STRING "newccu"
#define OLDCCU_STRING "oldccu"
#define FINDCCU_OPCODE "FIND_CCU"
#define LOGIN_OPCODE "LOGIN"
#define HEARTBEAT_OPCODE "CCU_HB"
#define SYNC_OPCODE "SYNC_INFO"
#define GET_ZB_DEVS_HW_INFO_OPCODE "GET_ZIGBEE_DEVS_HW_INFO"
#define SWITCH_OPCODE "SWITCH"
#define VALUERANGE_STRING "valueRange"
#define DEVICE_FIELD_STRING "device_field"
#define DEVICE_FIELD_IDNDEX_STRING "device_field_index"
......@@ -31,4 +42,4 @@
#define OPERATE_TYPE_STRING "operate_type"
#define ROOM_ID_STRING "room_id"
#define DEVICE_STATUS_STRING "device_status"
#endif
\ No newline at end of file
#endif
......@@ -6,8 +6,11 @@
#define APP2MID "ipc:///tmp/app2mid.ipc"
#define APP2MID_PUBSUB "ipc:///tmp/app2mid_pubsub.ipc"
#define PLAT2MID "ipc:///tmp/plat2mid.ipc"
//#define GW2CCU_PIPE "tcp://%s:5555"
//#define GW2CCU_PUBSUB "tcp://%s:5557"
#define GW2CCU_PIPE "tcp://%s:35567"
#define GW2CCU_PUBSUB "tcp://%s:35568"
#define MAGIC "magic12"
#define MAGIC_ACK "magic12ack"
#define FILTERSTR "|"
......
......@@ -38,6 +38,11 @@ typedef enum {
#define MSG_PAYLOAD_STR "payload"
#define MSG_INFO_STR "info"
#define MSG_INDENTIFIER_STR "identifier"
#define MSG_DATA_TYPE_STR "dataType"
#define MSG_PARAMS_STR "params"
#define MSG_IOTClOUDSTATE_STR "IOTCloudState"
#define MSG_TOPO_CHANGE_TYPE_STR "changeType"
......@@ -64,6 +69,8 @@ typedef enum {
#define MSG_TIMER_SETCOUNTDOWN_GETCOUNTDOWN "getCountDown"
#define MSG_PROPERTY_STR "property"
#define MSG_PROPERTIES_STR "properties"
#define MSG_ONLINE_STATUS_STR "onlineStatus"
/************************LOCK KEY*************************/
#define MSG_KEYDELETE_NOTIFICATION_KEYID "KeyDeletedNotification.KeyID"
#define MSG_KEYDELETE_NOTIFICATION_KEYTYPE "KeyDeletedNotification.KeyType"
......
......@@ -31,7 +31,7 @@
#define PRODUCT_TPYE "kk"
#define CCU_LAN "eth1"
#define KK_CCU_ID "CCU_77777"
#define KK_CCU_ID "CCU_77771"
#define KK_CCU_PRODUCTID "ccu_n12"
#define KK_GW_PRODUCTID "gateway_2"
#define KK_CCU_RANDOM "0000000000"
......
......@@ -13,7 +13,7 @@ COMP_LIB_COMPONENTS := \
#SUBDIRS += application/kcloud
$(call Append_Conditional, SUBDIRS, application/kcloud, KCLOUD_PLATFORM_SUPPORT)
$(call Append_Conditional, SUBDIRS, application/kk_luoma, LUOMA_PLATFORM_SUPPORT)
SUBDIRS += application/oled
#SUBDIRS += application/oled
SUBDIRS += application/klansdk
SUBDIRS += midware/midware
SUBDIRS += common/mqtt
......
......@@ -154,6 +154,8 @@ static int kk_get_properties_info(char *deviceCode,cJSON *obj)
valueType == KK_TSL_DATA_TYPE_ENUM||
valueType == KK_TSL_DATA_TYPE_BOOL){
cJSON_AddNumberToObject(propertyItem, propertyStr, atoi(valueStr));
}else if(valueType == KK_TSL_DATA_TYPE_DOUBLE){
cJSON_AddNumberToObject(propertyItem, propertyStr, atof(valueStr));
}
}
cJSON_AddItemToObject(obj, KK_SYNC_PROPERTY_STR, propertyItem);
......
......@@ -139,29 +139,29 @@ int kk_utils_itoa(_IN_ int input, _OU_ char **output)
}
void *kk_MutexCreate(void)
{
int err_num;
pthread_mutex_t *mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
if (NULL == mutex)
int err_num;
pthread_mutex_t *mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
if (NULL == mutex)
{
return NULL;
}
return NULL;
}
if (0 != (err_num = pthread_mutex_init(mutex, NULL)))
if (0 != (err_num = pthread_mutex_init(mutex, NULL)))
{
printf("create mutex failed\n");
free(mutex);
return NULL;
}
printf("create mutex failed\n");
free(mutex);
return NULL;
}
return mutex;
return mutex;
}
void kk_MutexLock(void *mutex)
{
int err_num;
if (0 != (err_num = pthread_mutex_lock((pthread_mutex_t *)mutex)))
int err_num;
if (0 != (err_num = pthread_mutex_lock((pthread_mutex_t *)mutex)))
{
printf("lock mutex failed: - '%s' (%d)\n", strerror(err_num), err_num);
}
printf("lock mutex failed: - '%s' (%d)\n", strerror(err_num), err_num);
}
}
void kk_MutexUnLock(void *mutex)
......
......@@ -80,8 +80,8 @@ static inline void dlist_init(dlist_t *node)
static inline void INIT_AOS_DLIST_HEAD(dlist_t *list)
{
list->next = list;
list->prev = list;
list->next = list;
list->prev = list;
}
static inline int dlist_empty(const dlist_t *head)
......
......@@ -24,14 +24,14 @@
{
"opcode":"SWITCH",
"identifiermap":"PowerSwitch_1",
"dataType":"string",
"dataType":"map",
"channel":"1",
"valueRange":["OFF","ON"]
},
{
"opcode":"SWITCH",
"identifiermap":"PowerSwitch_2",
"dataType":"string",
"dataType":"map",
"channel":"2",
"valueRange":["OFF","ON"]
}
......
.PHONY: doc detect config reconfig toolchain sub-mods final-out env cmake one help package squashfs firmware
all: detect config toolchain sub-mods final-out
$(TOP_Q) \
if [ -f $(STAMP_PRJ_CFG) ]; then \
$(RECURSIVE_MAKE) toolchain; \
rm -f $(STAMP_PRJ_CFG); \
fi
@rm -rf $(STAMP_DIR)
RESET_ENV_VARS := \
CROSS_PREFIX \
CFLAGS \
HOST \
LDFLAGS \
help:
@echo -e "\033[1;37m[$(RULE_DIR)/docs]\e[0m"
@echo ""
@cat $(RULE_DIR)/docs/Help.md
@echo ""
doc:
$(TOP_Q)rm -rf $(DOXYGEN_DIR)/html; mkdir -p $(DOXYGEN_DIR)
$(TOP_Q) \
$(SED) \
-e 's:^PROJECT_NAME.*:PROJECT_NAME = $(PRJ_NAME):g;' \
-e 's:^PROJECT_NUMBER.*:PROJECT_NUMBER = $(PRJ_VERSION):g;' \
-e 's:^OUTPUT_DIRECTORY.*:OUTPUT_DIRECTORY = $(DOXYGEN_DIR):g;' \
build-rules/misc/Doxyfile.tpl > $(OUTPUT_DIR)/.doxygen.cfg
$(TOP_Q)doxygen $(OUTPUT_DIR)/.doxygen.cfg
detect:
@if [ -d .git ]; then \
mkdir -p .git/hooks; \
for i in $(RULE_DIR)/hooks/*; do \
cp -f $$i .git/hooks && chmod a+x .git/hooks/$$(basename $$i); \
done; \
fi
prune:
@echo "$(TOP_DIR).pkgs directory removed!"|grep --color ".*"
@rm -rf $(TOP_DIR).pkgs
@$(MAKE) --no-print-directory distclean
unzip: config $(STAMP_BLD_VAR)
@echo "Components: "
@echo ""
@for i in $(ALL_SUB_DIRS); do \
$(MAKE) --no-print-directory pre-build target-$${i} ; \
echo -ne "\r. $${i}"; \
echo -e " "; \
done
@echo ""
cmake:
$(TOP_Q)$(MAKE) -s distclean
$(TOP_Q)$(MAKE) -s DEFAULT_BLD=$(RULE_DIR)/misc/config.generic.cmake config
$(TOP_Q)$(foreach V,$(INFO_ENV_VARS),$(V)="$($(V))") CFLAGS=$(CFLAGS) \
SEP_LIBS="$$(grep -m 1 '^COMP_LIB_FILES' $(STAMP_BLD_ENV) | cut -d' ' -f3-)" \
bash $(if $(TOP_Q),,-x) $(RULE_DIR)/scripts/gen_top_cmake.sh $(TOP_DIR)/CMakeLists.txt
$(TOP_Q)for D in $(ALL_SUB_DIRS); do \
echo "+ $${D}"; \
$(MAKE) --no-print-directory -C $(OUTPUT_DIR)/$${D} cmake; \
done
$(TOP_Q)echo ""
one: COMP_LIB_OBJS = $(foreach V,$(COMP_LIB_COMPONENTS),$(foreach U,$(LIB_OBJS_$(V)),$(V)/$(U)))
one:
$(TOP_Q)$(foreach V,$(INFO_ENV_VARS),$(V)="$($(V))") \
CFLAGS="$(subst ",,$(CFLAGS))" \
ALL_LIBS="$(strip $(foreach V,$(SUBDIRS),$(LIBA_TARGET_$(V))))" \
ALL_LIBSO="$(strip $(foreach V,$(SUBDIRS),$(LIBSO_TARGET_$(V))))" \
ALL_PROG="$(strip $(foreach V,$(SUBDIRS) $(COMP_LIB_COMPONENTS),$(TARGET_$(V))))" \
COMP_LIB_OBJS="$(COMP_LIB_OBJS)" \
bash $(RULE_DIR)/scripts/gen_one_makefile.sh
config:
@mkdir -p $(OUTPUT_DIR) $(STAMP_DIR) $(INSTALL_DIR)
@mkdir -p $(SYSROOT_BIN) $(SYSROOT_INC) $(SYSROOT_LIB)
$(TOP_Q) \
if [ -f $(STAMP_BLD_VAR) ]; then \
if [ "$$($(SED) '/[-_/a-zA-Z0-9]* = *..*/d' $(STAMP_BLD_VAR)|wc -l|$(SED) 's:^ *::g')" != "0" ]; then \
rm -vf $(STAMP_BLD_VAR); \
fi \
fi
$(TOP_Q)+( \
if [ -f $(CONFIG_TPL) ]; then \
if [ "$(filter comp-lib,$(MAKECMDGOALS))" = "" ]; then \
printf "BUILDING WITH EXISTING CONFIGURATION:\n\n"; \
command grep -m 1 "VENDOR *:" $(CONFIG_TPL)|cut -c 3-; \
command grep -m 1 "MODEL *:" $(CONFIG_TPL)|cut -c 3-; \
echo ""; \
fi \
else \
if ([ "$(MAKECMDGOALS)" = "all" ]) || ([ "$(DEFAULT_BLD)" != "" ] && [ -f $(DEFAULT_BLD) ] && \
([ "$(DEFAULT_BLD)" = "$(RULE_DIR)/misc/config.generic.default" ] \
|| [ "$(MAKECMDGOALS)" = "" ] || [ "$(MAKECMDGOALS)" = "config" ])); then \
printf "# Automatically Generated Section End\n\n" >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "VENDOR :" $$(basename $(DEFAULT_BLD)|cut -d. -f2) >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "MODEL :" $$(basename $(DEFAULT_BLD)|cut -d. -f3) >> $(CONFIG_TPL); \
cat $(DEFAULT_BLD) >> $(CONFIG_TPL); \
else \
printf "SELECT A CONFIGURATION:\n\n"; \
LIST=$$(for i in $(CONFIG_DIR)/config.*.*; do basename $${i}; done|sort); \
select V in $${LIST}; do \
echo ""; \
printf "# Automatically Generated Section End\n\n" >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "VENDOR :" $$(echo $${V}|cut -d. -f2) >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "MODEL :" $$(echo $${V}|cut -d. -f3) >> $(CONFIG_TPL); \
cp -f -P $(IMPORT_DIR)/$$(echo $${V}|cut -d. -f2)/$(PREBUILT_LIBDIR)/*.so* $(SYSROOT_LIB) 2>/dev/null; \
cat $(CONFIG_DIR)/$${V} >> $(CONFIG_TPL); \
break; \
done; \
fi && \
printf "SELECTED CONFIGURATION:\n\n" && \
command grep -m 1 "VENDOR *:" $(CONFIG_TPL)|cut -c 3- && \
command grep -m 1 "MODEL *:" $(CONFIG_TPL)|cut -c 3- && \
echo ""; \
if [ "$(MAKECMDGOALS)" = "config" ]; then true; else \
if [ "$(DEFAULT_BLD)" = "" ]; then \
touch $(STAMP_PRJ_CFG); \
fi; \
fi; \
for i in $(RESET_ENV_VARS); do unset $${i}; done; \
$(MAKE) --no-print-directory -f $(TOP_MAKEFILE) $(STAMP_BLD_VAR); \
fi)
@$(MAKE) --no-print-directory one
DL_TOOLCHAIN_VARS = \
TOOLCHAIN_DLDIR \
OUTPUT_DIR \
toolchain:
@$(foreach V,$(DL_TOOLCHAIN_VARS),$(V)=$($(V))) \
CC=$(shell basename $(CC)) \
AR=$(shell basename $(AR)) \
RELPATH=` $(call Relative_TcPath,$(shell basename $(CC))) ` \
GITPATH=` $(call Gitrepo_TcPath,$(shell basename $(CC))) ` \
bash $(RULE_DIR)/scripts/gen_cross_toolchain.sh
reconfig: distclean
$(TOP_Q)+( \
if [ -d $(CONFIG_DIR) ]; then \
$(RECURSIVE_MAKE) config DEFAULT_BLD=not-exist-actually; \
else \
$(RECURSIVE_MAKE) config; \
fi)
$(TOP_Q)rm -f $(STAMP_PRJ_CFG)
clean:
$(TOP_Q) \
$(TOP_Q) \
rm -rf \
$(LIBOBJ_TMPDIR) \
$(COMPILE_LOG) \
$(DIST_DIR)/* \
$(STAMP_DIR) \
$(STAMP_LCOV) \
$(SYSROOT_INC)/* $(SYSROOT_LIB)/* $(SYSROOT_LIB)/../bin/* \
$(shell $(SHELL_DBG) find $(OUTPUT_DIR) -name "$(COMPILE_LOG)" \
-or -name "$(WARNING_LOG)" \
-or -name "$(STAMP_BUILD)" \
-or -name "$(STAMP_INSTALL)" \
-or -name "$(STAMP_POSTINS)" \
-or -name "*.so" \
-or -name "*.a" \
-or -name "*.o" \
-or -name "*.d" \
-or -name "*.gc*" \
| grep -v '$(OUTPUT_DIR)/compiler' \
2>/dev/null)
distclean:
$(TOP_Q) \
rm -rf \
$(CONFIG_TPL) $(COMPILE_LOG) \
$(STAMP_PRJ_CFG) $(STAMP_BLD_ENV) $(STAMP_BLD_VAR) $(STAMP_POST_RULE) $(STAMP_LCOV) \
$(DIST_DIR) $(STAMP_DIR) *.gcda \
$(TOP_Q) \
if [ -d $(OUTPUT_DIR) ]; then \
cd $(OUTPUT_DIR); \
if [ "$(CONFIG_TOOLCHAIN_NAME)" = "" ]; then \
rm -rf *; \
else \
rm -rf $$(ls -I $(CONFIG_TOOLCHAIN_NAME)); \
fi \
fi
#buildDate=$(shell date "+%Y.%m.%d")
releaseDir=kk
package:
@echo "$(buildDate)"
echo "$(releaseDir)"
rm -rf $(releaseDir)
mkdir $(releaseDir)
mkdir $(releaseDir)/lib
mkdir $(releaseDir)/bin
cp -rf $(TOP_DIR)/tsl $(TOP_DIR)/$(releaseDir)
cp -rf $(TOP_DIR)/output/release/lib/*.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/output/release/bin/* $(TOP_DIR)/$(releaseDir)/bin
cp -rf $(TOP_DIR)/process_check.sh $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_map_table.json $(TOP_DIR)/$(releaseDir)/dev_config_table/
ifeq ($(CONFIG_MODEL),ubuntu)
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_ubuntu.so $(TOP_DIR)/$(releaseDir)/lib/libnanomsg.so.5
cp -rf $(TOP_DIR)/common/ev/libev_ubuntu.so $(TOP_DIR)/$(releaseDir)/lib
else ifeq ($(CONFIG_MODEL),nx5)
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_nx5.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/ev/libev_nx5.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3.so $(TOP_DIR)/$(releaseDir)/lib
else
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/ev/libev.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3.so $(TOP_DIR)/$(releaseDir)/lib
endif
cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/build/exe/Z3GatewayHost $(TOP_DIR)/$(releaseDir)/
fromdos $(releaseDir)/*.sh
echo $(PWD)
squashfs: package
@echo "build squashfs"
rm -rf kkdir kkdir.squashfs
mkdir kkdir
cp -rf $(TOP_DIR)/$(releaseDir) $(TOP_DIR)/kkdir/
cp -rf $(TOP_DIR)/app.sh $(TOP_DIR)/kkdir/
TOP_DIR='$(TOP_DIR)' $(TOP_DIR)/tools/mk2fs/mk2fs.sh
rm -rf kkdir kkdir.squashfs
echo $(PWD)
firmware:
@echo "build firmware"
ifneq (ap86-key-factory.bin, $(wildcard ap86-key-factory.bin))
@echo "================请把包括产测的固件ap86-key-factory.bin放在当前目录下================="
exit 1
endif
cp -rf $(TOP_DIR)/ap86-key-factory.bin $(TOP_DIR)/tools/mk2fs/
cd $(TOP_DIR)/tools/mk2fs/ && ./mkfirmware-ap86-key.sh
mv $(TOP_DIR)/tools/mk2fs/ap86-key-new-zone-factory-burn-firmware.bin $(TOP_DIR)/
rm $(TOP_DIR)/tools/mk2fs/ap86-key-factory.bin
@echo "build firmware success"
ifeq ($(shell uname),Darwin)
KCONFIG_MCONF := tools/prebuilt/macos/kconfig-frontends-mac/kconfig-mconf
else
KCONFIG_MCONF := tools/prebuilt/ubuntu/bin/kconfig-mconf
endif
COMMON_CONFIG_ENV = \
KCONFIG_CONFIG=mconf.config \
KCONFIG_AUTOCONFIG=$(OUTPUT_DIR)/auto.conf \
KCONFIG_AUTOHEADER=$(OUTPUT_DIR)/autoconf.h \
CONFIG_=FEATURE_ \
menuconfig: $(KCONFIG_MCONF)
$(TOP_Q)chmod a+x $(KCONFIG_MCONF) $(if $(TOP_Q),2>/dev/null) || true
$(TOP_Q)$(COMMON_CONFIG_ENV) $^ -s $(TOP_DIR)/tools/Config.in $(if $(TOP_Q),2>/dev/null)
$(TOP_Q) \
( \
if [ ! -f mconf.config ]; then exit 0; fi; \
\
cp -Lf mconf.config make.settings; \
rm -f mconf.config*; \
)
.PHONY: doc detect config reconfig toolchain sub-mods final-out env cmake one help package squashfs firmware
all: detect config toolchain sub-mods final-out
$(TOP_Q) \
if [ -f $(STAMP_PRJ_CFG) ]; then \
$(RECURSIVE_MAKE) toolchain; \
rm -f $(STAMP_PRJ_CFG); \
fi
@rm -rf $(STAMP_DIR)
RESET_ENV_VARS := \
CROSS_PREFIX \
CFLAGS \
HOST \
LDFLAGS \
help:
@echo -e "\033[1;37m[$(RULE_DIR)/docs]\e[0m"
@echo ""
@cat $(RULE_DIR)/docs/Help.md
@echo ""
doc:
$(TOP_Q)rm -rf $(DOXYGEN_DIR)/html; mkdir -p $(DOXYGEN_DIR)
$(TOP_Q) \
$(SED) \
-e 's:^PROJECT_NAME.*:PROJECT_NAME = $(PRJ_NAME):g;' \
-e 's:^PROJECT_NUMBER.*:PROJECT_NUMBER = $(PRJ_VERSION):g;' \
-e 's:^OUTPUT_DIRECTORY.*:OUTPUT_DIRECTORY = $(DOXYGEN_DIR):g;' \
build-rules/misc/Doxyfile.tpl > $(OUTPUT_DIR)/.doxygen.cfg
$(TOP_Q)doxygen $(OUTPUT_DIR)/.doxygen.cfg
detect:
@if [ -d .git ]; then \
mkdir -p .git/hooks; \
for i in $(RULE_DIR)/hooks/*; do \
cp -f $$i .git/hooks && chmod a+x .git/hooks/$$(basename $$i); \
done; \
fi
prune:
@echo "$(TOP_DIR).pkgs directory removed!"|grep --color ".*"
@rm -rf $(TOP_DIR).pkgs
@$(MAKE) --no-print-directory distclean
unzip: config $(STAMP_BLD_VAR)
@echo "Components: "
@echo ""
@for i in $(ALL_SUB_DIRS); do \
$(MAKE) --no-print-directory pre-build target-$${i} ; \
echo -ne "\r. $${i}"; \
echo -e " "; \
done
@echo ""
cmake:
$(TOP_Q)$(MAKE) -s distclean
$(TOP_Q)$(MAKE) -s DEFAULT_BLD=$(RULE_DIR)/misc/config.generic.cmake config
$(TOP_Q)$(foreach V,$(INFO_ENV_VARS),$(V)="$($(V))") CFLAGS=$(CFLAGS) \
SEP_LIBS="$$(grep -m 1 '^COMP_LIB_FILES' $(STAMP_BLD_ENV) | cut -d' ' -f3-)" \
bash $(if $(TOP_Q),,-x) $(RULE_DIR)/scripts/gen_top_cmake.sh $(TOP_DIR)/CMakeLists.txt
$(TOP_Q)for D in $(ALL_SUB_DIRS); do \
echo "+ $${D}"; \
$(MAKE) --no-print-directory -C $(OUTPUT_DIR)/$${D} cmake; \
done
$(TOP_Q)echo ""
one: COMP_LIB_OBJS = $(foreach V,$(COMP_LIB_COMPONENTS),$(foreach U,$(LIB_OBJS_$(V)),$(V)/$(U)))
one:
$(TOP_Q)$(foreach V,$(INFO_ENV_VARS),$(V)="$($(V))") \
CFLAGS="$(subst ",,$(CFLAGS))" \
ALL_LIBS="$(strip $(foreach V,$(SUBDIRS),$(LIBA_TARGET_$(V))))" \
ALL_LIBSO="$(strip $(foreach V,$(SUBDIRS),$(LIBSO_TARGET_$(V))))" \
ALL_PROG="$(strip $(foreach V,$(SUBDIRS) $(COMP_LIB_COMPONENTS),$(TARGET_$(V))))" \
COMP_LIB_OBJS="$(COMP_LIB_OBJS)" \
bash $(RULE_DIR)/scripts/gen_one_makefile.sh
config:
@mkdir -p $(OUTPUT_DIR) $(STAMP_DIR) $(INSTALL_DIR)
@mkdir -p $(SYSROOT_BIN) $(SYSROOT_INC) $(SYSROOT_LIB)
$(TOP_Q) \
if [ -f $(STAMP_BLD_VAR) ]; then \
if [ "$$($(SED) '/[-_/a-zA-Z0-9]* = *..*/d' $(STAMP_BLD_VAR)|wc -l|$(SED) 's:^ *::g')" != "0" ]; then \
rm -vf $(STAMP_BLD_VAR); \
fi \
fi
$(TOP_Q)+( \
if [ -f $(CONFIG_TPL) ]; then \
if [ "$(filter comp-lib,$(MAKECMDGOALS))" = "" ]; then \
printf "BUILDING WITH EXISTING CONFIGURATION:\n\n"; \
command grep -m 1 "VENDOR *:" $(CONFIG_TPL)|cut -c 3-; \
command grep -m 1 "MODEL *:" $(CONFIG_TPL)|cut -c 3-; \
echo ""; \
fi \
else \
if ([ "$(MAKECMDGOALS)" = "all" ]) || ([ "$(DEFAULT_BLD)" != "" ] && [ -f $(DEFAULT_BLD) ] && \
([ "$(DEFAULT_BLD)" = "$(RULE_DIR)/misc/config.generic.default" ] \
|| [ "$(MAKECMDGOALS)" = "" ] || [ "$(MAKECMDGOALS)" = "config" ])); then \
printf "# Automatically Generated Section End\n\n" >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "VENDOR :" $$(basename $(DEFAULT_BLD)|cut -d. -f2) >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "MODEL :" $$(basename $(DEFAULT_BLD)|cut -d. -f3) >> $(CONFIG_TPL); \
cat $(DEFAULT_BLD) >> $(CONFIG_TPL); \
else \
printf "SELECT A CONFIGURATION:\n\n"; \
LIST=$$(for i in $(CONFIG_DIR)/config.*.*; do basename $${i}; done|sort); \
select V in $${LIST}; do \
echo ""; \
printf "# Automatically Generated Section End\n\n" >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "VENDOR :" $$(echo $${V}|cut -d. -f2) >> $(CONFIG_TPL); \
printf "# %-10s %s\n" "MODEL :" $$(echo $${V}|cut -d. -f3) >> $(CONFIG_TPL); \
cp -f -P $(IMPORT_DIR)/$$(echo $${V}|cut -d. -f2)/$(PREBUILT_LIBDIR)/*.so* $(SYSROOT_LIB) 2>/dev/null; \
cat $(CONFIG_DIR)/$${V} >> $(CONFIG_TPL); \
break; \
done; \
fi && \
printf "SELECTED CONFIGURATION:\n\n" && \
command grep -m 1 "VENDOR *:" $(CONFIG_TPL)|cut -c 3- && \
command grep -m 1 "MODEL *:" $(CONFIG_TPL)|cut -c 3- && \
echo ""; \
if [ "$(MAKECMDGOALS)" = "config" ]; then true; else \
if [ "$(DEFAULT_BLD)" = "" ]; then \
touch $(STAMP_PRJ_CFG); \
fi; \
fi; \
for i in $(RESET_ENV_VARS); do unset $${i}; done; \
$(MAKE) --no-print-directory -f $(TOP_MAKEFILE) $(STAMP_BLD_VAR); \
fi)
@$(MAKE) --no-print-directory one
DL_TOOLCHAIN_VARS = \
TOOLCHAIN_DLDIR \
OUTPUT_DIR \
toolchain:
@$(foreach V,$(DL_TOOLCHAIN_VARS),$(V)=$($(V))) \
CC=$(shell basename $(CC)) \
AR=$(shell basename $(AR)) \
RELPATH=` $(call Relative_TcPath,$(shell basename $(CC))) ` \
GITPATH=` $(call Gitrepo_TcPath,$(shell basename $(CC))) ` \
bash $(RULE_DIR)/scripts/gen_cross_toolchain.sh
reconfig: distclean
$(TOP_Q)+( \
if [ -d $(CONFIG_DIR) ]; then \
$(RECURSIVE_MAKE) config DEFAULT_BLD=not-exist-actually; \
else \
$(RECURSIVE_MAKE) config; \
fi)
$(TOP_Q)rm -f $(STAMP_PRJ_CFG)
clean:
$(TOP_Q) \
$(TOP_Q) \
rm -rf \
$(LIBOBJ_TMPDIR) \
$(COMPILE_LOG) \
$(DIST_DIR)/* \
$(STAMP_DIR) \
$(STAMP_LCOV) \
$(SYSROOT_INC)/* $(SYSROOT_LIB)/* $(SYSROOT_LIB)/../bin/* \
$(shell $(SHELL_DBG) find $(OUTPUT_DIR) -name "$(COMPILE_LOG)" \
-or -name "$(WARNING_LOG)" \
-or -name "$(STAMP_BUILD)" \
-or -name "$(STAMP_INSTALL)" \
-or -name "$(STAMP_POSTINS)" \
-or -name "*.so" \
-or -name "*.a" \
-or -name "*.o" \
-or -name "*.d" \
-or -name "*.gc*" \
| grep -v '$(OUTPUT_DIR)/compiler' \
2>/dev/null)
distclean:
$(TOP_Q) \
rm -rf \
$(CONFIG_TPL) $(COMPILE_LOG) \
$(STAMP_PRJ_CFG) $(STAMP_BLD_ENV) $(STAMP_BLD_VAR) $(STAMP_POST_RULE) $(STAMP_LCOV) \
$(DIST_DIR) $(STAMP_DIR) *.gcda \
$(TOP_Q) \
if [ -d $(OUTPUT_DIR) ]; then \
cd $(OUTPUT_DIR); \
if [ "$(CONFIG_TOOLCHAIN_NAME)" = "" ]; then \
rm -rf *; \
else \
rm -rf $$(ls -I $(CONFIG_TOOLCHAIN_NAME)); \
fi \
fi
#buildDate=$(shell date "+%Y.%m.%d")
releaseDir=kk
package:
@echo "$(buildDate)"
echo "$(releaseDir)"
rm -rf $(releaseDir)
mkdir $(releaseDir)
mkdir $(releaseDir)/lib
mkdir $(releaseDir)/bin
cp -rf $(TOP_DIR)/tsl $(TOP_DIR)/$(releaseDir)
cp -rf $(TOP_DIR)/output/release/lib/*.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/output/release/bin/* $(TOP_DIR)/$(releaseDir)/bin
cp -rf $(TOP_DIR)/process_check.sh $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_config_table $(TOP_DIR)/$(releaseDir)/
#cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/ZB/dev_map_table.json $(TOP_DIR)/$(releaseDir)/dev_config_table/
ifeq ($(CONFIG_MODEL),ubuntu)
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_ubuntu.so $(TOP_DIR)/$(releaseDir)/lib/libnanomsg.so.5
cp -rf $(TOP_DIR)/common/ev/libev_ubuntu.so $(TOP_DIR)/$(releaseDir)/lib
else ifeq ($(CONFIG_MODEL),nx5)
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg_nx5.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/ev/libev_nx5.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3.so $(TOP_DIR)/$(releaseDir)/lib
else
cp -rf $(TOP_DIR)/common/nanomsg/libnanomsg.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/ev/libev.so $(TOP_DIR)/$(releaseDir)/lib
cp -rf $(TOP_DIR)/common/sqlite/libsqlite3.so $(TOP_DIR)/$(releaseDir)/lib
endif
cp -rf $(TOP_DIR)/platform/zigbee/app/builder/Z3GatewayHost/build/exe/Z3GatewayHost $(TOP_DIR)/$(releaseDir)/
fromdos $(releaseDir)/*.sh
echo $(PWD)
squashfs: package
@echo "build squashfs"
rm -rf kkdir kkdir.squashfs
mkdir kkdir
cp -rf $(TOP_DIR)/$(releaseDir) $(TOP_DIR)/kkdir/
cp -rf $(TOP_DIR)/app.sh $(TOP_DIR)/kkdir/
TOP_DIR='$(TOP_DIR)' $(TOP_DIR)/tools/mk2fs/mk2fs.sh
rm -rf kkdir kkdir.squashfs
echo $(PWD)
firmware:
@echo "build firmware"
ifneq (ap86-key-factory.bin, $(wildcard ap86-key-factory.bin))
@echo "================请把包括产测的固件ap86-key-factory.bin放在当前目录下================="
exit 1
endif
cp -rf $(TOP_DIR)/ap86-key-factory.bin $(TOP_DIR)/tools/mk2fs/
cd $(TOP_DIR)/tools/mk2fs/ && ./mkfirmware-ap86-key.sh
mv $(TOP_DIR)/tools/mk2fs/ap86-key-new-zone-factory-burn-firmware.bin $(TOP_DIR)/
rm $(TOP_DIR)/tools/mk2fs/ap86-key-factory.bin
@echo "build firmware success"
ifeq ($(shell uname),Darwin)
KCONFIG_MCONF := tools/prebuilt/macos/kconfig-frontends-mac/kconfig-mconf
else
KCONFIG_MCONF := tools/prebuilt/ubuntu/bin/kconfig-mconf
endif
COMMON_CONFIG_ENV = \
KCONFIG_CONFIG=mconf.config \
KCONFIG_AUTOCONFIG=$(OUTPUT_DIR)/auto.conf \
KCONFIG_AUTOHEADER=$(OUTPUT_DIR)/autoconf.h \
CONFIG_=FEATURE_ \
menuconfig: $(KCONFIG_MCONF)
$(TOP_Q)chmod a+x $(KCONFIG_MCONF) $(if $(TOP_Q),2>/dev/null) || true
$(TOP_Q)$(COMMON_CONFIG_ENV) $^ -s $(TOP_DIR)/tools/Config.in $(if $(TOP_Q),2>/dev/null)
$(TOP_Q) \
( \
if [ ! -f mconf.config ]; then exit 0; fi; \
\
cp -Lf mconf.config make.settings; \
rm -f mconf.config*; \
)
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