BluetoothLE

개요

외부 디바이스와 Bluetooth 방식의 연결을 제공하는 오브젝트입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




- Bluetooth Low Energy 방식을 지원하며 Windows 8, Android 4.3, iOS 5, OSX 10.6 이상의 환경에서 사용할 수 있습니다.

- BluetoothLE 오브젝트의 모든 메소드는 비동기로 실행됩니다.
   메소드 실행 결과는 이벤트로 전달됩니다.

속성

id

BluetoothLE의 고유 식별자를 설정하는 속성입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




속성 타입

☐ Enum

☐ Expr

☐ Control

☐ Hidden

☑ ReadOnly

☐ Bind

☐ Collection

☐ StringResource

문법

BluetoothLE.id

문법 설정

id

BluetoothLE를 구별할 수 있는 유일값을 갖습니다.

참고

-  addChild나 insertChild 메소드를 사용하여 컴포넌트를 등록할때 parent 가 자식컴포넌트를 구별하기 위한 고유한 key값입니다.

- 속성명이나 메소드명과 같은 예약어를 id 속성값으로 설정할 경우 오류가 발생할 수 있습니다.

- 컴포넌트의 속성은 아니지만 편의를 위하여 넥사크로 스튜디오에서 설정할 수 있는 기능이 제공됩니다.

- name 속성은 사용자가 지정한 컴포넌트의 이름으로 논리적으로 중복이 가능합니다.

- 넥사크로 스튜디오에서 컴포넌트를 생성하거나 id 값을 설정하면 name 속성에 동일한 값이 설정됩니다.

name

BluetoothLE 의 이름을 설정하는 속성입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




속성 타입

☐ Enum

☐ Expr

☐ Control

☑ Hidden

☐ ReadOnly

☐ Bind

☐ Collection

☐ StringResource

문법

BluetoothLE.name[= strName]

문법 설정

strName

컴포넌트의 이름을 설정합니다.

참고

- name 속성은 사용자가 지정한 컴포넌트의 이름으로 논리적으로 중복이 가능합니다.

- 넥사크로 스튜디오에서 컴포넌트를 생성하거나 id 값을 설정하면 name 속성에 동일한 값이 설정됩니다.

메서드

connect

Peripheral 디바이스와 연결을 수행하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.connect( strAddress )

파라미터

Parameters

Type

Description

strAddress

String

Peripheral 디바이스의 주소를 문자열로 설정합니다.


Windows NRE 와 Android NRE 는 MAC Address 를 사용합니다.

macOS NRE 는 OS 가 부여한 UUID 를 사용합니다.

iOS/iPadOS NRE 는 검색된 디바이스 목록의 Index 를 사용합니다.

this.BluetoothLE00.connect( "00:00:00:00:00:00" );

참고

- Peripheral 디바이스와 연결에 성공하면 onsuccess 이벤트가 발생합니다.
   Peripheral 디바이스와 연결에 실패하면 onerror 이벤트가 발생합니다.

- Peripheral 디바이스의 주소는 scanStart() 메소드 실행 시 발생하는 onscanresult 이벤트에서 확인할 수 있습니다.


◆  Windows NRE 제약

- Windows OS 는 "Bluetooth 및 기타 디바이스" 화면을 통해서만 Peripheral 디바이스와 명시적 연결을 제공합니다.
   OS 를 통한 명시적 연결이 제공되지 않은 상태에서 connect() 메소드를 사용하면 에러가 발생할 수 있습니다.

disconnect

Peripheral 디바이스와의 연결을 해제하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.disconnect()

파라미터

this.BluetoothLE00.disconnect();

참고

- Peripheral 디바이스와 연결 해제에 성공하면 onsuccess 이벤트가 발생합니다.
   Peripheral 디바이스와 연결 해제에 실패하면 onerror 이벤트가 발생합니다.


◆  Windows NRE 제약

- Windows OS 는 "Bluetooth 및 기타 디바이스" 화면을 통해서만 Peripheral 디바이스와의 명시적 연결 해제를 제공합니다.
   disconnect() 메소드로 디바이스와 연결을 해제해도 실제로 연결이 해제되지 않습니다.

discoverService

연결된 Peripheral 디바이스가 제공하는 서비스 UUID 를 요청하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.discoverService()

파라미터

this.BluetoothLE00.discoverService();

참고

