coreBluetooth

所需积分/C币:20 2014-05-23 10:11:35 666KB PDF
0
收藏 收藏
举报

BLE 说明档,开发蓝牙4.0 时使用,必备资料
Contents Build your tree of services and characteristics 27 Publishing Your Services and Characteristics 28 Advertising Your Services 29 Responding to Read and Write Requests from a Central 30 Sending Updated Characteristic Values to Subscribed Centrals 33 Core Bluetooth Background Processing for iOS Apps 35 Foreground-Only Apps 35 Take Advantage of Peripheral Connection Options 36 Core bluetooth Background Execution Modes 36 The bluetooth-central Background Execution Mode 37 The bluetooth-peripheral Background Execution Mode 37 Use Background Execution Modes Wisely 38 Performing Long-Term Actions in the background 38 State Preservation and restoration 39 Adding Support for State Preservation and Restoration 40 Best Practices for Interacting with a Remote Peripheral Device 45 Be mindful of radio Usage and power Consumption 45 Scan for Devices Only When You Need To 45 Specify the CBCentralManagerScanOptionAllow DuplicatesKey Option Only When Necessary 45 Explore a Peripherals Data Wisely 46 Subscribe to Characteristic Values That Change often 46 Disconnect from a device when You have all the data you need 47 Reconnecting to Peripherals 47 Retrieving a List of Known Peripherals 49 Retrieving a List of Connected peripherals 50 Best Practices for Setting Up Your Local Device as a Peripheral 51 Advertising Considerations 51 Respect the Limits of Advertising Data 51 Advertise Data Only When You Need To 52 Configuring Your Characteristics 52 Configure Your Characteristics to Support Notifications 53 Require a paired Connection to Access sensitive Data 53 Document Revision History 55 2013-09-18 Copyright O 2013 Apple Inc. All Rights Reserved 3 Figures Core bluetooth overview 9 Figure 1-1 Central and peripheral devices 9 Figure 1-2 Advertising and discovery 10 igure 1-3 Fi A peripheral's service and characteristics 11 Fiqure 1-4 Core bluetooth objects on the central side 12 Figure 1-5 A remote peripheral s tree of services and characteristics 13 Figure 1-6 Core Bluetooth objects on the peripheral side 14 Figure 1-7 A local peripherals tree of services and characteristics 14 Best Practices for Interacting with a Remote Peripheral Device 45 Figure 5-1 A sample reconnection workflow 48 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved. About core bluetooth The Core bluetooth framework provides the classes needed for your iOS and Mac apps to communicate with devices that are equipped with bluetooth low energy wireless technology. For example, your app can discover, explore, and interact with low energy peripheral devices, such as heart rate monitors and digital thermostats As of oS X v10.9 and iOS 6, Mac and ioS devices can also function as bluetooth low energy peripherals, serving data to other devices, including other mac and ios devices Apps Core bluetooth Bluetooth low energy rotocol stack GATT ATT L2CAP At a glance Bluetooth low energy wireless technology is based on the bluetooth 4.0 specification, which, among other things, defines a set of protocols for communicating between low energy devices. The Core Bluetooth framework is an abstraction of the Bluetooth low energy protocol stack. That said, it hides many of the low-level detail of the specification from you, the developer, making it much easier for you to develop apps that interact with Bluetooth low energy devices Centrals and Peripherals Are the Key players in Core Bluetooth In Bluetooth low energy communication, there are two key players: the central and the peripheral. Each player has a different role to play in bluetooth low energy communication. a peripheral typically has data that is needed by other devices. A central typically uses the information served up by a peripheral to accomplish some task. For example a digital thermostat equipped with bluetooth low energy technology might provide the temperature of a room to an iOS app that then displays the temperature in a user-friendly way 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved. 5 About core bluetooth At a glance Just as each player has a different role to play in Bluetooth low energy communication, each player performs a different set of tasks. Peripherals make their presence known by advertising the data they have over the air Centrals,on the other hand, can scan for peripherals that might have data they're interested in. When a central discovers such a peripheral, the central can request to connect with the peripheral and begin exploring and interacting with the peripherals data. The peripheral is then responsible for responding to the central in approprlate ways Relevant Chapters: Core Bluetooth Overview"(page 9) Core Bluetooth Simplifies Common Bluetooth Tasks The Core bluetooth framework abstracts away the low-level details from the bluetooth 4.0 specification. As a result, many of the common bluetooth low energy tasks you need to implement in your app are simplified. If you are developing an app that implements the central role, Core bluetooth makes it easy to discover and connect with a peripheral, and to explore and interact with the peripheral s data. In addition Core bluetooth makes it easy to set up your local device to implement the peripheral role Relevant Chapters: "Performing Common Central Role Tasks"(page 16),"Performing Common Peripheral Role Tasks"(page 25 iOS App States Affect Bluetooth Behavior When your iOS app is in the background or in a suspended state its Bluetooth-related capabilities are affected By default, your app is unable to perform bluetooth low energy tasks while it is in the background or in a suspended state. That said, if your app needs to perform Bluetooth low energy tasks while in the background you can declare it to support one or both of the Core bluetooth background execution modes (there 's one for the central role, and one for the peripheral role). Even when you declare one or both of these background execution modes, certain Bluetooth tasks operate differently while your app is in the background. You want to take these differences into account when designing your app Even apps that support background processing may be terminated by the system at any time to free up memory for the current foreground app. As of iOS 7, Core bluetooth supports saving state information for central and peripheral manager objects and restoring that state at app launch time. You can use this feature to support long-term actions involving Bluetooth devices 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved 6 About core bluetooth How to use this document Relevant Chapters: Core Bluetooth Background Processing for iOS Apps"(page 35) Follow Best Practices to Enhance the User Experience The core bluetooth framework gives your app control over many of the common bluetooth low energy transactions. Follow best practices to harness this level of control in a responsible way and enhance the user's experlence For example, many of the tasks you perform when implementing the central or the peripheral role use your device's onboard radio to transmit signals over the air because your device s radio is shared with other forms of wireless communication and because radio usage has an adverse effect on a device's battery life always design your app to minimize how much it uses the radio Relevant Chapters: "Best Practices for Interacting with a Remote Peripheral Device"(page 45) Best Practices for Setting Up Your Local Device as a Peripheral"(page 51) How to Use this document If you have never used the Core bluetooth framework, or if you are unfamiliar with basic bluetooth low energy concepts, read this document in its entirety. In "Core Bluetooth Overview"(page 9), you learn the key terms and concepts that you need to know for the remainder of the book. After you understand the key concepts, read"Performing Common Central Role Tasks"(page 16)to learn how to develop your app to implement the central role on your local device. Similarly, to learn how to develop your pp to implement the peripheral role on your local device, read"Performing Common Peripheral role Tasks"(page 25 To ensure that your app is performing well and adhering to best practices, read the later chapters: Core Bluetooth Background Processing for ioS Apps"(page 35)," Best Practices for Interacting with a remote Peripheral Device"(page 45), and"Best Practices for Setting Up Your Local Device as a Peripheral"(page 51) See also The official Bluetooth Special Interest Group(SIG)website provides the definitive information about bluetooth low energy wireless technology. There, you can also find the Bluetooth 4.0 specification 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved. About core bluetooth See also If you are designing hardware accessories that use bluetooth low energy technology to communicate with Apple products, including Mac, iPhone, iPad, and iPod touch models, read Bluetooth Accessory Design Guidelines for Apple Products. If your bluetooth accessory( that connects to an ioS device through a bluetooth low energy link needs access to notifications that are generated on ioS devices, read Apple Notification Center Service(ANcs) Specification 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved. Core bluetooth overview The Core bluetooth framework lets your ioS and mac apps communicate with bluetooth low energy devices For example, your app can discover, explore, and interact with low energy peripheral devices, such as heart rate monitors, digital thermostats, and even other ios devices The framework is an abstraction of the bluetooth 4.0 specification for use with low energy devices. that said, it hides many of the low-level details of the specification from you, the developer, making it much easier for you to develop apps that interact with bluetooth low energy devices. Because the framework is based on the specification, some concepts and terminology from the specification have been adopted This chapter introduces you to the key terms and concepts that you need to know to begin developing great apps using the Core Bluetooth framework Central and Peripheral devices and Their roles in bluetooth Communication There are two major players involved in all Bluetooth low energy communication: the central and the peripheral Based on a somewhat traditional client-server architecture, a peripheral typically has data that is needed by other devices. a central typically uses the information served up by peripherals to accomplish some particular task. As Figure 1-1 shows, for example a heart rate monitor may have useful information that your Mac or iOS app may need in order to display the user's heart rate in a user-friendly way Figure 1-1 Central and peripheral devices Client server Wants data Has data Central Peripheral 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved Core bluetooth overview Central and Peripheral Devices and Their roles in Bluetooth Communication Centrals Discover and Connect to Peripherals That Are Advertising Peripherals broadcast some of the data they have in the form of advertising packets. An advertising packet is a relatively small bundle of data that may contain useful information about what a peripheral has to offer, such as the peripherals name and primary functionality. For instance, a digital thermostat may advertise that it provides the current temperature of a room In bluetooth low energy advertising is the primary way that peripherals make their presence known. A central, on the other hand, can scan and listen for any peripheral device that is advertising information that it's interested in, as shown in Figure 1-2. a central can ask to connect to any peripheral that it has discovered advertising Figure 1-2 Advertising and discovery Central Peripheral How the Data of a peripheral ls structured The purpose of connecting to a peripheral is to begin exploring and interacting with the data it has to offer Before you can do this, however, it helps to understand how the data of a peripheral is structured Peripherals may contain one or more services or provide useful information about their connected signal strength. a service is a collection of data and associated behaviors for accomplishing a function or feature of a device(or portions of that device). For example, one service of a heart rate monitor may be to expose heart rate data from the monitor' s heart rate sensor 2013-09-18 Copyright O 2013 Apple InC. All Rights Reserved.

...展开详情
试读 56P coreBluetooth
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
sqz316 没有翻译的官方文档
2014-05-29
回复
上传资源赚积分or赚钱
    最新推荐
    coreBluetooth 20积分/C币 立即下载
    1/56
    coreBluetooth第1页
    coreBluetooth第2页
    coreBluetooth第3页
    coreBluetooth第4页
    coreBluetooth第5页
    coreBluetooth第6页
    coreBluetooth第7页
    coreBluetooth第8页
    coreBluetooth第9页
    coreBluetooth第10页
    coreBluetooth第11页
    coreBluetooth第12页

    试读结束, 可继续读5页

    20积分/C币 立即下载 >