void GlobalServicesScriptingInterface::setFindableBy(const QString& discoverabilityMode) {
    auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>();
    
    if (discoverabilityMode.toLower() == "none") {
        discoverabilityManager->setDiscoverabilityMode(Discoverability::None);
    } else if (discoverabilityMode.toLower() == "friends") {
        discoverabilityManager->setDiscoverabilityMode(Discoverability::Friends);
    } else if (discoverabilityMode.toLower() == "all") {
        discoverabilityManager->setDiscoverabilityMode(Discoverability::All);
    } else {
        qDebug() << "GlobalServices setFindableBy called with an unrecognized value. Did not change discoverability.";
    }
}
Esempio n. 2
0
  /* negative error code (of the form APPLICATION_ERROR_XXX).          */
int Bluetooth::initializeApplication()
{
  int ret_val = -1;
  SerialPortID = 0;

  /* Initiailize some defaults.                                        */
  /*SerialPortID           = 0;
  UI_Mode                = UI_MODE_SELECT;
  LoopbackActive         = FALSE;
  DisplayRawData         = FALSE;
  AutomaticReadActive    = FALSE;
  NumberofValidResponses = 0;*/

 /* Try to Open the stack and check if it was successful.          */
 if(!openStack()){
 	/* The stack was opened successfully.  Now set some defaults.  */

	/* First, attempt to set the Device to be Connectable.         */
	ret_val = setConnectabilityMode(cmConnectableMode);

	/* Next, check to see if the Device was successfully made      */
	/* Connectable.                                                */
	if(!ret_val)
	{
	   /* Now that the device is Connectable attempt to make it    */
	   /* Discoverable.                                            */
	   ret_val = setDiscoverabilityMode(dmGeneralDiscoverableMode);

	   /* Next, check to see if the Device was successfully made   */
	   /* Discoverable.                                            */
	   if(!ret_val)
	   {
		  /* Now that the device is discoverable attempt to make it*/
		  /* pairable.                                             */
		  ret_val = setPairable();
		  if(!ret_val)
		  {
			 /* Attempt to register a HCI Event Callback.          */
			 ret_val = HCI_Register_Event_Callback(bluetoothStackID, HCI_Event_Callback, (unsigned long)this);
			 if(ret_val > 0)
			 {
				/* Assign a NULL BD_ADDR for comparison.           */
				ASSIGN_BD_ADDR(NullADDR, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

				/* Return success to the caller.                   */
				ret_val = (int)bluetoothStackID;
			 }

		  }

	   }

	}

	/* In some error occurred then close the stack.                */
	if(ret_val < 0)
	{
	   /* Close the Bluetooth Stack.                               */
	   closeStack();
	}
 }
 else
 {
	/* There was an error while attempting to open the Stack.      */
	return -1;
 }

 return ret_val;
}