- 연결된 Peripheral 디바이스에 서비스 UUID 요청을 성공하면 onsuccess 이벤트가 발생합니다.
   연결된 Peripheral 디바이스에 서비스 UUID 요청을 실패하면 onerror 이벤트가 발생합니다.

- 연결된 Peripheral 디바이스에서 제공하는 서비스 UUID 갯수만큼 onsuccess 이벤트가 발생합니다.

readCharacteristic

연결된 Peripheral 디바이스에 특정 서비스의 Characteristic 값을 요청하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.readCharacteristic( strSvcUUID, strCharUUID )

파라미터

Parameters

Type

Description

strSvcUUID

String

Characteristic 이 정의된 서비스의 UUID 를 문자열로 설정합니다.

strCharUUID

String

값을 가져오려는 Characteristic 의 UUID 를 문자열로 설정합니다.

// Serial 통신 서비스의 RX Characteristic 값 요청
this.BluetoothLE00.readCharacteristic( "6E400001-B5A3-F393-E0A9-E50E24DCCA9E", "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" );

참고

- Peripheral 디바이스에 Characteristic 값 요청을 성공하면 onsuccess 이벤트가 발생합니다.
   Peripheral 디바이스에 Characteristic 값 요청을 실패하면 onerror 이벤트가 발생합니다.

scanStart

게시(Advertisement)중인 Peripheral 디바이스의 검색을 시작하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.scanStart( [nDuration [, strSvcUUID]] )

파라미터

Parameters

Type

Description

nDuration

Number

검색을 지속할 시간을 밀리초(Millisecond) 단위의 숫자로 설정합니다.


값 생략 시 2000 으로 적용됩니다.

strSvcUUID

String

찾으려고 하는 특정 서비스의 UUID 를 문자열로 설정합니다.


값 생략 시 게시(Advertiesement)중인 모든 Peripheral 디바이스를 검색합니다.

this.BluetoothLE.scanStart();
this.BluetoothLE.scanStart( 5000 );
this.BluetoothLE.scanStart( 5000, "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" ); // Serial 통신 서비스

참고

- 검색이 정상적으로 시작되거나 종료되면 onsuccess 이벤트가 발생합니다.
   게시(Advertisement)중인 디바이스를 찾을 때마다 onscanresult 이벤트가 발생합니다.
   검색이 정상적으로 시작되지 않았거나 오류가 생기면 onerror 이벤트가 발생합니다.


◆  Windows NRE 제약

- Windows OS 는 "Bluetooth 및 기타 디바이스" 화면을 통해서만 Peripheral 디바이스와 명시적 연결을 제공합니다.
   따라서 scanStart() 메소드 실행 시 "Bluetooth 및 기타 디바이스" 화면에 게시된 디바이스가 검색됩니다.

scanStop

게시(Advertisement)중인 Peripheral 디바이스의 검색을 종료하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.scanStop()

참고

- 검색이 정상적으로 종료되면 onsuccess 이벤트가 발생합니다.
   검색 종료에 실패하면 onerror 이벤트가 발생합니다.

subscribe

연결된 Peripheral 디바이스에 특정 서비스의 Characteristic 값이 변경될 때 Notification 을 요청하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.subscribe( strSvcUUID, strCharUUID )

파라미터

Parameters

Type

Description

strSvcUUID

String

Characteristic 이 정의된 서비스의 UUID 를 문자열로 설정합니다.

strCharUUID

String

Notification 을 요청할 Characteristic 의 UUID 를 문자열로 설정합니다.


Characteristic 의 값이 변경되면 서버로 부터 Notification 이 전달됩니다.

// Serial 통신 서비스의 RX Characteristic 값 변경 시 Notification 요청
this.BluetoothLE00.subscribe( "6E400001-B5A3-F393-E0A9-E50E24DCCA9E", "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" );

참고

- Peripheral 디바이스에 Notification 요청을 성공하면 onsuccess 이벤트가 발생합니다.
   Peripheral 디바이스에 Notification 요청을 실패하면 onerror 이벤트가 발생합니다.

- Peripheral 디바이스에서 Notification 이 전달되면 onsubscriberesult 이벤트가 발생합니다.

unsubscribe

연결된 Peripheral 디바이스에 Notification 해지를 요청하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.unsubscribe( strSvcUUID, strCharUUID )

파라미터

Parameters

Type

Description

strSvcUUID

String

Characteristic 이 정의된 서비스의 UUID 를 문자열로 설정합니다.

