Commit 5bd87730 authored by 尹佳钦's avatar 尹佳钦

test

parent b7f0c6d5
...@@ -494,9 +494,13 @@ void kk_device_config_item_report(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId c ...@@ -494,9 +494,13 @@ void kk_device_config_item_report(EmberEUI64 eui64,uint8_t EP,EmberAfClusterId c
kk_rpc_report func; kk_rpc_report func;
pCode = kk_device_find_productCode(eui64); pCode = kk_device_find_productCode(eui64);
cfgMap = kk_device_config_find(pCode); cfgMap = kk_device_config_find(pCode);
if(cfgMap==NULL) return ;
if(cfgMap==NULL) {
emberAfDebugPrintln("cfgMap==NULL!");
return ;
}
item = &cfgMap->item; item = &cfgMap->item;
while(item!=NULL){ while(item!=NULL){
......
...@@ -62,12 +62,14 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId ...@@ -62,12 +62,14 @@ static int kk_tsl_report(EmberEUI64 mac,uint8_t EP,int status,uint16_t clusterId
kk_dev_config_map *dev_info = NULL; kk_dev_config_map *dev_info = NULL;
kk_dev_config_item *item = NULL; kk_dev_config_item *item = NULL;
char macString[RPC_EUI64_STRING_LENGTH]; char macString[RPC_EUI64_STRING_LENGTH];
rpc_eui64ToString(mac,macString); rpc_eui64ToString(mac,macString);
root = rpc_cJSON_CreateObject(); root = rpc_cJSON_CreateObject();
dev = kk_device_find_by_mac(mac); dev = kk_device_find_by_mac(mac);
if(dev == NULL){ if(dev == NULL){
printf("mac:%s not find in zb dev table!!!\n",macString);
return tsl_rpt_err; return tsl_rpt_err;
} }
printf("[%s][%d]dev->productCode:%s\n",__FUNCTION__,__LINE__,dev->productCode); printf("[%s][%d]dev->productCode:%s\n",__FUNCTION__,__LINE__,dev->productCode);
......
...@@ -205,7 +205,6 @@ void emberAfMainTickCallback(void) ...@@ -205,7 +205,6 @@ void emberAfMainTickCallback(void)
unsigned int time = halCommonGetInt32uMillisecondTick(); unsigned int time = halCommonGetInt32uMillisecondTick();
kk_sub_dev_manage(); kk_sub_dev_manage();
ncp_queue_tick();
if((time-last_time)>=3000){ if((time-last_time)>=3000){
last_time = time; last_time = time;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
void ipcHandle(void); void ipcHandle(void);
void get_prey_handle(void); void ncp_queue_handle(void);
void rpc_reportDevices(void); void rpc_reportDevices(void);
......
...@@ -72,31 +72,49 @@ rpc_table_s rpc_table[]={ ...@@ -72,31 +72,49 @@ rpc_table_s rpc_table[]={
void kk_tsl_msg_ack(char *productCode,char *deviceCode) void kk_tsl_msg_ack(const char * id,const char *ackMsgType,const char *productCode,const char *deviceCode)
{ {
cJSON *root = rpc_cJSON_CreateObject(); cJSON *root = rpc_cJSON_CreateObject();
cJSON *info = rpc_cJSON_CreateObject(); cJSON *info = rpc_cJSON_CreateObject();
cJSON *payload = rpc_cJSON_CreateObject(); cJSON *payload = rpc_cJSON_CreateObject();
cJSON *data = rpc_cJSON_CreateObject();
rpc_cJSON_AddItemToObject(root,"info",info); rpc_cJSON_AddItemToObject(root,"info",info);
rpc_cJSON_AddItemToObject(root,"payload",payload); rpc_cJSON_AddItemToObject(root,"payload",payload);
rpc_cJSON_AddStringToObject(info, "msgType", "/thing/service/property/get_reply"); rpc_cJSON_AddStringToObject(info, "msgType", ackMsgType);
rpc_cJSON_AddStringToObject(info, "productCode", productCode); rpc_cJSON_AddStringToObject(info, "productCode", productCode);
rpc_cJSON_AddStringToObject(info, "deviceCode", deviceCode); rpc_cJSON_AddStringToObject(info, "deviceCode", deviceCode);
rpc_cJSON_AddStringToObject(payload, "msgId", "*******"); rpc_cJSON_AddStringToObject(payload, "msgId", id);
rpc_cJSON_AddNullToObject(payload, "code");
rpc_cJSON_AddItemToObject(payload,"data",data);
jrpc_send_msg(root); jrpc_send_msg(root);
rpc_cJSON_Delete(root);
} }
static int send_result_resp(cJSON * result, static int kk_tsl_send_msg_ack(const char* msgType,const char* productCode,const char* deviceCode,const char* id) {
cJSON * id) {
cJSON *root = rpc_cJSON_CreateObject();
cJSON *info = rpc_cJSON_CreateObject();
cJSON *payload = rpc_cJSON_CreateObject();
rpc_cJSON_AddItemToObject(root,"info",info);
rpc_cJSON_AddItemToObject(root,"payload",payload);
rpc_cJSON_AddStringToObject(info, "msgType", "/thing/service/property/get_reply");
rpc_cJSON_AddStringToObject(info, "productCode", productCode);
rpc_cJSON_AddStringToObject(info, "deviceCode", deviceCode);
rpc_cJSON_AddStringToObject(payload, "msgId", "*******");
return 0; return 0;
} }
static int send_result_resp(int code, char* message,cJSON * id)
{
}
static int send_error_resp(int code, char* message, static int send_error_resp(int code, char* message,
cJSON * id) { cJSON * id) {
...@@ -164,7 +182,7 @@ static int invoke_procedure(struct jrpc_server *server, ...@@ -164,7 +182,7 @@ static int invoke_procedure(struct jrpc_server *server,
if (ctx.error_code) if (ctx.error_code)
return send_error_resp(ctx.error_code, ctx.error_message, id); return send_error_resp(ctx.error_code, ctx.error_message, id);
else else
return send_result_resp(returned, id); return 0;//send_result_resp(returned, id);
} }
} }
...@@ -191,7 +209,7 @@ static int eval_request(struct jrpc_server *server, cJSON *root) { ...@@ -191,7 +209,7 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
if(strcmp(msgType->valuestring,"/thing/service/property/get")==0) if(strcmp(msgType->valuestring,"/thing/service/property/get")==0)
kk_tsl_msg_ack(productCode->valuestring,deviceCode->valuestring); kk_tsl_msg_ack(id,msgType->valuestring,productCode->valuestring,deviceCode->valuestring);
return invoke_procedure(server, msgType->valuestring, return invoke_procedure(server, msgType->valuestring,
params, id_copy,deviceCode); params, id_copy,deviceCode);
...@@ -206,19 +224,7 @@ static int eval_request(struct jrpc_server *server, cJSON *root) { ...@@ -206,19 +224,7 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
#define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade" #define KK_THING_OTA_DEVICE_UPGRADE "/ota/device/upgrade"
void ncp_queue_tick(void)
{
cJSON *root = NULL;
char *str;
if(ncp_queue_dequeue(REV_MSG,&root)==0){
str = rpc_cJSON_Print(root);
printf("Dequeue cJson = %s\n",str);
free(str);
eval_request(&my_server, root);
rpc_cJSON_Delete(root);
}
}
void _cb(void* data, int len, char* chlmark){ void _cb(void* data, int len, char* chlmark){
if (data != NULL){ if (data != NULL){
printf("plat_cb: %s [%d]RECEIVED \r\n", data,len); printf("plat_cb: %s [%d]RECEIVED \r\n", data,len);
...@@ -530,26 +536,50 @@ int kk_connect_check(){ ...@@ -530,26 +536,50 @@ int kk_connect_check(){
} }
} }
void get_prey_handle(void) static void _msg_deal_from_mid(void)
{
cJSON *root = NULL;
char *str;
if(ncp_queue_dequeue(REV_MSG,&root)==0){
str = rpc_cJSON_Print(root);
printf("Dequeue cJson = %s\n",str);
free(str);
eval_request(&my_server, root);
rpc_cJSON_Delete(root);
}
}
static void _get_prey_from_dev(void)
{ {
get_property_data_s *data; get_property_data_s *data;
EmberStatus status; EmberStatus status;
while(1){
if(ncp_queue_dequeue(GET_PROPERTY,&data)==0){
printf("\n================dequeue==================\n");
printf("node = 0x%04X,ep=%d,clu=0x%04X,len=%d\n",data->node,data->ep,data->clu,data->len);
for(int i=0;i<data->len;i++){
printf("attr=0x%04X\n",data->attr[i]);
}
status = zclGReadAttrs(data->node,1,data->ep,false,data->clu,data->len,data->attr,true); if(ncp_queue_dequeue(GET_PROPERTY,&data)==0){
printf("\n================dequeue==================\n");
free(data->attr); printf("node = 0x%04X,ep=%d,clu=0x%04X,len=%d\n",data->node,data->ep,data->clu,data->len);
free(data); for(int i=0;i<data->len;i++){
printf("attr=0x%04X\n",data->attr[i]);
} }
status = zclGReadAttrs(data->node,1,data->ep,false,data->clu,data->len,data->attr,true);
free(data->attr);
free(data);
} }
}
void ncp_queue_handle(void)
{
UTIL_LOG_INFO("\nncp_queue_handle start~~~~~~~~~~~~~~~~~~~~\n");
while(1){
_msg_deal_from_mid();
_get_prey_from_dev();
usleep(100000);
}
UTIL_LOG_WARNING("\nncp_queue_handle end!!!!!!!!!!!!!!!!!!!\n");
} }
void ipcHandle(void) void ipcHandle(void)
...@@ -728,10 +758,7 @@ static void rpc_send_message(cJSON *data,char *method) ...@@ -728,10 +758,7 @@ static void rpc_send_message(cJSON *data,char *method)
jrpc_send_msg(item); jrpc_send_msg(item);
} }
void rpc_read_attribute_response(cJSON *data)
{
rpc_send_message(data,"read_attribute_response");
}
void rpc_report_attribute(cJSON *data) void rpc_report_attribute(cJSON *data)
{ {
...@@ -921,6 +948,7 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId, ...@@ -921,6 +948,7 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
uint8_t *dataPtr = &bufferTemp[ATTRIBUTE_BUFFER_REPORT_DATA_TYPE+1+1+typeSize]; uint8_t *dataPtr = &bufferTemp[ATTRIBUTE_BUFFER_REPORT_DATA_TYPE+1+1+typeSize];
rpc_cJSON_AddDataToObject(item_attr,dataPtr,dataLen); rpc_cJSON_AddDataToObject(item_attr,dataPtr,dataLen);
UTIL_LOG_INFO("\nkk_device_config_item_report~~~~~~~~~~~~~~~~~~~~\n");
kk_device_config_item_report(nodeEui64,ep,clusterId,attributeId,dataType,dataLen,dataPtr); kk_device_config_item_report(nodeEui64,ep,clusterId,attributeId,dataType,dataLen,dataPtr);
kk_read_attr_response(nodeId, kk_read_attr_response(nodeId,
...@@ -949,7 +977,6 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId, ...@@ -949,7 +977,6 @@ bool rpc_ReadAttributesResponseCallback(EmberAfClusterId clusterId,
i = i + bufferSize; i = i + bufferSize;
} }
rpc_read_attribute_response(item);
return false; return false;
} }
......
...@@ -95,7 +95,7 @@ extern void test_123(int val); ...@@ -95,7 +95,7 @@ extern void test_123(int val);
extern void kk_ota_test111(); extern void kk_ota_test111();
extern void kk_ota_test123123123(); extern void kk_ota_test123123123();
extern void aaaBBB(); extern void aaaBBB();
extern void kk_tsl_msg_ack(char *productCode,char *deviceCode); extern void kk_tsl_msg_ack(const char * id,const char *ackMsgType,const char *productCode,const char *deviceCode);
void kk_message_process(char *messageString) void kk_message_process(char *messageString)
{ {
...@@ -122,7 +122,7 @@ void kk_message_process(char *messageString) ...@@ -122,7 +122,7 @@ void kk_message_process(char *messageString)
} }
if(MEMCOMPARE(messageString,"AT+TEST\r\n",len)==0){ if(MEMCOMPARE(messageString,"AT+TEST\r\n",len)==0){
aaaBBB(); aaaBBB();
kk_tsl_msg_ack("123","456"); kk_tsl_msg_ack("666","/thing/event/property/post_reply","123","456");
} }
} }
......
...@@ -534,7 +534,7 @@ void chip_reset() ...@@ -534,7 +534,7 @@ void chip_reset()
void emberAfMainInit(void) void emberAfMainInit(void)
{ {
chip_reset(); //chip_reset();
} }
int emberAfMain(MAIN_FUNCTION_PARAMETERS) int emberAfMain(MAIN_FUNCTION_PARAMETERS)
...@@ -599,7 +599,7 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS) ...@@ -599,7 +599,7 @@ int emberAfMain(MAIN_FUNCTION_PARAMETERS)
pthread_t prey_tid; pthread_t prey_tid;
//pthread_create(&tid, NULL, rpcInterfaceParse, NULL); //pthread_create(&tid, NULL, rpcInterfaceParse, NULL);
pthread_create(&tid, NULL, ipcHandle, NULL); pthread_create(&tid, NULL, ipcHandle, NULL);
pthread_create(&prey_tid, NULL, get_prey_handle, NULL); pthread_create(&prey_tid, NULL, ncp_queue_handle, NULL);
// initialize the ZCL framework ,(plug in) ,mqtt init is here // initialize the ZCL framework ,(plug in) ,mqtt init is here
emAfInit(); emAfInit();
......
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