#define CMD_LINE_ARG_NODENAME 1
#define CMD_LINE_ARG_INVITEE 2
-
-void logger_cb(meshlink_handle_t *mesh, meshlink_log_level_t level,
- const char *text) {
- (void)mesh;
- (void)level;
-
- fprintf(stderr, "meshlink>> %s\n", text);
-}
+#define CMD_LINE_ARG_SUBMESH 3
int main(int argc, char *argv[]) {
char *invite = NULL;
+ meshlink_submesh_t *s = NULL;
/* Start mesh, generate an invite and print out the invite */
- /* Set up logging for Meshlink */
- meshlink_set_log_cb(NULL, MESHLINK_DEBUG, logger_cb);
-
- /* Create meshlink instance */
- meshlink_handle_t *mesh = meshlink_open("testconf", argv[1], "node_sim", DEV_CLASS_STATIONARY);
- assert(mesh);
-
- /* Set up logging for Meshlink with the newly acquired Mesh Handle */
- meshlink_set_log_cb(mesh, MESHLINK_DEBUG, logger_cb);
- meshlink_enable_discovery(mesh, false);
- assert(meshlink_start(mesh));
- invite = meshlink_invite_ex(mesh, NULL, argv[2], MESHLINK_INVITE_LOCAL | MESHLINK_INVITE_NUMERIC);
+ meshlink_handle_t *mesh = execute_open(argv[CMD_LINE_ARG_NODENAME], "1");
+ execute_start();
+
+ if(argc > CMD_LINE_ARG_SUBMESH) {
+ s = meshlink_submesh_open(mesh, argv[CMD_LINE_ARG_SUBMESH]);
+ }
+
+ invite = execute_invite(argv[CMD_LINE_ARG_INVITEE], s);
printf("%s\n", invite);
- meshlink_close(mesh);
+ execute_close();
return EXIT_SUCCESS;
}