BtLibrary  0.97
Bluetooth Classic Library for Unity
Static Public Member Functions | Events | List of all members
TechTweaking.Bluetooth.BluetoothAdapter Class Reference

Represents the local device Bluetooth adapter. More...

Inheritance diagram for TechTweaking.Bluetooth.BluetoothAdapter:

Static Public Member Functions

static void showDevices ()
 Display the default Android Bluetooth devices list. More...
 
static bool isBluetoothEnabled ()
 the Bluetooth adapter state. More...
 
static bool enableBluetooth ()
 Force Enabling the bluetooth, without asking the user. More...
 
static bool disableBluetooth ()
 Disables the bluetooth. More...
 
static void askEnableBluetooth ()
 Asks the user to enable bluetooth. More...
 
static void startServer (string UUID)
 Starts the server. More...
 
static void startServer (string UUID, int time)
 Starts the server. More...
 
static void startServer (string UUID, int time, bool connectOneDevice)
 Starts the server. More...
 
static void listenToBluetoothState ()
 Listens the state of the Bluetooth adapter of this device. More...
 
static void stopListenToBluetoothState ()
 Stop listening to the state of the Bluetooth adapter of this device. More...
 
static BluetoothDevice[] getPairedDevices ()
 Gets the paired devices. More...
 
static bool startDiscovery ()
 Start Discovery for nearby devices, get those discovered devices by listening to the event OnDeviceDiscovered More...
 
static void makeDiscoverable (int time)
 Simply it makes the Android device discoverable. If you want other devices to connect to your device, use startServer (string UUID). More...
 

Events

static Action< BluetoothDeviceOnConnected
 Occurs when a BluetoothDevice instance get connected, and pass its reference. More...
 
static Action< BluetoothDeviceOnDisconnected
 Occurs when a BluetoothDevice instance get disconnected, and pass its reference. More...
 
static Action< BluetoothDeviceOnDeviceNotFound
 Occurs when a BluetoothDevice instance can't be found as a near by Device, and pass its reference. More...
 
static Action< BluetoothDeviceOnDeviceOFF
 Occurs when a BluetoothDevice instance has been found but failed to connect to it, and pass its reference. More...
 
static Action< BluetoothDeviceOnSendingError
 Occurs when on sending error. Passes the BluetoothDevice reference that has the error. More...
 
static Action< BluetoothDeviceOnReadingError
 Occurs when on reading error. Passes the BluetoothDevice reference that has the error. More...
 
static Action< BluetoothDeviceOnDevicePicked
 Occurs when on a device picked by user from the default Android Bluetooth devices list. More...
 
static Action< BluetoothDeviceOnClientRequest
 Occurs when a client remote device request to connect to your server. More...
 
static Action< BluetoothDeviceOnReadingStarted
 Occurs when on reading starts for a BluetoothDevice insance and Passes its reference. More...
 
static Action< BluetoothDeviceOnReadingStoped
 Occurs when on reading stops for a BluetoothDevice insance and Passes its reference. More...
 
static Action OnBluetoothON
 Occurs when this Android device changes its Bluetoth Adapter state to ON. More...
 
static Action OnBluetoothOFF
 Occurs when this Android device changes its Bluetoth Adapter state to OFF. More...
 
static Action< BluetoothDevice, short > OnDeviceDiscovered
 Occurs when a nearby device has been discovered after calling startDiscovery() . More...
 

Detailed Description

Represents the local device Bluetooth adapter.

This class has all the general actions that aren't just specific to the remote device you are connecting to, like enabling or checking the status of the Bluetooth Adapter or showing the nearby devices. Also it has all the events that can be raised by this library.

Member Function Documentation

static void TechTweaking.Bluetooth.BluetoothAdapter.askEnableBluetooth ( )
static

Asks the user to enable bluetooth.

A yes/no dialog box will appear to the user asking him to turn Bluetooth ON

static bool TechTweaking.Bluetooth.BluetoothAdapter.disableBluetooth ( )
static

Disables the bluetooth.

Returns
true, if Bluetooth disabling process was started, false otherwise.
static bool TechTweaking.Bluetooth.BluetoothAdapter.enableBluetooth ( )
static

Force Enabling the bluetooth, without asking the user.

Returns
true, if Bluetooth enabling process started, false otherwise.
static BluetoothDevice [] TechTweaking.Bluetooth.BluetoothAdapter.getPairedDevices ( )
static

Gets the paired devices.

Returns
BluetoothDevice array of the paired devices on your Android.
static bool TechTweaking.Bluetooth.BluetoothAdapter.isBluetoothEnabled ( )
static

the Bluetooth adapter state.

Returns
true, if Bluetooth was enabled, false otherwise.
static void TechTweaking.Bluetooth.BluetoothAdapter.listenToBluetoothState ( )
static

