Skip to content
Snippets Groups Projects
Verified Commit d15e6c63 authored by Amin Ben Romdhane's avatar Amin Ben Romdhane Committed by IOPSYS Dev
Browse files

Added support for DeviceInfo.MemoryStatus.MemoryMonitor. Object

parent b7a44f16
No related branches found
No related tags found
1 merge request!7Added support for DeviceInfo.MemoryStatus.MemoryMonitor. Object
Pipeline #181980 passed
......@@ -235,7 +235,7 @@ DMOBJ tDeviceInfoObj[] = {
#endif
#ifdef SYSMNGR_MEMORY_STATUS
{"MemoryStatus", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoMemoryStatusParams, NULL, BBFDM_BOTH},
{"MemoryStatus", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoMemoryStatusObj, tDeviceInfoMemoryStatusParams, NULL, BBFDM_BOTH},
#endif
#ifdef SYSMNGR_PROCESS_STATUS
......
This diff is collapsed.
......@@ -12,6 +12,10 @@
#ifndef __MEMORY_H
#define __MEMORY_H
extern DMOBJ tDeviceInfoMemoryStatusObj[];
extern DMLEAF tDeviceInfoMemoryStatusParams[];
void sysmngr_memory_init(void);
void sysmngr_memory_clean(void);
#endif //__MEMORY_H
......@@ -24,6 +24,10 @@
#include "processes.h"
#endif
#ifdef SYSMNGR_MEMORY_STATUS
#include "memory.h"
#endif
extern DM_MAP_OBJ tDynamicObj[];
static void usage(char *prog)
......@@ -36,9 +40,24 @@ static void usage(char *prog)
fprintf(stderr, "\n");
}
static void config_reload_cb(struct ubus_context *ctx, struct ubus_event_handler *ev,
const char *type, struct blob_attr *msg)
{
BBF_ERR("Reloading sysmngr upon 'sysmngr.reload' event");
#ifdef SYSMNGR_MEMORY_STATUS
sysmngr_memory_clean();
sysmngr_memory_init();
#endif
}
int main(int argc, char **argv)
{
struct bbfdm_context bbfdm_ctx = {0};
struct ubus_event_handler ev = {
.cb = config_reload_cb,
};
int log_level = LOG_ERR;
int c = 0;
......@@ -72,9 +91,16 @@ int main(int argc, char **argv)
sysmngr_process_init(&bbfdm_ctx.ubus_ctx);
#endif
#ifdef SYSMNGR_MEMORY_STATUS
sysmngr_memory_init();
#endif
if (bbfdm_ubus_regiter_init(&bbfdm_ctx))
goto out;
if (ubus_register_event_handler(&bbfdm_ctx.ubus_ctx, &ev, "sysmngr.reload"))
goto out;
uloop_run();
out:
......@@ -84,6 +110,10 @@ out:
sysmngr_process_clean(&bbfdm_ctx.ubus_ctx);
#endif
#ifdef SYSMNGR_MEMORY_STATUS
sysmngr_memory_clean();
#endif
closelog();
return 0;
......
......@@ -229,6 +229,30 @@ int sysmngr_uci_delete(struct uci_context *uci_ctx, const char *package, const c
return 0;
}
int sysmngr_ubus_invoke_sync(const char *obj, const char *method, struct blob_attr *msg, sysmngr_ubus_cb data_callback, void *callback_args)
{
uint32_t id;
int rc = 0;
struct ubus_context *ubus_ctx = ubus_connect(NULL);
if (!ubus_ctx) {
BBF_ERR("Failed to connect with ubus, error: '%d'", errno);
return -1;
}
if (!ubus_lookup_id(ubus_ctx, obj, &id)) {
rc = ubus_invoke(ubus_ctx, id, method, msg, data_callback, callback_args, 5000);
} else {
BBF_ERR("Failed to lookup ubus object: '%s'", obj);
rc = -1;
}
ubus_free(ubus_ctx);
return rc;
}
int sysmngr_ubus_invoke_async(struct ubus_context *ubus_ctx, const char *obj, const char *method, struct blob_attr *msg,
sysmngr_ubus_cb data_callback, sysmngr_ubus_async_cb complete_callback)
{
......
......@@ -28,6 +28,7 @@ int sysmngr_uci_delete(struct uci_context *uci_ctx, const char *package, const c
typedef void (*sysmngr_ubus_cb)(struct ubus_request *req, int type, struct blob_attr *msg);
typedef void (*sysmngr_ubus_async_cb)(struct ubus_request *req, int ret);
int sysmngr_ubus_invoke_sync(const char *obj, const char *method, struct blob_attr *msg, sysmngr_ubus_cb data_callback, void *callback_args);
int sysmngr_ubus_invoke_async(struct ubus_context *ubus_ctx, const char *obj, const char *method, struct blob_attr *msg,
sysmngr_ubus_cb data_callback, sysmngr_ubus_async_cb complete_callback);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment