Callback on mavsdk.subscribe_on_new_system is never called

Hallo,

I cannot uderstand why callback provided in mavsdk.subscribe_on_new_system is never called:

	Mavsdk mavsdk;

	Mavsdk::Configuration configuration(
		Mavsdk::Configuration::UsageType::Autopilot);

	int opt;
	uint8_t _id;

	char url[256] = DEF_URL;

	while ((opt = getopt(argc, argv, "i:u:")) != -1)
	{
	   switch (opt)
	   {
		   case 'i':
			   cout << "System id: " << optarg << endl;
			   _id = (uint8_t)atoi(optarg);
			   configuration.set_system_id(_id);
			   break;

		   case 'u':
			   cout << "Connecting on: " << optarg << endl;
			   strcpy(url , optarg);
			   break;

		   default:
			   fprintf(stderr, "Usage: %s [-i system_id] [-u connection_url]\n", argv[0]);
			   exit(EXIT_FAILURE);
	   }
   }


	mavsdk.set_configuration(configuration);

	cout << "Making connection...";

	ConnectionResult conn_result = mavsdk.add_any_connection(url);

	if (conn_result != mavsdk::ConnectionResult::Success) {
	    cout << "connection failed: " << conn_result << endl;
	    return -1;
	}
	else {
		cout << "connection created" << endl;

        mavsdk.subscribe_on_new_system(
            [&](){
        		cout << "System connected"  << endl;
            }
        );
	}

do {
     this_thread::sleep_for(std::chrono::milliseconds(1000));
  } while(1);

Does mavsdk say that a system is discovered (in the log output)?

Yes it is … if I check on mavsdk.systems().size() sooner or later it will become != 0 and I can poll connected systems and so on…

But this imply making something like a polling cycle in a separate thread or to start a timer to periodically check for new systems… but why ?

Did you try subscribing your callback before calling add_any_connection?

Yes I did it now… without luck.

Which version of MAVSDK are you using?

1.4 compiled from source