Pixels Plugin for Unity
Enable communications with Pixels dice using Bluetooth Low Energy.
Loading...
Searching...
No Matches
Apple_Objective-C

A collection of Objective-C classes that provides a simplified access to Bluetooth Low Energy peripherals. More...

Classes

class  SGBleCentralManagerDelegate
 Implementation of CBCentralManagerDelegate protocol. Stores and notifies of discovered Bluetooth Low Energy (BLE) peripherals, also notifies of peripherals connection events and of the host device Bluetooth radio state changes. More...
 
class  SGBlePeripheralQueue
 Implementation of the CBPeripheralDelegate protocol. Queues up operations to be performed with a Bluetooth Low Energy (BLE) peripheral, run them sequentially and notify of their outcome. More...
 
class  SGBleRequest
 Internal type, represents a Bluetooth operation to be performed on a peripheral. Used by SGBlePeripheralQueue. More...
 

Typedefs

typedef NSError *_Nullable(^ SGBleRequestExecuteHandler) ()
 Internal type, runs the Bluetooth operation associated with a SGBleRequest object.
 
typedef void(^ SGBleRequestCompletionHandler) (NSError *_Nullable error)
 Internal type, completion handler for operations associated with a SGBleRequest object.
 
typedef void(^ SGBlePeripheralDiscoveryHandler) (CBPeripheral *_Nonnull peripheral, NSDictionary< NSString *, id > *_Nonnull advertisementData, NSNumber *_Nonnull rssi)
 Peripheral discovery handler.
 
typedef void(^ SGBleConnectionEventHandler) (CBPeripheral *_Nonnull peripheral, SGBleConnectionEvent connectionEvent, NSError *_Nullable error)
 Peripheral connection event handler.
 
typedef void(^ SGBleCharacteristicValueEventHandler) (SGBlePeripheralQueue *_Nonnull peripheralQueue, CBCharacteristic *_Nonnull characteristic, NSError *_Nullable error)
 Peripheral connection event handler.
 

Enumerations

enum  {
  SGBleRequestTypeUnknown = 0 , SGBleRequestTypeConnect , SGBleRequestTypeDisconnect , SGBleRequestTypeReadRssi ,
  SGBleRequestTypeReadValue , SGBleRequestTypeWriteValue , SGBleRequestTypeSetNotifyValue
}
 Internal type, list the Bluetooth operations supported by SGBleRequest.
 
enum  {
  SGBleConnectionEventConnecting , SGBleConnectionEventConnected , SGBleConnectionEventFailedToConnect , SGBleConnectionEventReady ,
  SGBleConnectionEventDisconnecting , SGBleConnectionEventDisconnected
}
 Peripheral connection events. More...
 
enum  {
  SGBleConnectionEventReasonUnknown = -1 , SGBleConnectionEventReasonSuccess = 0 , SGBleConnectionEventReasonCanceled , SGBleConnectionEventReasonNotSupported ,
  SGBleConnectionEventReasonTimeout , SGBleConnectionEventReasonLinkLoss , SGBleConnectionEventReasonAdapterOff
}
 Peripheral connection events reasons. More...
 
enum  {
  SGBleErrorOutOfMemory , SGBleErrorNotImplemented , SGBleErrorInvalidParameter , SGBleErrorInvalidState ,
  SGBleErrorRequestCanceled , SGBleErrorPeripheralDisconnected
}
 Error codes. More...
 

Variables

NSError * SGBleOutOfMemoryError
 Application out of memory.
 
NSError * SGBleNotImplementedError
 Call not implemented.
 
NSError * SGBleInvalidParameterError
 Peripheral request was given one or more invalid parameters.
 
NSError * SGBleInvalidStateError
 Bluetooth or peripheral not in proper state to execute request.
 
NSError * SGBleRequestCanceledError
 Peripheral request got canceled.
 
NSError * SGBleDisconnectedError
 Peripheral got disconnected.
 

Detailed Description

A collection of Objective-C classes that provides a simplified access to Bluetooth Low Energy peripherals.

Note
Some knowledge with Bluetooth Low Energy semantics is recommended for reading this documentation.

The Systemic Games Bluetooth Low Energy library for Apple devices provides classes for scanning for Bluetooth Low Energy (BLE) peripherals, connecting to and communicating with them. Those classes are based on the Apple's Core Bluetooth framework.

The SGBleCentralManagerDelegate class implements the Apple CBCentralManagerDelegate protocol. It stores and notifies of discovered BLE peripherals, also notifies of peripherals connection events and of the host device Bluetooth radio state changes.

The SGBlePeripheralQueue class implements the Apple CBPeripheralDelegate protocol. It queues BLE operations to be performed with a BLE peripheral, run them sequentially and notify of their outcome. The next request is run one the current one completes (whether successfully or not).

This library also includes a set of C functions to be called from Unity for acessing Bluetooth devices.

Below is a diagram of the main classes of this library:

Classes diagram

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Peripheral connection events.

Enumerator
SGBleConnectionEventConnecting 

Raised at the beginning of the connect sequence and is followed either by Connected or FailedToConnect.

SGBleConnectionEventConnected 

Raised once the peripheral is connected, just before services are being discovered.

SGBleConnectionEventFailedToConnect 

Raised when the peripheral fails to connect, the reason of failure is also given.

SGBleConnectionEventReady 

Raised after a Connected event, once the required services have been discovered.

SGBleConnectionEventDisconnecting 

Raised at the beginning of a user initiated disconnect.

SGBleConnectionEventDisconnected 

Raised when the peripheral is disconnected, the reason for the disconnection is also given.

◆ anonymous enum

anonymous enum

Peripheral connection events reasons.

Enumerator
SGBleConnectionEventReasonUnknown 

The disconnect happened for an unknown reason.

SGBleConnectionEventReasonSuccess 

The disconnect was initiated by user.

SGBleConnectionEventReasonCanceled 

Connection attempt canceled by user.

SGBleConnectionEventReasonNotSupported 

Peripheral doesn't have all required services.

SGBleConnectionEventReasonTimeout 

Peripheral didn't responded in time.

SGBleConnectionEventReasonLinkLoss 

Peripheral was disconnected while in "auto connect" mode.

SGBleConnectionEventReasonAdapterOff 

The local device Bluetooth adapter is off.

◆ anonymous enum

anonymous enum

Error codes.

Enumerator
SGBleErrorOutOfMemory 

Application out of memory.

SGBleErrorNotImplemented 

Call not implemented.

SGBleErrorInvalidParameter 

Peripheral request has one or more invalid parameters.

SGBleErrorInvalidState 

Bluetooth or peripheral not in proper state to execute request.

SGBleErrorRequestCanceled 

Peripheral request got canceled.

SGBleErrorPeripheralDisconnected 

Peripheral got disconnected while executing request.