X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=test%2Fblackbox%2Futil%2Fgen_invite.c;h=4014b68bd9a1761bbd450bff7159dd52c9b45053;hp=83c3f4f80a06325c5779f985fcb640b9ddb6e13b;hb=1c04402a6d2f3a85d0cb4a5b4a6db5b1f3a79511;hpb=6054182c9e208fd0b3f5c6c90f54cb5af75d3f5c diff --git a/test/blackbox/util/gen_invite.c b/test/blackbox/util/gen_invite.c index 83c3f4f8..4014b68b 100644 --- a/test/blackbox/util/gen_invite.c +++ b/test/blackbox/util/gen_invite.c @@ -17,6 +17,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include +#include #include #include "../../../src/meshlink.h" #include "../common/test_step.h" @@ -24,15 +25,32 @@ #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); +} + int main(int argc, char *argv[]) { char *invite = NULL; /* Start mesh, generate an invite and print out the invite */ - execute_open(argv[CMD_LINE_ARG_NODENAME], "1"); - execute_start(); - invite = execute_invite(argv[CMD_LINE_ARG_INVITEE]); + /* 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, argv[2], MESHLINK_INVITE_LOCAL | MESHLINK_INVITE_NUMERIC); printf("%s\n", invite); - //execute_close(); + meshlink_close(mesh); return EXIT_SUCCESS; }