eyeDrops  v2.3
A new approach to detecting eye blinks.
Instance Methods | Class Methods | Protected Attributes | List of all members
BLEDeviceManager Class Reference

The Bluetooth low energy device manager. More...

#import <BLEDeviceManager.h>

Inherits NSObject, <CBCentralManagerDelegate>, and <CBPeripheralDelegate>.

Instance Methods

(void) - scanForDevices
 
(void) - abortScanning
 
(void) - connectToDevice:
 
(void) - disconnectFromDevice
 
(void) - setProfile:
 
(UserProfile *) - getCurrentProfile
 
(NSUInteger) - getEnforcedBlinks
 
(void) - communicateMessage:withData:
 
(CBPeripheral *) - getConnectedDevice
 
(void) - startCalibrationWithDevice
 
(void) - stopCalibrationWithDevice
 
(void) - calibrationComplete
 
(void) - wantsBlurring:
 
(bool) - hasConnection
 
(void) - requestBatteryLevel
 

Class Methods

(id) + sharedInstance
 

Protected Attributes

CBCentralManager * manager
 
CBPeripheral * peripheral
 
NSString * lastKnownDevice
 
CBPeripheral * lastKnownPeripheral
 
NSString * hardwareState
 
NSInteger state
 
bool autoScan
 
bool autoConnect
 
CBCharacteristic * send_characteristic
 
CBCharacteristic * disconnect_characteristic
 
bool loadedService
 
bool isConnected
 
bool isCalibrating
 
bool wantsBlurring
 
NSMutableArray * BLEDevices
 
NSTimer * repeatingTimer
 
NSUInteger enforcedBlinks
 
UserProfileuserProfile
 
NSUInteger noBlinkTimeInterval
 
NSUInteger packageCounter
 
float batteryLevel
 

Detailed Description

The Bluetooth low energy device manager.

This class manages the connection and communication with a BLE device. It uses the defined protocol to decode and encode the sent messages between the RFDuino and the PC.

Since the device manager is handling the imcoming messages, blink detection messages are recognized here. In normal operating mode (blink detection) a timer is used to start blurring the screen if there was no blink in a user defined time interval. Every incoming blink message from the RFDuino will reset this timer. If the user wants a blurring screen depends on the global setting made by control-clicking the ApplicationIcon in the menubar.

Based on the BLE-Chat-Demo: https://github.com/nandev/BLE-Chat-Demo

Author
Benjamin Thiemann
Date
2017/01/17

Method Documentation

◆ abortScanning()

- (void) abortScanning

This method aborts the current scan for Bluetooth low energy devices.

◆ calibrationComplete()

- (void) calibrationComplete

This method is invoked when the calibration process is completed. The BLE device manager will go into normal mode and, depending on whether blurring is desired, the blurring timer will be started.

◆ communicateMessage:withData:()

- (void) communicateMessage: (BLE_OUT_MESSAGE message
withData: (NSNumber *)  data 

This method represents a message receiver. By calling this method and passing a BLE_OUT_MESSAGE a corresponding communication with the connected device will take place. If there is addional data to send, the data has to be passed via the obj parameter.

See also
BLE_OUT_MESSAGE
Parameters
messageThe outgoing message to the connected device.
dataThe data to be send.

◆ connectToDevice:()

- (void) connectToDevice: (CBPeripheral *)  device

This method establishes a connection to the given device.

Parameters
deviceThe device to connect to.

◆ disconnectFromDevice()

- (void) disconnectFromDevice

This method disconnects from the current device.

◆ getConnectedDevice()

- (CBPeripheral *) getConnectedDevice

This method returns the connected device as a CBPeripheral object.

Returns
The connected device.

◆ getCurrentProfile()

- (UserProfile *) getCurrentProfile

This methods returns the current user profile.

Returns
The current user profile.

◆ getEnforcedBlinks()

- (NSUInteger) getEnforcedBlinks

This method returns the enforced blinks counter.

Returns
The current counter of enforced blinks.

◆ hasConnection()

- (bool) hasConnection

This method returns the connection state.

Returns
The connection state.

◆ requestBatteryLevel()

- (void) requestBatteryLevel

This methods requests the battery level. The value sent by the RFDuino is stored in batterLevel.

◆ scanForDevices()

- (void) scanForDevices

This method scans for Bluetooth low energy devices.

◆ setProfile:()

- (void) setProfile: (UserProfile *)  profile

This method sets the current user profile to the given profile by sending the profiles calibration data to the device. There it is stored and used from now on until this method is called again or the device is reset. The RFDuino has no possibility to nonvolatile store the parameters.

Parameters
profileThe user profile to set.

◆ sharedInstance()

+ (instancetype) sharedInstance

This method returns the shared instance of this singleton class.

◆ startCalibrationWithDevice()

- (void) startCalibrationWithDevice

This methods starts a calibration process with the connected device. The RFDuino will now start sending calibration data.

◆ stopCalibrationWithDevice()

- (void) stopCalibrationWithDevice

This methods stop a calibration process with the connected device. The RFDuino will now stop sending calibration data.

◆ wantsBlurring:()

- (void) wantsBlurring: (BOOL)  blurring

This method sets the current value of whethe the user wants to have the screen blurred or not.

Parameters
blurringThe new value for wantsBlurring.

Member Data Documentation

◆ autoConnect

- (bool) autoConnect
protected

Boolean value that indicates whether an autoconnect to the last known device is desired.

◆ autoScan

- (bool) autoScan
protected

Boolean value that indicates whether an autoscan is desired.

◆ batteryLevel

- (float) batteryLevel
protected

The battery level.

◆ BLEDevices

- (NSMutableArray*) BLEDevices
protected

Stores all found BLE devices.

◆ disconnect_characteristic

- (CBCharacteristic*) disconnect_characteristic
protected

CoreBluetooth characteristic for disconnecting. Stores additional information about the device.

◆ enforcedBlinks

- (NSUInteger) enforcedBlinks
protected

The counter for enforced blinks.

◆ hardwareState

- (NSString*) hardwareState
protected

The bluetooth hardware state (turned off, not supported and so on)

◆ isCalibrating

- (bool) isCalibrating
protected

Boolean value that indicates whether a calibration is ongoing.

◆ isConnected

- (bool) isConnected
protected

Boolean value that indicates whether a connection to a device is established.

◆ lastKnownDevice

- (NSString*) lastKnownDevice
protected

The last known CoreBluetooth peripheral's UUID string.

◆ lastKnownPeripheral

- (CBPeripheral*) lastKnownPeripheral
protected

The last known CoreBluetooth peripheral a connection has been established to.

◆ loadedService

- (bool) loadedService
protected

Boolean value that indicates whether a service is loaded.

◆ manager

- (CBCentralManager*) manager
protected

The CoreBluetooth central manager.

◆ noBlinkTimeInterval

- (NSUInteger) noBlinkTimeInterval
protected

The allowed time interval without a blink.

◆ packageCounter

- (NSUInteger) packageCounter
protected

Package counter

◆ peripheral

- (CBPeripheral*) peripheral
protected

The CoreBluetooth peripheral a connection is established to.

◆ repeatingTimer

- (NSTimer*) repeatingTimer
protected

The timer to stop time with a blink.

◆ send_characteristic

- (CBCharacteristic*) send_characteristic
protected

CoreBluetooth characteristic for sending. Stores additional information about the device.

◆ state

- (NSInteger) state
protected

The state the instance of this class is currently in.

◆ userProfile

- (UserProfile*) userProfile
protected

The current user profile.

◆ wantsBlurring

- (bool) wantsBlurring
protected

Boolean value that indicates whether blurring is desired.


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