strCharUUID

String

Notification 해제를 요청할 Characteristic 의 UUID 를 문자열로 설정합니다.

// Serial 통신 서비스의 RX Characteristic 에 대한 Notification 해제
this.BluetoothLE00.unsubscribe( "6E400001-B5A3-F393-E0A9-E50E24DCCA9E", "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" );

참고

- Peripheral 디바이스에 Notification 해제 요청을 성공하면 onsuccess 이벤트가 발생합니다.
   Peripheral 디바이스에 Notification 해제 요청을 실패하면 onerror 이벤트가 발생합니다.

writeCharacteristic

연결된 Peripheral 디바이스에 특정 서비스의 Characteristic 값을 저장하는 메소드입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

BluetoothLE.writeCharacteristic( strSvcUUID, strCharUUID, strVal )

파라미터

Parameters

Type

Description

strSvcUUID

String

Characteristic 이 정의된 서비스의 UUID 를 문자열로 설정합니다.

strCharUUID

String

값을 저장하려는 Characteristic 의 UUID 를 문자열로 설정합니다.

strVal

String

Characteristic 에 저장할 값을 문자열로 설정합니다.

// Serial 통신 서비스의 RX Characteristic 값 저장
this.BluetoothLE00.readCharacteristic( "6E400001-B5A3-F393-E0A9-E50E24DCCA9E", "6E400003-B5A3-F393-E0A9-E50E24DCCA9E", "C#B0" );

참고

- Peripheral 디바이스에 Characteristic 값 저장에 성공하면 onsuccess 이벤트가 발생합니다.
   Peripheral 디바이스에 Characteristic 값 저장에 실패하면 onerror 이벤트가 발생합니다.

이벤트

onerror

BluetoothLE 에서 요청된 작업이 실패했을 때 발생하는 이벤트입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

onerror(obj:nexacro.BluetoothLE,e:nexacro.BluetoothLEErrorEventInfo);

파라미터

Parameters

Type

Description

obj

BluetoothLE

Event가 발생한 Object.

e

BluetoothLEErrorEventInfo

Event Object.

참고

- 이벤트가 발생한 원인은 e 오브젝트(BluetoothLEErrorEventinfo) 의 reason 속성값을 참조하시기 바랍니다.

onscanresult

scanStart() 메소드로 특정 서비스가 제공되는 디바이스를 찾았을 때 발생하는 이벤트입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

onscanresult(obj:nexacro.BluetoothLE,e:nexacro.BluetoothLEScanDeviceEventInfo);

파라미터

Parameters

Type

Description

obj

BluetoothLE

Event가 발생한 Object.

e

BluetoothLEScanDeviceEventInfo

Event Object.

참고

- 특정 서비스가 제공되는 디바이스를 찾을 때마다 발생하는 이벤트입니다.

- 찾아낸 디바이스에 대한 정보는 e 오브젝트(BluetoothLEScanDeviceEventInfo) 의 devicename, deviceaddress 속성을 참조하시기 바랍니다.

onsubscriberesult

BluetoothLE 와 연결된 디바이스에서 Notification 이 전달되었을 때 발생하는 이벤트입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

onsubscriberesult(obj:nexacro.BluetoothLE,e:nexacro.BluetoothLEEventInfo);

파라미터

Parameters

Type

Description

obj

BluetoothLE

Event가 발생한 Object.

e

BluetoothLEEventInfo

Event Object.

참고

- subscribe() 메소드로 요청한 Notification 이 수신되었을 때 발생하는 이벤트입니다.

onsuccess

BluetoothLE 에서 요청된 작업이 성공했을 때 발생하는 이벤트입니다.

지원 환경

Desktop NRE

Desktop WRE

☑ Windows

☑ macOS

☐ Edge

☐ Chrome

☐ Safari

☐ Firefox

☐ Opera

Mobile NRE

Mobile WRE

☑ Android

☑ iOS/iPadOS

☐ Android

☐ iOS/iPadOS




문법

onsuccess(obj:nexacro.BluetoothLE,e:nexacro.BluetoothLEEventInfo);

파라미터

Parameters

Type

Description

obj

BluetoothLE

Event가 발생한 Object.

e

BluetoothLEEventInfo

Event Object.

참고

- 이벤트가 발생한 원인은 e 오브젝트(BluetoothLEEventinfo) 의 reason 속성값을 참조하시기 바랍니다.