feat: add scan tags reqest & response

This commit is contained in:
gc87
2024-05-20 16:01:53 +08:00
parent 7461693cff
commit 0effd044d2
16 changed files with 424 additions and 8 deletions
+3
View File
@@ -65,6 +65,9 @@ typedef struct adapter_callbacks {
void (*update_im)(neu_adapter_t *adapter, const char *group,
const char *tag, neu_dvalue_t value,
neu_tag_meta_t *metas, int n_meta);
void (*scan_tags_response)(neu_adapter_t *adapter, void *r,
int error, void *tags, neu_type_e type,
bool is_array);
} driver;
};
} adapter_callbacks_t;
+1
View File
@@ -137,6 +137,7 @@ typedef enum {
NEU_ERR_PLUGIN_NOT_SUPPORT_READ_SYNC = 3018,
NEU_ERR_PLUGIN_TYPE_NOT_SUPPORT = 3019,
NEU_ERR_PLUGIN_TAG_VALUE_OUT_OF_RANGE = 3020,
NEU_ERR_PLUGIN_NOT_SUPPORT_SCAN_TAGS = 3021,
NEU_ERR_MQTT_FAILURE = 4000,
NEU_ERR_MQTT_NO_CERTFILESET = 4001,
+51
View File
@@ -0,0 +1,51 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/*
* DO NOT EDIT THIS FILE MANUALLY!
* It was automatically generated by `json-autotype`.
*/
#ifndef _NEU_JSON_API_NEU_JSON_SCAN_H_
#define _NEU_JSON_API_NEU_JSON_SCAN_H_
#include "json/json.h"
#include "tag.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char *node;
char *id;
} neu_json_scan_tags_req_t;
int neu_json_decode_scan_tags_req(char *buf, neu_json_scan_tags_req_t **result);
void neu_json_decode_scan_tags_req_free(neu_json_scan_tags_req_t *req);
int neu_json_encode_scan_tags_resp(void *json_object, void *param);
#ifdef __cplusplus
}
#endif
#endif
+29
View File
@@ -114,6 +114,8 @@ typedef enum neu_reqresp_type {
NEU_REQ_PRGFILE_PROCESS,
NEU_RESP_PRGFILE_PROCESS,
NEU_REQ_SCAN_TAGS,
NEU_RESP_SCAN_TAGS,
} neu_reqresp_type_e;
static const char *neu_reqresp_type_string_t[] = {
@@ -189,6 +191,9 @@ static const char *neu_reqresp_type_string_t[] = {
[NEU_REQ_PRGFILE_UPLOAD] = "NEU_REQ_PRGFILE_UPLOAD",
[NEU_REQ_PRGFILE_PROCESS] = "NEU_REQ_PRGFILE_PROCESS",
[NEU_RESP_PRGFILE_PROCESS] = "NEU_RESP_PRGFILE_PROCESS",
[NEU_REQ_SCAN_TAGS] = "NEU_REQ_SCAN_TAGS",
[NEU_RESP_SCAN_TAGS] = "NEU_RESP_SCAN_TAGS",
};
inline static const char *neu_reqresp_type_string(neu_reqresp_type_e type)
@@ -923,6 +928,30 @@ typedef struct {
char reason[256];
} neu_resp_prgfile_process_t;
typedef struct neu_req_scan_tags {
char driver[NEU_NODE_NAME_LEN];
char id[NEU_TAG_ADDRESS_LEN];
} neu_req_scan_tags_t;
typedef struct {
char name[NEU_TAG_NAME_LEN];
char id[5 + 1 + NEU_TAG_ADDRESS_LEN]; // ns + ! + address
uint8_t type;
} neu_scan_tag_t;
typedef struct {
UT_array * scan_tags;
int32_t error;
neu_type_e type;
bool is_array;
} neu_resp_scan_tags_t;
typedef struct {
char name[NEU_TAG_NAME_LEN];
char id[5 + 1 + NEU_TAG_ADDRESS_LEN];
neu_type_e type;
} neu_scan_tag_attribute_t;
#ifdef __cplusplus
}
#endif
+1
View File
@@ -108,6 +108,7 @@ typedef struct neu_plugin_intf_funs {
neu_datatag_t *tags,
int n_tag); // create tags by API
int (*del_tags)(neu_plugin_t *plugin, int n_tag);
int (*scan_tags)(neu_plugin_t *plugin, void *req, char *id);
} driver;
};