Listens the state of the Bluetooth adapter of this device.

After calling this method register for OnBluetoothOFF or OnBluetoothON, they won't be broadcasted unless you called this methods

static void TechTweaking.Bluetooth.BluetoothAdapter.makeDiscoverable ( int  time)
static

Simply it makes the Android device discoverable. If you want other devices to connect to your device, use startServer (string UUID).

static void TechTweaking.Bluetooth.BluetoothAdapter.showDevices ( )
static

Display the default Android Bluetooth devices list.

Subscribe to OnDevicePicked Event in order to get a reference of the picked device.

static bool TechTweaking.Bluetooth.BluetoothAdapter.startDiscovery ( )
static

Start Discovery for nearby devices, get those discovered devices by listening to the event OnDeviceDiscovered

Returns
true, if Discovery has started, false otherwise.
static void TechTweaking.Bluetooth.BluetoothAdapter.startServer ( string  UUID)
static

Starts the server.

Listen to the Event OnClientRequest in order to get a refrence of the remote device is trying to connect

This server will run for 100 seconds, and will close after the first client requests a connection which means after the first OnClientRequest event Broadcasted

Parameters
UUIDa Unique identifier that other devices will use to connect and identefy your server
static void TechTweaking.Bluetooth.BluetoothAdapter.startServer ( string  UUID,
int  time 
)
static

Starts the server.

Listen to the Event OnClientRequest in order to get a refrence of the remote device that is trying to connect

This server will close after the first client requests a connection which means after the first OnClientRequest event Broadcasted

Parameters
UUIDa Unique identifier that other devices will use to connect and identefy your server
timehow long the server will be running in seconds
static void TechTweaking.Bluetooth.BluetoothAdapter.startServer ( string  UUID,
int  time,
bool  connectOneDevice 
)
static

Starts the server.

Listen to the Event OnClientRequest in order to get a refrence of the remote devices which are trying to connect

Parameters
UUIDa Unique identifier that other devices will use to connect and identefy your server
timehow long the server will be running in seconds
connectOneDeviceIf set to true it will close after the first client requests a connection which means OnClientRequest will be broadcasted once.
If set to false it will stay running and accepting connection attempts for the whole time period of a time number of seconds
static void TechTweaking.Bluetooth.BluetoothAdapter.stopListenToBluetoothState ( )
static

Stop listening to the state of the Bluetooth adapter of this device.

After calling this method unregister for OnBluetoothOFF and OnBluetoothON events, because they won't be broadcasted after calling this method

Event Documentation

Action TechTweaking.Bluetooth.BluetoothAdapter.OnBluetoothOFF
static

Occurs when this Android device changes its Bluetoth Adapter state to OFF.

You need to call listenToBluetoothState() inorder to rescieve this event. Call stopListenToBluetoothState() to stop rescieving this event.

Action TechTweaking.Bluetooth.BluetoothAdapter.OnBluetoothON
static

Occurs when this Android device changes its Bluetoth Adapter state to ON.

You need to call listenToBluetoothState() inorder to rescieve this event. Call stopListenToBluetoothState() to stop rescieving this event.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnClientRequest
static

Occurs when a client remote device request to connect to your server.

After calling one of the startServer(string) methods, you can listen to client requesting to connect using this event.

The Event Passes a BluetoothDevice reference of the remote client device that is trying to connect

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnConnected
static

Occurs when a BluetoothDevice instance get connected, and pass its reference.

Action<BluetoothDevice,short> TechTweaking.Bluetooth.BluetoothAdapter.OnDeviceDiscovered
static

Occurs when a nearby device has been discovered after calling startDiscovery() .

It passes a BluetoothDevice reference and its RSSI value

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnDeviceNotFound
static

Occurs when a BluetoothDevice instance can't be found as a near by Device, and pass its reference.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnDeviceOFF
static

Occurs when a BluetoothDevice instance has been found but failed to connect to it, and pass its reference.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnDevicePicked
static

Occurs when on a device picked by user from the default Android Bluetooth devices list.

Passes the BluetoothDevice instance which the user picked

You can show the list using showDevices()

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnDisconnected
static

Occurs when a BluetoothDevice instance get disconnected, and pass its reference.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnReadingError
static

Occurs when on reading error. Passes the BluetoothDevice reference that has the error.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnReadingStarted
static

Occurs when on reading starts for a BluetoothDevice insance and Passes its reference.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnReadingStoped
static

Occurs when on reading stops for a BluetoothDevice insance and Passes its reference.

Action<BluetoothDevice> TechTweaking.Bluetooth.BluetoothAdapter.OnSendingError
static

Occurs when on sending error. Passes the BluetoothDevice reference that has the error.


The documentation for this class was generated from the following file: