蓝牙研发网

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8357|回复: 0

KeyFobDemoApplication Overview

[复制链接]
发表于 2014-7-31 21:18:42 | 显示全部楼层 |阅读模式
–Advertise and connect with master device 广播以及和主设备连接
–Key press notifications 按键通知
–Proximity alarm 近场警报
–Battery percentage measurement 电池电量测量
–Accelerometer data notification 加速计数据通知

•The following application files are a part of the KeyFobDemo project:
以下为KeyFobDemo工程中的部分文件:
–KeyFob_Main.c –contains the main function, which performs HAL and OSAL intialization, and calls osal_start_system to start the main loop
包含主要函数,执行HAL和OSAL初始化,调用osal_start_system开启主循环
–OSAL_KeyFobDemo.c –defines the global tasksArr and tasksEvents arrays and the osalInitTasks function as required by OSAL
定义OSAL需要的,包括tasksArr、任务事件数组和初始化OSAL中的task的函数。
–keyfobdemo.c –main application module, including the application task initialization and event handler functions
主应用程序模块,包含应用程序任务初始化和事件处理函数。
–keyfobdemo.h –header file for application; defines the application OSAL task events
应用程序的头文件,定义应用程序操作系统抽象层的任务事件。
–buzzer.c –controls the audio buzzer on the keyfob
控制钥匙扣上的蜂鸣器的音频。
–cma3000d.c –controls and reads data from the accelerometer
对加速计进行控制和读取数据

BLE Stack Overview
•The BLE protocol stack is based on the approved Bluetooth Core specification version 4.0 (June 30, 2010)
蓝牙低功耗协议栈是基于批准的蓝牙核心规范版本4.0
&#8226rotocol stack provided as a single library file in KeyFobDemo application (three versions provided: one for each hardware platform)
在KeyFobDemo工程中,协议栈以一个library文件提供。(提供三个版本:一个用于每个硬件平台)
•Application usually does not need to directly call protocol stack API‟s
应用程序通常不需要直接调用协议栈的API
&#8226rofiles provide a means for application to send and receive control messages and data with stack
配置为应用程序提供方法,通过协议栈发送和接收消息控制和数据

Profiles Overview 配置概览
&#8226rofiles provide a layer of software between the application and the BLE protocol stack
配置提供一个软件层在应用程序和BLE协议栈之间
•Allow developer to perform basic BLE functions without having in-depth knowledge of the stack
运行开发组执行基础的BLE函数,而不需要深度了解协议栈
•Directly communicate with the top two layers of the BLE stack
直接和BLE协议栈的顶部两层进行通讯

–GAP Peripheral Role Profile –Handles advertisements, scan requests, connections, and connection parameters
GAP从角色配置——处理广播,浏览请求,连接以及连接属性
–GAP Peripheral Bond Manager –Handles responses to pairing and bonding requests, and the storage and management of security keys
GAP从机绑定管理器——处理响应配对和绑定的请求,以及存储和管理安全密钥
–GATT Profiles –Maintain GATT attributes in table, processing of read and write requests, and notifications
GATT配置——保持GATT属性在表格上,处理读写请求,以及通知

GAP Peripheral Role Profile:
Purpose 目的
•Allows device to act as a GAP peripheral and perform the following:
运行设备作为GAP从机以及执行以下:
–Turn advertising on and off
开关广播
–Send connectable advertisements and accept connection requests
发送可连接的广播以及接收连接请求
–Request automatic updates of link-layer connection parameters to a central device:
自动请求更新链路层连接到主设备的参数
•Connection interval 连接间隔
•Slave latency 奴隶延迟
•Supervision timeout 监视超时
–Notify application of connection state changes 通知应用程序连接状态改变

Public Functions 公共函数
&#8226eripheral Role Profile is an OSAL task, and contains initialization and event processing functions called by OSAL:
–GAPRole_Init
–GAPRole_ProcessEvent
&#8226rofile contains several parameters, accessed through:
–GAPRole_SetParameter
–GAPRole_GetParameter
•Initialization from application:
–GAPRole_StartDevice
•Terminate a connection:
–GAPRole_TerminateConnection
Initialization
•OSAL initializes Peripheral Role with call to GAPRole_Init
•Application registers two callback functions with Peripheral Role Profile by passing function pointers as parameter to GAPRole_StartDevice function:
–peripheralStateNotificationCB –notifies application that the peripheral device has changed GAP states (for example, devices goes from advertising to being in a connection)
–rssiAvailableCB –notifies application of the RSSI when it becomes available (set to NULL in KeyFobDemo application since it does not use RSSI information)
•When GAPRole_StartDevice is called:
–Profile signals GAP to begin advertising (if enabled)
–Profile registers itself with GAP as the task to receive GAP event messages (this allows profile to always know the connection status)
•In KeyFobDemo application, GAPRole_StartDevice is not called until 500ms delay (triggered by KEYFOB_START_DEVICE_EVT)

Key Parameters
Advertisement and Scan Response Data
AD Types Used
After Link Establishment
RSSI Measurement
After Link Termination
Switching to multi-role profile

GATT Service Profiles:
Overview
•Allows device to implement a GATT service:
–As defined by Bluetooth SIG
–Custom
&#8226rovides means for application to read and write service data on the attribute table
•Lets a remote GATT client access characteristics through:
–GATT reads
–GATT writes
–GATT notifications and indications
•Verifies the validity of data being written from a remote device
•GATT service profiles typically do not need to be OSAL tasks, and are accessed directly by the protocol stack and by the application
•Most GATT service profiles have a very similar structure
•New GATT service profiles can be easily created by copying an existing profile and renaming variables and functions

Typical Functions
Structure
InitService Function
RegisterAppCBs Function
Notifications
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|蓝牙研发网 ( 粤ICP备14052215号-1 )

GMT+8, 2024-12-22 21:12 , Processed in 0.046875 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表