refactor(vd960Loop): 算法回退到 DLD154V4B,四通道适配
- 用 DLD154V4B vd1_task/per_channel 替换 vds_task 复杂算法
- 移除 FUNCTION_B/二次判断/快速变化/多重确认等增强特性
- 保留平坦性离开算法 (CN200910309382),每通道独立状态
- 灵敏度表改为 DLD154V4B 4级: {216,108,36,10} / {108,72,18,9}
- 清理废弃类型: FltHistoryManager, Loop_ACS_Info, StageRangeConfig 等
- 首次添加 vd960DBN 完整源码
This commit is contained in:
211
vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c
Normal file
211
vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/simple_json.c
Normal file
@@ -0,0 +1,211 @@
|
||||
/*******************************************************
|
||||
* File name: simple_json.c
|
||||
* Author : wfq
|
||||
* Versions : 1.0
|
||||
* Description: simple json parse function.
|
||||
* Do not solve the completed json_string or string with json-string.
|
||||
* Completed: like array.
|
||||
* Must satisfy the yipai dev-protocol, and test by yipai dev-protocol.
|
||||
* History:
|
||||
* 1.Date: 2016-10-10
|
||||
* Author: wfq
|
||||
* Action: create
|
||||
*********************************************************/
|
||||
|
||||
|
||||
#include "simple_json.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void simple_parse_json(const char * data, char *key_str, char *value_str)
|
||||
{
|
||||
char *p, *q, *t, *y;
|
||||
//char * zq; //[ ]
|
||||
int len = 0;
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
printf("\r\nsimple_parse_json data is NULL\r\n");
|
||||
return;
|
||||
}
|
||||
if(strlen(value_str) != 0)
|
||||
{
|
||||
printf("clear value:%s\n", value_str);
|
||||
memset(value_str, 0, strlen(value_str));
|
||||
}
|
||||
|
||||
p = strstr(data, key_str);
|
||||
if(p == NULL) return;
|
||||
p += strlen(key_str) + 1;
|
||||
|
||||
// printf("\nmy_parse_json2, first,data:%s\n", p);
|
||||
while(*p == ' ')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
// printf("\nmy_parse_json2, sec,data:%s\n", p);
|
||||
|
||||
q = strchr(p, '{');
|
||||
t = strchr(p, '\"');
|
||||
y = strchr(p, ',');
|
||||
//zq = strchr(p, '[');
|
||||
|
||||
if((q == NULL) && (t == NULL) && (y == NULL))
|
||||
{
|
||||
q = strstr(p, "\r\n");
|
||||
if(q == NULL) q = strstr(p, "\n");
|
||||
if(q == NULL) q = strstr(p, "}");
|
||||
|
||||
if(q == NULL) len = strlen(p);
|
||||
else len = strlen(p) - strlen(q);
|
||||
|
||||
memcpy(value_str, p, len);
|
||||
return;
|
||||
}
|
||||
|
||||
if((q == NULL) || ((t != NULL) && (strlen(t) > strlen(q))))
|
||||
{
|
||||
if((y != NULL) && (strlen(y) > strlen(t)))
|
||||
{
|
||||
len = strlen(p) - strlen(y);
|
||||
memcpy(value_str, p, len);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
t += 1;
|
||||
q = strstr(t, "\",");
|
||||
if(q == NULL)
|
||||
{
|
||||
q = strstr(t, "\"\r\n");
|
||||
if(q == NULL)
|
||||
{
|
||||
q = strstr(t, "\"\n");
|
||||
if(q == NULL)
|
||||
{
|
||||
q = strstr(t, "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
len = strlen(t) - strlen(q);
|
||||
memcpy(value_str, t, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
q += 1;
|
||||
y = strstr(q, "},");
|
||||
if(y == NULL)
|
||||
{
|
||||
y = strstr(q, "}\r\n");
|
||||
if(y == NULL) strstr(q, "}\n");
|
||||
}
|
||||
len = strlen(q) - strlen(y);
|
||||
memcpy(value_str, q, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char * simpleJsonGetObject(const char * data, const char * key)
|
||||
{
|
||||
if(data == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void simple_json_getarray_item(const char * data, char *key_str, char *value_str)
|
||||
{
|
||||
char *p, *q, *t, *y;
|
||||
//char * zq; //[ ]
|
||||
int len = 0;
|
||||
|
||||
if(data == NULL)
|
||||
{
|
||||
printf("\r\nsimple_parse_json data is NULL\r\n");
|
||||
return;
|
||||
}
|
||||
if(strlen(value_str) != 0)
|
||||
{
|
||||
printf("clear value:%s\n", value_str);
|
||||
memset(value_str, 0, strlen(value_str));
|
||||
}
|
||||
|
||||
p = strstr(data, key_str);
|
||||
if(p == NULL) return;
|
||||
p += strlen(key_str) + 1;
|
||||
|
||||
// printf("\nmy_parse_json2, first,data:%s\n", p);
|
||||
while(*p == ' ')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
// printf("\nmy_parse_json2, sec,data:%s\n", p);
|
||||
|
||||
q = strchr(p, '{');
|
||||
t = strchr(p, '\"');
|
||||
y = strchr(p, ',');
|
||||
//zq = strchr(p, '[');
|
||||
|
||||
if((q == NULL) && (t == NULL) && (y == NULL))
|
||||
{
|
||||
q = strstr(p, "\r\n");
|
||||
if(q == NULL) q = strstr(p, "\n");
|
||||
if(q == NULL) q = strstr(p, "}");
|
||||
|
||||
if(q == NULL) len = strlen(p);
|
||||
else len = strlen(p) - strlen(q);
|
||||
|
||||
memcpy(value_str, p, len);
|
||||
return;
|
||||
}
|
||||
|
||||
if((q == NULL) || ((t != NULL) && (strlen(t) > strlen(q))))
|
||||
{
|
||||
if((y != NULL) && (strlen(y) > strlen(t)))
|
||||
{
|
||||
len = strlen(p) - strlen(y);
|
||||
memcpy(value_str, p, len);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
t += 1;
|
||||
q = strstr(t, "\",");
|
||||
if(q == NULL)
|
||||
{
|
||||
q = strstr(t, "\"\r\n");
|
||||
if(q == NULL)
|
||||
{
|
||||
q = strstr(t, "\"\n");
|
||||
if(q == NULL)
|
||||
{
|
||||
q = strstr(t, "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
len = strlen(t) - strlen(q);
|
||||
memcpy(value_str, t, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
q += 1;
|
||||
y = strstr(q, "},");
|
||||
if(y == NULL)
|
||||
{
|
||||
y = strstr(q, "}\r\n");
|
||||
if(y == NULL) strstr(q, "}\n");
|
||||
}
|
||||
len = strlen(q) - strlen(y);
|
||||
memcpy(value_str, q, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user