The demo application provides a
description on how to use the demo application to connect two configured boards and
communicate over BluetoothLE. The included application registers a custom service on
a board when the stack is initialized.
Device 1 (Server) setup on the demo
application
- To start, one of the devices has to have the Alert Notification Service running
on it. It can be started by running Register ANS.
- Next, the device acting as a
Server needs to advertise to other devices. This can be done by running
AdvertiseLE 1.
Device 2 (Client) setup on the demo applicationNote: Steps c and d are
optional if you already know the Bluetooth address of the device that you want to
connect to.
- The Client LE device can try to find which LE devices are in the vicinity using
the command: StartScanning.
- Once you have found the device,
you can stop scanning by using the command: StopScanning.
Initiating connection from device 2
- Once the application on the
Client side knows the Bluetooth address of the device that is advertising, it
can connect to that device using the command: ConnectLE <Bluetooth
Address>
Identify supported services
- After initialization, the Client
needs to find out whether ANS services are supported and what ANS features are
available. For this, DiscoverANS is run on the Client. After the service
discovery operation is complete, the ANS Service Discovery Summary is shown and
list of supported features is shown.
- After getting the list of
supported features, the next step is to configure the ANS on the Client. We can
have support for either New Alerts, Unread Alerts or both.
- In our case, we configure it with
both New and Unread Alerts enabled.
Alert Notification between Client and Server
- After configuration, the Alert Notification system is active. To send alerts,
first the New and Unread alerts need to be enabled on the Client. For this,
EnableNewAlertNotifications and EnableUnreadAlertNotifications
is used.
- For the
EnableNewAlertNotifications command, the following are the list of
options. We can enable either one or all of the options.
- In our case, we enable all of
them at the same time.
- Similarly, one can enable either
one or all of the options for EnableUnreadAlertNotifications. In our case
we enable all of them.
- After enabling the Alert
notifications on the Client side, we can use NotifyNewAlerts to notify the
Client from the Server side. NotifyNewAlerts has options similar to the previous
menu but the accompanying parameter is a bit field and not a numerical option.
For example, to send a Simple Alert we would send NotifyNewAlerts 1. To
send an Email Alert, we would send NotifyNewAlerts 2 and to send a New
Alert, we would send NotifyNewAlerts 4. If we wanted to send both an
Email and a Simple Alert we would send NotifyNewAlerts 3.
- In our case we send a simple
alert for email. Once it's complete, it shows Success.
- On the Client side, it recieves
the alert from the sender and it shows New Alert Status with the category of
Alert (Simple in our case) and the number of alerts (New Simple Alerts which is
zero in our case).
- NotifyUnreadAlerts like
NotifyNewAlerts has the accompanying parameter as a bit field.
- In this example case, we send an
unread email alert. Once, its transmitted it shows success on the Server
side.
- Figure 242: ANP Demo ANS Terminal
15 r) And on the Client side, it receives the alert from the sender and it shows
Unread Alert Status with the category of Alert (email in our case) and the
number of alerts (Unread Emails, which is zero in our case).
We can also get and set the New and Unread Alerts for the different categories,
get and set the Supported categories for New and Unread Alerts, Enable and Disable
New and Unread Alert notifications and Notify Immediately New and Unread
Alerts.