Microchip Technology ATBTLC1000 Training Manual
Microchip Technology ATBTLC1000 Training Manual

Microchip Technology ATBTLC1000 Training Manual

Bluetooth low energy custom service implementation
Hide thumbs Also See for ATBTLC1000:

Advertisement

Quick Links

Bluetooth® Low Energy Custom Service Implementation

Introduction

This document demonstrates how to use the ATBTLC1000 Bluetooth
custom specific profile using the
Technical overview of the ATBTLC1000 board from hardware architecture to software design
Description of the required process for developing the Bluetooth Low Energy peripheral application
with the ATBTLC1000
Handling of Bluetooth Low Energy custom services and characteristics
Note:  The custom service implementation procedure uses the
procedure is also applicable for other supported platforms, as mentioned in
Figure 1. Bluetooth Low Energy System Solution with ATBTLC1000
©
2017 Microchip Technology Inc.
Microchip
BluSDK. This document includes the following topics:
Training Manual
ATBTLC1000
®
Low Energy SoC by building a
ATBTLC1000ZR-XSTK
kit. This
BluSDK Release
Notes.
DS00002599A-page 1

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ATBTLC1000 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Microchip Technology ATBTLC1000

  • Page 1: Introduction

    Microchip BluSDK. This document includes the following topics: • Technical overview of the ATBTLC1000 board from hardware architecture to software design • Description of the required process for developing the Bluetooth Low Energy peripheral application with the ATBTLC1000 •...
  • Page 2: Table Of Contents

    1.1. Software Prerequisites ........................ 4 1.2. Software Setup..........................4 1.3. ATBTLC1000 Embedded Firmware..................... 5 1.4. ATBTLC1000 Host Software API....................5 1.5. Hardware Prerequisites........................7 1.6. Hardware Setup........................... 9 2. Creating the Project and Initializing ................ 12 2.1. Creating Project from ASF......................12 2.2.
  • Page 3 ATBTLC1000 Worldwide Sales and Service..................57 Training Manual DS00002599A-page 3 © 2017 Microchip Technology Inc.
  • Page 4: Getting Started

    Install the Advanced Software Framework (ASF) package. Note:  The software for ATBTLC1000-ZR is supported with ASF 3.35.1 and above. Note:  For more information on the previous releases, refer to the Atmel Studio Release Notes available on the Microchip web page.
  • Page 5: Atbtlc1000 Embedded Firmware

    Bluetooth Low Energy Protocol Stack. ATBTLC1000 Host Software API The ATBTLC1000 is provided with a dedicated Host software API layer. The purpose of this API layer is to provide an easy and reliable solution to add Bluetooth Low Energy capabilities to any user application.
  • Page 6 The API operation relies on a request-response mechanism. The specific requests are sent to ATBTLC1000 through dedicated API function call. The event messages are then returned by the ATBTLC1000 on request processing or on specific Bluetooth Low Energy events. These event messages are to be handled by the host device, according to the user application requirements.
  • Page 7: Hardware Prerequisites

    The connection with any Xplained Pro modules or external component is possible through available external connectors, which makes the board perfect for prototyping the low-power applications. Training Manual DS00002599A-page 7 © 2017 Microchip Technology Inc.
  • Page 8 The ATBTLC1000ZR Xplained Pro extension evaluation kit is based on Bluetooth Low Energy 4.1 compliant SoC ATBTLC1000-ZR110CA module. This extension is plugged to any of the supported host MCU Xplained Pro evaluation boards, to quickly add Bluetooth Low Energy connectivity to the platform.
  • Page 9: Hardware Setup

    C) and SMBus serial interfaces • Current Measurement Header – Allows measurement of the current consumption of the board. It must be closed to enable power to the ATBTLC1000-ZR110CA module Hardware Setup Ensure that ATBTLC1000ZR-XPRO power consumption header is closed and that jumpers are placed on pins 2 to 3 of headers J105, J106, J107 and J108, as shown in the following figure.
  • Page 10 Connect the ATBTLC1000ZR-XPRO extension to EXT1 of SAM L21 XPRO, as illustrated in the following figure. Figure 1-8. ATBTLC1000ZR-XPRO Extension connected with SAM L21 XPRO Connect the board to PC using the “Debug USB Connector”. Figure 1-9. SAM L21 XPRO Connection to PC Training Manual DS00002599A-page 10 © 2017 Microchip Technology Inc.
  • Page 11 ATBTLC1000 Getting Started Now, the Hardware is ready for development. Training Manual DS00002599A-page 11 © 2017 Microchip Technology Inc.
  • Page 12: Creating The Project And Initializing

    Advanced Software Framework has a pre-configured Bluetooth Low Energy Startup template project that includes Bluetooth Low Energy software API for Host and ATBTLC1000, and their peripheral driver dependencies. This is used as starting project for any Bluetooth Low Energy project development.
  • Page 13 Creating the Project and Initializing Figure 2-2. Advanced Software Framework_New Example Project Note:  ATBTLC1000/SAMB11 related projects are prefixed with “BLE”, making it easier to filter the project in the dialogue box. Select the appropriate “BLE-Startup Template” project corresponding to the intended Host MCU Xplained Pro board and then press OK button to import the BLE startup template project.
  • Page 14 Note:  The main project routine of “Startup Template project” already includes host MCU low level initialization, BLE and ATBTLC1000 initialization. The added ASF components in project can be viewed from “ASF>ASF Wizard”. Select the created project from "Project" drop down box.
  • Page 15: Configuring Asf For Atbtlc1000-Zr

    Creating the Project and Initializing Figure 2-5. Main Routine Flowchart Configuring ASF for ATBTLC1000-ZR The default “Startup Template Project” is configured for ATBTLC1000-MR module with 6-Wire mode. Navigate to Project properties: Project > Project properties > Toolchain > ARM/GNU C Compiler >...
  • Page 16: Compiling And Testing The Project

    Figure 2-9. Selection of Debugger/Programmer Open any Terminal application (for example, TeraTerm). Select the COM port enumerated on the PC and set the following parameters:. – EDBG associated COM Port (Check Windows Device Manager) Training Manual DS00002599A-page 16 © 2017 Microchip Technology Inc.
  • Page 17 If initialization fails, make sure to verify the hardware configuration is aligned with the description, refer to Hardware Setup. The initialization of ATBTLC1000 takes few seconds, due to patch download process. Training Manual DS00002599A-page 17 © 2017 Microchip Technology Inc.
  • Page 18: Establishing Connection With Central Device

    The Bluetooth Low Energy connectivity is added to the application that is used to connect with the Bluetooth Low Energy central. The first step is about the management of Bluetooth connection with a central device. When using ATBTLC1000 device, this process is managed by dedicated API function calls associated with ATBTLC1000 events handling.
  • Page 19: Configuring And Starting The Advertisement Process

    Figure 3-3. Advertisement Process During advertisement, the payload structure to be sent differs from application to application and is set by using encapsulated packet data unit type information (PDU_TYPE). Training Manual DS00002599A-page 19 © 2017 Microchip Technology Inc.
  • Page 20 UUIDs". The number of advertisement data types that can be added to the advertisement payload are limited by the advertisement payload size of 31 octets. Following is a list of advertisement data types that are commonly found in ADV_IND payload. Training Manual DS00002599A-page 20 © 2017 Microchip Technology Inc.
  • Page 21 For management of advertisement process and cover the different configurations specified by SIG, the ATBTLC1000 Host driver provides the two functions elaborated in the following sections. In the application, use these two functions to setup the following ADV_IN type payload.
  • Page 22 – Advertising type to be used, can be: – AT_BLE_ADV_TYPE_UNDIRECTED – AT_BLE_ADV_TYPE_DIRECTED – AT_BLE_ADV_TYPE_SCANNABLE_UNDIRECTED – AT_BLE_ADV_TYPE_NONCONN_UNDIRECTED – AT_BLE_ADV_TYPE_DIRECTED_LDC – AT_BLE_ADV_TYPE_SCAN_RESPONSE • mode – Advertising mode to be used, can be: Training Manual DS00002599A-page 22 © 2017 Microchip Technology Inc.
  • Page 23 Declare the following adv_data global variable in startup_template.c as static. static uint8_t adv_data[] = { 0x08,// AD2 Length = 8 (AD_TYPE + AD) 0x09,// AD2 Type = Complete local Name Training Manual DS00002599A-page 23 © 2017 Microchip Technology Inc.
  • Page 24 " to save the project <Ctrl+S>. Click " " button to compile the project <F7>. Verify that no build error appears in Atmel Studio output window. Figure 3-7. Atmel Studio Output Window Training Manual DS00002599A-page 24 © 2017 Microchip Technology Inc.
  • Page 25: Managing Gap Events

    The management of the Bluetooth connection at the host MCU level is done through reception and handling of events reported by the ATBTLC1000. These events are generated by ATBTLC1000 GAP, GATT and L2CAP layers to notify the host about the ongoing Bluetooth interaction with other devices in its vicinity.
  • Page 26 ATBTLC1000 Establishing Connection with Central Device To manage events coming from the ATBTLC1000 module, the host driver must provide a ble_mgr_events_callback_handler function that allows registration of application callback function to be executed on each event reported by the ATBTLC1000 module.
  • Page 27 Declare and implement the following "ble_disconnected_cb" function in "startup_template.c" file. /* Callback registered for AT_BLE_DISCONNECTED event */ static at_ble_status_t ble_disconnected_cb (void *param) printf("\n*** Assignment 2.2: Application disconnected "); connected_flag = false; start_advertisement(); ALL_UNUSED(param);return AT_BLE_SUCCESS; Training Manual DS00002599A-page 27 © 2017 Microchip Technology Inc.
  • Page 28 Add the following "register_btlc1000_callbacks" function in "startup_template.c". /* Register GAP callbacks at BLE manager level*/ void register_btlc1000_callbacks(void){ /* Register GAP Callbacks */ printf("\n*** Assignment 2.2: Register ATBTLC1000 callbacks"); ble_status = ble_mgr_events_callback_handler(REGISTER_CALL_BACK,\ BLE_GAP_EVENT_TYPE,&app_gap_handle); if (ble_status != true) printf("\n##Error when Registering ATBTLC1000 callbacks");...
  • Page 29 ” to save the project <Ctrl+S>. 11. Click “ ” to program the project binary on the SAM L21 Xplained Pro. <Ctrl+Alt+F5> and check correct initialization of the ATBTLC1000. ™ 12. Open the "Microchip SmartConnect" application on Android or iOS device.
  • Page 30: Setting/Handling Of Pre-Defined Service

    Setting/Handling of Pre-Defined Service Setting/Handling of Pre-Defined Service The management of services are done in the GATT layer of the ATBTLC1000 ROM coded Bluetooth Low Energy Stack. The GATT transactions are based on high-level nested objects called "Profiles", "Services" and "Characteristics" stored in SRAM memory of ATBTLC1000 device. This assignment adds the pre- defined service of information service from ASF library.
  • Page 31: Adding Device Info Service Component From Asf Wizard To Project

    Setting/Handling of Pre-Defined Service In this assignment, the following steps are added to the Host MCU application to set up and handle a device information service within the ATBTLC1000 module. The following steps are added to the startup project: •...
  • Page 32 Click Apply to add the component to the project. Figure 4-5. Adding the Modules to Project The “Device Information Service” component is added to the project and is confirmed by device_information folder added in Solution Explorer. Training Manual DS00002599A-page 32 © 2017 Microchip Technology Inc.
  • Page 33: Configuring And Loading Device Information Service

    Setting/Handling of Pre-Defined Service Figure 4-6. Device Information Service Added to Project Configuring and Loading Device Information Service The ATBTLC1000 Host driver provides a set of GATT functions that allows storing and updating the services in ATBTLC1000 memories. Prototype : at_ble_status_t at_ble_primary_service_define(...
  • Page 34 #include "console_serial.h" #include "timer_hw.h" #include "conf_extint.h" #include "ble_manager.h" #include "ble_utils.h" #include "conf_serialdrv.h" #include "startup_template.h" #include "device_info.h" Define a device info service handler as global in startup_template.c file. /* Services handlers */dis_gatt_service_handler_t dis_service_handler; Training Manual DS00002599A-page 34 © 2017 Microchip Technology Inc.
  • Page 35 API. It is the responsibility of users to keep the device name set in advertisement payload the same as that configured in at_ble_device_name_set(). The Service must now be visible after pairing with peripheral under Microchip SmartConnect application. Training Manual DS00002599A-page 35 © 2017 Microchip Technology Inc.
  • Page 36 “Forget Device” from the mobile settings. The reason for this is that the mobile app stores the previous pairing information, but the ATBTLC1000 device lost the previous pairing information due to RESET since it was stored on temporary storage (RAM).
  • Page 37: Setting Up And Handling Custom Service

    The central is not required to send read characteristic commands explicitly to the peripheral (GATT server). To setup and handle the custom environment service in ATBTLC1000 module, the following steps are added to the Host MCU application: •...
  • Page 38: Configuring And Loading The Custom Environment Service

    Figure 5-2. Custom Service Flowchart Configuring and Loading the Custom Environment Service The ATBTLC1000 Host driver provides the following set of GATT functions that allows it to push and update the service descriptions in the ATBTLC1000 SRAM memory. Note:  Before starting this assignment, be sure to follow the steps mentioned in...
  • Page 39 = AT_BLE_CHAR_READ |\ AT_BLE_CHAR_NOTIFY; environment_service_characs[0].value_max_len = sizeof(uint8_t); // length of temperature value environment_service_characs[0].value_permissions =\ (AT_BLE_ATTR_READABLE_NO_AUTHN_NO_AUTHR); /* Push service configuration in ATBTLC1000 */ if(at_ble_primary_service_define(&environment_service_uuid,\ &environment_service_handler,NULL,0,\ environment_service_characs,1)!=AT_BLE_SUCCESS) printf("\n*** Assignment 4.1: Failed to Initialize custom environment service"); Training Manual DS00002599A-page 39 ©...
  • Page 40 Assignment 4.1: Register GATT Server callbacks"); ble_status = ble_mgr_events_callback_handler(REGISTER_CALL_BACK,\ BLE_GATT_SERVER_EVENT_TYPE,&app_gatt_server_handle); if (ble_status != true) printf("\n##Error when Registering ATBTLC1000 callbacks"); Add custom_environment_service_init and register_gatt_server_callbacks function calls prior to start advertisement in the application main routine to initialize custom service and to register the GATT server callbacks.
  • Page 41 DBG_LOG("Initializing BLE Application"); /* initialize the BLE chip and Set the Device Address */ ble_device_init(NULL); /* Register ATBTLC1000 Callbacks */ register_btlc1000_callbacks(); /* Custom service init */ custom_environment_service_init ( ) ; /* Register Gatt server callbacks */ register_gatt_server_callbacks ( ) ;...
  • Page 42 Note:  Custom service is displayed as unknown service in the above figure, as this service is not a SIG-defined service. Figure 5-5. General Information 16. Serial terminal client must display the following Log output. Training Manual DS00002599A-page 42 © 2017 Microchip Technology Inc.
  • Page 43: Updating The Temperature Characteristic

    Figure 5-7. Characteristic Notification 5.2.1 Setting a Characteristic Value ( at_ble_characteristic_value_set) Prototype – at_ble_status_t at_ble_characteristic_value_set at_ble_handle_t handle, uint8_t *value, uint16_t len) Description – Sets a characteristic value in ATBTLC1000 memory. Parameters – Training Manual DS00002599A-page 43 © 2017 Microchip Technology Inc.
  • Page 44 10 seconds. /* Register GATT callbacks at BLE manager level*/ void send_temperature_notification(void){ /* Register GAP Callbacks */ printf("\n*** Assignment 4.2: Send temperature update notification"); /* Dummy temperature value */ Temperature_value++; Training Manual DS00002599A-page 44 © 2017 Microchip Technology Inc.
  • Page 45 11. Open “Microchip SmartConnect” Application on Android or iOS device. 12. Connect and pair to the peripheral (pass key: 123456). 13. Click NOTIFY to start the notification. 14. Temperature information in HEX values must be displayed in Microchip SmartConnect application. Training Manual DS00002599A-page 45 © 2017 Microchip Technology Inc.
  • Page 46 ATBTLC1000 Setting up and Handling Custom Service Figure 5-9. Notification Window 15. Serial terminal must display the following log output: Figure 5-10. Log Output Window Training Manual DS00002599A-page 46 © 2017 Microchip Technology Inc.
  • Page 47: Appendix A: Software Solution - Pre-Defined Svc

    .connected = ble_connected_cb, // AT_BLE_CONNECTED .disconnected = ble_disconnected_cb, // AT_BLE_DISCONNECTED /* Register GAP callbacks at BLE manager level*/ void register_btlc1000_callbacks(void){ /* Register GAP Callbacks */ printf("\n*** Assignment 2.2: Register ATBTLC1000 callbacks"); Training Manual DS00002599A-page 47 © 2017 Microchip Technology Inc.
  • Page 48 DBG_LOG("Initializing BLE Application"); /* initialize the BLE chip and Set the Device Address */ ble_device_init(NULL); /* Register ATBTLC1000 Callbacks */ register_btlc1000_callbacks(); /* Initialize Device Info service in GATT */ printf("\n*** Assignment 3.2: Start Device Info Service"); dis_init_service(&dis_service_handler); /* Define the primary service in the GATT server database */ if((dis_primary_service_define(&dis_service_handler)) != AT_BLE_SUCCESS)
  • Page 49: Appendix B: Software Solution - Custom Service

    = AT_BLE_CHAR_READ |\ AT_BLE_CHAR_NOTIFY; environment_service_characs[0].value_max_len = sizeof(uint8_t); // length of temperature value environment_service_characs[0].value_permissions =\ (AT_BLE_ATTR_READABLE_NO_AUTHN_NO_AUTHR); /* Push service configuration in ATBTLC1000 */ if(at_ble_primary_service_define(&environment_service_uuid,\ &environment_service_handler,NULL,0,\ environment_service_characs,1)!=AT_BLE_SUCCESS) printf("\n*** Assignment 4.1: Failed to Initialize custom environment service"); else printf("\n*** Assignment 4.1: Initialize custom environment service");...
  • Page 50 /* Register GAP Callbacks */ printf("\n*** Assignment 4.1: Register GATT Server callbacks"); ble_status = ble_mgr_events_callback_handler(REGISTER_CALL_BACK,\ BLE_GATT_SERVER_EVENT_TYPE,&app_gatt_server_handle); if (ble_status != true) printf("\n##Error when Registering ATBTLC1000 callbacks"); void start_advertisement (void){ printf("\n*** Assignment 2.1: Start Advertisement"); /*Set advertisement data*/ ble_status = at_ble_adv_data_set(adv_data,sizeof(adv_data), NULL, 0);...
  • Page 51 ATBTLC1000 Appendix B: Software Solution - Custom Service /* Register GAP Callbacks */ printf("\n*** Assignment 2.2: Register ATBTLC1000 callbacks"); ble_status = ble_mgr_events_callback_handler(REGISTER_CALL_BACK,\ BLE_GAP_EVENT_TYPE,&app_gap_handle); if (ble_status != true) printf("\n##Error when Registering ATBTLC1000 callbacks"); /* timer callback function */ static void timer_callback_fn(void) /* Add timer callback functionality here */ timer_flag = true;...
  • Page 52 Appendix B: Software Solution - Custom Service /* Register Gatt server callback */ register_gatt_server_callbacks(); /* Start Advertising process */ start_advertisement(); while(true) ble_event_task(); if(connected_flag == true && timer_flag == true) { timer_flag = false; send_temperature_notification(); Training Manual DS00002599A-page 52 © 2017 Microchip Technology Inc.
  • Page 53: Document Revision History

    ATBTLC1000 Document Revision History Document Revision History Rev A - 12/2017 Section Changes Document Initial release Training Manual DS00002599A-page 53 © 2017 Microchip Technology Inc.
  • Page 54: The Microchip Web Site

    Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. • Microchip is willing to work with the customer who is concerned about the integrity of their code. Training Manual DS00002599A-page 54 © 2017 Microchip Technology Inc.
  • Page 55: Legal Notice

    SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries. GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries.
  • Page 56: Quality Management System Certified By Dnv

    ATBTLC1000 © 2017, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. ISBN: 978-1-5224-2513-7 Quality Management System Certified by DNV ISO/TS 16949 Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California ®...
  • Page 57 New York, NY Sweden - Stockholm Tel: 631-435-6000 Tel: 46-8-5090-4654 San Jose, CA UK - Wokingham Tel: 408-735-9110 Tel: 44-118-921-5800 Tel: 408-436-4270 Fax: 44-118-921-5820 Canada - Toronto Tel: 905-695-1980 Fax: 905-695-2078 Training Manual DS00002599A-page 57 © 2017 Microchip Technology Inc.

Table of Contents