Commit 34eda340 authored by 尹佳钦's avatar 尹佳钦

2020/10/22

parent 4a1ab0ed
...@@ -72,43 +72,29 @@ rpc_table_s rpc_table[]={ ...@@ -72,43 +72,29 @@ rpc_table_s rpc_table[]={
void kk_tsl_msg_ack(char *productCode,char *deviceCode)
{
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", "*******");
jrpc_send_msg(root);
}
static int send_result_resp(cJSON * result, static int send_result_resp(cJSON * result,
cJSON * id) { cJSON * id) {
#if 0
int return_value = 0;
cJSON *info_root = rpc_cJSON_CreateObject();
if(info_root){
rpc_cJSON_AddStringToObject(info_root, "msgType", "");
rpc_cJSON_AddStringToObject(info_root, "productType", "");
rpc_cJSON_AddStringToObject(info_root, "productCode", "");
rpc_cJSON_AddStringToObject(info_root, "deviceCode", "");
}
cJSON *payload_root = rpc_cJSON_CreateObject();
if(payload_root){
rpc_cJSON_AddItemToObject(payload_root, "msgId", id);
rpc_cJSON_AddItemToObject(payload_root, "code", result);
rpc_cJSON_AddStringToObject(payload_root, "data", "{}");
}
cJSON *result_root = rpc_cJSON_CreateObject();
if(result_root){
rpc_cJSON_AddItemToObject(result_root, "info", info_root);
rpc_cJSON_AddItemToObject(result_root, "payload", payload_root);
}
char * str_result = rpc_cJSON_Print(result_root);
printf("send json:\n%s\n",str_result);
return_value = kk_sendData2CCU(str_result, strlen(str_result));
free(str_result);
rpc_cJSON_Delete(result_root);
return return_value;
#else
return 0; return 0;
#endif
} }
...@@ -183,12 +169,13 @@ static int invoke_procedure(struct jrpc_server *server, ...@@ -183,12 +169,13 @@ static int invoke_procedure(struct jrpc_server *server,
} }
static int eval_request(struct jrpc_server *server, cJSON *root) { static int eval_request(struct jrpc_server *server, cJSON *root) {
cJSON *params, *id,*mac,*info,*msgType,*payload; cJSON *params, *id,*deviceCode,*productCode,*info,*msgType,*payload;
info = rpc_cJSON_GetObjectItem(root, "info"); info = rpc_cJSON_GetObjectItem(root, "info");
if(info != NULL){ if(info != NULL){
msgType = rpc_cJSON_GetObjectItem(info, "msgType"); msgType = rpc_cJSON_GetObjectItem(info, "msgType");
mac = rpc_cJSON_GetObjectItem(info, "deviceCode"); deviceCode = rpc_cJSON_GetObjectItem(info, "deviceCode");
productCode = rpc_cJSON_GetObjectItem(info, "productCode");
} }
payload = rpc_cJSON_GetObjectItem(root, "payload"); payload = rpc_cJSON_GetObjectItem(root, "payload");
if(payload != NULL){ if(payload != NULL){
...@@ -196,13 +183,18 @@ static int eval_request(struct jrpc_server *server, cJSON *root) { ...@@ -196,13 +183,18 @@ static int eval_request(struct jrpc_server *server, cJSON *root) {
params = rpc_cJSON_GetObjectItem(payload, "params"); params = rpc_cJSON_GetObjectItem(payload, "params");
id = rpc_cJSON_GetObjectItem(payload, "msgId"); id = rpc_cJSON_GetObjectItem(payload, "msgId");
} }
if(id != NULL && params != NULL && msgType != NULL && mac != NULL){ if(id != NULL && params != NULL && msgType != NULL && deviceCode != NULL){
cJSON * id_copy = NULL; cJSON * id_copy = NULL;
id_copy = (id->type == cJSON_String) ? rpc_cJSON_CreateString(id->valuestring) : \ id_copy = (id->type == cJSON_String) ? rpc_cJSON_CreateString(id->valuestring) : \
rpc_cJSON_CreateNumber(id->valueint); rpc_cJSON_CreateNumber(id->valueint);
if(strcmp(msgType->valuestring,"/thing/service/property/get")==0)
kk_tsl_msg_ack(productCode->valuestring,deviceCode->valuestring);
return invoke_procedure(server, msgType->valuestring, return invoke_procedure(server, msgType->valuestring,
params, id_copy,mac); params, id_copy,deviceCode);
} }
...@@ -1103,4 +1095,4 @@ void rpc_reportDevices(void) ...@@ -1103,4 +1095,4 @@ void rpc_reportDevices(void)
} }
} }
rpc_report_devices(devicesJson); rpc_report_devices(devicesJson);
} }
\ No newline at end of file
...@@ -95,6 +95,7 @@ extern void test_123(int val); ...@@ -95,6 +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);
void kk_message_process(char *messageString) void kk_message_process(char *messageString)
{ {
...@@ -121,6 +122,7 @@ void kk_message_process(char *messageString) ...@@ -121,6 +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");
} }
} }
......
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