Inherits from NSObject
Declared in LEDeviceManager.h

Overview

This class is the main entry point for connecting and communicating with a LEGO Device. You must implement the LEDeviceManagerDelegate protocol and set the delegate property before scanning for and connecting to devices.

Tasks

Getting an instance of the Device Manager

Scan for Devices

Connect and Disconnect

Add and Remove delegates

Properties

allDevices

Returns a list with all known devices regardless of their current connect state.

@property (nonatomic, readonly) NSArray *allDevices

Discussion

Returns a list with all known devices regardless of their current connect state.

For BLE devices, the list is ordered according to relative distance, based of the RSSI values received for each Device. The Device closest will be first in the list. Note, the RSSI value is only updated while in advertising mode.

Declared In

LEDeviceManager.h

automaticReconnectOnConnectionLostEnabled

If enabled, the LEGDeviceManager will attempt to reconnect in case of a connection loss, but only if the connection was not closed by the user, the default value is NO.

@property (nonatomic, readwrite) BOOL automaticReconnectOnConnectionLostEnabled

Discussion

If enabled, the LEGDeviceManager will attempt to reconnect in case of a connection loss, but only if the connection was not closed by the user, the default value is NO.

If this property is set to YES an automatic attempt to connect is made in the following cases:

  • If a connection requests fails with an ‘unexpected error’ (e.g. not due to a time-out). If the second connection attempt also fails, no further attempts are made to connect automatically.
  • If a connection in lost in state LEDeviceStateInterrogating with an ‘unexpected error’ (e.g. not closed by user). If the second connection attempt also fails, no further attempts are made to connect automatically.
  • If a connection is lost after successful connection (i.e. in state LEDeviceStateInterrogationFinished)

If the connect-request does not succeed within the connectRequestTimeout no attempt is made to automatically reconnect.

Declared In

LEDeviceManager.h

connectRequestTimeoutInterval

If a connect request is not successful within this time interval the connection attempt is cancelled and the [LEDeviceManagerDelegate deviceManager:didFailToConnectToDevice:error] is invoked. The default value is 10 seconds.

@property (nonatomic, readwrite) NSTimeInterval connectRequestTimeoutInterval

Discussion

If a connect request is not successful within this time interval the connection attempt is cancelled and the [LEDeviceManagerDelegate deviceManager:didFailToConnectToDevice:error] is invoked. The default value is 10 seconds.

Declared In

LEDeviceManager.h

Class Methods

sharedDeviceManager

The shared LEDeviceManager

+ (LEDeviceManager *)sharedDeviceManager

Return Value

The shared LEDeviceManager

Declared In

LEDeviceManager.h

Instance Methods

addDelegate:

Add a delegate to receive device discovery and connection events

- (void)addDelegate:(id<LEDeviceManagerDelegate>)delegate

Parameters

delegate

The delegate to add

Discussion

Add a delegate to receive device discovery and connection events

Declared In

LEDeviceManager.h

cancelDeviceConnection:

Disconnect from a LEGO Bluetooth LE Device.

- (void)cancelDeviceConnection:(LEDevice *)device

Parameters

device

The device to disconnect from

Discussion

Disconnect from a LEGO Bluetooth LE Device.

Declared In

LEDeviceManager.h

connectToDevice:

Connect to a LEGO LEDevice. If a connection is not established within the connectRequestTimeoutInterval the connection attempt is cancelled and the [LEDeviceManagerDelegate deviceManager:didFailToConnectToDevice:error] is invoked.

- (void)connectToDevice:(LEDevice *)device

Parameters

device

The device to establish a connection to

Discussion

Connect to a LEGO LEDevice. If a connection is not established within the connectRequestTimeoutInterval the connection attempt is cancelled and the [LEDeviceManagerDelegate deviceManager:didFailToConnectToDevice:error] is invoked.

Declared In

LEDeviceManager.h

removeDelegate:

Remove a delegate

- (void)removeDelegate:(id<LEDeviceManagerDelegate>)delegate

Parameters

delegate

The delegate to remove

Discussion

Remove a delegate

Declared In

LEDeviceManager.h

scan

Start scanning for LEGO BLE devices

- (void)scan

Discussion

Start scanning for LEGO BLE devices

Declared In

LEDeviceManager.h

stopScanning

Stop scanning for LEGO BLE devices and removes all discovered but un-connected devices from the list of allDevices

- (void)stopScanning

Discussion

Stop scanning for LEGO BLE devices and removes all discovered but un-connected devices from the list of allDevices

Declared In

LEDeviceManager.h