CBService Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreBluetooth.framework
Availability
Available in iOS 5.0 and later.
Companion guide
Declared in
CBService.h
Related sample code

Overview

CBService and its subclass CBMutableService represent a peripheral’s service—a collection of data and associated behaviors for accomplishing a function or feature of a device (or portions of that device). CBService objects in particular represent services of a remote peripheral device (represented by a CBPeripheral object). Services are either primary or secondary and may contain a number of characteristics or included services (references to other services).

Tasks

Identifying a Service

Accessing Service Data

Properties

characteristics

A list of characteristics that have been discovered in this service. (read-only)

@property(retain, readonly) NSArray *characteristics
Discussion

This array contains CBCharacteristic objects that represent a service’s characteristics. Characteristics provide further details about a peripheral’s service. For example, a heart rate service may contain one characteristic that describes the intended body location of the device’s heart rate sensor and another characteristic that transmits heart rate measurement data.

Availability
  • Available in iOS 5.0 and later.
Declared In
CBService.h

includedServices

A list of included services that have been discovered in this service. (read-only)

@property(retain, readonly) NSArray *includedServices
Discussion

This array contains CBService objects that represent the included services of a service. A service of a peripheral may contain a reference to other services that are available on the peripheral. These other services are the included services of the service and can be discovered using the discoverIncludedServices:forService: method of the CBPeripheral class.

Availability
  • Available in iOS 5.0 and later.
Declared In
CBService.h

isPrimary

A Boolean value indicating whether the type of service is primary or secondary. (read-only)

@property(readonly, nonatomic) BOOL isPrimary
Discussion

A peripheral’s service is either primary or secondary. A primary service describes the primary function of a device and can be included by another service. A secondary service describes a service that is relevant only in the context of another service that has referenced it. For example, the primary service of a heart rate monitor may be to expose heart rate data from the monitor’s heart rate sensor, whereas a secondary service may be to expose the sensor’s battery data. If the value of this property is YES, the type of service is primary. If the value of this property is NO, the type of service is secondary.

Availability
  • Available in iOS 6.0 and later.
Declared In
CBService.h

peripheral

The peripheral to which this service belongs. (read-only)

@property(weak, readonly, nonatomic) CBPeripheral *peripheral
Availability
  • Available in iOS 5.0 and later.
Declared In
CBService.h

UUID

The Bluetooth-specific UUID of the service. (read-only)

@property(readonly, nonatomic) CBUUID *UUID
Discussion

This property is a 128-bit UUID that identifies the service.

Availability
  • Available in iOS 5.0 and later.
Declared In
CBService.h