Skip to content
Snippets Groups Projects
Commit dbca3e03 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

update dongle.c to rely more on hotplug events

parent afad6212
No related branches found
No related tags found
No related merge requests found
...@@ -426,9 +426,9 @@ int get_devices_from_path(char *input_path) ...@@ -426,9 +426,9 @@ int get_devices_from_path(char *input_path)
perror("calloc"); perror("calloc");
goto fail_dev; goto fail_dev;
} }
dev->usb.product = get_usb_stat(input_path, de->d_name, "product"); dev->usb.product = get_usb_stat(input_path, "", "product");
dev->usb.product_id = get_usb_stat(input_path, de->d_name, "idProduct"); dev->usb.product_id = get_usb_stat(input_path, "", "idProduct");
dev->usb.vendor_id = get_usb_stat(input_path, de->d_name, "idVendor"); dev->usb.vendor_id = get_usb_stat(input_path, "", "idVendor");
dev->usb.if_name = name; dev->usb.if_name = name;
dev->ip = get_device_ip(dev->usb.if_name); dev->ip = get_device_ip(dev->usb.if_name);
...@@ -650,6 +650,15 @@ int alert(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -650,6 +650,15 @@ int alert(struct ubus_context *ctx, struct ubus_object *obj,
goto fail; goto fail;
usb_path = (char *)blobmsg_data(tb[USB_PATH]); usb_path = (char *)blobmsg_data(tb[USB_PATH]);
/* FIX THROUGH BASH SCRIPT INSTEAD... */
if (strstr(usb_path, ":")) {
printf("contained :\n");
goto fail;
}
printf("did not contain :\n");
printf("%s\n", usb_path);
get_devices_from_path(usb_path); get_devices_from_path(usb_path);
return 0; return 0;
fail: fail:
...@@ -676,13 +685,25 @@ fail: ...@@ -676,13 +685,25 @@ fail:
return UBUS_STATUS_INVALID_ARGUMENT; return UBUS_STATUS_INVALID_ARGUMENT;
} }
int update(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
printf("lets update!\n");
get_devices();
tag_missing_devices();
return 0;
}
struct ubus_method dongle_object_methods[] = { struct ubus_method dongle_object_methods[] = {
UBUS_METHOD_NOARG("test", test), UBUS_METHOD_NOARG("test", test),
UBUS_METHOD_NOARG("list", print_list), UBUS_METHOD_NOARG("list", print_list),
UBUS_METHOD_NOARG("clear", clear), UBUS_METHOD_NOARG("clear", clear),
UBUS_METHOD("remove_device", remove_device, dev_policy), UBUS_METHOD("remove_device", remove_device, dev_policy),
UBUS_METHOD("alert", alert, usb_policy) UBUS_METHOD("alert", alert, usb_policy),
}; UBUS_METHOD_NOARG("update", update)
};
struct ubus_object_type dongle_object_type = UBUS_OBJECT_TYPE("dongle", dongle_object_methods); struct ubus_object_type dongle_object_type = UBUS_OBJECT_TYPE("dongle", dongle_object_methods);
...@@ -695,7 +716,7 @@ struct ubus_object dongle_object = { ...@@ -695,7 +716,7 @@ struct ubus_object dongle_object = {
void uloop_add_get_devices(struct uloop_timeout *t) void uloop_add_get_devices(struct uloop_timeout *t)
{ {
uloop_timeout_set(t, 5000); uloop_timeout_set(t, 60000);
uloop_timeout_add(t); uloop_timeout_add(t);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment