搜档网
当前位置:搜档网 › CC254041低功耗蓝牙模块软件开发说明

CC254041低功耗蓝牙模块软件开发说明

CC254041低功耗蓝牙模块软件开发说明
CC254041低功耗蓝牙模块软件开发说明

Texas Instruments CC2540/41 Bluetooth? Low Energy Software Developer’s Guide

v1.3.2

Document Number: SWRU271F

REFERENCES (4)

USEFUL LINKS (4)

1OVERVIEW (5)

1.1I NTRODUCTION (5)

1.2BLE P ROTOCOL S TACK B ASICS (5)

2TEXAS INSTRUMENTS BLE SOFTWARE DEVELOPMENT PLATFORM (6)

2.1C ONFIGURATIONS (6)

2.2P ROJECTS (8)

3SOFTWARE OVERVIEW (9)

3.1O PERATING S YSTEM A BSTRACTION L AYER (OSAL) (9)

3.1.1Task Initialization (10)

3.1.2Task Events and Event Processing (10)

3.1.3Heap Manager (10)

3.1.4OSAL Messages (11)

3.2H ARDWARE A BSTRACTION L AYER (HAL) (11)

3.3BLE P ROTOCOL S TACK (12)

3.3.1Generic Access Profile (GAP) (12)

3.3.2Generic Attribute Profile (GATT) (14)

3.3.3Using the GAP and GATT Stack API (16)

3.3.4GATT Server Application API (17)

3.3.5Library Files (17)

3.4P ROFILES (18)

3.4.1GAP Peripheral Role Profile (18)

3.4.2GAP Peripheral / Broadcaster Multi-Role Profile (19)

3.4.3GAP Central Role Profile (19)

3.4.4GAP Bond Manager (20)

3.4.5Simple GATT Profile (21)

3.4.6Simple Keys GATT Profile (23)

3.4.7Device Information Service (24)

3.4.8Additional GATT Profiles (25)

4WORKING WITH PROJECTS USING IAR EMBEDDED WORKBENCH 8.10.4 (25)

4.1IAR O VERVIEW (25)

4.2U SING IAR E MBEDDED W ORKBENCH (25)

4.2.1Open an Existing Project (25)

4.2.2Project Options, Configurations, and Defined Symbols (26)

4.2.3Building and Debugging a Project (29)

4.2.4Linker Map File (31)

4.3S IMPLE BLEP ERIPHERAL S AMPLE P ROJECT (32)

4.3.1Project Overview (32)

4.3.2Initialization (34)

4.3.3Periodic Event (34)

4.3.4Peripheral State Notification Callback (34)

4.3.5Key Presses (CC2540/41DK-MINI Keyfob only) (34)

4.3.6LCD Display (CC2540/41 Slave only) (35)

4.3.7Complete Attribute Table (35)

4.4S IMPLE BLEC ENTRAL S AMPLE P ROJECT (38)

4.4.1Project Overview (38)

4.4.2User Interface (38)

4.4.3Basic Operation (39)

4.4.4Initialization (39)

4.4.5Event Processing (39)

4.4.6Callbacks (40)

4.4.7Service Discovery (40)

4.5H OST T EST R ELEASE N ETWORK P ROCESSOR P ROJECT (40)

Copyright ? 2010-2013 Texas Instruments, Inc.

4.5.1Project Overview (40)

4.5.2External Device Control of BLE Stack (41)

4.6A DDITIONAL S AMPLE P ROJECTS (41)

5GENERAL INFORMATION (42)

5.1R ELEASE N OTES H ISTORY (42)

5.2D OCUMENT H ISTORY (54)

6ADDRESS INFORMATION (54)

7TI WORLDWIDE TECHNICAL SUPPORT (54)

Copyright ? 2010-2013 Texas Instruments, Inc.

References

Included with Texas Instruments Bluetooth Low Energy v1.3.2 Stack Release (All path and file references in this document assume that the BLE development kit software has been installed to the default path C:\Texas Instruments\BLE-CC254X-1.3.2\):

[1]OSAL API Guide

C:\Texas Instruments\ BLE-CC254X-1.3.2\Documents\osal\OSAL API.pdf

[2]HAL API Guide

C:\Texas Instruments\ BLE-CC254X-1.3.2\Documents\hal\HAL API.pdf

[3]TI BLE Vendor Specific HCI Reference Guide

C:\Texas Instruments\ BLE-CC254X-1.3.2\Documents\

TI_BLE_Vendor_Specific_HCI_Guide.pdf

[4]Texas Instruments CC2540 Bluetooth Low Energy API Guide

C:\Texas Instruments\ BLE-CC254X-1.3.2\Documents\BLE_API_Guide_main.htm

[5]Texas Instruments CC2540 Bluetooth Low Energy Sample Applications Guide

C:\Texas Instruments\ BLE-CC254X-1.3.2\Documents\

TI_BLE_Sample_Applications_Guide.pdf

Available for download from the Texas Instruments web site:

[6]Texas Instruments CC2540DK-MINI Bluetooth Low Energy User Guide v1.1

https://www.sodocs.net/doc/2915062219.html,/lit/pdf/swru270

Available for download from the Bluetooth Special Interest Group (SIG) web site:

[7]Specification of the Bluetooth System, Covered Core Package version: 4.0 (30-June-2010)

https://https://www.sodocs.net/doc/2915062219.html,/docman/handlers/downloaddoc.ashx?doc_id=229737

[8]Device Information Service (Bluetooth Specification), version 1.0 (24-May-2011)

https://https://www.sodocs.net/doc/2915062219.html,/docman/handlers/downloaddoc.ashx?doc_id=238689

Useful Links

TI Bluetooth LE Wiki-page: https://www.sodocs.net/doc/2915062219.html,/ble-wiki

Latest stack download: https://www.sodocs.net/doc/2915062219.html,/ble-stack

Support forum: https://www.sodocs.net/doc/2915062219.html,/ble-forum

Copyright ? 2010-2013 Texas Instruments, Inc.

Copyright ? 2010-2013 Texas Instruments, Inc.

1 Overview The purpose of this document is to give an overview of the Texas Instruments CC2540/41 Bluetooth? low energy (BLE) software development kit. This document also serves as an introduction to the BLE standard; however it should not be used as a substitute for the complete specification. For more details, see [7]. The release history of the BLE software development kit, including detailed information on changes, enhancements, bug fixes, and known issues, can be found in section 5.1.

1.1 Introduction Version 4.0 of the Bluetooth? standard allows for two systems of wireless technology: Basic Rate (BR; often referred to as “BR/EDR” for “Basic Rate / Enhanced Data Rate”) and Bluetooth low energy (BLE). The BLE system was created for the purpose of transmitting very small packets of data at a time, while consuming significantly less power than BR/EDR devices. Devices that can support BR and BLE are referred to as dual-mode devices and go under the branding Bluetooth Smart Ready. Typically in a Bluetooth system, a mobile phone or laptop computer will be a dual-mode device. Devices that only support BLE are referred to as single-mode devices and go under the branding Bluetooth Smart. These single-mode devices are generally used for application in which low power consumption is a primary concern, such as

those that run on coin cell batteries.

Figure 1 Bluetooth Smart and Smart Ready Branding Marks

1.2

BLE Protocol Stack Basics The BLE protocol stack architecture is illustrated here:

Figure 2: BLE Protocol Stack

The protocol stack consists of two sections: the controller and the host. This separation of

controller and host goes back to standard Bluetooth BR/EDR devices, in which the two sections

本文是对TI CC2540/41低功耗蓝牙软件开发包的概述

同时也对BLE 标准作介绍但不能代替完整规范

可以在章节5.1找到BLE 软件开发包的版本更新历史,包括功能变化、增强,bug 修复和已知问题的详细信息。

蓝牙4.0支持经典蓝牙和低功耗蓝牙

低功耗蓝牙每次传输非常小的数据包,比经

典蓝牙的功耗小很多

双模器件支持经典蓝牙和低功耗蓝牙,比较有代表

性的,手机和笔记本电脑的蓝牙系统单模器件只支持低功耗蓝牙,通常用于低功耗要求比较高的应用场合,比如使用纽扣电池供电的

协议栈包括两部分:控制器和主机,这种划分可追溯到经典蓝牙器件,当时这两部分经常单独执行

Copyright ? 2010-2013 Texas Instruments, Inc.

were often implemented separately. Any profiles and applications that are being used sit on top of the GAP and GATT layers of the stack.

The PHY layer is a 1Mbps adaptive frequency-hopping GFSK (Gaussian Frequency-Shift Keying) radio operating in the unlicensed 2.4 GHz ISM (Industrial, Scientific, and Medical) band. The LL essentially controls the RF state of the device, with the device being in one of five possible states: standby, advertising, scanning, initiating, or connected. Advertisers transmit data without being in a connection, while scanners listen for advertisers. An initiator is a device that is responding to an advertiser with a connection request. If the advertiser accepts, both the advertiser and initiator will enter a connected state. When a device is in a connection, it will be connected in one of two roles: master or slave. The device that initiated the connection becomes

the master, and the device that accepted the request becomes the slave.

The HCI layer provides a means of communication between the host and controller via a

standardized interface. This layer can be implemented either through a software API, or by a hardware interface such as UART, SPI, or USB. The L2CAP layer provides data encapsulation services to the upper layers, allowing for logical end-to-end communication of data.

The SM layer defines the methods for pairing and key distribution, and provides functions for the other layers of the stack to securely connect and exchange data with another device.

The GAP layer directly interfaces with the application and/or profiles, and handles device

discovery and connection-related services for the device. In addition, GAP handles the initiation of security features. The ATT protocol allows a device to expose certain pieces of data, known as “attributes”, to another device. In the context of ATT, the device exposing attributes is referred to as the “server”, and the peer device is referred to as the “client”. The LL state (master or slave) of the device is independent of the ATT role of the device. For example, a master device may either be an ATT server or an ATT client, and a slave device may also be either an ATT server or an ATT client. It

is also possible for a device to be both an ATT server and an ATT client simultaneously. The GATT layer is a service framework that defines the sub-procedures for using ATT. GATT specifies the structure of profiles. In BLE, all pieces of data that are being used by a profile or service are called “characteristics”. All data communications that occur between two devices in a

BLE connection are handled through GATT sub-procedures. Therefore, the application and/or profiles will directly use GATT. 2 Texas Instruments BLE software development platform

The Texas Instruments royalty-free BLE software development kit is a complete software platform for developing single-mode BLE applications. It is based on the CC2540/41, complete System-on-Chip (SoC) solutions. The CC2540/41 combines a 2.4GHz RF transceiver, microcontroller, up to 256kB of in-system programmable memory, 8kB of RAM, and a full range of peripherals.

2.1 Configurations The platform supports two different stack / application configurations:

任何协议和应用都是在协议栈的GAP 和GATT 应用的

高斯频移键控工业科学医疗物理层是在2.4GHz ISM 无管制频带内1Mbps 自适应调频高斯频移监控链路层从根本上控制器件的射频状态,器件可能处于五种状态之一:待机、广播、扫描、启动、连接中广播器件发送数据不需要在连接状态,扫描器件收听广播启动状态是器件正在响应一个带连接请求的广播如果广播器件接受,广播器件和启动器件同时进入连接状态连接状态或者作为主机或者作为从机器件启动连接从主机开始,接受请求从从机开始主控制器接口层使得主机和控制器能够通过标准接口通讯这一层可以通过软件API 接口执行也可以通过硬件接口执行比如USRT,SPI,USB 逻辑链路控制和适配协议层为上层提供数据封包服务,允许逻辑端到端的数据交互安全管理器层配对方法、键分配、协议栈其他层的安全连接和与其他器件的安全数据交互通用接入规范层直接与应用或者配置文件联系,处理器件发现和联系有关的服务另外,这一层还掌管安全功能的初始化

属性规范层允许器件显示某些数据段,对于另一个器件来说,这就是属性

显示属性的器件被成为服务器,对应的器件被成为客户机器件的链路层状态(主从状态)独立于器件的属性规范外比如,一个主机可以是ATT 服务器也可以是ATT 客户机,从机也是也可能一个器件同一时间既是ATT 服务器也是客户机

通用属性配置文件决定子程序使用ATT 的服务架构GATT 决定规范的结构低功耗蓝牙中,所有被配置文件或服务使用的数据段被称为“特征”所有同一低功耗蓝牙连接下的两个器件间的数据通信都是由GATT 子程序处理的因此,应用或配置文件会直接使用GATT 授权

PHY

LL HCI L2CAP SM GAP ATT GATT

Single-Device: The controller, host, profiles, and application are all implemented on the CC2540/41 as a true single chip solution. This is the simplest and most common configuration when using the CC2540/41. This is the configuration that most of our sample projects use. It is most cost effective and provides the lowest-power performance. The SampleBLEPeripheral and SimpleBLECentral projects are examples of applications built using the single-device configuration. More information on these projects can be found in section 4.

Figure 3: Single-Device Configuration

Copyright ? 2010-2013 Texas Instruments, Inc.

Copyright ? 2010-2013 Texas Instruments, Inc.

Network Processor: The controller and host are implemented together on the CC2540/41,

while the profiles and application are implemented separately. The application and profiles communicate with the CC2540/41 by means of vendor-specific HCI commands using a SPI or UART interface, or using a virtual UART interface over USB. This configuration is useful for applications which execute on either another device (such as an external microcontroller) or a PC. In these cases, the application can be developed externally while still running the BLE

stack on the CC2540/41. To use the network processor, the HostTestRelease project must be used. More information on the HostTestRelease project can be found in section 4.5.

Figure 4: Network Processor Configuration

2.2 Projects The SimpleBLEPeripheral project consists of sample code that demonstrates a very simple

application in the single-device configuration. It can be used as a reference for developing a slave / peripheral application.

The SimpleBLECentral project is similar, in that it demonstrates a simple master / central

application in the single-device configuration, and can be used as a reference for developing master / central applications.

The HostTestRelease project is used to build the BLE network processor software for the CC2540/41. It contains configurations for both master and slave roles.

Several other sample projects are included in the BLE development kit, implementing various profiles and demo applications. More information on these projects can be found in [5]

依赖于供应商特定的执行示范

Copyright ? 2010-2013 Texas Instruments, Inc.

3 Software Overview

Software developed using the BLE software development kit consists of five major sections: the OSAL, HAL, the BLE Protocol Stack, profiles, and the application. The BLE protocol stack is provided as object code, while the OSAL and HAL code is provided as full source. In addition, three GAP profiles (peripheral role, central role, and peripheral bond manager) are provided, as well as several sample GATT profiles and applications.

All path and file references in this document assume that the BLE development kit software has been installed to the default path: C:\Texas Instruments\BLE-CC254X-1.3.2\.

Note. In this section, the SimpleBLEPeripheral project will be used as a reference; however all of the BLE projects included in the development kit will have a similar structure.

3.1 Operating System Abstraction Layer (OSAL) The BLE protocol stack, the profiles, and all applications are all built around the Operating System Abstraction Layer (OSAL). The OSAL is not an actual operating system (OS) in the traditional sense, but rather a control loop that allows software to setup the execution of events. For each layer of software that requires this type of control, a task identifier (ID) must be created, a task initialization routine must be defined and added to the OSAL initialization, and an event

processing routine must be defined. Optionally, a message processing routine may be defined as well. Several layers of the BLE stack, for example, are OSAL tasks, with the LL being the highest priority (since it has very strict timing requirements). In addition to task management, the OSAL provides additional services such as message passing, memory management, and timers. All OSAL code is provided as full source.

Figure 5: OSAL task loop

主要的操作系统抽象层

低功耗蓝牙协议栈、配

置文件和所有应用都是围绕OSAL 建立的。与其说OSAL 是传统观念里实际的操作系统,不如说是一个允许软件设置事件执行的控制回路。对

于软件每个需要这种控制的层来说,一个任务

ID 被制造出来,任务的例行初始化需要定义并

加入到OSAL 的初始化中,一个事件的例行处理需要定义。视情况消息的例行处理也可以定义。BLE 堆栈的几个层,比如,链路层最高

优先级的可以是OSAL 任务除任务管理之外,OSAL 提供额外的服务,比如消息传递、存储管理、定时器。所有OSAL 代码都是作为全套服务提供

Copyright ? 2010-2013 Texas Instruments, Inc.

Note: The OSAL is capable of providing many more services than are covered in this guide,

including message management, timer management, and more; however for many applications this level of depth is not required. This guide should serve as an introduction to the basic

framework of the OSAL. Additional information on the OSAL can be found in [1]:

3.1.1 Task Initialization In order to use the OSAL, at the end of the main function there should be a call to osal_start_system . This is the OSAL routine that starts the system, and which will call the osalInitTasks function that is defined by the application. In the SimpleBLEPeripheral project, this function can be found in the file OSAL_SimpleBLEPeripheral.c . Each layer of software that is using the OSAL must have an initialization routine that is called from the function osalInitTasks . Within this function, the initialization routine for every layer of software is called. As each task initialization routine is called, an 8-bit “task ID ” value is assigned to the task. Note that when creating an application, it is very important that it be added to the end of the list, such that it has a higher task ID than the others. This is because the priority of tasks is determined by the task ID, with a lower value meaning higher priority. It is important that the protocol stack tasks have the highest priority in order to function properly. Such is the case with

the SimpleBLEPeripheral application: its initialization function is SimpleBLEPeripheral_Init , and it has the highest task ID and therefore the lowest priority.

3.1.2 Task Events and Event Processing

After the OSAL completes initialization, it runs the executive loop checking for task events. This

loop can be found in the function osal_start_system in the file OSAL.c . Task events are implemented as a 16-bit variable (one for each task) where each bit corresponds to a unique event. The definition and use of these event flags is completely up to the application.

For example, the SimpleBLEPeripheral application defines a flag in simpleBLEPeripheral.h : SBP_START_DEVICE_EVT (0x0001), which indicates that the initial start has completed, and the application should begin. The only flag value which is reserved and cannot be defined by the application is 0x8000, which corresponds to the event SYS_EVENT_MSG (this event is used for messaging between tasks, which is covered in section 3.1.3). When the OSAL detects an event for a task, it will call that task’s event processing routine. The layer must add its event processing routine to the table formed by the array of function pointers called tasksArr (located in OSAL_SimpleBLEPeripheral.c in the example). You will notice that the order of the event processing routines in tasksArr is identical to the order of task ID’s in the osalInitTasks function. This is required in order for events to be processed by the correct software layer.

In the case of the SimpleBLEPeripheral application, the function is called

SimpleBLEPeripheral_ProcessEvent . Note that once the event is handled and if it is not

removed from the event flag, the OSAL will continue to call the t ask’s process event handler. As can be seen in the SimpleBLEPeripheral application function

SimpleBLEPeripheral_ProcessEvent , after the START_DEVICE_EVT event occurs, it returns the 16-bit events variable with the SBP_START_DEVICE_EVT flag cleared.

It is possible for any layer of the software to set an OSAL event for any other layer, as well as for itself. The simplest way to set up an OSAL event is to use the osal_set_event function (prototype in OSAL.h ), which immediately schedules a new event. With this function, you specify the task ID (of the task that will be processing the event) and the event flag as parameters. Another way to set an OSAL event for any layer is to use the osal_start_timerEx function

(prototype in OSAL_Timers.h ). This function operates just like the osal_set_event function. You select task ID of the task that will be processing the event and the event flag as parameters; however for a third parameter in osal_start_timerEx you input a timeout value in milliseconds. The OSAL will set a timer, and the specified event will not get set until the timer expires.

3.1.3 Heap Manager 本文仅作为OSAL 基本架构的说明

如要使用OSAL ,在主函数的结尾需要调用osal_start_system 这是启动OSAL 系统的例行程序它会调用应用定义的osallnitTasks 函数勘误,在主函数中段先调用osal_init_system()函数,这个函数中会调用osalInitTasks()在主函数的结尾再调用osal_start_system()软件中所有使用OSAL 的层都需要有一个从函数osalInitTasks 调用的例行初始化在这个函数中,软件每个层的例行初始化程序被调用每个例行初始化任务被调用时,一个8位的“task ID ”被分配给该任务注意,当创建一个新应用时,将例行初始化加到列表的末尾非常重要,这样就可以有一个比其他任务值更大的task ID 这是因为任务的优先级取决于task ID ,值越小优先级越高协议栈任务拥有最高优先级以便正确的起作用,这非常重要init OSAL 结束初始化后,会运行执行程序循环检查任务事件任务时间被以一个16位的变量来执行,每一位对应一个唯一事件这些事件标志位的定义和使用完全由应用负责唯一被保留且不能被应用定义的标志位值是0x8000,对应事件SYS_EVENT_MSG 该事件用于不同任务间的消息传递,在章节3.1.3中提到在

tasksArr 中事件例行处理的顺序和osalInitTasks 函数中的task ID 的顺序完全一致

新建事件的两种方式:

1.osal_set_event()

2.osal_start_timerE x()

堆管理

Copyright ? 2010-2013 Texas Instruments, Inc.

OSAL provides basic memory management functions. The osal_mem_alloc function serves as a basic memory allocation function similar to the standard C malloc function, taking a single

parameter determining the number of bytes to allocate, and returning a void pointer. If no memory is available, a NULL pointer will be returned. Similarly, the osal_mem_free function works similar to the standard C free function, freeing up memory that was previously allocated using

osal_mem_alloc . The pre-processor define INT_HEAP_LEN is used to reserve memory for dynamic allocation. To see how much memory you typically need, you can set the pre-processor define

OSALMEM_METRICS=TRUE in the project options. After a stress test of the application where you send as many messages, have as many clients as you will in the worst case, remembering to use bonding and encryption during the test if that ’s applicable, you can look at the value of the variable memMax in OSAL_Memory.c to see how much memory was ever allocated at the same time. This figure could be used as a guideline for lowering INT_HEAP_LEN if necessary, but thorough testing is needed, as the heap is used by the BLE stack.

3.1.4 OSAL Messages OSAL also provides a system for different subsystems of the software to communicate with each other by sending or receiving messages. Messages can contain any type of data and can be any size. To send an OSAL message, first the memory must be allocated by calling the

osal_msg_allocate function, passing in the length of the message as the only parameter. A pointer to a buffer containing the allocated space will be returned (you do not need to use

osal_mem_alloc when using osal_msg_allocate ). If no memory is available, a NULL pointer will be returned. You can then copy the data into the buffer. To send the message, the

osal_msg_send should be called, with the destination task for the message indicated as a parameter.

The OSAL will then signal the receiving task that a message is arriving by setting the

SYS_EVENT_MSG flag for that task. This causes the recei ving task’s event handler function to be called. The receiving task can then retrieve the data by calling osal_msg_receive , and can process accordingly based on the data received. It is recommended that every OSAL task have a local message processing function (the simpleBLEPeripheral application’s message processing function is simpleBLEPeripheral_ProcessOSALMsg ) that decides what action to take based on the type of message received. Once the receiving task has completed processing the message, it must deallocate the memory using the function osal_msg_deallocate (you do not need to use osal_mem_free when using osal_msg_deallocate ).

3.2 Hardware Abstraction Layer (HAL) The Hardware Abstraction Layer (HAL) of the CC2540/41 software provides an interface of

abstraction between the physical hardware to and the application and protocol stack. This allows for the development of new hardware (such as a new PCB) without making changes to the protocol stack or application source code. The HAL includes software for the SPI and UART

communication interfaces, ADC, keys, and LED’s etc. The HAL drivers that are provided support the following hardware platforms:

? SmartRF05EB + CC2540EM

? SmartRF05EB + CC2541EM

? CC2540 Keyfob

? CC2541 Keyfob

? CC2541 SensorTag

? CC2540 USB Dongle

When developing with a different hardware platform, it might be necessary to modify the HAL source for compatibility.

More information on the HAL API can be found in [2]. 基本内存分配函数

内存释放函数为动态分配预留内存不同子系统通过收发信息进行沟通

软件的硬件抽象层为物理硬件和应用、协议栈提供了一个抽象的接口部分支持的硬件不需要修改接口源码

新开发的硬件需要修改

Copyright ? 2010-2013 Texas Instruments, Inc.

3.3 BLE Protocol Stack

The entire BLE protocol stack is provided as object code in a single library file (Texas Instruments does not provide the protocol stack source code as a matter of policy). The functionality of the GAP and GATT layers should be understood as they interact directly with the application and profiles.

3.3.1 Generic Access Profile (GAP) The GAP layer of the BLE Protocol Stack is responsible for handling the device’s access modes and procedures, including device discovery, link establishment, link termination, initiation of security features, and device configuration. The GAP layer is always operating in one of four roles:

?

Broadcaster – an advertiser that is non-connectable ?

Observer – scans for advertisements, but cannot initiate connections ?

Peripheral – an advertiser that is connectable, and operates as a slave in a single link-layer connection. ? Central – scans for advertisements and initiates connections; operates as a master in a

single or multiple link-layer connections. Currently, the BLE central stack supports up to three simultaneous connections.

The BLE specification allows for certain combinations of multiple-roles. The default setup of the sample application is to only support the peripheral role, though source code is provided to run a combination peripheral and broadcaster role. In a typical Bluetooth Low Energy system, the peripheral device advertises with specific data letting any central device know that it is a connectable device. This advertisement contains the device address, and can contain some additional data as well, such as the device name. The central device, upon receiving the advertisement, sends a “scan request” to the peripheral. The peripheral responds with a “scan response”. This is the process of device discovery, in that the central device is now aware of the peripheral device, and knows that it can form a connection with it. The central device can then send out a request to establish a link with the peripheral device. A connection request contains a few connection parameters:

? Connection Interval – In a BLE connection between two devices, a frequency-hopping

scheme is used, in that the two devices each send and receive data from one another on a specific channel, then “meet” at a new channel (the link layer of the BLE stack handles the channel switching ) at a specific amount of time later. This “meeting” where the two devices send and receive data is known as a “connection event”. Even if there is no application data to be sent or received, the two devices will still exchange link layer data to maintain the connection. The connection interval is the amount of time between two connection events, in

units of 1.25ms. The connection interval can range from a minimum value of 6 (7.5ms) to a maximum of 3200 (4.0s). Different applications may require different connection intervals. The advantage of having a very long connection interval is that significant power is saved, since the device can sleep most of the time between connection events. The disadvantage is that if a device has data that it needs to send, it must wait until the next connection event. The advantage of having a very short connection interval is that there is more opportunity for data to be sent or received, as the two devices will connect more frequently. The disadvantage is that more power will be consumed, since the device is frequently waking up for connection events. ? Slave Latency – This parameter gives the slave (peripheral) device the option of skipping a number of connection events. This gives the peripheral device some flexibility, in that if it does not have any data to send it can choose to skip connection events and stay asleep, thus providing some power savings. The decision is up to the peripheral device. BLE 协议栈的GAP 层负责处理器件的接入模式和程序包括器件的发现、链接的编制、链接的终止、安全特征的启动、器件配置外围设备发广播主设备发送扫描请求外围设备扫描响应主设备发送请求建立连接调频方案无应用数据交互也仍会

进行链路层数据交互以保持连接。时间间隔以1.25ms 为基本时间单位

不同应用的连接时间间隔是不一样的长时间间隔优点是低功耗,间隔内可进入睡眠模式,缺点是有数据要发送时需要等待下一次连接

短时间间隔的优缺点正好与上面相反连接间隔(就是通信间隔)从机延时(外围设备、被连接的设备 延时)

该参数让从机可以有权

选择跳过一些连接事件,当没有数据要发送时可以灵活选择跳过一

些连接事件、保持休眠状态以降低功耗,这由

从机决定

TI CC254x Bluetooth Low E nergy Software Developer’s Guide SWRU271F Version 1.3.1

Copyright ? 2010-2013 Texas Instruments, Inc. The slave latency value represents the maximum number of events that can be skipped. It can range from a minimum value of 0 (meaning that no connection events can be skipped) to a maximum of 499; however the maximum value must not make the effective connection

interval (see below) greater than 16.0s.

? Supervision Timeout – This is the maximum amount of time between two successful connection events. If this amount of time passes without a successful connection event, the device is to consider the connection lost, and return to an unconnected state. This parameter value is represented in units of 10ms. The supervision timeout value can range from a minimum of 10 (100ms) to 3200 (32.0s). In addition, the timeout must be larger than the

effective connection interval (explained below). The “effective connection interval” is equal to the amount of time between two connection events, assuming that the slave skips the maximum number of possible events if slave latency is allowed (the effective connection interval is equal to the actual connection interval if slave latency is set to zero). It can be calculated using the formula: Effective Connection Interval = (Connection Interval) * ( 1 + (Slave Latency) )

Take the following example:

Connection Interval: 80 (100ms)

Slave Latency: 4

Effective Connection Interval: (100ms) * ( 1 + 4 ) = 500ms

This tells us that in a situation in which no data is being sent from the slave to the master, the slave will only transmit during a connection event once every 500ms.

In many applications, the slave will skip the maximum number of connection events. Therefore it is useful to consider the effective connection interval when selecting your connection parameters. Selecting the correct group of connection parameters plays an important role in power

optimization of your BLE device. The following list gives a general summary of the trade-offs in connection parameter settings: Reducing the connection interval will:

?

Increase the power consumption for both devices ?

Increase the throughput in both directions ? Reduce the amount of time that it takes for data to be sent in either direction Increasing the connection interval will:

?

Reduce the power consumption for both devices ?

Reduce the throughput in both directions ? Increase the amount of time that it takes for data to be sent in either direction

Reducing the slave latency (or setting it to zero) will: ?

Increase the power consumption for the peripheral device ? Reduce the amount of time that it takes for data sent from the central device to be received by

the peripheral device Increasing the slave latency will:

?

Reduce power consumption for the peripheral during periods when the peripheral has no data to send to the central device ? Increase the amount of time that it takes for data sent from the central device to be received

by the peripheral device In some cases, the central device will request a connection with a peripheral device containing connection parameters that are unfavorable to the peripheral device. In other cases, a peripheral device might have the desire to change parameters in the middle of a connection, based on the 该参数代表可以跳过的最大数量的时间,范围从0到499,但这个最大值并不能使有效连接间隔大于16.0s ,也就是说最大时间间隔是16s

超时监控设定了两次成功连接间的最大时间间隔,如果超出这个时间还没有成功的连接,就被认为是连接丢失,设备会返回无连接状态

该参数基本单位是10ms

设定范围10-3200,即100ms-32s ,另外该参数必须大于有效连接间隔有效连接间隔 即 两次连接事件的时间间隔,有效连接间隔=连接间隔*(1+从机延时)

连接参数设定 怎么取舍的概要:

减小连接间隔会导致:1.增加通信双方的功耗2.增加双向的数据量 3.减小任一方向数据发送的时间

增加连接间隔导致的结果与上面相反减小从机延时会导致:

1.增加从机功耗

2.减小主机发送数据到从机的时间

有时主设备连接请求中的连接参数可能对从机并不合适

Copyright ? 2010-2013 Texas Instruments, Inc. peripheral application. The peripheral device can request the central device to change the connection settings by sending a “Connection Parameter Update Request”. This request is handled by the L2CAP layer of the protocol stack. This request contains four parameters: minimum connection interval, maximum connection

interval, slave latency, and timeout. These values represent the parameters that the peripheral device desires for the connection (the connection interval is given as a range). When the central device receives this request, it has the option of accepting or rejecting the new parameters. A connection can be voluntarily terminated by either the master or the slave for any reason. One side initiates termination, and the other side must respond accordingly before both devices exit the connected state.

GAP also handles the initiation of security features during a BLE connection. Certain data may be readable or writeable only in an authenticated connection. Once a connection is formed, two

devices can go through a process called pairing. When pairing is performed, keys are established which encrypt and authenticate the link. In a typical case, the peripheral device will require that

the central device provide a passkey in order to complete the pairing process. This could be a fixed value, such as “000000”, or could be a randomly generated value that gets provided to the user (such as on a display). After the central device sends the correct passkey, the two devices exchange security keys to encrypt and authenticate the link.

In many cases, the same central and peripheral devices will be regularly connecting and disconnecting from each other. BLE has a security feature that allows two devices, when pairing, to give each other a long-term set of security keys. This feature, called bonding, allows the two

devices to quickly re-establish encryption and authentication after re-connecting without going through the full pairing process every time that they connect, as long as they store the long-term key information. In the SimpleBLEPeripheral application, the management of the GAP role is handled by the GAP role profile, and the management of bonding information is handled by the GAP security profile. More information on the GAP profiles included with the CC2540/41 BLE Protocol Stack can be found in section 3.4

3.3.2 Generic Attribute Profile (GATT) The GATT layer of the BLE Protocol Stack is designed to be used by the application for data

communication between two connected devices. From a GATT standpoint, when two devices are connected they are each in one of two roles:

?

GATT Client – This is the device that is reading/writing data from/to the GATT Server. ? GATT Server – This is the device containing the data that is being read/written by the GATT

Client.

It is important to note that the GATT roles of Client and Server are completely independent from the BLE link-layer roles of slave and master, or from the GAP peripheral and central roles. A slave can be either a GATT Client or a GATT Server, and a master can be either a GATT client or a GATT Server.

A GATT server consists of one or more GATT services, which are collections of data to

accomplish a particular function or feature.

In the case of the SimpleBLEPeripheral application, there are three GATT services: ? Mandatory GAP Service – This service contains device and access information, such as the

device name and vendor and product identification, and is a part of the BLE protocol stack. It is required for every BLE device as per the BLE specification. The source code for this

service is not provided, as it is built into the stack library.

?

Mandatory GATT Service – This service contains information about the GATT server and is a part of the BLE protocol stack. It is required for every GATT server device as per the BLE specification. The source code for this service is not provided, as it is built into the stack

library.

此时从机可以向主机发送“连接参数更新请求”来改变连接设定

这个请求由L2CAP 层处理

主机从机都可任意中止连接

GAP 也负责处理BLE 连接中的安全机制

连接形成--两边设备进

行配对--配对成功后,对链接进行加密和验证

的密钥就确定了密钥可以是固定值,也可以是随机生成的值对经常连接和断开连接的设备有一个安全机制叫粘结,可以节省时间GATT 被应用用来在两个已连接的设备间进行数据交互强制服务、必备服务

Copyright ? 2010-2013 Texas Instruments, Inc.

? SimpleGATTProfile Service – This service is a sample profile that is provided for testing and

for demonstration. The full source code is provided in the files simpleGATTProfile.c and

simpleGATTProfile.h .

“Characteristics” are values that are used by a service, along with properties and conf iguration information. GATT defines the sub-procedures for discovering, reading, and writing attributes over a BLE connection.

The characteristic values, along with their properties and their configuration data (known as

“descriptors”) on the GATT Server are stored in the attribute table. The attribute table is simply a database containing small pieces of data called attributes. In addition to the value itself, each attribute has the following properties associated with it:

?

Handle – this is essentially the attribute’s “address” in the table. Every attribute has a unique handle. ?

Type – this indicates what the data represents. It is often referred to as a “UUID” (universal unique identifier) assigned by the Bluetooth SIG, or a custom type ? Permissions – this enforces if and how a GATT client device can access the attribute’s

value. GATT defines several sub-procedures for communication between the GATT server and client. Here are a few of the sub-procedures: ? Read Characteristic Value – The client requests to read the characteristic value at a specific

handle, and the server responds to the client with the value (assuming that the attribute has read permissions). ? Read Using Characteristic UUID – The client requests to read all characteristic values of a

certain type, and the server responds to the client with the handles and values (assuming that the attribute has read permissions) of all characteristics with matching type. The client does not need to know the handles of these characteristics. ? Read Multiple Characteristic Values – The client requests to read the characteristic values

of several handles in a single request, and the server responds to the client with the values (assuming that the attributes all have read permissions). The client must know how to parse the data between the different characteristic values.

?

Read Characteristic Descriptor – The client requests to read a characteristic descriptor at a specific handle, and the server responds to the client with the descriptor value (assuming that the attribute has read permissions). ? Discover Characteristic by UUID – The client requests to discover the handle of a specific

characteristic by its type. The server responds with the characteristic declaration, containing the handle of the characteristic value as well as the characteristic’s permissions.

? Write Characteristic Value – The client requests to write a characteristic value at a specific handle to the server, and the server responds to the client to indicate whether the write was successful or not.

?

Write Characteristic Descriptor – The client requests to write to a characteristic descriptor at a specific handle to the server, and the server responds to the client to indicate whether the write was successful or not. ? Characteristic Value Notification – The server notifies the client of a characteristic value.

The client does not need to prompt the server for the data, nor does it need to send any

response when a notification is received, but it must first configure the characteristic to enable notifications. A profile defines when the server is supposed to send the data.

Each profile initializes its corresponding service and internally registers the service with the GATT server on the device. The GATT server adds the entire service to the attribute table, and assigns unique handles to each attribute.

句柄

类型权限读特征值

读正在使用的特征的UUID

读多个特征值

读特征描述符根据UUID 发现特征写特征值写特征描述符特征值通知

Copyright ? 2010-2013 Texas Instruments, Inc.

There are a few special attribute types that are found in the GATT attribute table, with values defined by the Bluetooth SIG:

?

GATT_PRIMARY_SERVICE_UUID – This indicates the start of a new service, and the type of the service provided ?

GATT_CHARACTER_UUID – This is known as the “characteristic declaration”, and it indicates that the attribute immediately following it is a GATT characteristic value ? GATT_CLIENT_CHAR_CFG_UUID – This attribute represents a characteristic descriptor that

corresponds to the nearest preceding (by handle) characteristic value in the attribute table. It allows the GATT client to enable notifications of the characteristic value

?

GATT_CHAR_USER_DESC_UUID – This attribute represents a characteristic descriptor that corresponds to the nearest preceding (by handle) characteristic value in the attribute table. It contains an ASCII string with a description of the corresponding characteristic These are just few of the special attribute types that are included in the BLE specification. For more details on other attribute types, see [4].

3.3.3 Using the GAP and GATT Stack API

The application and profiles directly call GAP and GATT API functions to perform BLE-related functions, such as advertising, connecting, and reading and writing characteristics. For detailed information on the APIs of the different layers of the BLE protocol stack, the interactive HTML guide can be consulted. For more details on this, see [4].

The general procedure for using the GAP or GATT API is as follows:

1. Call API function with appropriate parameters

2. Stack performs specified action and returns

3. After action is complete, or whenever the stack has information to report back to calling task,

the stack sends an OSAL message to the calling task

4. Calling task receives and processes accordingly based on the message

5. Calling task de-allocates the message

An example of this procedure can be seen in the GAP peripheral role profile (peripheral.c):

1. In order to initialize the device, the profile calls the GAP API function GAP_DeviceInit .

2. GAP performs the initialization and the function returns a value of SUCCESS (0x00).

3. After initialization is complete, the BLE stack sends an OSAL message back to the peripheral

role profile with a header event value of GAP_MSG_EVENT , and an opcode value of

GAP_DEVICE_INIT_DONE_EVENT .

4. The profile task receives a SYS_EVENT_MSG event, indicating that it has a message

waiting. The profile receives the message and looks at the header and opcode values. Based on this, the profile knows to cast the message data to the appropriate type

(gapDeviceInitDoneEvent_t ) and process accordingly. In this case, the profile stores the generated keys in the NV memory space and locally saves the device address.

5. The profile de-allocates the message and returns.

Here is one more example that would occur if a GATT client device wants to perform a GATT read request on a peer GATT server:

1. The application calls the GATT sub-procedure API function, passing the connection handle,

the characteristic handle (contained within thedata type), and its own task ID as parameters.

2. GATT processes the request, and returns a value of SUCCESS (0x00).

3. The stack sends out the read request at the next connection event. When a read response is

received from the remote device, the stack sends an OSAL message containing the data in

可咨询HTML 交互式指南通过适当的参数调用API 函数

堆栈执行指定的操作并返回

在操作完成后或者堆栈有信息要回报给调用的任务,堆栈发送一条OSAL 信息给调用函数的任务

调用API 函数的任务收到信息并处理调用API 函数的任务自动向下分配信息

the read response back to the application. The message contains a header event value of GATT_MSG_EVENT and a method value of ATT_READ_RSP.

4.The application task receives a SYS_EVENT_MSG event, indicating that it has a message

waiting. The profile receives the message and looks at at the header and method values.

Based on this, the profile knows to cast the message data to the appropriate type

(attReadRsp_t) and retrieve the data that was received in the read response.

5.The profile de-allocates the message and returns.

3.3.4GATT Server Application API

The GATT Server Application provides APIs to the higher layer GATT profiles to perform two primary functions:

注册注销

?Register or deregister service attributes and callback functions from the GATT Server

?Add or delete a GATT Service. This API adds or deletes the GATT Service’s attribute list and callback functions to/from the GATT Server Application

A profile may support one or more services. Each of the services may support characteristics or references to other services. Each characteristic contains a value and may contain optional descriptors. The service, characteristic, characteristic value and descriptors are all stored as attributes on the server.

The service attribute list to be registered with the GATT Server Application must start with a service attribute followed by all the attributes associated with that service attribute. Each service is an array of type gattAttribute_t, as defined in the file gatt.h.

3.3.5Library Files

Even though a single library file is needed for a BLE application to use the stack, there are two different files corresponding to two different configurations for either CC2540 or CC2541 (see section 2.1 for more information on stack / application configurations). Table 1 below can be used

as a reference to determine the correct library file to use in the project:

Copyright ? 2010-2013 Texas Instruments, Inc.

Table 1: BLE Stack Libraries

3.4Profiles

The BLE software development kit includes three GAP role profiles, one GAP security profile, and several sample GATT service profiles.

3.4.1GAP Peripheral Role Profile

The peripheral role profile provides the means for the keyfob to advertise, connect with a central device (though the initiation of the connection must come from the central device), and request a specific set of connection parameters from a master device.

The primary API function prototypes for the peripheral role profile can be found in the file peripheral.h.The API provides functions to get and set certain GAP profile parameters: GAPRole_GetParameter and GAPRole_SetParameter, respectively. Here are a few GAP role parameters of interest:

?GAPROLE_ADVERT_ENABLED– This parameter enables or disables advertisements. The default value for this parameter is TRUE.

?GAPROLE_ADVERT_DATA– This is a string containing the data to appear in the advertisement packets. By setting this value to { 0x02, 0x01, 0x05 }, the device will use limited discoverable mode when advertising. More information on advertisement data types and definitions can be found in [7].

?GAPROLE_SCAN_RSP_DATA– This is a string containing the name of the device that will appear in scan response data. If an observer or central device is scanning and sends a scan request to the peripheral device, the peripheral will respond back with a scan response

containing this string.

?GAPROLE_ADVERT_OFF_TIME– This parameter is used when the device is put into limited discoverable mode. It sets how long the device should wait before becoming

discoverable again at the end of the limited discovery period. By setting this value to 0, the device will not become discoverable again until the GAPROLE_ADVERT_ENABLED is set back to TRUE.

?GAPROLE_PARAM_UPDATE_ENABLE– This enables automatic connection parameter update requests. The profile default value is FALSE.

?GAPROLE_MIN_CONN_INTERVAL– This parameter is the minimum desired connection interval value. The default value is 80, corresponding to 100ms.

?GAPROLE_MAX_CONN_INTERVAL– This parameter is the maximum desired connection interval value. The default value is 3200, corresponding to 4.0s.

?GAPROLE_SLAVE_LATENCY– This parameter is the desired slave latency. The default value is 0.

?GAPROLE_TIMEOUT_MULTIPLIER– This parameter is the desired connection supervision timeout. The default value is 1000 (corresponding to 10.0s)

The GAP peripheral role uses callback functions to notify the application of events. These are set up by means of the function GAPRole_StartDevice. This function initializes the GAP peripheral

Copyright ? 2010-2013 Texas Instruments, Inc.

role, and should only be called once. Its single parameter is a pointer to a variable of type gapRolesCBs_t, which is a structure containing two function pointers:

?pfnStateChange – This function gets called every time the GAP changes states, with the new state of the GAP passed as a parameter.

?pfnRssiRead – This function gets called every time the RSSI has been read, with the RSSI value passed as a parameter.

It is up to the application to provide the actual callback functions. In the case of the sample application, the state change function is peripheralStateNotificationCB, while no function is defined for the RSSI read (a NULL pointer is passed as the parameter for pfnRssiRead).

The peripheral profile also contains an automatic connection parameter update feature that can be enabled by setting the GAPROLE_PARAM_UPDATE_ENABLE parameter to TRUE. If the feature is enabled and the peripheral device enters a connection with a connection interval that falls outside of the range of the desired interval, or with a slave latency or timeout setting that is not the desired value, the peripheral profile will automatically send a Connection Parameter Update Request with the desired parameters. As long as the parameter values are legal as per the BLE specification, the central device should accept the request and change the connection parameters. In the sample application, the desired connection parameters are set in the SimpleBLEPeripheral_Init function, and can easily be changed to other values.

Additional details on using the GAP Peripheral Role Profile can be found in [4].

3.4.2GAP Peripheral / Broadcaster Multi-Role Profile

The peripheral / broadcaster multi-role profile operates almost identically to the peripheral role profile; however it provides additional functionality allowing the device to operate in both the peripheral and broadcaster GAP roles simultaneously. In order to use this multi-role functionality, the files peripheral.c and peripheral.h should be excluded from the build, and the files peripheralBroadcaster.c and peripheralBroadcaster.h should be included. In addition, the preprocessor value PLUS_BROADCASTER should be defined when using the peripheral / broadcaster multi-role profile.

The function names within the peripheral / broadcaster profile are the same as they are in the peripheral profile. This allows the developer to take a single-role application and add multi-role support with minimal changes to the existing source code.

Additional details on using Multi-Role Profiles can be found in [4].

3.4.3GAP Central Role Profile

The central role profile provides the means for a central device to discover advertising devices, establish a connection with peripheral device, update the connection parameters, and monitor the RSSI.

The primary API function prototypes for the central role profile can be found in the file central.h. The API provides functions to get and set certain GAP profile parameters:

GAPCentralRole_GetParameter and GAPCentralRole_SetParameter, respectively.

The GAP Central Role Profile uses callback functions to notify the application of events. These are set up by means of the function GAPCentralRole_StartDevice. This function initializes the GAP central role, and should only be called once. Its single parameter is a pointer to a variable of type gapCentralRolesCBs_t, which is a structure containing two function pointers:

?eventCB – This function gets called every time a GAP event occurs, such as when a device is discovered while scanning, or when a connection is established or terminated.

?rssiCB – This function gets called every time the RSSI has been read, with the RSSI value passed as a parameter.

Copyright ? 2010-2013 Texas Instruments, Inc.

It is up to the application to provide the actual callback functions. In the case of the SimpleBLECentral sample application (see section 4.4), the event callback function is simpleBLECentralEventCB and the RSSI callback function is simpleBLECentralRssiCB.

The peripheral profile also contains an automatic connection parameter update feature that can be enabled by setting the GAPROLE_PARAM_UPDATE_ENABLE parameter to TRUE. If the feature is enabled and the peripheral device enters a connection with a connection interval that falls outside of the range of the desired interval, or with a slave latency or timeout setting that is not the desired value, the peripheral profile will automatically send a Connection Parameter Update Request with the desired parameters. As long as the parameter values are legal as per the BLE specification, the central device should accept the request and change the connection parameters. In the sample application, the desired connection parameters are set in the SimpleBLEPeripheral_Init function, and can easily be changed to other values.

Additional details on using the GAP Central Role Profile can be found in [4].

3.4.4GAP Bond Manager

Note: The GAP Peripheral Bond Manager from the BLEv1.0 software release has been replaced by the GAP Bond Manager in BLEv1.1, which now supports both peripheral and central role configurations. The files gapperiphbondmgr.c and gapperiphbondmgr.h are still included to support legacy applications; however for it is recommended that future applications use the new bond manager, as it is had additional features and is based on the latest updates.

The GAP Bond Manager allows the device to automatically initiate or respond to pairing requests from a connected device. After pairing, if security keys are exchanged and bonding is enabled, the bond manager saves the security key information in non-volatile memory.

Whenever the bond manager initiates, it loads any previously-stored bonding information into memory. When the device goes into a new connection and if the peer device address matches the address of the information that was loaded, it passes the keys and other necessary data to the GAP layer of the BLE protocol stack. This way, encryption can easily (or automatically) be re-established.

The bond manager is primarily controlled by the GAP role profile; however the application can access a parameter in the bond manager using the GAPBondMgr_SetParameter and GAPBondMgr_GetParameter functions. The sample application uses the

GAPBondMgr_SetParameter function during initialization to setup the bond manager. Here are a few bond manager parameters of interest:

?GAPBOND_PAIRING_MODE – This parameter tells the bond manager whether pairing is allowed, and if so, whether it should wait for a request from the central device, or initiate pairing on its own. The default setting is to wait for a request from the central device.

?GAPBOND_MITM_PROTECTION– This parameter sets whether man-in-the-middle protection is enabled or not. If it is enabled, the pairing request will also authenticate the connection between the slave and master. The profile default value is FALSE, though the sample application sets it to TRUE during initialization.

?GAPBOND_IO_CAPABILITIES – This parameter tells the bond manager the input and output capabilities of the device. This is needed in order to determine whether the device can display and/or enter a passkey. Therefore, the default value is

GAPBOND_IO_CAP_DISPLAY_ONLY, indicating that the device has a display but no

keyboard. Even if the device does not have a physical display, a passkey presented in a user guide (such as this one) can be considered to be a “display”. The default passkey value is a six digit string of zeros: “000000”.

?GAPBOND_BONDING_ENABLED– This parameter enables bonding. The profile default value is FALSE, though the SimpleBLEPeripheral application sets it to TRUE during

initialization.

Copyright ? 2010-2013 Texas Instruments, Inc.

蓝牙模块使用说明书

蓝牙模块使用说明 一、模块简介: 1、芯片简介 该蓝牙模块采用台湾胜普科技有限公司的BMX-02X模块为核心,它采用CSR BLUEcore4-External芯片并配置8Mbit的软件存储空间,成本低,使用方便。 CSR BlueCore4是英国Cambridge Silicon Radio(CSR)公司日前推出的第四代蓝牙硅芯片。这种硅芯片用于蓝牙技术推广小组(SIG)推出的增强数据传输率(EDR)蓝牙。CSR的BlueCore4的数据传输率将比现有的v 1.2蓝牙装置快三倍,并且使蓝牙移动电话或手机的耗电量较低。 蓝牙EDR的最大数据传输率为每秒2.1兆比特,而目前v1.2标准传输率则为每秒721千比特。传输率的提高意味着对一个特定量的数据来说,EDR无线电的工作将比v1.2无线电快三倍,从而减少耗电量,大大有利于依赖蓄电池的移动设备。 CSR BlueCore4完全能与现有蓝牙v1.1和v1.2装置兼容。蓝牙EDR用一种相移键控(PSK)调制模式取代标准传输率的Gaussian频移键控(GFSK),实现更高的数据传输率。 CSR BlueCore4正在以两种形式提供——一种用于外部“快闪”存储器,一种用于掩模ROM。BlueCore4-External以一种8×8mm BGA(球形格栅矩阵)封装提供,是十分灵活的解决方案,能够适应迅速更新的市场。例如,由于BlueCore

是目前可以得到的唯一能够支持蓝牙v1.2规格的所有强制和可选功能的硅芯片,BlueCore4-External为PC应用程序提供了理想的解决方案,使它们得益于以三倍速度的传输率无线传输文件,或者同时操作多个高需求的蓝牙链路。 鉴于蓝牙固件安装在芯片只读存储器上,CSR BlueCore4-ROM 的成本较低,占用面积小得多(在小片尺寸包装中为3.8×4mm,在与BC2-ROM和BC3-ROM引脚兼容的BGA中为6×6mm)。ROM芯片的尺寸和成本使它日益成为要求蓝牙功能综合起来的移动电话、手机和其它批量生产和成本敏感的应用产品的选择。 BlueCore4提供48KB的RAM,而以前的BlueCore硅芯片仅为32KB。部分这种额外的记忆存储用于对付增强数据传输率的附加缓冲空间,而其余部分则确保象Scattermode这样的未来规格得到充分支持。 BlueCore4-External和BlueCore4-ROM将先把蓝牙EDR快速数据传输率的优越性带给现有一些主要的蓝牙市场,加快文件传送,降低耗电并实现多个同时链路的操作。它还将为这种技术开辟某些潜在的新应用领域。 2、主要特性 ◆蓝牙版本:V2.0+EDR ◆输出功率:class II ◆Flash存储容量:8Mbit ◆供应电压:5V

KC-01蓝牙模块说明书-VER1.1

KC-01蓝牙模块规格书 一.模块功能描述 KC-01模块是一个高集成度,低成本,低功耗的蓝牙立体声带通话功能+U盘+TF卡+FM+Line in全功能单芯片模块,符合V4.2+BR+EDR+BLE规范。 1.可播放MP3/WAV; 2.蓝牙立体声传输,蓝牙通话; 3.支持76-108MHZ FM收音; 4.TF/SD卡控制,支持USB功能,可以实现读卡器功能; 5.立体声Line-in输入; 6.IR遥控; 7.两个可控LED、支持外部功放mute功能; 8.内部集成电源管理(根据SDK的支持而调整); 9、支持U盘控制; 10、带高速UART调试及升级接口。 二.模块产品应用 该模块主要用于短距离的音乐传输,可以方便地和笔记本电脑,手机,PDA等数码产品的蓝牙设备相连,实现音乐的无线传输,由于集成了FM与MMC卡的播放功能,使本产品具有有极高的性价比。 三.模块产品规格 蓝牙版本V4.2+BR+EDR+BLE 调制方式PSK 3Mbps,π/4-DQPSK和8DPSK 支 持HFP/HSP,OPP,A2DP/AVRCP,PBAP profiles 灵敏度(0.1% BER) -85dBm 发射功率满足class2 and class3的发射功率要求,可以提供+2dbm的发射功 率 供电电压DC 3.2V~4.2V 耗电电流正常工作电流25mA,播放暂停时12mA 信 噪 比>90dB 工作温度-20 ~ +50℃ 尺 寸23mmx13mm x2.05mm

四.模块详细尺寸 五.模块PIN脚说明

PIN脚序号 名称 功能说明 1,,24 GND GND 2 USBDM USB Negative Data;ISP_DI: 3 USBDP USB Positive Data;ISP_DO: PA3 AMUX1L:Simulator Channel 1 Left; Touch10:Touch Input Channel 10; ADC0:ADC Input Channel 0; UART2TXA:Uart2 Data Out(A); ISP_CLK: Wakeup8:Port Interrupt /Wakeup 8; 4 PWM0H/ADC0/PA5 UART0TXA:Uart0 Data Out(A); Touch12:Touch Input Channel 12; ADC2:ADC Input Channel 2; IIC_SCL_D:IIC SCL(D); Wakeup9:Port Interrupt /Wakeup 9; 5 MIC MIC 6 DACR DAC Right Channel 7 DACL DAC Left Channel 8 VCOMO DAC Reference out 9 DACVDD DAC Power 10 AGND DAC Ground 11 FMIP FMIP 12 VDDIO POWER 3.3V 13 PB12/SD0CLK GPIO AMUX2R:Simulator Channel2 Right; NFCRX:NFC Data In Touch7:Touch Input Channel 7; ADC11:ADC Input Channel 11; SPI1DOA:SPI1 Data Out(A); SD0CLKB:SD0 Clk(B); 14 PB11/SD0CMD GPIO AMUX2L :Simulator Channel2 Left; NFCTX:NFC Data Out Touch6:Touch Input Channel 6; ADC10:ADC Input Channel 10; SPI1CLKA:SPI1 Clk(A); SD0CMDB:SD0 Command(B); Wakeup13:Port Interrupt /Wakeup 13; PB7 GPIO UART0RXB:Uart0 Data In(B); ADC6:ADC Input Channel 6; TMR3:Timer3 Clock Input; 15 PB10 /SD0/DAT/ADC9/PWM3H GPIO UART2RXC:Uart2 Data In(C); Touch5:Touch Input Channel 5; ADC9:ADC Input Channel 9; SPI1_DI A:SPI1 Data In(A);

ATK蓝牙模块说明书

ATK-SPP蓝牙串口说明书 ATK-SPP 蓝牙数传模块 一.模块概述 ATK-SPP是一款专为数据传输设计的蓝牙模块,遵循 蓝牙 3.0协议。支持SPP蓝牙串口协议,支持UART接口。 具 有成本低,兼容性好,功耗低等优点。 二.应用领域 1 蓝牙打印机 2 蓝牙遥控玩具 3 智能家居 4 汽车诊断仪 5 蓝牙无线数据传输 6 蓝牙游戏手柄

7 无线数据传输 8 蓝牙GPS 9 工业遥 控 三.引脚说明

引脚引脚功能描述 1 VCC 3.3V电源 2 P00 LED 3 P01 I/O 4 P30 I/O 5 P35 I/O 6 P45 I/O 7 GND 电源地 8 GND 电源地 9 P10 I/O 10 P20 UART-RXD 11 P21 UART-TXD 12 P22 I/O 13 P23 I/O

14 P24 I/O 15 P25 I/O 16 P26 I/O或者PWM口 17 NC 悬空 18 P11 I/O 四.模块尺寸 尺寸大小:12.7x23.4x1mm Pcb pad layout size是 1.5×1mm 五.应用电路

六.命令参数 1.设置命令:#AT#SET=m# #:特征码 m:0退出命令设置模式 1-9进入命令设置模式,1代表5S,2代表10S,依 此类

推,最大可以设置45S。这个数字表示在该时间内没 有输 入命令或者收到错误的命令,自动退出设置模式。命 令的 设置需要蓝牙连接成功以后,用终端去设置,例如手 机, 电脑等。只有使用该命令进入到设置模式后,其它命 令才 有效。收到正确命令后返回“OK”。 例:#AT#SET=3#进入设置模式15S #AT#SET=0# 退出设置模式 2.修改蓝牙名字:#AT#NAME=nnnnn# 蓝牙名字最长位数为32位字符,修改成功后返回“OK”。 例:#AT#NAME=BLUETOOTH# 蓝牙名字改为: BLUETOOTH,重新上电后生效。

音频蓝牙模块说明书V1.00

广州唯创电子有限公司MP3录音模块 音频蓝牙模块 目录 1.产品概述 (2) 2.产品应用领域 (2) 3.模块特点 (2) 4.功能框图简介 (3) 5.管脚介绍 (3) 6.模块尺寸图 (5) 7.模块功能详解 (5) 7.1.MP3功能部分简介 (5) 7.1.1.TF卡座连接电路 (6) https://www.sodocs.net/doc/2915062219.html,B连接电路 (6) 7.1.3.按键电路 (7) 7.2.蓝牙部分 (8) 7.3.红外线遥控部分 (8) 8.相关参数 (9) 8.1.音频播放参数 (9)

8.2.蓝牙射频特性 (9) 8.3.电气参数 (10) 9.版本信息 (10) 音频蓝牙模块 1.产品概述 音频蓝牙模块是深圳唯创知音电子自主研发的智能型无线音频数据传输加上MP3音频播放产品,是低成本高效率的立体声无线传输方案,具有集成度高,体积小,低功耗,传输速度快等特点,只需在模块外围加上少许的元器件就可以实现高品质立体声音频的无线接收。模块本身采用免驱动方式,客户只需要把模块接入应用产品,就可以快捷的实现音乐无线传输,享受蓝牙模块的乐趣。 模块本身主要具备三大功能特点、自身MP3功能(可以外挂TF卡、U盘)、手机蓝牙通讯、红外线遥控。 2.产品应用领域 该模块主要用于短距离的音乐传输,可以方便地和笔记本电脑,手机,PDA等数码产品的蓝牙设备相连,实现音乐的无线传输。 ●蓝牙音响 ●蓝牙立体声耳机 ●免提电话 ●蓝牙无线传输音频 ●车载音响系统 ●车载免提 ●便捷式导航设备 3.模块特点 1)支持MP3LayerI II III,WA V(PCM,IMA-ADPCM)格式文件的播放; 2)支持SD/MMC/TF卡和各种U盘; 3)支持FA T12/FAT16/FA T32/EXFAT文件系统; 4)支持快进,快退,断点记忆,AB复读,EQ功能; 5)支持双设备同时在线功能; 6)支持MIC录音功能; 7)支持蓝牙音乐播放和通话功能;

蓝牙耳机使用说明书

蓝牙耳机使用说明书 一、开机。在没有开机的情况下只需要一直按住开机键10秒左右当二级指示灯长亮或者红、蓝两色灯交替闪烁即为开机。中途看到蓝牙指示灯一闪一闪不要松手。当蓝牙跟配对设备连接之后指示灯才会变成一闪一闪的。二、配对。耳机正常开机后手机搜索蓝牙设备一般可以在5秒钟左右的时间可以搜索到耳机然后在手机上选择你找到的蓝牙耳机设备手机会提示你输入密码。通用密码0000. 三、连接。当手机搜索到耳机同时你也正确输入了密码后并不是说你的手机就可以用蓝牙耳机了有很多手机在找到蓝牙设备后还需要和耳机进行连接。四、充电。蓝牙耳机的充电时间一般都在2小时左右大多数蓝牙耳机充电时红灯亮充满后灯灭。疑难问题解决1.手机无法搜索到蓝牙耳机解决方法①确认蓝牙是否开机是否指示灯常亮或红、蓝指示灯交替闪烁②如果蓝牙已开机仍无法搜到请重启蓝牙和手机。 2.蓝牙耳机和手机连接之后总是断线或是有杂音解决方法①蓝牙耳机电力不足需要尽快给蓝牙耳机充电②手机和蓝牙之间有阻隔或距离超出信号接收距离请不要用手捂住蓝牙为了保持信号的连续稳定性请尽量保持蓝牙和手机在同一方向。 3.蓝牙已连接但是不能听歌解决方法①单声道蓝牙耳机仅在配对诺基亚手机时可以用蓝牙听音乐如果你用的不是诺基亚的手机是不能用单声道蓝牙听音乐的②检查蓝牙设置声音路径转到免提装置③部分国产手机和山寨手机还需要进入播放器设置两个地方在播放器里把蓝牙功能开启并在下面一个耳麦的图标里选择刚连接的蓝牙设备点击确定即可。④

个别国产手机没有完整立体声蓝牙模块没有蓝牙听音乐功能。可用蓝牙连接其他手机检测该蓝牙耳机是否可用。 4.如何用蓝牙耳机在电脑上听歌和语音聊天解答如果你的电脑自带蓝牙打开蓝牙功能搜索正开启的蓝牙就行不然就需要一个蓝牙适配器适配器的作用是连接蓝牙耳机和电脑通过一个蓝牙小软件BlueSoleil就可以实现与电脑连接。XP系统可自动识别任何蓝牙适配器无需驱动程序但是XP自带的适配器软件只能传输文件不能传输音频。必须安装光盘里自带的BlueSoleil这个软件传输音频。1、我的手机能使用蓝牙吗答蓝牙是一种世界标准的协议只要你的手机有蓝牙功能都能使用蓝牙耳机、蓝牙免提等蓝牙手机配件。常见的几个主要品牌的手机可以去其网站查看自己的手机是否支持蓝牙。2、我怎样选择蓝牙耳机答首先是选择品牌的蓝牙耳机无论从质量还是售后服务都可以保证其次是选择音质和待机时间长的蓝牙耳机因为耳机的寿命实际就是蓝牙耳机电池的寿命电池的寿命是由充电的次数多少决定的所以待机时间越长的蓝牙耳机其使用寿命就会越长。3、蓝牙耳机使用简单吗答蓝牙耳机使用很简单比手机使用简单得多了。蓝牙耳机使用前先要跟手机配对简单的配对过程介绍先按住耳机的多功能按钮说明书有说几秒钟耳机的指示灯会变为红兰交替闪烁大部分的耳机再用手机搜索蓝牙设备手机找到后会显示所找到的蓝牙名称输入配对密码一般是0000后接着按手机的确定按键那配对过程就这样简单的完成了。立体声的蓝牙耳机部分手机需要在蓝牙设备内进行再次连接才可以正常使用立体声来听音乐。蓝牙耳机的按键不多大部分只有音量按钮、

蓝牙音箱5.0版本杰理方案

蓝牙音箱5.0版本杰理方案 一、简要说明 随着时间的推移,杰理蓝牙技术也在不断成熟。这不,杰理今年3月份又推出了AC692N 系列单芯片蓝牙ic。也必将为今后两年蓝牙音箱和耳机产品的主选方案。但对大多数的厂家来说,选用什么样的蓝牙芯片方案,也不是一件简单的事情。以下是我列出了一些现有的主流方案,他们都有自己的市场定位,方案特点,希望对你有所帮助。 二、AC692N系列的优点: (1)、AC692N针对蓝牙音响市场: (2)、音质好,96dB。 (3)、收音效果提升2-3D,收音效果是AC692N最为明显的亮点。 (4)、功耗提升AC690N的40+MA,AC692N的20+MA。 (5)、抗静电提升AC690N600-700V,AC692N2000V。 (6)、DAC白噪声降一些,信噪比可到80多db以上。 三、AC692N选型表: 四、杰里692N系列与之前版本的功能比较说明:

三、AC692N系列功能引脚说明

五、总结 虽然市场很大,需求也很大,但是在实际的产品中,我们往往首先会问客的市场定位在哪里,因为只有你的产品市场定位准了,才能去选择的合适的方案。不可能你产品定位在高端,并且销往欧美,还选用低端的方案。也不可能你的产品定位低端销往东南亚,而选择高端的方案,所以这一点很重要,也是我们和户沟通中的第一要点。 同时也要考虑自己的产品是否功能有差异化,如果有,就能选择那种高端的方案,为什么呢?因为像CSR、创杰、TI这类的方案,可开的功能实在太少了.如果想灵活的定制很多功能,选则类型的方案是不合适的,可能别人答应可以做,但是实际做的时候往往会卡在一些地方,导致项目进展严重滞后。 所以,有需求的客户,请一定要定位好自己的产品,以及对自己产品的规划,再找到合适、并且有诚意的配合厂家,这样才能保证产品能顺利的走下去.

蓝牙模块HC05使用说明

蓝牙模块HC-05使用说明

————————————————————————————————作者: ————————————————————————————————日期: ?

HC-05蓝牙模块介绍与配置 1.蓝牙介绍 图7-1产品实物图图7-2 引脚对应图 HC-05蓝牙模块的特点: (1)采用CSR主流蓝牙芯片,蓝牙V2.0协议标准; (2)输入电压:3.6V--6V,禁止超过7V; (3)波特率为1200,2400,4800,9600,19200,38400,57600,115200 用户可设置; (4)带连接状态指示灯,LED快闪表示没有蓝牙连接;LED慢闪表示进入 AT命令模式; (5)板载3.3V稳压芯片,输入电压直流3.6V-6V;未配对时,电流约 30mA(因LED灯闪烁,电流处于变化状态);配对成功后,电流大约10mA。(6)用于GPS导航系统,水电煤气抄表系统,工业现场采控系统; (7)可以与蓝牙笔记本电脑、电脑加蓝牙适配器等设备进行无缝连接。(8) HC-05嵌入式蓝牙串口通讯模块(以下简称模块)具有两种工作模式:命令响应工作模式和自动连接工作模式,在自动连接工作模式下模块又可分为主(Master)、从(Slave)和回环(Loopback)三种工作角色。当模块处于自动连接工作模式时,将自动根据事先设定的方式连接的数据传输;当模块处于命令响应工作模式时能执行下述所有 AT命令,用户可向模块发送各种AT 指令,为模块设定控制参数或发布控制命令。通过控制模块外部引脚(PI O11)输入电平,可以实现模块工作状态的动态转换。

2.蓝牙配置 (1)主要内容 ?所需材料: USB转TTL模块(下载器)、HC-05蓝牙模块一对、串口调试助手。 ?配置要求: 实现两个蓝牙模块的主从绑定。 ?注意事项: USB转TTL模块(下载器)与HC-05蓝牙模块的连接方法如下: 蓝牙模块USB转TTL模块 RXD <------ --->TXD TXD <---- ----->RXD VCC <------- --> 5V GND<------ ---> GND 注意:交叉连接 ?设置步骤 ?进入AT指令模式(所有AT指令都必须换行) ?设置串口波特率9600,无校验位,无停止位 ?修改蓝牙名称、密码 ?设置蓝牙的主从模式(1主1从) ?实现主从模块的绑定(两个模块实现透传) (2)操作实例 A.用杜邦线连接好USB转TTL模块(下载器)与HC-05蓝牙模块(注意交叉!!) B.进入AT指令模式 ?将下载器与电脑连接,(按住HC-05上的复位键,再接通电源,发现指

蓝牙模块学习笔记(1)

蓝牙模块学习笔记(1)

蓝牙模块学习 刚拿到蓝牙模块,心中有点小激动啊; 民用级:HC-05,HC-06(HC-06-M,HC-06-S) HC-05-D,HC-06-D(是带底板的模块,主要是用户用于测试和评估) 本文介绍的为HC-06蓝牙串口模块。 蓝牙串口模块用于把串口转换为蓝牙,这种模块工作的时候分为主机和从机,其中偶数命名的型号出厂时就确定了是从机或者是主机,并无法更改。奇数命名的型号可以用户自己通过AT指令修改模块为主机或者从机。 主机:HC-06-M , M=master 从机:HC-06-S , S = slaver 串口模块的使用,是不需要驱动的,只要是串口就可以接入,配对完毕即可通信,模块与模 块的通信需要至少 2 个条件: 1、必须是主机与从机之间 2、必须密码一致(密码:1234) 主机: 记忆最后一次配对过的从机,并只与该从机配对,直到KEY(26 脚)高电平触发时放弃记忆,26 脚默认应该接低电平。 配对方式: 主机自动搜索从设备进行配对。 典型方式:在一定条件下,主从之间自动配对 AT 模式:

配对前就是AT 模式,配对完毕后透明通信 图1 是HC-06 图片及主要引脚 现在你手中拿到的HC-06引出了四个引脚,分别为VCC、GND、TXD、RXD。四个引脚分别对应单片机的电源5V或3.3V;GND接地;TXD、RXD交叉连接(对应单片机的P3^0,P3^1)。 连接好,单片机上电,此时蓝牙模块上led闪烁,表示尚未连接其他蓝牙设备。此时用手机蓝

牙搜索,可以搜索到HC-06.点击连接,输入pin 密码则可以连接。 连接好后,利用蓝牙串口助手就可以对蓝牙模块通信了,编程也就可以把蓝牙当作普通串口来对待。 注意编写好程序后,向单片机烧录时,必须将TXD、RXD拔出才能烧写!!! 问题:串口发送字符串时,最后没有标志可寻。可以将字符串接收到数组中,发送数据到12864,检测是否到’\0’,如果检测得到,将标识符flag 置为1;串口中断服务程序中,检测到flag为1时,这证明数据显示成功。此时应当清屏! 清屏方法:while(Tem[i]!='\0') { Tem[i]=' '; i++; }

蓝牙模块HC-05使用说明

HC-05蓝牙模块介绍与配置 1.蓝牙介绍 图7-1产品实物图图7-2 引脚对应图 HC-05蓝牙模块的特点: (1)采用CSR主流蓝牙芯片,蓝牙V2.0协议标准; (2)输入电压:3.6V--6V,禁止超过7V; (3)波特率为1200,2400,4800,9600,19200,38400,57600,115200 用户可设置; (4)带连接状态指示灯,LED快闪表示没有蓝牙连接;LED慢闪表示进入 AT命令模式; (5)板载3.3V稳压芯片,输入电压直流3.6V-6V;未配对时,电流约 30mA(因LED灯闪烁,电流处于变化状态);配对成功后,电流大约10mA。 (6)用于GPS导航系统,水电煤气抄表系统,工业现场采控系统; (7)可以与蓝牙笔记本电脑、电脑加蓝牙适配器等设备进行无缝连接。 (8) HC-05 嵌入式蓝牙串口通讯模块(以下简称模块)具有两种工作模式:命令响应工作模式和自动连接工作模式,在自动连接工作模式下模块又可分为主(Master)、从(Slave)和回环(Loopback)三种工作角色。当模块处于自动连接工作模式时,将自动根据事先设定的方式连接的数据传输;当模块处于命令响应工作模式时能执行下述所有 AT 命令,用户可向模块发送各种 AT 指令,为模块设定控制参数或发布控制命令。通过控制模块外部引脚(PIO11)输入电平,可以实现模块工作状态的动态转换。 2.蓝牙配置

(1)主要内容 所需材料: USB转TTL模块(下载器)、HC-05蓝牙模块一对、串口调试助手。 配置要求: 实现两个蓝牙模块的主从绑定。 注意事项: 设置步骤 ?进入AT指令模式(所有AT指令都必须换行) ?设置串口波特率9600,无校验位,无停止位 ?修改蓝牙名称、密码 ?设置蓝牙的主从模式(1主1从) ?实现主从模块的绑定(两个模块实现透传) (2)操作实例 A.用杜邦线连接好USB转TTL模块(下载器)与HC-05蓝牙模块 (注意交叉!!) B.进入AT指令模式 ?将下载器与电脑连接,(按住HC-05上的复位键,再接通电源,发现指示灯缓慢闪灭,表示进入AT指令模式),并且打开串口助手。设置波特率38400,数据位8 位,停止位1位,无校验位,无流控制。 ?测试通讯 发送:AT(换行) 返回:OK 如下图所示:

蓝牙模块

蓝牙模块使用手册 1.蓝牙模块概述: 本说明书适用于蓝牙通信模块BF10,蓝牙通信模块BF10 为一款自主开发的智能型无线数据传输产品,高灵敏性接收, 低成本,体积小巧,低功耗,用于蓝牙的数据传输领域。 BlueCore4-Ext芯片,完全兼容蓝牙2.0规范 Uart接口,支持1200bps~2764800bps等多种波特率 支持SPP协议最高可支持3M调制模式 外围IO口通信 内建8M Flash 2. 蓝牙模块应用领域: 该模块主要用于短距离的数据无线传输领域。可以方便的和PC机(PDA手机)的蓝牙设备相连,也可以两个模块之间的数据互通。避免繁琐的线缆连接,能直接替代现有的串口线。 ※蓝牙打印机、条码扫描设备 ※工业遥控、遥测; ※POS系统,无线键盘、鼠标; ※交通,井下定位、报警; ※自动化数据采集系统; ※无线数据传输、银行系统; ※无线抄表、无线数据采集; ※楼宇自动化、安防、机房设备无线监控、门禁系统; ※智能家居、工业控制; ※汽车检测设备; ※电视台的互动节目表决设备; ※政府路灯节能设备 ※无线LED显示屏系统 3.蓝牙模块封装信息

管脚功能描述 序号名称描述 1 TXD串口数据发射,连接单片机的RXD接收 2 RXD 串口数据接收,连接单片机的TXD发射 3 CTS 串行CTS功能脚 4 RTS 串行RTS功能脚 5 PCM_CLK 未使用到 6 PCM_OUT 未使用到 7 PCM_IN 未使用到 8 PCM_SYNC 未使用到 9 AIO0 未使用到 10 AIO1 未使用到 11 RESET 复位脚低电平复位,该管脚上拉470K电阻,下接104电容 12 VCC 3.3V供电正端,电压范围为3.15-3.3V 13 GND 供电负端 14 GND供电负端 15 USB - USB- 16 SPI_CSB 未使用到 17 SPI_MOSI 未使用到 18 SPI_MISO 未使用到 19 SPI_CLK 未使用到 20 USB + USB + 21 GND 供电负端 22 GND 供电负端 23 PIO0 外围IO口 24 PIO1 外围IO口 25 PIO2 外围IO口 26 PIO3 外围IO口 27 PIO4 外围IO口 29 PIO5 外围IO口 29 PIO6 外围IO口 30 PIO7 外围IO口 31 PIO8 外围IO口 32 PIO9 外围IO口 33 PIO10 外围IO口 34 PIO11 外围IO口 4. UART及外围PIO Uart串口信息: 电平: 3.3V CMOS电平 波特率: 1200,2400, 4800,9600,19200,38400, 57600, 76800,115200,230400,460800,921600,1382400, 数据位:8bit 停止位: 1bit 校验位: 无 注:若芯片与标准RS232、RS485连接则需要使用驱动芯片 PIO口信息

蓝牙4.0模块使用手册

蓝牙4.0 BLE模块使用手册 一、模块引脚介绍 蓝牙模块引出5个针脚: 1、EN:可编程输入输出接口,正常使用没用到 2、VCC:电源输入,3.6V--5V 3、GND: 地 4、TXD:接单片机串口的RX 5、RXD:接单片机串口的TX 6、STATE: 主机中断指示口,空闲为低,连接上为高。与手机蓝牙连接上后输出高电平,用于检测是否连接上。led指示蓝牙连接状态,闪烁表示没有蓝牙连接,常亮表示蓝牙已连接并打开了端口

二、蓝牙4.0 BLE介绍 从蓝牙4.0开始有两个分支,经典4.0和BLE4.0,经典4.0 就是传统的3.0蓝牙升级而成,向下兼容。而BLE 4.0是一个新的分支,无法向下兼容。 BLE 是Bluetooth Low Energy 低功耗蓝牙的缩写,顾名思义,其功耗较低。 三、主从模式设置 模块已经选择用软件设置主从模式。 两个模块之间的搜索,需要一个设为主,一个为从,用AT+ROLE 进行配置。然后发送AT 指令进行搜索连接. 简单举例: 设置模块为主模式:通过串口发送AT+ROLE1(回车或者加\r\n),返回OK,则表示设置成功,此时模块LED灯进入快闪。主模块连接从模块需要通过AT指令进行连接(详情请参照BT05 AT指令集)。 四 、模块与407开发板(高配版)连接

五、实验操作与现象 1、板子上电,下载配套的例程程序 2、板子断电,插上蓝牙4.0 BLE模块 3、板子上电后,蓝牙4.0 BLE模块工作,led灯闪烁 4、手机设置中打开手机蓝牙(此处搜不到模块的蓝牙) 5、之后打开“启明BLE”app,app会自己搜索蓝牙,此时app 将搜索到名为“BT05”,点击连接后,led灯常亮 6、连接成功后手机APP就可以控制开发板了 六、常见问题 1、支持哪些设备 答:苹果手机限定:4s 及以上型号,系统版本 iOS6 及以上, 安卓手机限定:手机蓝牙版本为4.0,系统为4.3版本及以上。 2、为什么在手机设置蓝牙界面下找不到BLE设备 答:手机蓝牙默认工作在经典模式下,您需要通过软件程序来实现搜索,配对连接和通迅的整个过程。 苹果手机,可以从苹果APP商店下载LightBlue测试软件 安卓手机,可以用我们提供的“启明BLE”这个测试软件测试 3、 为什么电脑上不支持 BLE 答:电脑上如果装配了4.0双模的蓝牙适配器(双模指经典4.0 和 BLE4.0)在硬件上是支持BLE的,只不过,目前的现状比较尴尬,找不到配套的软件去驱动这个适配器。

蓝牙串口从机模块使用说明

性能概要完整的蓝牙解决方案 ?蓝牙2.0 带EDR,2Mbps-3Mbps 调制度 ?内置2.4GHz 天线, 用户无需调试天线 ?外置8Mbit FLASH ?低电压3.3V 工作 ?可选PIO 控制 ?标准HCI 端口(UART or USB) ?USB 协议: Full Speed USB1.1, Compliant With 2.0 ?模块可以作为SMD 贴片工艺 ?RoHS 制程 ?引脚半孔工艺 ?数字2.4GHz 无线收发射 ?CSR BC04 蓝牙芯片技术 ?自适应跳频技术 ?体积小,(27mm×13mm×2mm) ?简单的外围设计电路 ?蓝牙Class 2 功率级别 ?存储温度:-40至+85 度,工作温度:-25 至+75 度 ?协波干扰:2.4MHz,发射功率3 dBm ?误码率:0,但会在传输链路产生信号衰变,才有误码,如RS232 和TTL线路处理线路中 一、从机模块使用说明

在应用方面从机是用于单片机跟电脑或者手机配对通讯。使用方法是把模块的通信线RXD TXD连接到单片机,然后用手机或者电脑搜索蓝牙设备,并配对连接。如果是使用手机,我们提供安卓系统的测试程序,如果是wm系统,则可以从网上下载一个串口调试助手。使用电脑连接后会自动分配com口,一般会出现两个,分别试验一下,有一个口可以通信。如果是想利用电脑连接模块,我们推荐用IVT软件,因为微软自带的蓝牙驱动存在很多问题。详细内容请参照文档《使用蓝牙适配器连接模块说明.doc》。 如何进行A T指令操作? 模块的参数设置是需要通过A T指令进行的。比如设置设备名称,配对密码,修改波特率等。 如果您的设备使用中参数基本固定,可以在使用前修改完毕,以后就直接利用其通讯即可,参数设置只需设置一次,之后会保存住。这样我们可以采用电脑修改,用电脑进行A T 指令,需要用一根USB转TTL线连接到模块,USB的RXD、TXD直接连接到模块的TXD、RXD。在模块的指示灯闪烁的情况下进行。也可以通过连接到单片机设置,单片机的RXD、TXD直接连接到模块的TXD、RXD。然后再模块没有配对连接的情况下(即灯闪烁),直接通过串口发送A T指令对应的字符即可。 从机模块在没有配对连接的情况下(灯闪烁)可以进行A T指令。因为配对连接后进行数据传输,模块对于数据相当于透明处理,蓝牙接收到的数据直接从模块TXD发出,模块RXD接收到的数据也直接通过蓝牙发出了。模块进行A T指令必须连接模块的通信线RXD TXD。 二、未带转接板模块引脚说明

蓝牙发射适配器使用说明书

RRD-074S蓝牙发射适配器使用说明书 一、产品概述: RRD-074S蓝牙发射适配器本公司自主开发的智能型无线音频传输产品,是低成本的高性价比的立体声无线发射传输方案,整体性能优越。可以快捷地实现音乐的无线传输,享受无线音乐的乐趣 二、应用领域: 该模块主要用于短距离的音乐传输,可以方便地和笔记本电脑,手机,PDA 等数码产品的蓝牙设备相连,实现音乐的无线传输。 ※蓝牙音响 ※蓝牙立体声耳机 ※蓝牙无线传输音频 三、基本特性 Bluetooth Profiles ※Bluetooth V2.1+EDR specification support ※A2DPv1.2 ※AVRCPv1.0 ※HFPv1.5 ※GAVDP1.2 ※IOP 四、性能参数: 型号RRD-074S蓝牙发射适配器 蓝牙规格Bluetooth V2.1+EDR 供电电压:DC2.8-4.2V 支持蓝牙协议HFPV1.5, A2DPV1.2, GAVDP1.2,IOP 工作电流≤60mA 待机电流<500uA 温度范围-40oC to +85oC 无线传输范围:大于10 米 传输功率:CLASS2,4dbm 灵敏度:-80dBm<0.1%BER 频率范围:2.4GHz-2.480GHz 对外接口:I2C, SPI and UART interface 音频性能SBC解码 音频信噪比:≥75dB 五、注意事项: A.关于无线蓝牙的使用环境,无线信号包括蓝牙应用都受周围环境的影响很大,如树木、金属等障碍物会对无线信号有一定的吸收,从而在实际应用中,数据传输的距离受一定的影响。

B.由于蓝牙模块都要配套现有的系统,放置在外壳中。由于金属外壳对无线射频信号是有屏蔽作用的。所以建议不要安装在金属外壳中。 六、接线图 B

蓝牙音频模块说明文档V1.3(5V)

蓝牙音频模块说明文档(5V) 一、外观 实际产品,已经焊接了插针,默认为90度弯针 二、端口说明: 1、+5V 电源:接电源正极,电压范围4.2V~5V ,请确保供电在此范围内,超这个范围可能损坏模块,或者导致工作不正常; 2、地:GDN 接电源负极,也是音频的地,此地必需分开两根地线分别接电源地跟音频地; 3、左声道:接功放板左声道输入,或者耳机的左声道,建议在该输出端口接入一个电容(视功放所匹配的输入而定); 4、右声道:接功放板右声道输入,或者耳机的右声道,建议在该输出端口接入一个电容(视功放所匹配的输入而定); 5、静音输出端口:该端口预置为高电平,当静音时该端口输出低电平; 6、状态指示灯:当蓝牙未连接时,该灯快闪,一旦蓝牙连接成功则变为慢闪; 7、预留端口:该端口已经上拉到5V ,当该端口给一个低电平触发后关机,当再次给该端口一个低电平复开机。 系统典型接线图: 注意:从蓝牙音频模块到电源或者到音频接口,请采用焊接的方式,不要采用插线的方式,接触电阻比较大会引入噪声。 三、使用注意事项:

1、供电电源:蓝牙音频模块属于对高频干扰敏感的电路,建议采用线性稳压电源,若采用DC-DC供电时,请加入LC滤波,降低电源谐波干扰,尤其采用手机充电器等开关电源,电源纹波可能致使蓝牙不能正常连接,而且这类的5V输出,往往在5.1V~5.4V之间,超过了蓝牙音频模块的工作电压; 当采用手机适配器等开关电源工作时,请加这个供电电路,电感可不加。 2、接地:由于音频信号对于接地点引起的干扰比较敏感,可以在蓝牙模块的输出插针上面焊两根地结,一根接到电源的负极(GND),另外一根接到功放板的音频输入地,尽量焊在线路板上,不要采用引线接连(容易受干扰),并且建议可以多试一下那个接地点干扰最小; 3、天线干扰:蓝牙天线极其容易受到高频,或者强电磁信号干扰,相对来说尽量远离功放板的强信号的地方,并且天线不能紧挨着金属物品,保持一定的距离; 4、外壳屏蔽:由于金属外壳的机壳对于蓝牙信号有屏蔽作用,可能衰减蓝牙信号致使接收不良,请保持在有相应的开孔,或者外露。 注:对于一些功放板容易受到干扰,干扰不容易处理的情况,请分开供电,即功放板单独一路供电,蓝牙模块一路供电。 四、附加电路: 1、状态指示灯接线图 由于模块的驱动能力较弱,建议LED灯采用红色LED灯,或者外加三极管驱动LED灯; 2、静音端口 (1)、对于有静音功能的功放板,如果为低电平静音的可以直接接入,对于高电平表静音请加一级三极管作为反相,正常播音时静音处于输出高电平约为3V左右; (2)、对于没有静音输入的功放板可以自己增加静音电路

手机通过蓝牙模块与单片机通信 (1)

Android手机通过蓝牙模块与单片机通信第一步.编写好串口程序 /********************************************* 名称单片机蓝牙 功能手机通过蓝牙模块与单片机通信 作者蒋 院校南航 ********************************************/ #include sbit dula=P2^6; //数码管段选,锁存器控制信号 sbit wela=P2^7; //数码管位选,锁存器控制信号 unsigned char k,a; unsigned char flag; void delay1ms(unsigned int f)//延时程序 { unsigned int i,j; for(i=0;i

{ TH0=0xFC; TL0=0x18; receivem();//定时将SBUF接收 } void main() { flag=0; wela=0; dula=0; timer_int(); while(1) { if(flag==1) { dula=0; P1=SBUF; a=SBUF; P0=SBUF; dula=1; dula=0; wela=0; P0=0x7e; wela=1; wela=0; delay1ms(10); SBUF=a; while(!TI); TI=0; delay1ms(10); flag=0; } } }注意:这里使用了52单片机定时器2作为波特率发生器! //设置T2为工作方式2,作为波特率时钟 TCLK = 1; RCLK = 1; C_T2 = 0;//T2的输入时钟为主时钟的2分频,不采用外部输入 T2MOD&= ~DCEN_;//递增计数方式 /******************************************************************** * T2作为串口波特率时钟,设置T2初始值: * MCU工作时钟Fclk = 11.0592MHz * 机器周期Tm = 12/11.0592us = 1.085us, * T1初值= 0x10000 - Fclk/(32*BaudRate),即0xFFDC

蓝牙模块简介

蓝牙模块介绍 主机模块实物与从机一样,模块上有白点,主机模块会自动和从机模块配对,省却配对的麻烦,适合在需要两个设备间通过蓝牙串口无线通信的应用,无需电脑。 蓝牙透传模块可以让你原来使用串口的设备摆脱线缆的束缚在10米范围内实现无线串口通信。使用该模块无需了解复杂的蓝牙底层协议,只要简单的几个步骤即可享受到无线通信的便捷。蓝牙透传模块只有4个AT指令,分别是测试通讯,改名称,改波特率,改配对密码,AT指令必须从TXD,RXD信号脚设置,不能通过蓝牙信道设置。发送AT指令的设备可以是各种类型的MCU(比如51,avr,pic,msp430,arm等),也可以是电脑通过串口(PC串口接MAX232以后或者USB转串口)发送。 特别注意: 1、主机模块和从机模块均不能切换工作模式,只能是单一的工作模式(主或从) 2、主机模块只能配对HC06的从机模块,主机模块之间不能配对连接,主机模块也不能跟带蓝牙的电脑或者手机等其他蓝牙设备配对

3、从机模块可以跟带蓝牙的电脑或者部分带蓝牙的手机配对使用,从机模块之间不能连接,如果电脑没有蓝牙适配器,可以购买我们的蓝牙适配器 4、主机模块的AT指令比从机模块少了AT+NAME指令,其他指令相同 5、主机模块和从机模块的接口均为3.3V电平,可以直接连接各种TTL电平带串口MCU(5V的MCU请串联1K电阻)直接连接,设置参数可以用MCU或者本店的USB转串口,或者增加MAX232转换电路后的电脑串口 小常识: TXD:发送端,一般表示为自己的发送端,正常通信的时候接另一个设备的RXD。 RXD:接收端,一般表示为自己的接收端,正常通信的时候接另一个设备的TXD。 正常通信时候本身的TXD永远接设备的RXD! 自收自发:顾名思义,也就是自己接收自己发送的数据,也就是自身的TXD接到自身的RXD,用来测试本身的发送和接收是否正常。也称回环测试。 由于蓝牙核心板不方便接线,因此我们把它焊接到底板上,底板上含3.3V LDO,为了方便再拆卸,仅焊接有用的引脚,引出VCC、GND、TXD、RXD(TXD、RXD均为3.3V电平)四根线方便接线,STATE为LED

蓝牙模块HC-05使用说明

HC-05蓝牙模块介绍与配置 1. 蓝牙介绍 TX(I) ItX (2) EET(Se) I bl:Uz' 3- 3V(I3) GNV(13} 图7-1产品实物图图7-2引脚对应图 HC-05蓝牙模块的特点: (1)采用CSF主流蓝牙芯片,蓝牙V2.0协议标准; (2)输入电压36V--6V,禁止超过7V; (3)波特率为1200, 2400, 4800, 9600,19200, 38400, 57600,115200 用户可设置; (4)带连接状态指示灯丄ED快闪表示没有蓝牙连接;LED慢闪表示进入AT命令模式; (5)板载3.3V稳压芯片,输入电压直流3.6V-6V;未配对时,电流约30mA因LED灯闪烁,电流处于变化状态);配对成功后,电流大约10mA (6)用于GPS导航系统,水电煤气抄表系统,工业现场采控系统; (7)可以与蓝牙笔记本电脑、电脑加蓝牙适配器等设备进行无缝连接。 (8)HC-05嵌入式蓝牙串口通讯模块(以下简称模块)具有两种工作模 式:命令响应工作模式和自动连接工作模式,在自动连接工作模式下模块又可分为主(MaSter)、从(Slave)和回环(LOOPbaCk)三种工作角色。当模块处于自动连接工作模式时,将自动根据事先设定的方式连接的数据传输;当模块处于 命令响应工作模式时能执行下述所有AT命令,用户可向模块发送各种AT指令, 为模块设定控制参数或发布控制命令。通过控制模块外部引脚(PIO11)输入电平,可以实现模块工作状态的动态转换。 2. 蓝牙配置 (1)主要内容 所需材料: USB转TTL模块(下载器)、HC-05蓝牙模块一对、串口调试助手

珠海杰理芯片ic方案分类总结

珠海杰理芯片分类 一、简介 MP3方案,蓝牙方案,WIFI方案,行车记录仪方案是目前主打的方案。而目前为止主推的还是蓝牙方案。作为一家准上市的芯片原厂,杰里的发展无疑是快速并且稳健的,目前杰里成立了短短5年的时间,现在已经发展到接近200人的研发团队,发展之迅猛,令人敬佩不已。 同时杰里之下的生态圈,已经遍及整个珠海三角,下属的方案公司和代理商不计其数。因为杰里的芯片方案在市场上还是有一定的优势,并且不断的有新产品投向市场,作为杰里下面的一家,我们见证了杰里发展的这5年,只能说,真心不容易,佩服 二、AC109N系列芯片的特点 ●小型封装SOP16。生产加工方便 ●支持USB设备、TF卡、FM、AUX、FLASH。 ●支持遥控功能 ●按键稳定支持10个,上一曲、下一曲 ●可以扩展玩具方案、插卡音箱方案 下面举例最低成本的方案,即AC1082 1、AC1082的管脚说明以及资源 三、AC309N系列芯片的特点 1、目前3系列的芯片出货量偏低,所以价格是相对比较高一点,目前3系列出货的芯片就只有两款,分别是AC3090和AC3094 2、系列芯片的特点是支持录音和WMA解码,其它的和1系列基本一样。另外3系列的芯片支持SPI方案,也就是支持“歌词显示”方案。其实杰里的歌词显示方案做得并不好,做得最好的还是炬力的 3、这个系列的方案不推荐朋友们关注,因为这个已经退出接近4年了,后面迟早会停产的

四、AC319N系列芯片的特点 1、目前AC319N系列芯片的用量还不是很大,也不算便宜,基本上都只是一些大客户再用, 2、此系列的芯片主要争对的是车机,以及复读机之类的方案, 3、因为此款芯片的特点是可录音,不支持WMA格式的解码,支持播放变速变调等等特点 五、AC410N系列芯片的特点 1、此系列的芯片是一个过渡期的产品,目前已经停产了,不建议朋友们关注 2、支持蓝牙2.1版本的,但是RF需要外加别人的芯片,主流的如:BK3515、RDA5876之类的芯片。 3、此系列的芯片有新的方案替代,也就是杰里的AC460N系列芯片,这里就不做详细的介绍 六、AC46N系列芯片的特点 此系列的芯片是杰里最新的蓝牙方案,也是杰里目前花精力最多的芯片方案。此系列为单芯片蓝牙方案,支持插卡和蓝牙单芯片完成,市场优势比较大 付上原理图,是不是很简洁,生产也是极其方便的 这个同时是目前的主流

相关主题