Inherits from NSObject
Declared in LEService.h

Overview

An LEService represent an IO of some kind, for example a motor or sensor. It could also be an internal IO, such as Voltage sensor build into the device.

The LEService has a number of sub-classes for known IO types. This includes LEMotor, LETiltSensor and LEMotionSensor just to mention a few.

Add a instance of a LEServiceDelegate using addDelegate: to be notified when a service receives an updated value.

Tasks

General Service Info

Configure the IO mode

Configure and read valid data formats

Read IO Input Value

Reset IO state

Write data

Add and remove delegates

Check for equality

Properties

connectInfo

General info about the connected service

@property (nonatomic, readonly) LEConnectInfo *connectInfo

Discussion

General info about the connected service

Declared In

LEService.h

defaultInputFormat

The default input format that will be uploaded to the device for this service upon discovery of the service. Only the known service types (LEMotor, LETiltSensor, etc.) has a default input format.

@property (nonatomic, readonly) LEInputFormat *defaultInputFormat

Discussion

The default input format that will be uploaded to the device for this service upon discovery of the service. Only the known service types (LEMotor, LETiltSensor, etc.) has a default input format.

Declared In

LEService.h

device

The Device this service is related to

@property (nonatomic, weak, readonly) LEDevice *device

Discussion

The Device this service is related to

Declared In

LEService.h

inputFormat

The current input format for this service.

@property (nonatomic, readonly) LEInputFormat *inputFormat

Discussion

The current input format for this service.

Declared In

LEService.h

inputFormatMode

Convenience method that will return the mode of the current inputFormat. If no inputFormat is set, it will return the mode of the defaultInputFormat. If no inputFormat or defaultInputFormat is set, it will return mode 0.

@property (nonatomic, readonly) uint8_t inputFormatMode

Discussion

Convenience method that will return the mode of the current inputFormat. If no inputFormat is set, it will return the mode of the defaultInputFormat. If no inputFormat or defaultInputFormat is set, it will return mode 0.

Declared In

LEService.h

isInternalService

Is YES if this service represents an internal IO, such as an LEVoltageSensor

@property (nonatomic, readonly) BOOL isInternalService

Discussion

Is YES if this service represents an internal IO, such as an LEVoltageSensor

Declared In

LEService.h

serviceName

The name of the service

@property (nonatomic, readonly) NSString *serviceName

Discussion

The name of the service

Declared In

LEService.h

validDataFormats

The data formats that this service may use to parse received data.

@property (nonatomic, readonly) NSSet *validDataFormats

Discussion

The data formats that this service may use to parse received data.

When a new value for a service is received from the device, the SDK will look for a LEDataFormat among the validDataFormats that matches the [LEInputFormat unit] and [LEInputFormat mode]. If a match is found the LEDataFormat is used to parse the received data correctly (as a float, integer).

The known service types such as LETiltSensor and LEMotionSensor etc. comes with a set of predefined validDataFormat and you do not need to add valid data formats yourself. However, if you wish to use the LEService with a service type unknown to the SDK you must add the valid data formats using the addValidDataFormat: method.

Declared In

LEService.h

valueAsFloat

The latest received value from the service as an integer. If no valid data format is found to parse the data zero is returned, see validDataFormats.

@property (nonatomic, readonly) Float32 valueAsFloat

Discussion

The latest received value from the service as an integer. If no valid data format is found to parse the data zero is returned, see validDataFormats.

Declared In

LEService.h

valueAsInteger

The latest received value from the service as an integer. If no valid data format is found to parse the data zero is returned, see validDataFormats.

@property (nonatomic, readonly) int32_t valueAsInteger

Discussion

The latest received value from the service as an integer. If no valid data format is found to parse the data zero is returned, see validDataFormats.

Declared In

LEService.h

valueData

The latest received value from the service as raw data

@property (nonatomic, readonly) NSData *valueData

Discussion

The latest received value from the service as raw data

Declared In

LEService.h

Instance Methods

addDelegate:

Add a delegate to receive service updates.

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

Parameters

delegate

The delegate to add

Discussion

Add a delegate to receive service updates.

Declared In

LEService.h

addValidDataFormat:

Add a new valid data format.

- (void)addValidDataFormat:(LEDataFormat *)dataFormat

Parameters

dataFormat

The data format to add.

Discussion

Add a new valid data format.

Declared In

LEService.h

isEqualToService:

Returns YES if this service is equal to otherService - two services are considered equal if their connectInfo are equal

- (BOOL)isEqualToService:(LEService *)otherService

Parameters

otherService

The service to be compared to the receiver.

Discussion

Returns YES if this service is equal to otherService - two services are considered equal if their connectInfo are equal

Declared In

LEService.h

removeDelegate:

Remove a delegate

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

Parameters

delegate

The delegate to remove

Discussion

Remove a delegate

Declared In

LEService.h

removeValidDataFormat:

Remove a valid data format

- (void)removeValidDataFormat:(LEDataFormat *)dataFormat

Parameters

dataFormat

The data format to remove.

Discussion

Remove a valid data format

Declared In

LEService.h

sendReadValueRequest

If the notifications is disabled for the service in the inputFormat through [LEInputFormat notificationsEnabled] you will have to use this method to request an updated value for the service. The updated value will be delivered through the delegate method [LEServiceDelegate service:didUpdateValueDataFrom:to:].

- (void)sendReadValueRequest

Discussion

If the notifications is disabled for the service in the inputFormat through [LEInputFormat notificationsEnabled] you will have to use this method to request an updated value for the service. The updated value will be delivered through the delegate method [LEServiceDelegate service:didUpdateValueDataFrom:to:].

Declared In

LEService.h

sendResetStateRequest

This will send a reset command to the Device for this service. Some services has state, such as a bump-count for a tilt sensor that you may wish to reset.

- (void)sendResetStateRequest

Discussion

This will send a reset command to the Device for this service. Some services has state, such as a bump-count for a tilt sensor that you may wish to reset.

Declared In

LEService.h

updateCurrentInputFormatWithNewMode:

Send and updated input format with newMode for this service to the device. If no current inputFormat is set, the message will be based on the defaultInputFormat of this service. If no defaultInputFormat is set, the call to this method is ignored.

- (void)updateCurrentInputFormatWithNewMode:(uint8_t)newMode

Parameters

newMode

The input new service mode

Discussion

Send and updated input format with newMode for this service to the device. If no current inputFormat is set, the message will be based on the defaultInputFormat of this service. If no defaultInputFormat is set, the call to this method is ignored.

Declared In

LEService.h

updateInputFormat:

Send an updated input format for this service to the device. If successful this will trigger an invocation of the delegate callback method [LEServiceDelegate service:didUpdateInputFormatFrom:to].

- (void)updateInputFormat:(LEInputFormat *)newFormat

Parameters

newFormat

The input format to send to the device.

Discussion

Send an updated input format for this service to the device. If successful this will trigger an invocation of the delegate callback method [LEServiceDelegate service:didUpdateInputFormatFrom:to].

Declared In

LEService.h

writeData:

Will send data to the IO backed by this service. Useful to write data to an output unknown to the SDK.

- (void)writeData:(NSData *)data

Parameters

data

The data to write.

Discussion

Will send data to the IO backed by this service. Useful to write data to an output unknown to the SDK.

Declared In

LEService.h