Chapter 32. Interfacing with Peripherals

In This Chapter

Listing accessories connected to the device through Bluetooth or the dock connector
Connecting to devices using the External Accessories framework
Talking to accessories using streams

A new feature in iPhone OS 3 is support for interfacing with third-party accessories through the dock connector or over Bluetooth. The framework responsible for doing this is called the External Accessory framework, and it is this framework that this chapter will discuss.

Creating Accessories That Interface with iPhone

In order for an accessory to interface with iPhone OS, it has to support some form of communication protocol. iPhone OS does not specify the types of protocols that are required to be implemented in order to communicate. When interfacing with an accessory, the API internal to the application is simply a stream API. The data that is streamed (the protocol itself) is entirely up to the developer of the accessory and the developer of the application. The accessory does need to declare what protocols it supports, and the application, when looking for accessories to communicate with, should look at the accessory information to be certain that the accessory supports the protocol it wants to use to communicate with it.

Your application must declare the types of protocols that it supports. To do this, you need to add to your Info.plist file a key of UISupportedExternalAccessoryProtocols, which should be an array of strings indicating the protocols ...

Get Cocoa Touch™ for iPhone® OS 3 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.