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 19, 2023
1 parent 44efd77 commit 876c33f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 46 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.

3 changes: 2 additions & 1 deletion proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,8 @@ leds_handle(struct blob_attr **rpc)
duration = blobmsg_get_u32(tb[LED_DURATION]);

if (!strcmp(blobmsg_get_string(tb[LED_PATTERN]), "blink")) {
blink_run(duration, id);
result_send_error(0, "success", 0, id);
ubus_blink_leds(duration);
return;
}
action_handle(rpc, "leds", 1, 1, 1, 0);
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
3 changes: 1 addition & 2 deletions ucentral.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ void ubus_init(void);
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 ubus_blink_leds(int duration);

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

0 comments on commit 876c33f

Please sign in to comment.