libnetconf2
libnetconf2 copied to clipboard
How to create notification with values?
Hello
I´d like to extend oven example to send notification with values, as an exercise/tutorial. The notification is called "oven-new-config" and will be sent whenever the oven receives a new configuration.
I changed oven.yang with:
notification oven-ready {
....
}
notification oven-new-config
{
description "Event of new configuration accepted.";
leaf turned-on {
description "New value for power switch.";
type boolean;
}
leaf temperature {
description "New value for desired temperature.";
type oven-temperature;
}
}
and for oven.c.... I don´t know how to create and fill a set of values,
static int
oven_config_change_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *xpath,
sr_event_t event, uint32_t request_id, void *private_data)
{
...
sr_val_t *pValues = NULL;
int values_count = 0;
pValues = ????(config_temperature, (oven_tid!=0) );
values_count = 2;
rc = sr_notif_send(sess, "/oven:oven-new-config", pValues, values_count, 0, 0);
if (rc != SR_ERR_OK) {
SRPLG_LOG_ERR("oven", "Oven-ready notification generation failed: %s.", sr_strerror(rc));
}
return SR_ERR_OK;
can someone help me please? I think this would help others too..
Thank you.
You can look into sysrepo tests for example, test_notif.
Thank you, I´ll take a look.