Skip to Content
蓝牙低功耗入门指南
book

蓝牙低功耗入门指南

by Kevin Townsend, Carles Cufí, Akiba, Robert Davidson
July 2025
Beginner
180 pages
2h 9m
Chinese
O'Reilly Media, Inc.
Content preview from 蓝牙低功耗入门指南

第 8 章 Android 编程 安卓编程

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

使用蓝牙低功耗这样的无线标准的主要好处之一是它支持各种智能手机和平板电脑。这为嵌入式硬件项目开辟了一个新的交互层面,现在可以设计出廉价的硬件和丰富的界面。

除界面外,您还可以将手机作为通向更大范围互联网的网关,或与其他应用程序或 API 结合使用,创建与您创建的嵌入式硬件的自定义混搭。这样就能制造出价格低廉但功能丰富的全新设备。

本章概述了在 Android 操作系统上实现低功耗蓝牙所需的硬件、软件和流程。

入门

本章开发的 Android 示例项目与德州仪器(TI)生产的低成本 SensorTag 设备("SensorTag")连接。SensorTag 提供多种传感器,是复杂传感器设备的典范,可提供大量信息供处理和可视化。

由于 Android 的图形用户界面可能有点复杂,而且通常超出了本书的范围,因此本章将重点介绍如何从 SensorTag 中提取数据并通过低功耗蓝牙接收数据。在这一点上,许多其他可用资源都能展示呈现数据的方法。

获取硬件

硬件方面,您需要一台运行 Android 4.3 或更高版本的 Android 设备。虽然 Android 已开始支持 4.3 版本的 BLE,但我们建议使用运行至少 4.4 版本的设备,该版本包含更新且更稳定的 BLE 协议栈。您还需要确保硬件支持低功耗蓝牙。本示例项目使用的是运行 Android 4.4 的 Google Nexus 7。

注意

要确认您的设备是否支持 BLE,请参阅 Blueooth 的智能设备列表

您还需要购买一个 TI SensorTag,它将作为本项目的外围设备。有关 SensorTag 设备的更多信息,请参阅"SensorTag"

获取软件

本项目需要三个主要软件:

Eclipse Android 开发工具 (ADT)

从安卓开发者网站获取

蓝牙应用加速器

请访问蓝牙技术联盟网站

TI SensorTag Android 应用程序源代码

请访问德州仪器网站

设置中最重要也最耗时的部分是安装 Android 开发工具,这也需要了解一些如何使用 Eclipse IDE。你最好去Android Developer 网站了解设置工作环境的详细说明。您需要下载最新的 SDK 和 Android 开发工具的任何更新。

配置硬件

在将 Android 设备用作开发设备之前,需要对其进行一些配置。首先,如果尚未启用开发者模式,则需要启用该模式。Go 进入 "设置 "菜单,向下滚动到底部,选择 "关于"。在 "关于 "屏幕上(如图 8-1 所示),连续点击七次 "版本号",打开开发者模式。

gsbl 0801
图 8-1. 从 "关于 "屏幕启用开发人员模式

现在,你应该会在 "设置 "菜单中看到一个新的 "开发人员选项 "项目。现在,你需要启用 "USB 调试 "和 "保持清醒 "选项,如图 8-2 所示。

gsbl 0802
图 8-2. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

802.11n技術手冊

802.11n技術手冊

Matthew Gast
物联网设备安全

物联网设备安全

Nitesh Dhanjani

Publisher Resources

ISBN: 9798341662957