Bluetooth 4.0/ble protocol Stack Learning notes (i)

Source: Internet
Author: User
Tags documentation


Bluetooth 4.0/ble protocol Stack Learning notes (i)

Required Software tools:

1. BLE protocol stack (ble-cc254x-1.4.0)

2. IAR development software (IAR Embedded Workbench8.20.2)

Note: The 1.4.0 protocol stack uses the 8.20.2 version of IAR, the 1.3.2 protocol stack, etc., using the 8.10.4 IAR version.

BLE protocol stack installation directory under folder description:

Accessories some tools and compiled hex files This folder has Btool installation packages, USB-CDC driver attachments.

Components Hal Driver, Osal source code, protocol stack common source this folder is the implementation of the osal of each layer.

Documents help document the protocol stack documentation, including the protocol stack and demo presentation and development documentation, which is the best information to learn about ble.

Projects project files Here are some TI's demo, we develop generally on the basis of the demo to modify.

About the BLE protocol stack work flow chart is probably the following way:

The BLE protocol stack is divided into two parts: host and controller. The host part includes: Logical Link Control and Adaptive protocol layer, security management layer, attribute protocol layer, general access profile layer, common attribute profile layer, controller part includes: Physical layer, link layer, host Control interface layer.

The configuration file layer of the BLE protocol stack includes the Gap role/Security profile, the GATT profile two parts, the top level of the protocol stack, and the configuration file layer to associate the protocol stack with the application layer. The gap layer handles device access modes and connections, such as broadcast enable/disable, broadcast interval, pairing bindings and connection control, and initialization security management. After the device is successfully connected, the corresponding function can be called to obtain the service (services) of the device and to read and write the Characterister (label) in the service. The GATT layer is mainly used for data communication, namely service and Characterister. One or more services can be added to the BLE protocol stack of the device, and the service (the server) contains one or more characterister (tags).

BLE protocol stack Four device types: central host, peripheral Slave, observer observer, broadcaster broadcaster. The host and slave communication process is probably: from the machine to open the broadcast, the host began scanning, when the host from the computer received a scan message, the host will send scan response data. The host then initiates the connection and establishes the communication.

Message broadcast:

After completing a processing event, you need to broadcast the message, add the value to the broadcast array advertdata[], call Gaprole_setparameter (Gaprole_advert_data, sizeof (Advertdata), Advertdata); The function broadcasts out so that it cannot be broadcast successfully. Enter gaprole_setparameter inside found missing gap_updateadvertisingdata function, need to modify dynamic broadcast data, add the following code:

Case Gaprole_advert_data:

if (len <= b_max_adv_len)

{

VOID Osal_memset (gaprole_advertdata,0, B_max_adv_len);

VOID osal_memcpy (Gaprole_advertdata,pvalue, Len);

Gaprole_advertdatalen = Len;

Gap_updateadvertisingdata (Gaprole_taskid,

True,gaprole_advertdatalen, Gaprole_advertdata);

}

Else

{

ret = Bleinvalidrange;

}

Break

After calling the Gaprole_setparameter function can be broadcast, you need to control the task call time control after adding Osal_start_timerex function, this is a timed loop to send event messages to the task, the actual time can be self-determined.

Gaprole_setparameter (Gaprole_advert_data, sizeof (Advertdata), advertdata);

Osal_start_timerex (simpleblebroadcaster_taskid,sbp_adv_rgb_evt,100);

Return (events ^sbp_adv_rgb_evt);

This data can be broadcast, using the Packetsniffer grab packet can be seen in the Advdata broadcast data (hexadecimal number).

When you use a feature, you must configure the C/c++compiler preprocessor Add macro definition to open it under option. For example, use the serial port to add Hal_uart=ture, logoff power_saving. When using the ADC function, add the hal_adc=true.

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.