Skip to content

Commit 392a72b

Browse files
authored
Merge pull request #2357 from hxy7yx/main-1
feat(scan tag):add type
2 parents d7feb2f + 9258276 commit 392a72b

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

include/neuron/msg.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1372,9 +1372,11 @@ typedef struct neu_req_scan_tags {
13721372
} neu_req_scan_tags_t;
13731373

13741374
typedef struct {
1375-
char name[NEU_TAG_NAME_LEN];
1376-
char id[5 + 1 + NEU_TAG_ADDRESS_LEN]; // ns + ! + address
1377-
uint8_t tag;
1375+
char name[NEU_TAG_NAME_LEN];
1376+
char id[5 + 1 + NEU_TAG_ADDRESS_LEN]; // ns + ! + address
1377+
uint8_t tag;
1378+
bool is_last_layer;
1379+
neu_type_e type;
13781380
} neu_scan_tag_t;
13791381

13801382
typedef struct {

src/parser/neu_json_scan.c

+23-17
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,32 @@ int neu_json_encode_scan_tags_resp(void *json_object, void *param)
107107
utarray_foreach(resp->scan_tags, neu_scan_tag_t *, p_tag)
108108
{
109109
if (NULL != p_tag) {
110-
neu_json_elem_t tag_elems[] = {
111-
{
112-
.name = "name",
113-
.t = NEU_JSON_STR,
114-
.v.val_str = p_tag->name,
115-
},
116-
{
117-
.name = "id",
118-
.t = NEU_JSON_STR,
119-
.v.val_str = p_tag->id,
120-
},
121-
{
122-
.name = "tag",
123-
.t = NEU_JSON_INT,
124-
.v.val_int = p_tag->tag,
125-
},
110+
neu_json_elem_t tag_elems[4];
111+
tag_elems[0] = (neu_json_elem_t) {
112+
.name = "name",
113+
.t = NEU_JSON_STR,
114+
.v.val_str = p_tag->name,
115+
};
116+
tag_elems[1] = (neu_json_elem_t) {
117+
.name = "id",
118+
.t = NEU_JSON_STR,
119+
.v.val_str = p_tag->id,
126120
};
121+
tag_elems[2] = (neu_json_elem_t) {
122+
.name = "tag",
123+
.t = NEU_JSON_INT,
124+
.v.val_int = p_tag->tag,
125+
};
126+
if (p_tag->is_last_layer) {
127+
tag_elems[3] = (neu_json_elem_t) {
128+
.name = "tag_type",
129+
.t = NEU_JSON_INT,
130+
.v.val_int = p_tag->type,
131+
};
132+
}
127133

128134
neu_json_encode_array(tag_array, tag_elems,
129-
NEU_JSON_ELEM_SIZE(tag_elems));
135+
p_tag->is_last_layer ? 4 : 3);
130136
}
131137
}
132138

0 commit comments

Comments
 (0)