9 #include "../src/meshlink.h"
12 meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
14 // Open two new meshlink instance.
16 meshlink_handle_t *mesh_a, *mesh_b;
17 open_meshlink_pair(&mesh_a, &mesh_b, "discovery");
19 // Forget the canoncial address
21 assert(meshlink_clear_canonical_address(mesh_a, meshlink_get_node(mesh_a, "b")));
22 assert(meshlink_clear_canonical_address(mesh_b, meshlink_get_node(mesh_b, "a")));
24 int port_a = meshlink_get_port(mesh_a);
25 int port_b = meshlink_get_port(mesh_b);
27 // Swap and change ports
32 meshlink_close(mesh_a);
33 assert(meshlink_set_port(mesh_b, port_a));
34 meshlink_close(mesh_b);
35 mesh_a = meshlink_open("discovery_conf.1", "a", "discovery", DEV_CLASS_BACKBONE);
37 assert(meshlink_set_port(mesh_a, port_b));
38 mesh_b = meshlink_open("discovery_conf.2", "b", "discovery", DEV_CLASS_BACKBONE);
41 assert(meshlink_get_port(mesh_a) == port_b);
42 assert(meshlink_get_port(mesh_b) == port_a);
44 // Verify that the nodes can find each other
46 meshlink_enable_discovery(mesh_a, true);
47 meshlink_enable_discovery(mesh_b, true);
49 start_meshlink_pair(mesh_a, mesh_b);
53 close_meshlink_pair(mesh_a, mesh_b);