3 static struct ubus_context
*ctx
;
5 static const struct ubus_signature test_object_sig
[] = {
6 UBUS_METHOD_START("hello"),
8 UBUS_TABLE_START(NULL
),
9 UBUS_FIELD(INT32
, "id"),
10 UBUS_FIELD(STRING
, "msg"),
15 static struct ubus_object_type test_object_type
=
16 UBUS_OBJECT_TYPE("test", test_object_sig
);
18 static struct ubus_object test_object
= {
20 .type
= &test_object_type
,
23 static struct ubus_object test_object2
= {
25 .type
= &test_object_type
,
28 int main(int argc
, char **argv
)
32 ctx
= ubus_connect(NULL
);
34 fprintf(stderr
, "Failed to connect to ubus\n");
38 fprintf(stderr
, "Connected as ID 0x%08x\n", ctx
->local_id
);
40 fprintf(stderr
, "Publishing object\n");
41 ret
= ubus_publish(ctx
, &test_object
);
43 fprintf(stderr
, "Failed to publish object: %s\n", ubus_strerror(ret
));
45 fprintf(stderr
, "Object ID: %08x\n", test_object
.id
);
46 fprintf(stderr
, "Object Type ID: %08x\n", test_object
.type
->id
);
49 fprintf(stderr
, "Publishing object\n");
50 ret
= ubus_publish(ctx
, &test_object2
);
52 fprintf(stderr
, "Failed to publish object: %s\n", ubus_strerror(ret
));
54 fprintf(stderr
, "Object ID: %08x\n", test_object2
.id
);
55 fprintf(stderr
, "Object Type ID: %08x\n", test_object2
.type
->id
);
58 uloop_fd_add(&ctx
->sock
, ULOOP_READ
| ULOOP_EDGE_TRIGGER
);