Adding the BLE module to the project

This commit adds the BLE module to the project and adds a
simple event handler for the event that the module uses to notify
the app that the module is ready.

Now when you run the app, the label that was included with
the default project will display "BLE Module is ready!" when
the module is ready.
Adding UI elements

This commit adds all the UI elements of this simple app: a number of labels
and a button that is invisible by default.

The biggest part of this commit is a widget called 'display'. We use this widget
to display all kinds of information, from the module status to the reported
heart rate measurement.
Initialization and scanning

This commit adds the initialization and scanning code. At this point the app will automatically
start scanning at startup and display an alert if it finds a heart rate monitor.

The commit introduces two JavaScript libraries:

1) ble_utils.js holds generic BLE related functions.
2) hrm_utils.js holds functions specific to the heart rate monitore.
Connecting to the heart rate monitor

This commit adds the code that connects the app to the
heart rate monitor peripheral.

When a heart rate monitor is discovered, scanning is stopped
and a connection attempt is made. When the connection
succeeds ('connectedPeripheral' event is received),
the app stores the peripheral object representing the
now connected peripheral and updates the user interface.
Adding service discovery

This commit adds the code that will discover all the services
offered by the connected peripheral and print their UUID.

Ultimately the app will be interested in only two services:
the heart rate monitory service and the battery status service.
These services are identified by their UUID -- the app will
print an extra message when it discovers these services of
interest.
Discovering characteristics

This commit adds the code that discovers and handles
characteristics of interest -- that is, the characteristic
used to report heart rate measurements, and the
characteristic used to report battery status.

The characteristic used to report heart rate measurements
is one that the app can subscribe to, so we do that.
This will automatically result in receiving
updatedValueForCharacteristic events whenever the
heart rate monitor reports a new heart rate value.
We will handle these updates in the next commit.

The battery status characteristic can be polled on
demand -- that's why we the "Check Battery Status"
button. We will add the polling later. For now, we will
just save the object that represent this characteristic
in the batteryChar variable.
Handling connection failures and lost connections

This commit adds two event handlers that deal with
the loss of connection. It is essential that the app
handles these events gracefully, because
BLE communication, like any communication with
a remote entity, can be interrupted at any time.

In this case, the most important task is to restart
scanning, so that the device can be rediscovered
and connection can be established again.
Handling heart rate measurement updates

The heart rate monitor sends us periodic updates
about the measured heart rate. The BLE module
sends 'updatedValueForCharacteristic' events
when this happens. We verify that the update is
for the heart rate measurement characteristic,
and translate it to a 'heartRateUpdate' event,
and in the handler of that event update the
user interface.
Querying battery status

Unlike the heart rate measurements, which are reported
periodically, battery status must be polled. This commit
ties the code that does the polling to the "Check battery status"
button, and adds the code that updates the user interface
accordingly.