Android platform BLE application Development Guide

Source: Internet
Author: User

Since Android 4.3, BLE (Bluetooth low energy) has been supported on the Android platform. However, there are few BLE applications available on Android, especially in Chinese applications, and hopefully this article will help developers interested in developing BLE applications. This article is mainly to the existing andriod BLE development related data collation, give a development data index. (This article will be based on everyone's problems, constantly improve)

Basic Reference

  1. The most basic learning material is this Android Official document: "Bluetooth low energy". This document introduces the basic concepts involved in BLE and explains how to use the Android BLE API with the example code. The example source code used in the aosp/developers/samples/android/connectivity/bluetooth/bluetoothlegatt/.
  2. Development needs to use the BLE profile spec, can be found on the official website of the Bluetooth organization "specification adopted Documents", the page "gatt-based specifications" is the BLE Profile and service spec. Our application for developing mobile phones is primarily based on a profile spec, but the service spec for that profile also needs to be read, as it usually contains a description of the professional concepts associated with the profile and the definition of the data format, such as heart rate Service Spec describes the definition of heart rate measurement Value field, which is sent from sensor to the phone, and the cell phone will parse the data based on the field definition after receiving the data.
  3. The "Definition Browser" page is also an important reference in this page where you can "View the structure of XML definitions for GATTprofiles, Services, characteristics,descriptors and declarations and download the definitions in An XML format ", in addition to view Units and format Types. For example, you can see the table for assigned number (UUID16) and value fields in the characteristic under Characteristics->heart rate measurement.
  4. Profile, service, characteristic, etc. all have a 128-bit UUID (universally Unique Identifier), which can be obtained by adding uuid16 to the high 32 bits of Base_uuid, You can refer to "Service Discovery".
BLE-related classes and BLE-related classes have the following seven:
    • Bluetoothgatt
    • Bluetoothgattcallback
    • Bluetoothgattservice
    • Bluetoothgattcharacteristics
    • Bluetoothgattdescriptor
    • Bluetoothgattserver
    • Bluetoothgattservercallback
Among them, the first two implementations of the GATT client support, the latter two implementation of the GATT server support. In most cases, mobile phones play the role of the GATT client. These classes are included in the Android.bluetooth package. Currently Android does not have a GATT-based profiles API, such as heart rate profiles, developers need to use these classes to connect and configure heart rate Sensor based on heart rate profile spec. The measurement data for heart rate sensor is then obtained and parsed. In addition, Android does not fully support some of the parameters and events of the GATT layer, so not all GATT profiles can be implemented on the current Android version (4.4.4). Android support for BLE is still being perfected, and there should be better support for BLE in subsequent releases.

Android platform BLE application Development Guide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.