Android Programming Press on the image to return to the main documentation page.

BLE2

List of types:

BleManager2

BleManager2

This library replaces the BLE library. It allows you to search for and connect to BLE devices.
It is supported by Android 4.3+ (API 18).

Permissions:

android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN

Events:

StateChanged (State As Int)
DeviceFound (Name As String, DeviceId As String, AdvertisingData As Map, RSSI As Double)
Disconnected
Connected (Services As List)
DataAvailable (ServiceId As String, Characteristics As Map)
WriteComplete (Characteristic As String, Status As Int)
RssiAvailable (Success As Boolean, RSSI As Double)

Members:


  Connect (DeviceId As String)

  Connect2 (DeviceId As String, AutoConnect As Boolean)

  Disconnect

  GetCharacteristicProperties (Service As String, Characteristic As String) As Int

  GetRecordsFromAdvertisingData (AdvertisingData As Map, Key As Int) As List

  Initialize (EventName As String)

  ReadData (Service As String)

  ReadData2 (Service As String, Characteristic As String)

  ReadRemoteRssi

  Scan (ServiceUUIDs As List)

  Scan2 (ServiceUUIDs As List, AllowDuplicates As Boolean)

  SetIndication (Service As String, Characteristic As String, Notify As Boolean)

  SetNotify (Service As String, Characteristic As String, Notify As Boolean)

  State As Int [read only]

  STATE_POWERED_OFF As Int

  STATE_POWERED_ON As Int

  STATE_UNSUPPORTED As Int

  StopScan

  WriteData (Service As String, Characteristic As String, Data() As Byte)

Members description:

Connect (DeviceId As String)
Connects to a device with the given id. You can only connect to previously discovered devices.
Note that the Disconnected event will be raised if the connection has failed.
Connect2 (DeviceId As String, AutoConnect As Boolean)
Similar to Connect. Allows you to disable auto connection.
Disconnect
GetCharacteristicProperties (Service As String, Characteristic As String) As Int
Returns a numeric value from which you can find the properties of the specified characteristic.
GetRecordsFromAdvertisingData (AdvertisingData As Map, Key As Int) As List
Returns a List with all the records with the specified type.
This is useful when there could be several records with the same type.
Each item in the list is an array of bytes.
Initialize (EventName As String)
Initializes the object. The StateChanged event will be raised after this method with the current BLE state.
ReadData (Service As String)
Asynchronously reads all characteristics from the given service. The DataAvailable will be raised when the data is available.
ReadData2 (Service As String, Characteristic As String)
Asynchronously reads the value of the specified characteristic.
The DataAvailable will be raised when the data of this characteristic is available.
ReadRemoteRssi
Reads the RSSI value of a connected device. The RssiAvailable event will be raised when the value is available.
Scan (ServiceUUIDs As List)
Starts scanning for devices. The DeviceFound event will be raised when a device is found.
ServiceUUIDs - A list (or array) with service uuids. Devices that don't advertise these uuids will not be discovered.
Pass Null to discover all devices.
Scan2 (ServiceUUIDs As List, AllowDuplicates As Boolean)
Similar to Scan. If AllowDuplicates is true then the DeviceFound event will be raised whenever a packet is received.
SetIndication (Service As String, Characteristic As String, Notify As Boolean)
Similar to SetNotify. Sets the descriptor value to 2 (indication) instead of 1 (notification).
SetNotify (Service As String, Characteristic As String, Notify As Boolean)
Adds or removes a notification listener that monitor value changes.
The DataAvailable event will be raised when the value of the characteristic changes.
Service - The service id (as returned in the Connected event).
Characteristic - The characteristic id.
Notify - True to add a listener, false to remove it.
State As Int [read only]
Returns the current Bluetooth adapter state.
STATE_POWERED_OFF As Int
STATE_POWERED_ON As Int
STATE_UNSUPPORTED As Int
StopScan
Stops scanning for new devices.
WriteData (Service As String, Characteristic As String, Data() As Byte)
Writes the data to the specified characteristic.
Top