Languages

Menu
Sites
Language
블루투스, 진동 질문

 

 

안녕하세요

타이젠 웹 애플리케이션 개발하고 있습니다.

 

1. 블루투스 on/off

블루투스 on/off 하는 동작을 해야 하는데,

tizen.bluetooth.getDefaultAdapter() 값이 null입니다.

그래서 블루투스 on/off 하는 동작을 할 수가 없습니다.

config.xml에 아래와 같이 feature, privilege는 추가한 상태입니다.

feature feature/network.bluetooth
privilege name privilege/bluetooth.admin
privilege name privilege/bluetooth.gap
privilege name privilege/bluetooth.spp

 

2. 진동

Help에서 Vibrate 관련 소스를 참고하여 진동이 울리게 하려고 하였으나, 진동 동작이 되지 않습니다.

제 코드는 navigator.vibrate(2000); 입니다.

 

확인 부탁드립니다.

감사합니다.

 

 

Responses

2 Replies
Adnan Maruf

1. bluetooth on/off
I'm not sure whether you asked to know the current bluetooth state (on/off) or you want to turn on/off bluetooth from your app. However, I will try to answer both.

- to get bluetooth state of the device, you need to use BluetoothAdapter interface as follows:

var adapter = tizen.bluetooth.getDefaultAdapter();
if (adapter.powered){
alert("Bluetooth is ON");
}
else{
alert("Bletooth is OFF");
}

Use following privileges:
<tizen:privilege name="http://tizen.org/privilege/bluetooth.admin"/>
<tizen:privilege name="http://tizen.org/privilege/bluetooth.gap"/>

Bluetooth API guide for Tizen 2.4 is here: https://developer.tizen.org/dev-guide/2.4.0/org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html

- To turn on/off bluetooth:
According to dev-guide, "The Bluetooth API does not provide a method to enable or disable the Bluetooth adapter of the device directly. Whenever Bluetooth is required, request a built-in Settings application to present the relevant switch to the user so that they can enable or disable the Bluetooth."

you can go through the tutorial to turn on/off Bluetooth here:
https://developer.tizen.org/ko/development/tutorials/web-application/tizen-features/communication/bluetooth?langredirect=1#Managing_BT_Adapter

2. Vibration:
I assume you were facing problem to trigger vibration in the device. But "navigator.vibrate(2000);" is working fine in Tizen 2.4. You can go through the dev-guide on Managing Vibrations, here: https://developer.tizen.org/dev-guide/web/2.3.0/org.tizen.mobile.web.appprogramming/html/tutorials/w3c_tutorial/device_tutorial/managing_vibration.htm

Seoghyun Kang

If you want to use the vibration, please refer the following code.

 

function basicVibration()
 {
    // Vibrate for 3 seconds 
    navigator.vibrate(3000);
 }

 function patternVibration1()
 {
    // Vibrate in a give pattern : 1 sec on, 0.5 sec off, 2 sec on
    navigator.vibrate([1000, 500, 2000]);
 } 
 
 function patternVibration2()
 {
    // Vibrate in a given pattern: 1 sec on, 1 sec off, 2 sec on, 2 sec off, 1 sec on
    navigator.vibrate([1000, 1000, 2000, 2000, 1000]);
 } 

 function stopVibration()
 {
    // Cancels any existing vibrations
    navigator.vibrate(0);
 } 

 

And please refer the folllowing url.

http://www.w3.org/TR/2012/WD-vibration-20120202/