beautypg.com

3 how to use ble connections, How to use ble connections, 2 - connection types – MagTek DynaPro Mini Programmer's99875629 User Manual

Page 21

background image

2 - Connection Types

DynaPro Mini| PIN Encryption Device | Programmer’s Reference (Commands)


Page 21

Bit

7

6

5

4

3

2

1

0

Byte 1..n

Command/Response as defined in section 3 Command Set.

IMPORTANT: Generally, iOS commands must be transmitted in MSB (big endian) order.
By convention, this document gives commands in LSB (little endian) order.

2.3 How to Use BLE Connections

This section provides information about developing software for a BLE-capable host that needs to
interface with the device using Bluetooth Low Energy (BLE). In this arrangement, the device will act as
a BLE server/peripheral, and the host will act as a client/central. The custom software wraps commands
in simple Get/Set wrappers, and should use whatever BLE library is appropriate for the chosen software
development framework. For example, iOS custom apps use Apple’s CoreBluetooth Framework, for
which sample code is available in the form of Apple’s Temperature Sensor app; see
https://developer.apple.com/library/IOS/samplecode/TemperatureSensor/Introduction/Intro.html.
Because the command set is common to all connection types, it is also helpful to read section 2.1.1 About
HID Usages
to become familiar with the types of available commands.

In its default configuration, the BLE module can be toggled between Advertising and not Advertising (for
example, for airline travel) as follows:

If the device is Advertising, press and hold the power button for 7 seconds or longer to reset the BLE

module and turn Advertising off. The device will also reset to this state if the battery completely
discharges.

If the device is not Advertising, press and release the power button, or connect the device to USB

power.


Some of the details described in this section may be abstracted by the libraries in the chosen development
framework. For general information about BLE and the associated terms, see the Bluetooth specifications
found at https://www.bluetooth.org/Technical/Specifications/adopted.htm.

The general steps for a host to communicate with the device via BLE are as follows. Refer to Table 2-3
for details about each BLE Characteristic (in this case, “Application” refers to the device):

1) If the device has been recently reset or has had its battery replaced, re-enable BLE Advertising by

pressing and releasing the power button or connecting the device to USB power.

2) Scan for nearby BLE peripherals advertising the desired GATT service UUID.

3) If multiple devices of the desired type are available, examine each device’s name property. A

specific device’s default name is a constant, equal to the product name plus a dash and the least
significant 4 digits of its Bluetooth address.

4) Establish a BLE connection with the device. If the device is not already powered on, it will start

powering on when the host establishes a connection. The power-on sequence takes about 10 seconds.
Any application data the host sends before the power-on sequence is complete will be lost.

5) Pair with the device using passkey 000000. In many cases this step is user-driven.

6) Configure the device to notify the host when the Application Data To Host Length

characteristic changes. The host should then use this notification as a trigger to read the
Application Data To Host characteristic and process incoming data from the device. The
specific method to enable notifications for a characteristic is different in different BLE development
libraries. For example, iOS code would be similar to [servicePeripheral
setNotifyValue:YES forCharacteristic:characteristic].