mirror of
https://github.com/emqx/neuron.git
synced 2026-10-23 10:22:32 +08:00
Merge pull request #541 from fengzeroz/main
refactor plugin interface config
This commit is contained in:
@@ -93,8 +93,6 @@ set(NEURON_SOURCES
|
||||
src/adapter/adapter.c
|
||||
src/adapter/driver/cache.c
|
||||
src/adapter/driver/driver.c
|
||||
src/adapter/config/config.c
|
||||
src/adapter/control/control.c
|
||||
plugins/restful/handle.c
|
||||
plugins/restful/license.c
|
||||
plugins/restful/license_handle.c
|
||||
|
||||
@@ -38,21 +38,9 @@ typedef enum {
|
||||
|
||||
#include "adapter_msg.h"
|
||||
|
||||
typedef struct neu_adapter neu_adapter_t;
|
||||
typedef struct neu_adapter_driver neu_adapter_driver_t;
|
||||
typedef struct neu_adapter_config neu_adapter_config_t;
|
||||
typedef struct neu_adapter_control neu_adapter_control_t;
|
||||
|
||||
typedef enum neu_config_type {
|
||||
NEU_CONFIG_UNKNOW,
|
||||
NEU_CONFIG_SETTING,
|
||||
} neu_config_type_e;
|
||||
|
||||
typedef struct neu_config {
|
||||
neu_config_type_e type;
|
||||
uint32_t buf_len;
|
||||
void * buf;
|
||||
} neu_config_t;
|
||||
typedef struct neu_adapter neu_adapter_t;
|
||||
typedef struct neu_adapter_driver neu_adapter_driver_t;
|
||||
typedef struct neu_adapter_app neu_adapter_app_t;
|
||||
|
||||
typedef enum {
|
||||
NEU_NODE_LINK_STATUS_DISCONNECTED = 0,
|
||||
@@ -78,9 +66,6 @@ typedef struct adapter_callbacks {
|
||||
int (*response)(neu_adapter_t *adapter, neu_reqresp_head_t *head,
|
||||
void *data);
|
||||
|
||||
void (*link_status)(neu_adapter_t * adapter,
|
||||
neu_node_link_status_e link_status);
|
||||
|
||||
union {
|
||||
struct {
|
||||
void (*update)(neu_adapter_t *adapter, const char *group,
|
||||
|
||||
@@ -58,14 +58,13 @@ struct neu_plugin_group {
|
||||
};
|
||||
|
||||
typedef struct neu_plugin_intf_funs {
|
||||
neu_plugin_t *(*open)(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks);
|
||||
neu_plugin_t *(*open)(void);
|
||||
int (*close)(neu_plugin_t *plugin);
|
||||
int (*init)(neu_plugin_t *plugin);
|
||||
int (*uninit)(neu_plugin_t *plugin);
|
||||
int (*start)(neu_plugin_t *plugin);
|
||||
int (*stop)(neu_plugin_t *plugin);
|
||||
int (*config)(neu_plugin_t *plugin, neu_config_t *configs);
|
||||
int (*setting)(neu_plugin_t *plugin, const char *setting);
|
||||
|
||||
int (*request)(neu_plugin_t *plugin, neu_reqresp_head_t *head, void *data);
|
||||
|
||||
|
||||
+4
-19
@@ -34,26 +34,11 @@ struct neu_plugin {
|
||||
neu_plugin_common_t common;
|
||||
};
|
||||
|
||||
static neu_plugin_t *dummy_plugin_open(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks)
|
||||
static neu_plugin_t *dummy_plugin_open()
|
||||
{
|
||||
neu_plugin_t *plugin;
|
||||
|
||||
if (adapter == NULL || callbacks == NULL) {
|
||||
nlog_error("Open plugin with NULL adapter or callbacks");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plugin = (neu_plugin_t *) malloc(sizeof(neu_plugin_t));
|
||||
if (plugin == NULL) {
|
||||
nlog_error("Failed to allocate plugin %s",
|
||||
neu_plugin_module.module_name);
|
||||
return NULL;
|
||||
}
|
||||
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
|
||||
|
||||
neu_plugin_common_init(&plugin->common);
|
||||
plugin->common.adapter = adapter;
|
||||
plugin->common.adapter_callbacks = callbacks;
|
||||
|
||||
nlog_info("Success to create plugin: %s", neu_plugin_module.module_name);
|
||||
return plugin;
|
||||
@@ -86,7 +71,7 @@ static int dummy_plugin_uninit(neu_plugin_t *plugin)
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int dummy_plugin_config(neu_plugin_t *plugin, neu_config_t *configs)
|
||||
static int dummy_plugin_config(neu_plugin_t *plugin, const char *configs)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -125,7 +110,7 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = {
|
||||
.uninit = dummy_plugin_uninit,
|
||||
.start = dummy_plugin_start,
|
||||
.stop = dummy_plugin_stop,
|
||||
.config = dummy_plugin_config,
|
||||
.setting = dummy_plugin_config,
|
||||
.request = dummy_plugin_request,
|
||||
};
|
||||
|
||||
|
||||
@@ -26,27 +26,11 @@
|
||||
|
||||
const neu_plugin_module_t neu_plugin_module;
|
||||
|
||||
static neu_plugin_t *ekuiper_plugin_open(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks)
|
||||
static neu_plugin_t *ekuiper_plugin_open(void)
|
||||
{
|
||||
neu_plugin_t *plugin;
|
||||
|
||||
if (adapter == NULL || callbacks == NULL) {
|
||||
zlog_error(neuron, "open plugin with NULL adapter or callbacks");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plugin = (neu_plugin_t *) malloc(sizeof(neu_plugin_t));
|
||||
if (plugin == NULL) {
|
||||
zlog_error(neuron, "failed to allocate plugin %s",
|
||||
neu_plugin_module.module_name);
|
||||
return NULL;
|
||||
}
|
||||
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
|
||||
|
||||
neu_plugin_common_init(&plugin->common);
|
||||
plugin->common.adapter = adapter;
|
||||
plugin->common.adapter_callbacks = callbacks;
|
||||
plugin->common.link_state = NEU_PLUGIN_LINK_STATE_DISCONNECTED;
|
||||
|
||||
zlog_info(neuron, "success to create plugin: %s",
|
||||
neu_plugin_module.module_name);
|
||||
@@ -147,7 +131,7 @@ static int ekuiper_plugin_stop(neu_plugin_t *plugin)
|
||||
return NEU_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static int ekuiper_plugin_config(neu_plugin_t *plugin, neu_config_t *configs)
|
||||
static int ekuiper_plugin_config(neu_plugin_t *plugin, const char *configs)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -208,7 +192,7 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = {
|
||||
.uninit = ekuiper_plugin_uninit,
|
||||
.start = ekuiper_plugin_start,
|
||||
.stop = ekuiper_plugin_stop,
|
||||
.config = ekuiper_plugin_config,
|
||||
.setting = ekuiper_plugin_config,
|
||||
.request = ekuiper_plugin_request,
|
||||
};
|
||||
|
||||
|
||||
+13
-18
@@ -24,15 +24,13 @@
|
||||
#include "modbus_req.h"
|
||||
#include "modbus_stack.h"
|
||||
|
||||
static neu_plugin_t *driver_open(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks);
|
||||
|
||||
static int driver_close(neu_plugin_t *plugin);
|
||||
static int driver_init(neu_plugin_t *plugin);
|
||||
static int driver_uninit(neu_plugin_t *plugin);
|
||||
static int driver_start(neu_plugin_t *plugin);
|
||||
static int driver_stop(neu_plugin_t *plugin);
|
||||
static int driver_config(neu_plugin_t *plugin, neu_config_t *config);
|
||||
static neu_plugin_t *driver_open(void);
|
||||
static int driver_close(neu_plugin_t *plugin);
|
||||
static int driver_init(neu_plugin_t *plugin);
|
||||
static int driver_uninit(neu_plugin_t *plugin);
|
||||
static int driver_start(neu_plugin_t *plugin);
|
||||
static int driver_stop(neu_plugin_t *plugin);
|
||||
static int driver_config(neu_plugin_t *plugin, const char *config);
|
||||
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
|
||||
void *data);
|
||||
|
||||
@@ -48,7 +46,7 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = {
|
||||
.uninit = driver_uninit,
|
||||
.start = driver_start,
|
||||
.stop = driver_stop,
|
||||
.config = driver_config,
|
||||
.setting = driver_config,
|
||||
.request = driver_request,
|
||||
|
||||
.driver.validate_tag = driver_validate_tag,
|
||||
@@ -65,15 +63,11 @@ const neu_plugin_module_t neu_plugin_module = {
|
||||
.type = NEU_NA_TYPE_DRIVER,
|
||||
};
|
||||
|
||||
static neu_plugin_t *driver_open(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks)
|
||||
static neu_plugin_t *driver_open(void)
|
||||
{
|
||||
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
|
||||
|
||||
neu_plugin_common_init(&plugin->common);
|
||||
plugin->common.adapter = adapter;
|
||||
plugin->common.adapter_callbacks = callbacks;
|
||||
plugin->common.link_state = NEU_PLUGIN_LINK_STATE_DISCONNECTED;
|
||||
|
||||
return plugin;
|
||||
}
|
||||
@@ -125,7 +119,7 @@ static int driver_stop(neu_plugin_t *plugin)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int driver_config(neu_plugin_t *plugin, neu_config_t *config)
|
||||
static int driver_config(neu_plugin_t *plugin, const char *config)
|
||||
{
|
||||
int ret = 0;
|
||||
char * err_param = NULL;
|
||||
@@ -134,10 +128,11 @@ static int driver_config(neu_plugin_t *plugin, neu_config_t *config)
|
||||
neu_json_elem_t host = { .name = "host", .t = NEU_JSON_STR };
|
||||
neu_conn_param_t param = { 0 };
|
||||
|
||||
ret = neu_parse_param(config->buf, &err_param, 3, &port, &host, &timeout);
|
||||
ret =
|
||||
neu_parse_param((char *) config, &err_param, 3, &port, &host, &timeout);
|
||||
|
||||
if (ret != 0) {
|
||||
plog_warn(plugin, "config: %s, decode error: %s", (char *) config->buf,
|
||||
plog_warn(plugin, "config: %s, decode error: %s", (char *) config,
|
||||
err_param);
|
||||
free(err_param);
|
||||
free(host.v.val_str);
|
||||
|
||||
+5
-14
@@ -408,7 +408,7 @@ static void *mqtt_routine_loop(void *argument)
|
||||
}
|
||||
|
||||
static mqtt_routine_t *mqtt_routine_start(neu_plugin_t *plugin,
|
||||
neu_config_t *config)
|
||||
const char * config)
|
||||
{
|
||||
assert(NULL != plugin);
|
||||
assert(NULL != config);
|
||||
@@ -419,7 +419,7 @@ static mqtt_routine_t *mqtt_routine_start(neu_plugin_t *plugin,
|
||||
}
|
||||
|
||||
// MQTT client start
|
||||
int rc = mqtt_option_init(config, &routine->option);
|
||||
int rc = mqtt_option_init((char *) config, &routine->option);
|
||||
if (0 != rc) {
|
||||
mqtt_option_uninit(&routine->option);
|
||||
free(routine);
|
||||
@@ -508,20 +508,11 @@ static void mqtt_routine_suspend(mqtt_routine_t *routine)
|
||||
neu_mqtt_client_suspend(routine->client);
|
||||
}
|
||||
|
||||
static neu_plugin_t *mqtt_plugin_open(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks)
|
||||
static neu_plugin_t *mqtt_plugin_open(void)
|
||||
{
|
||||
assert(NULL != adapter);
|
||||
assert(NULL != callbacks);
|
||||
|
||||
neu_plugin_t *plugin = (neu_plugin_t *) calloc(1, sizeof(neu_plugin_t));
|
||||
if (NULL == plugin) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
neu_plugin_common_init(&plugin->common);
|
||||
plugin->common.adapter = adapter;
|
||||
plugin->common.adapter_callbacks = callbacks;
|
||||
|
||||
return plugin;
|
||||
}
|
||||
@@ -572,7 +563,7 @@ static int mqtt_plugin_uninit(neu_plugin_t *plugin)
|
||||
return NEU_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static int mqtt_plugin_config(neu_plugin_t *plugin, neu_config_t *config)
|
||||
static int mqtt_plugin_config(neu_plugin_t *plugin, const char *config)
|
||||
{
|
||||
assert(NULL != plugin);
|
||||
assert(NULL != config);
|
||||
@@ -761,7 +752,7 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = {
|
||||
.uninit = mqtt_plugin_uninit,
|
||||
.start = mqtt_plugin_start,
|
||||
.stop = mqtt_plugin_stop,
|
||||
.config = mqtt_plugin_config,
|
||||
.setting = mqtt_plugin_config,
|
||||
.request = mqtt_plugin_request,
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -86,7 +86,7 @@ void mqtt_option_uninit(neu_mqtt_option_t *option)
|
||||
}
|
||||
}
|
||||
|
||||
int mqtt_option_init(neu_config_t *config, neu_mqtt_option_t *option)
|
||||
int mqtt_option_init(char *config, neu_mqtt_option_t *option)
|
||||
{
|
||||
if (NULL == config || NULL == option) {
|
||||
return -1;
|
||||
@@ -107,7 +107,7 @@ int mqtt_option_init(neu_config_t *config, neu_mqtt_option_t *option)
|
||||
neu_json_elem_t key = { .name = "key", .t = NEU_JSON_STR };
|
||||
neu_json_elem_t keypass = { .name = "keypass", .t = NEU_JSON_STR };
|
||||
|
||||
ret = neu_parse_param(config->buf, &error, 12, &id, &upload, &format, &ssl,
|
||||
ret = neu_parse_param(config, &error, 12, &id, &upload, &format, &ssl,
|
||||
&host, &port, &username, &password, &ca, &cert, &key,
|
||||
&keypass);
|
||||
if (0 != ret) {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ extern "C" {
|
||||
#include "connection/mqtt_client_intf.h"
|
||||
#include <neuron.h>
|
||||
|
||||
int mqtt_option_init(neu_config_t *config, neu_mqtt_option_t *option);
|
||||
int mqtt_option_init(char *config, neu_mqtt_option_t *option);
|
||||
void mqtt_option_uninit(neu_mqtt_option_t *option);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+5
-20
@@ -129,30 +129,15 @@ static nng_http_server *server_init(char *type)
|
||||
return server;
|
||||
}
|
||||
|
||||
static neu_plugin_t *dashb_plugin_open(neu_adapter_t * adapter,
|
||||
const adapter_callbacks_t *callbacks)
|
||||
static neu_plugin_t *dashb_plugin_open(void)
|
||||
{
|
||||
int rv;
|
||||
neu_plugin_t * plugin;
|
||||
uint32_t n_handler = 0;
|
||||
neu_plugin_t * plugin = calloc(1, sizeof(neu_plugin_t));
|
||||
uint32_t n_handler = 0;
|
||||
const struct neu_rest_handler *rest_handlers = NULL;
|
||||
const struct neu_rest_handler *cors = NULL;
|
||||
|
||||
if (adapter == NULL || callbacks == NULL) {
|
||||
nlog_error("Open plugin with NULL adapter or callbacks");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plugin = (neu_plugin_t *) malloc(sizeof(neu_plugin_t));
|
||||
if (plugin == NULL) {
|
||||
nlog_error("Failed to allocate plugin %s",
|
||||
neu_plugin_module.module_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
neu_plugin_common_init(&plugin->common);
|
||||
plugin->common.adapter = adapter;
|
||||
plugin->common.adapter_callbacks = callbacks;
|
||||
|
||||
plugin->handle_ctx = neu_rest_init_ctx(plugin);
|
||||
|
||||
@@ -241,7 +226,7 @@ static int dashb_plugin_uninit(neu_plugin_t *plugin)
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int dashb_plugin_config(neu_plugin_t *plugin, neu_config_t *configs)
|
||||
static int dashb_plugin_config(neu_plugin_t *plugin, const char *configs)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -324,7 +309,7 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = {
|
||||
.uninit = dashb_plugin_uninit,
|
||||
.start = dashb_plugin_start,
|
||||
.stop = dashb_plugin_stop,
|
||||
.config = dashb_plugin_config,
|
||||
.setting = dashb_plugin_config,
|
||||
.request = dashb_plugin_request,
|
||||
};
|
||||
|
||||
|
||||
+12
-13
@@ -514,8 +514,8 @@ neu_adapter_t *neu_adapter_create(neu_adapter_info_t *info,
|
||||
rv = nng_mtx_alloc(&adapter->nng.sub_grp_mtx);
|
||||
assert(rv == 0);
|
||||
|
||||
adapter->plugin_info.plugin = adapter->plugin_info.module->intf_funs->open(
|
||||
adapter, &adapter->cb_funs);
|
||||
adapter->plugin_info.plugin =
|
||||
adapter->plugin_info.module->intf_funs->open();
|
||||
assert(adapter->plugin_info.plugin != NULL);
|
||||
assert(neu_plugin_common_check(adapter->plugin_info.plugin));
|
||||
neu_plugin_common_t *common =
|
||||
@@ -542,8 +542,8 @@ void neu_adapter_destroy(neu_adapter_t *adapter)
|
||||
if (adapter->name != NULL) {
|
||||
free(adapter->name);
|
||||
}
|
||||
if (NULL != adapter->setting.buf) {
|
||||
free(adapter->setting.buf);
|
||||
if (NULL != adapter->setting) {
|
||||
free(adapter->setting);
|
||||
}
|
||||
|
||||
nng_mtx_free(adapter->nng.mtx);
|
||||
@@ -832,21 +832,20 @@ neu_adapter_type_e neu_adapter_get_type(neu_adapter_t *adapter)
|
||||
return (neu_adapter_type_e) adapter->plugin_info.module->type;
|
||||
}
|
||||
|
||||
int neu_adapter_set_setting(neu_adapter_t *adapter, neu_config_t *config)
|
||||
int neu_adapter_set_setting(neu_adapter_t *adapter, const char *setting)
|
||||
{
|
||||
int rv = -1;
|
||||
|
||||
const neu_plugin_intf_funs_t *intf_funs;
|
||||
|
||||
intf_funs = adapter->plugin_info.module->intf_funs;
|
||||
rv = intf_funs->config(adapter->plugin_info.plugin, config);
|
||||
rv = intf_funs->setting(adapter->plugin_info.plugin, setting);
|
||||
if (rv == 0) {
|
||||
adapter->setting.buf_len = config->buf_len;
|
||||
adapter->setting.type = config->type;
|
||||
if (adapter->setting != NULL) {
|
||||
free(adapter->setting);
|
||||
}
|
||||
adapter->setting = strdup(setting);
|
||||
|
||||
if (adapter->setting.buf != NULL)
|
||||
free(adapter->setting.buf);
|
||||
adapter->setting.buf = strdup(config->buf);
|
||||
if (adapter->state == ADAPTER_STATE_INIT) {
|
||||
adapter->state = ADAPTER_STATE_READY;
|
||||
}
|
||||
@@ -864,8 +863,8 @@ int neu_adapter_get_setting(neu_adapter_t *adapter, char **config)
|
||||
return NEU_ERR_NODE_NOT_EXIST;
|
||||
}
|
||||
|
||||
if (adapter->setting.buf != NULL) {
|
||||
*config = strdup(adapter->setting.buf);
|
||||
if (adapter->setting != NULL) {
|
||||
*config = strdup(adapter->setting);
|
||||
return NEU_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,7 @@ struct neu_adapter {
|
||||
uint32_t req_id;
|
||||
|
||||
adapter_callbacks_t cb_funs;
|
||||
neu_config_t setting;
|
||||
void * x;
|
||||
char * setting;
|
||||
|
||||
struct {
|
||||
void * handle; // handle of dynamic lib
|
||||
@@ -84,7 +83,7 @@ void neu_adapter_del_timer(neu_adapter_t *adapter, neu_event_timer_t *timer);
|
||||
const char * neu_adapter_get_name(neu_adapter_t *adapter);
|
||||
neu_manager_t * neu_adapter_get_manager(neu_adapter_t *adapter);
|
||||
neu_adapter_type_e neu_adapter_get_type(neu_adapter_t *adapter);
|
||||
int neu_adapter_set_setting(neu_adapter_t *adapter, neu_config_t *config);
|
||||
int neu_adapter_set_setting(neu_adapter_t *adapter, const char *config);
|
||||
int neu_adapter_get_setting(neu_adapter_t *adapter, char **config);
|
||||
neu_plugin_state_t neu_adapter_get_state(neu_adapter_t *adapter);
|
||||
neu_plugin_running_state_e
|
||||
|
||||
@@ -15,5 +15,4 @@
|
||||
* 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.
|
||||
**/
|
||||
#include "config_internal.h"
|
||||
**/
|
||||
@@ -15,5 +15,4 @@
|
||||
* 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.
|
||||
**/
|
||||
#include "control_internal.h"
|
||||
**/
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
#ifndef _NEU_ADAPTER_CONFIG_INTERNAL_H_
|
||||
#define _NEU_ADAPTER_CONFIG_INTERNAL_H_
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
#ifndef _NEU_ADAPTER_CONTROL_INTERNAL_H_
|
||||
#define _NEU_ADAPTER_CONTROL_INTERNAL_H_
|
||||
|
||||
#endif
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
void neu_plugin_common_init(neu_plugin_common_t *common)
|
||||
{
|
||||
common->magic = NEU_PLUGIN_MAGIC_NUMBER;
|
||||
common->magic = NEU_PLUGIN_MAGIC_NUMBER;
|
||||
common->link_state = NEU_NODE_LINK_STATUS_DISCONNECTED;
|
||||
}
|
||||
|
||||
bool neu_plugin_common_check(neu_plugin_t *plugin)
|
||||
|
||||
@@ -345,17 +345,12 @@ int neu_manager_node_ctl(neu_manager_t *manager, const char *node,
|
||||
int neu_manager_node_setting(neu_manager_t *manager, const char *node,
|
||||
const char *setting)
|
||||
{
|
||||
neu_config_t config = { 0 };
|
||||
neu_adapter_t *adapter = neu_node_manager_find(manager->node_manager, node);
|
||||
if (adapter == NULL) {
|
||||
return NEU_ERR_NODE_NOT_EXIST;
|
||||
}
|
||||
|
||||
config.type = NEU_CONFIG_SETTING;
|
||||
config.buf = (char *) setting;
|
||||
config.buf_len = strlen(setting);
|
||||
|
||||
return neu_adapter_set_setting(adapter, &config);
|
||||
return neu_adapter_set_setting(adapter, setting);
|
||||
}
|
||||
|
||||
int neu_manager_node_get_setting(neu_manager_t *manager, const char *node,
|
||||
|
||||
Reference in New Issue
Block a user