Skip to content

Commit

Permalink
move blink handler to ucentral-state
Browse files Browse the repository at this point in the history
Signed-off-by: John Crispin <john@phrozen.org>
  • Loading branch information
blogic committed Sep 8, 2023
1 parent 9852b3e commit 76be18d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ADD_DEFINITIONS(-Os -std=gnu99 -g3 -Wmissing-declarations -Wno-unused-parameter)

SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

SET(SOURCES main.c config.c proto.c ubus.c task.c cmd.c blink.c apply.c upload.c rebootlog.c event.c collide.c)
SET(SOURCES main.c config.c proto.c ubus.c task.c cmd.c apply.c upload.c rebootlog.c event.c collide.c)

FIND_LIBRARY(ubus NAMES ubus)
FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
Expand Down
42 changes: 0 additions & 42 deletions blink.c

This file was deleted.

1 change: 1 addition & 0 deletions proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ leds_handle(struct blob_attr **rpc)
duration = blobmsg_get_u32(tb[LED_DURATION]);

if (!strcmp(blobmsg_get_string(tb[LED_PATTERN]), "blink")) {
result_send_error(0, "success", 0, id);
blink_run(duration, id);
return;
}
Expand Down
16 changes: 16 additions & 0 deletions ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,22 @@ void ubus_set_client_status(char *status)
ubus_abort_request(&conn.ctx, &async);
}

void ubus_blink_leds(int duration)
{
struct ubus_request async = { };

if (!state) {
ULOG_ERR("state is not running\n");
return;
}
blob_buf_init(&u, 0);
blobmsg_add_string(&u, "state", "blink");
blobmsg_add_u32(&u, "duration", duration);

ubus_invoke_async(&conn.ctx, state, "set", u.head, &async);
ubus_abort_request(&conn.ctx, &async);
}

static const struct ubus_method ucentral_methods[] = {
UBUS_METHOD("health", ubus_health_cb, health_policy),
UBUS_METHOD("result", ubus_result_cb, result_policy),
Expand Down
2 changes: 0 additions & 2 deletions ucentral.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ void ubus_deinit(void);
void ubus_forward_radius(struct blob_buf *msg);
void ubus_set_client_status(char *status);

void blink_run(uint32_t duration, uint32_t id);

void health_run(uint32_t id, uint32_t immediate);
void health_update_interval(uint32_t periodic);
void health_deinit(void);
Expand Down

0 comments on commit 76be18d

Please sign in to comment.