Languages

Menu
Sites
Language
블루투스에 관한 질문입니다.

1. 블루투스 연결 상태 유무에 대해 알 수 있는 방법

 

2. 앱이 꺼져있는 상태에서 블루투스 연결됐을 때나 끊어졌을 때 앱이 이벤트를 받을 수 있도록 처리하는 방법

 

3. 앱이 백그라운드인 상태에서 블루투스 연결됐을 때나 끊어졌을 때 앱이 이벤트를 받을 수 있도록 처리하는 방법

 

해당 링크를 보고 있으나

양이 방대해서 쉽게 찾아보기가 어렵네요.

가이드를 부탁드립니다.

https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/2.3.1/org.tizen.web.apireference/html/device_api/wearable/tizen/bluetooth.html#BluetoothManagerObject

Edited by: JaeYeong Eom on 19 Jul, 2016

Responses

6 Replies
Iqbal Hossain

 Hi, 
 1. The way to find out about the existence Bluetooth connection status: 

please try like this to get connection information 
 

 function gotDeviceInfo(device) {
    console.log("Device Name: " + device.name);
    console.log("Device Address: " + device.address);
    console.log("Device Class: " + device.deviceClass.major);
    console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
 }

 function onError(e) {
    console.log ("Could not get device info:" + e.message);
 }

  var adapter = tizen.bluetooth.getDefaultAdapter();
  adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo, onError);
 

You can receive events when the app is in background state. You need to Service Application for this. 
But you can't receive events when the Bluetooth connection would have been disconnected. 
 
If you find my answer helpful, please mark as best answer. 
 
 

JaeYeong Eom

안녕하세요

 

getDevice method의 parameter에 있는  MacAdress는 해당 앱이 동작하고 있는 단말의  MacAdress인건가요?

JaeYeong Eom

안녕하세요

 

getDevice method의 parameter에 있는  MacAdress는 해당 앱이 동작하고 있는 단말의  MacAdress인건가요?

JaeYeong Eom

이런식으로 블루투스 연결 여부를 확인하면 되는건가요?

 

   function gotDeviceInfo(device) {
        console.log("Device Name: " + device.name);
        console.log("Device Address: " + device.address);
        console.log("Device Class: " + device.deviceClass.major);
        console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
    }

    function onError(e) {
        console.log("Could not get device info:" + e.message);
    }

    var adapter = tizen.bluetooth.getDefaultAdapter();
    

    function successWifiNetworkCB(property) {

        var macAdress = property.macAdress;
        adapter.getDevice(macAdress, gotDeviceInfo, onError);
    }
    
    tizen.systeminfo.getPropertyValue("WIFI_NETWORK", successWifiNetworkCB);

Iqbal Hossain

To check connection status please see the second answer. 

Iqbal Hossain

Hi, 
 1. The way to find out about the existence Bluetooth connection status: 

please try like this to get connection information 

var adapter = tizen.bluetooth.getDefaultAdapter();
  adapter.getDevice("11:22:33:44:55:66", function(device) {
     console.log("Is connected: " + (device.isConnected ? "Yes" : "No"));
   });