Commit 7549830f authored by 尹佳钦's avatar 尹佳钦

20210910,克隆。

parent 06b76807
......@@ -16,6 +16,9 @@
#define GUARD_STATUS_ARMING_LEAVE_HOME "ARMING_LEAVE_HOME"
#define GUARD_STATUS_DISARMING "DISARMING"
#define GUARD_STATUS_ARMING_IN_HOME "ARMING_IN_HOME"
#define ARMING_STATUS_GUARD_ZONE "ARMING_CUSTOM_GUARD_ZONE"
#define EMPTY_STR ""
......
......@@ -249,11 +249,14 @@ int kk_zb_devs_hw_ack_all(int sockfd)
cJSON *array = cJSON_CreateArray();
cJSON *item;
_kk_map_dev_mutex_lock();
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_map_dev_mutex_unlock();
_kk_zb_devs_hw_ack(sockfd,array);
return -1;
}
......@@ -266,6 +269,7 @@ int kk_zb_dev_hw_info_build_by_deviceCode(int sockfd,const char *deviceCode)
unsigned char online_status = 0;
int pid =-1;
_kk_map_dev_mutex_lock();
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)) {
......@@ -275,6 +279,7 @@ int kk_zb_dev_hw_info_build_by_deviceCode(int sockfd,const char *deviceCode)
return item;
}
}
_kk_map_dev_mutex_unlock();
return NULL;
}
......@@ -436,7 +441,7 @@ int is_arming_status_notify(cJSON *payload)
cJSON *params = NULL;
cJSON *ArmingState = NULL;
if((params = cJSON_GetObjectItem(payload, MSG_PARAMS_STR))!=NULL){
if((ArmingState = cJSON_GetObjectItem(payload, "ArmingState"))!=NULL){
if((ArmingState = cJSON_GetObjectItem(params, "ArmingState"))!=NULL){
if(ArmingState->type==cJSON_String &&
ArmingState->valuestring!=NULL){
return atoi(ArmingState->valuestring);
......@@ -482,9 +487,11 @@ void KK_Data_FromMid(void* str,int len)
if (strstr(msgtype->valuestring,SYNC_MSG_TYPE_REPLY) != NULL){
kk_parse_syncinfo(payload);
kk_create_syncinfo_to_sdk(payload);
}else if(strstr(msgtype->valuestring,"/thing/event/property/post")!= NULL){
}
else if(strstr(msgtype->valuestring,"/thing/event/property/post")!= NULL){
if(is_ccu_msg(productCode,deviceCode)){
int type;
if((type = is_arming_status_notify(payload))!=-1){
arming_status_notify(type);
......@@ -492,8 +499,6 @@ void KK_Data_FromMid(void* str,int len)
}else{
property_post_deal(deviceCode->valuestring,payload);
}
}else if(strstr(msgtype->valuestring,"/thing/topo/delete")!= NULL){
device_delete_sync(payload);
}else if(strstr(msgtype->valuestring,"/thing/status/online")!= NULL){
......
......@@ -18,14 +18,14 @@ kk_map_dev_ctx *_kk_map_dev_ctx(void)
return &g_map_dev_mgr;
}
static void _kk_map_dev_mutex_lock(void)
void _kk_map_dev_mutex_lock(void)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
if (ctx->mutex) {
kk_MutexLock(ctx->mutex);
}
}
static void _kk_map_dev_mutex_unlock(void)
void _kk_map_dev_mutex_unlock(void)
{
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
if (ctx->mutex) {
......@@ -53,7 +53,6 @@ void kk_map_dev_deinit(void)
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
printf("[lock]_kk_map_dev_mutex_lock\n");
_kk_map_dev_mutex_lock();
list_for_each_entry_safe(node,n,&ctx->dev_list, linked_list, kk_map_dev_node_t) {
......@@ -74,7 +73,6 @@ void kk_map_dev_deinit(void)
}
}
printf("[unlock]_kk_map_dev_mutex_lock\n");
_kk_map_dev_mutex_unlock();
}
......@@ -87,6 +85,7 @@ static kk_map_dev_node_t *kk_map_dev_node_create(const char *deviceCode,const ch
cJSON *newccu = NULL,*oldccu = NULL,*channel = NULL,*optype = NULL;
cJSON *syn_type = NULL,*syn_opcode = NULL;
printf("kk_map_dev_node_create\n");
node = malloc(sizeof(kk_map_dev_node_t));
if (node == NULL) {
return NULL;
......@@ -410,17 +409,21 @@ int kk_map_dev_search_by_deviceCode(char *deviceCode, kk_map_dev_node_t **node)
kk_map_dev_node_t *n = NULL;
//list_for_each_entry_safe
printf("[QAQ] kk_map_dev_search_by_deviceCode\n");
list_for_each_entry(search_node, &ctx->dev_list, linked_list, kk_map_dev_node_t) {
printf("+++\n");
if ( (strlen(search_node->deviceCode) == strlen(deviceCode)) &&
(memcmp(search_node->deviceCode, deviceCode, strlen(deviceCode)) == 0)) {
/* dm_log_debug("Device Found, devid: %d", devid); */
if (node) {
*node = search_node;
}
printf("[find]%s\n",search_node->deviceCode);
return 0;
}
}
ERROR_PRINT("Device Not Found, deviceCode: %s\n", deviceCode);
return -1;
}
......
......@@ -64,6 +64,7 @@ int main(int argc, char* argv[])
char *ppp;
open("kk_lan",LOG_PID,LOG_USER);
kk_lan_ccuid_init();
/*set the callback to get the device date to cloud*/
kk_ipc_init(IPC_APP2MID,(ipc_cb*)KK_Data_FromMid,NULL,NULL);
......
This diff is collapsed.
......@@ -42,7 +42,7 @@ cJSON *kk_get_raw_sync_data(cJSON *payload);
cJSON *kk_sync_rooms_to_sdk(cJSON *root,cJSON *payload);
cJSON *kk_sync_scence_to_sdk(cJSON *root,cJSON *data);
int kk_sync_devices_to_sdk(cJSON *root);
int kk_sync_devices_to_sdk(cJSON *root,cJSON *data);
int kk_sync_devices_status_to_sdk(cJSON *root);
int kk_create_syncinfo_to_sdk(cJSON *payload);
......
......@@ -138,7 +138,6 @@ cJSON *kk_devicestatus_build(kk_map_dev_node_t *node)
cJSON *newccu,*oldccu;
cJSON *dev_status;
kk_map_dev_ctx *ctx = _kk_map_dev_ctx();
printf("@@@@kk_devicestatus_build\n");
if (node == NULL ||node->syn_opcode==NULL){
......@@ -263,6 +262,7 @@ cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJS
cJSON *val;
cJSON *item_size;
cJSON *channel;
cJSON *epNum=NULL;
cJSON *opcode;
......@@ -278,6 +278,7 @@ cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJS
newccu = devNode->newccu;
item_size = cJSON_GetArraySize(oldccu);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
for(i=0;i<item_size;i++){
o_item = cJSON_GetArrayItem(oldccu,i);
......@@ -287,7 +288,7 @@ cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJS
n_id = cJSON_GetObjectItem(params,o_id_map->valuestring);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if(n_id!=NULL){
n_dataType = cJSON_GetObjectItem(n_item,"dataType");
......@@ -298,6 +299,16 @@ cJSON * attr_report_conver(const char *deviceCode,kk_map_dev_node_t *devNode,cJS
channel = cJSON_GetObjectItem(o_item,"channel");
epNum = cJSON_GetObjectItem(params,"epNum");
if(channel==NULL||epNum==NULL){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue;
}
if(strlen(channel->valuestring)!=strlen(epNum->valuestring) ||
strcmp(channel->valuestring,epNum->valuestring)!=0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue;
}
ch = atoi(channel->valuestring);
nodeId = kk_lan_db_node_get(deviceCode,ch);
......@@ -465,6 +476,7 @@ void property_syn_deal(const char *deviceCode,cJSON *properties)
kk_map_dev_node_t *dev;
if(kk_map_dev_search_by_deviceCode(deviceCode, &dev)==0){
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
attr_report_conver(deviceCode,dev,properties);
}
}
......@@ -495,10 +507,14 @@ int arming_status_notify(int type)
msg = old_ccu_msg_build(WILDCARD_CHARACTER_STR,GUARD_STATUS_DISARMING,SUCCESS_STR,WILDCARD_CHARACTER_STR);
}else if(type==2){
msg = old_ccu_msg_build(WILDCARD_CHARACTER_STR,GUARD_STATUS_ARMING_IN_HOME,SUCCESS_STR,WILDCARD_CHARACTER_STR);
}else if(type==3){
msg = old_ccu_msg_build(WILDCARD_CHARACTER_STR,ARMING_STATUS_GUARD_ZONE,SUCCESS_STR,WILDCARD_CHARACTER_STR);
}else{
printf("[unkown arming type]!!!\n");
return -1;
}
send_msg_to_module(msg);
cJSON_Delete(msg);
return 0;
......
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