Commit a8d1c966 authored by 尹佳钦's avatar 尹佳钦

8009语音面板控制设备支持:插座,灯控,窗帘

parent 750c1fa7
...@@ -501,7 +501,7 @@ void KK_Data_FromMid(void* str,int len) ...@@ -501,7 +501,7 @@ void KK_Data_FromMid(void* str,int len)
arming_status_notify(type); arming_status_notify(type);
} }
}else{ }else{
//property_post_deal(deviceCode->valuestring,payload); property_post_deal(deviceCode->valuestring,payload);
} }
}else if(strstr(msgtype->valuestring,"/thing/topo/delete")!= NULL){ }else if(strstr(msgtype->valuestring,"/thing/topo/delete")!= NULL){
device_delete_sync(payload); device_delete_sync(payload);
......
...@@ -36,30 +36,30 @@ ...@@ -36,30 +36,30 @@
static char s_ccuid[DEVICE_CODE_LEN] = {0}; static char s_ccuid[DEVICE_CODE_LEN] = {0};
int kk_lan_get_ccuid(_OU_ char *device_code) int kk_lan_get_ccuid(_OU_ char *device_code)
{ {
strncpy(device_code, s_ccuid, strlen(s_ccuid)); strncpy(device_code, s_ccuid, strlen(s_ccuid));
printf("kk_lan_get_ccuid:%s\n",s_ccuid); printf("kk_lan_get_ccuid:%s\n",s_ccuid);
return strlen(s_ccuid); return strlen(s_ccuid);
} }
static int _setDevice_Code(_IN_ char *device_code,int len) static int _setDevice_Code(_IN_ char *device_code,int len)
{ {
memset(s_ccuid, 0x0, DEVICE_CODE_LEN); memset(s_ccuid, 0x0, DEVICE_CODE_LEN);
printf("_setDevice_Code:%s\n",device_code); printf("_setDevice_Code:%s\n",device_code);
strncpy(s_ccuid, device_code, len); strncpy(s_ccuid, device_code, len);
return len; return len;
} }
extern int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len); extern int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len);
static void kk_lan_ccuid_init(void) static void kk_lan_ccuid_init(void)
{ {
uint8_t ccuid[DEVICE_CODE_LEN] = {0}; uint8_t ccuid[DEVICE_CODE_LEN] = {0};
int ccuid_len = 0; int ccuid_len = 0;
HAL_Execel_cmd(GET_CCUID_CMD,(char *)ccuid,sizeof(ccuid),&ccuid_len); HAL_Execel_cmd(GET_CCUID_CMD,(char *)ccuid,sizeof(ccuid),&ccuid_len);
printf("GET_CCUID_CMD:%s\n",ccuid); printf("GET_CCUID_CMD:%s\n",ccuid);
if(ccuid_len > 0 && ccuid_len <= DEVICE_CODE_LEN){ if(ccuid_len > 0 && ccuid_len <= DEVICE_CODE_LEN){
_setDevice_Code((char *)ccuid,ccuid_len-1); _setDevice_Code((char *)ccuid,ccuid_len-1);
}else{ }else{
_setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID)); _setDevice_Code(KK_CCU_ID,strlen(KK_CCU_ID));
} }
} }
......
This diff is collapsed.
...@@ -2,12 +2,34 @@ ...@@ -2,12 +2,34 @@
#include "kk_lan_vp_ctrl.h" #include "kk_lan_vp_ctrl.h"
#include "cJSON.h" #include "cJSON.h"
cJSON *PowerSwitch_msg_build(int ep,int onoff)
{
char epNum[12] = {0};
cJSON *params = cJSON_CreateObject();
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
memset(epNum,0,sizeof(epNum));
snprintf(epNum,sizeof(epNum),"%d",ep);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddStringToObject(params,"epNum",epNum);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddNumberToObject(params,"PowerSwitch",onoff);
printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return params;
}
static int is_light_dev(int pid); static int is_light_dev(int pid);
static cJSON *light_dev(int ep,int onoff); static cJSON *light_dev(int ep,int onoff);
static cJSON *light_dev_handle(int ep,uint8_t *arg); static cJSON *light_dev_handle(int ep,uint8_t *arg);
static int is_curtain_dev(int pid);
static cJSON *curtain_dev_msg_build(int ep,int OperationMode);
static cJSON *curtain_dev_handle(int ep,uint8_t *arg);
static int is_outlet_dev(int pid);
static cJSON *outlet_msg_build(int ep,int onoff);
static cJSON *outlet_dev_handle(int ep,uint8_t *arg);
typedef int (*pid_mth_func)(int pid); typedef int (*pid_mth_func)(int pid);
typedef cJSON *(*dev_handle)(int ep,uint8_t *arg); typedef cJSON *(*dev_handle)(int ep,uint8_t *arg);
...@@ -18,13 +40,24 @@ typedef struct{ ...@@ -18,13 +40,24 @@ typedef struct{
}KK_VP_CTRL; }KK_VP_CTRL;
static KK_VP_CTRL vp_ctrl_table[]={ static KK_VP_CTRL vp_ctrl_table[]={
{is_light_dev,light_dev_handle} {is_light_dev,light_dev_handle},
{is_curtain_dev,curtain_dev_handle},
{is_outlet_dev,outlet_dev_handle}
}; };
static int light_dev_pid[]={ static int light_dev_pid[]={
3023,3024 3023,3024
}; };
static int curtain_dev_pid[]={
3067
};
static int outlet_dev_pid[]={
3020
};
static int is_light_dev(int pid) static int is_light_dev(int pid)
{ {
int i; int i;
...@@ -36,7 +69,53 @@ static int is_light_dev(int pid) ...@@ -36,7 +69,53 @@ static int is_light_dev(int pid)
return 0; return 0;
} }
cJSON *light_dev_msg_build(int ep,int onoff) static int is_curtain_dev(int pid)
{
int i;
for(i=0;i<sizeof(curtain_dev_pid)/sizeof(int);i++){
if(pid==curtain_dev_pid[i]){
return 1;
}
}
return 0;
}
static int is_outlet_dev(int pid)
{
int i;
for(i=0;i<sizeof(outlet_dev_pid)/sizeof(int);i++){
if(pid==outlet_dev_pid[i]){
return 1;
}
}
return 0;
}
static cJSON *light_msg_build(int ep,int onoff)
{
return PowerSwitch_msg_build(ep,onoff);
}
static cJSON *light_dev_handle(int ep,uint8_t *arg)
{
uint8_t skill_type = arg[0];
printf("[%s][%d]skill_type=%d,ep=%d\n",__FUNCTION__,__LINE__,skill_type,ep);
switch(skill_type){
case VP_CTRL_OPEN://
return light_msg_build(ep,1);
case VP_CTRL_CLOSE:
return light_msg_build(ep,0);
default:break;
}
return NULL;
}
static cJSON *curtain_dev_msg_build(int ep,int OperationMode)
{ {
char epNum[12] = {0}; char epNum[12] = {0};
cJSON *params = cJSON_CreateObject(); cJSON *params = cJSON_CreateObject();
...@@ -47,20 +126,43 @@ cJSON *light_dev_msg_build(int ep,int onoff) ...@@ -47,20 +126,43 @@ cJSON *light_dev_msg_build(int ep,int onoff)
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddStringToObject(params,"epNum",epNum); cJSON_AddStringToObject(params,"epNum",epNum);
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
cJSON_AddNumberToObject(params,"PowerSwitch",onoff); cJSON_AddNumberToObject(params,"OperationMode",OperationMode);
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
return params; return params;
} }
static cJSON *light_dev_handle(int ep,uint8_t *arg) static cJSON *curtain_dev_handle(int ep,uint8_t *arg)
{
uint8_t skill_type = arg[0];
printf("[%s][%d]skill_type=%d,ep=%d\n",__FUNCTION__,__LINE__,skill_type,ep);
switch(skill_type){
case VP_CTRL_OPEN://
return curtain_dev_msg_build(ep,1);
case VP_CTRL_CLOSE:
return curtain_dev_msg_build(ep,0);
case VP_CTRL_STOP:
return curtain_dev_msg_build(ep,2);
default:break;
}
return NULL;
}
static cJSON *outlet_msg_build(int ep,int onoff)
{
return PowerSwitch_msg_build(ep,onoff);
}
static cJSON *outlet_dev_handle(int ep,uint8_t *arg)
{ {
uint8_t skill_type = arg[0]; uint8_t skill_type = arg[0];
printf("[%s][%d]skill_type=%d,ep=%d\n",__FUNCTION__,__LINE__,skill_type,ep); printf("[%s][%d]skill_type=%d,ep=%d\n",__FUNCTION__,__LINE__,skill_type,ep);
switch(skill_type){ switch(skill_type){
case VP_CTRL_OPEN:// case VP_CTRL_OPEN://
return light_dev_msg_build(ep,1); return outlet_msg_build(ep,1);
case VP_CTRL_CLOSE: case VP_CTRL_CLOSE:
return light_dev_msg_build(ep,0); return outlet_msg_build(ep,0);
default:break; default:break;
} }
return NULL; return NULL;
......
...@@ -228,7 +228,7 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con ...@@ -228,7 +228,7 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con
{ {
int i = 0,devNum = 0; int i = 0,devNum = 0;
cJSON *name = NULL; cJSON *name = NULL;
cJSON *deviceItem = NULL,*devCodeObj = NULL,*epNumObj = NULL; cJSON *deviceItem = NULL,*devCodeObj = NULL;
devNum = cJSON_GetArraySize(devices); devNum = cJSON_GetArraySize(devices);
printf("[%s][%d]devNum=%d\n",__FUNCTION__,__LINE__,devNum); printf("[%s][%d]devNum=%d\n",__FUNCTION__,__LINE__,devNum);
...@@ -239,24 +239,19 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con ...@@ -239,24 +239,19 @@ static int kk_vp_get_device_name(_IN cJSON *devices,_IN const char*epNum,_IN con
continue ; continue ;
} }
epNumObj = cJSON_GetObjectItem(deviceItem,"epNum");
devCodeObj = cJSON_GetObjectItem(deviceItem,"deviceCode"); devCodeObj = cJSON_GetObjectItem(deviceItem,"deviceCode");
if(epNumObj==NULL||epNumObj->type!=cJSON_String || if(devCodeObj==NULL||devCodeObj->type!=cJSON_String){
devCodeObj==NULL||devCodeObj->type!=cJSON_String){
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
continue ; continue ;
} }
printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(devCodeObj->valuestring), printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(devCodeObj->valuestring),
strlen(deviceCode),devCodeObj->valuestring,deviceCode); strlen(deviceCode),devCodeObj->valuestring,deviceCode);
printf("[%s][%d]%d,%d,%s,%s\n",__FUNCTION__,__LINE__,strlen(epNumObj->valuestring),
strlen(epNum),epNumObj->valuestring,epNum);
if((strlen(devCodeObj->valuestring)==strlen(deviceCode)) && if((strlen(devCodeObj->valuestring)==strlen(deviceCode)) &&
!strcmp(devCodeObj->valuestring,deviceCode) && !strcmp(devCodeObj->valuestring,deviceCode)){
(strlen(epNumObj->valuestring)==strlen(epNum)) &&
!strcmp(epNumObj->valuestring,epNum)){
printf("[%s][%d]\n",__FUNCTION__,__LINE__); printf("[%s][%d]\n",__FUNCTION__,__LINE__);
if((name = cJSON_GetObjectItem(deviceItem,"name"))!=NULL && if((name = cJSON_GetObjectItem(deviceItem,"name"))!=NULL &&
......
...@@ -60,7 +60,7 @@ int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len) ...@@ -60,7 +60,7 @@ int HAL_Execel_cmd(char * cmd,char * buf,int buf_len,int* ret_len)
} }
void *HAL_Malloc(_IN_ uint32_t size) void *HAL_Malloc(_IN_ uint32_t size)
{ {
return malloc(size); return malloc(size);
} }
void *HAL_Realloc(_IN_ void *ptr, _IN_ uint32_t size) void *HAL_Realloc(_IN_ void *ptr, _IN_ uint32_t size)
......
This diff is collapsed.
...@@ -653,10 +653,7 @@ void kk_platMsg_handle(void* data, char* chalMark){ ...@@ -653,10 +653,7 @@ void kk_platMsg_handle(void* data, char* chalMark){
if(jsonPay == NULL) goto error; if(jsonPay == NULL) goto error;
proCode = cJSON_GetObjectItem(jsonPay, MSG_PRODUCT_CODE_STR); proCode = cJSON_GetObjectItem(jsonPay, MSG_PRODUCT_CODE_STR);
devCode = cJSON_GetObjectItem(jsonPay, MSG_DEVICE_CODE_STR); devCode = cJSON_GetObjectItem(jsonPay, MSG_DEVICE_CODE_STR);
//mac = cJSON_GetObjectItem(jsonPay, "mac"); mac = cJSON_GetObjectItem(jsonPay, "mac");
mac = cJSON_GetObjectItem(jsonPay, MSG_DEVICE_CODE_STR);
if (proCode == NULL || devCode == NULL || mac == NULL){ if (proCode == NULL || devCode == NULL || mac == NULL){
ERROR_PRINT("productCode, deviceCode mac params are error\n"); ERROR_PRINT("productCode, deviceCode mac params are error\n");
goto error; goto error;
......
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