Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Display scan result after switch on bluetooth in a packed apps

  • 4 tontu
  • 5 am na jafe-jafe bii
  • 7 views
  • i mujjee tontu mooy sb00349044

more options

I want to develop a app for firefox os. On click on a button i need to display all bluetooth devices near by. User able to select a device and pair a device. It is by using external APP. Please guide me how to do it.

I want to develop a app for firefox os. On click on a button i need to display all bluetooth devices near by. User able to select a device and pair a device. It is by using external APP. Please guide me how to do it.

All Replies (4)

more options

Hi sb00349044,

For developer-related questions, you should look into MDN (Mozilla Developer Network) and StackOverflow. You can find these links below:

I hope you find this information helpful. Please let us know if you have any other questions about the usage of your Firefox OS device.

Thanks,

- Ralph

more options

Hi Ralph,

Thanks. But how to integrate to a apps. I want default on click of button bluetooth should enable and display the all devices near by.

more options

I think you should use the method startDiscovery on an instance of BluetoothAdapter. After the discovery is done a list of found bluetooth devices will be found in the property devices on the adapter.

https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdapter

more options

I want to check device is paired in bluetooth using custom APP.

I used below code but not working. If u know who to check devices were paired or not. Which files I need to include to use Bluetooth in custom APP.


var req = bluetooth.getDefaultAdapter(); req.onsuccess = function bt_getAdapterSuccess() {

 defaultAdapter = req.result;
 if (defaultAdapter == null) {
               // we can do nothing without DefaultAdapter, so set bluetooth disabled
               settings.createLock().set({'bluetooth.enabled': false});
               var msg = 'Get null bluetooth adapter!';
               cannotTransfer(msg);
               return;
 }
 if (callback) {
               callback();
 }

}; req.onerror = function bt_getAdapterFailed() {

 // we can do nothing without DefaultAdapter, so set bluetooth disabled
 settings.createLock().set({'bluetooth.enabled': false});
 var msg = 'Can not get bluetooth adapter!';
 cannotTransfer(msg);

};

var req = defaultAdapter.getPairedDevices(); req.onsuccess = function bt_getPairedSuccess() {

 pairList.index = req.result;
 var length = pairList.index.length;
 if (length == 0) {
               var msg = 'There is no paired device!' +
                                                 ' Please pair your bluetooth device first.';
               showPairingConfirmation(msg);
               return;
 }

} req.onerror = function() {

 var msg = 'Can not get paired devices from adapter.';
 cannotTransfer(msg);

};