Merge Ubus with the 2016.02.26 version.
This commit is contained in:
@@ -92,34 +92,37 @@ static void test_count(struct uloop_timeout *timeout)
|
||||
COUNT_TO_MAX = 1000000,
|
||||
PROGRESSION = 100,
|
||||
};
|
||||
|
||||
|
||||
uint32_t id;
|
||||
static uint32_t count_to = 100000;
|
||||
static int count_progression = PROGRESSION;
|
||||
char *s;
|
||||
|
||||
|
||||
if (count_to <= COUNT_TO_MIN)
|
||||
count_progression = PROGRESSION;
|
||||
else if (count_to >= COUNT_TO_MAX)
|
||||
count_progression = -PROGRESSION;
|
||||
|
||||
|
||||
count_to += count_progression;
|
||||
|
||||
|
||||
s = count_to_number(count_to);
|
||||
if (!s)
|
||||
if (!s) {
|
||||
fprintf(stderr, "Could not allocate memory to count up to '%u'\n", count_to);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Sending count up to '%u'; string has length '%u'\n",
|
||||
count_to, (uint32_t)strlen(s));
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_u32(&b, "to", count_to);
|
||||
blobmsg_add_string(&b, "string", s);
|
||||
|
||||
|
||||
if (ubus_lookup_id(ctx, "test", &id)) {
|
||||
free(s);
|
||||
fprintf(stderr, "Failed to look up test object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ubus_invoke(ctx, id, "count", b.head, test_count_data_cb, &count_to, 5000);
|
||||
|
||||
free(s);
|
||||
@@ -173,30 +176,30 @@ static void client_main(void)
|
||||
static struct ubus_request req;
|
||||
uint32_t id;
|
||||
int ret;
|
||||
|
||||
|
||||
ret = ubus_add_object(ctx, &test_client_object);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Failed to add_object object: %s\n", ubus_strerror(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (ubus_lookup_id(ctx, "test", &id)) {
|
||||
fprintf(stderr, "Failed to look up test object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_u32(&b, "id", test_client_object.id);
|
||||
ubus_invoke(ctx, id, "watch", b.head, NULL, 0, 3000);
|
||||
test_client_notify_cb(¬ify_timer);
|
||||
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_string(&b, "msg", "blah");
|
||||
ubus_invoke_async(ctx, id, "hello", b.head, &req);
|
||||
req.fd_cb = test_client_fd_cb;
|
||||
req.complete_cb = test_client_complete_cb;
|
||||
ubus_complete_request_async(ctx, &req);
|
||||
|
||||
|
||||
uloop_timeout_set(&count_timer, 2000);
|
||||
|
||||
uloop_run();
|
||||
@@ -206,7 +209,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
const char *ubus_socket = NULL;
|
||||
int ch;
|
||||
|
||||
|
||||
while ((ch = getopt(argc, argv, "cs:")) != -1) {
|
||||
switch (ch) {
|
||||
case 's':
|
||||
|
||||
Reference in New Issue
Block a user