Windows Phone 8.1 Bluetooth Low Energy Development-Nokia Treasure Tag

Windows Phone 8.1 Bluetooth Low Energy Development-Nokia Treasure Tag

1 Introduction

The previous article " Windows 8.1 Bluetooth Low Energy Development " described how to create a low energy Bluetooth application on the Windows 8.1 platform, and took TI's Sensor Tag as an example to give code steps and demonstrations. In fact, many current low-power Bluetooth application scenarios are connected to the user’s mobile phone. For example, TI’s Sensor Tag officially provides Android and iOS client applications (unfortunately there is no Windows Phone version, but now you can go to the Store I downloaded the Sensor Tag application developed by individual developers, and it just appeared in the US market some time ago). Another example is the 79 yuan bracelet that Xiaomi just released, which is also connected to Android devices through low-power Bluetooth. Today, let us take a look at how to develop low energy Bluetooth applications on Windows Phone 8.1.

2. Equipment

Most Windows Phone 8 devices support Bluetooth 4.0 BLE in terms of hardware, provided that the system must be upgraded. Taking Lumia devices as an example, it needs to be above Black. Moreover, judging from the news at the Build conference, most developers' Developer Preview systems currently do not support Bluetooth 4.0 BLE in software. However, the Windows Phone 8.1 Update 1 held in China just yesterday indicated that 1520, 1320, 1020 and other devices will soon usher in this critical system update. After the update, Bluetooth 4.0 BLE applications can be developed. In addition, Lumia 630 and Lumia 930 are native Windows Phone 8.1 systems that are already available on the market. They support Bluetooth 4.0 BLE. Here, I am using a Lumia 630 device, and the system version number is 8.10.12359.845.

The Bluetooth device uses the Nokia Treasure Tag, which is sold on Taobao, but it seems that there is no licensed product in China. For this little thing, I think many people may not know. In fact, this thing is more useful for people who are sloppy and love to throw things. We can hang the car key on it, or put it with important things such as wallets, and connect it with the mobile phone via Bluetooth. As long as the tag is connected to the mobile phone. If the distance exceeds a certain range, the mobile phone and Tag will send out an alarm to remind the user. When the distance between the mobile phone and the Treasure Tag is very far, the location can be located through the HERE map. There is a dedicated Nokia Treasure Tag application in the Store, which is used to achieve the above functions. The equipment used in the experiment is given below. The left one is Treasure Tag, the middle one is Lumia 630, and the right one is the key to be tracked, as shown in Figure 1.

figure 1

3. Preparation

If the Treasure Tag is used for the first time on Windows Phone, we need to pair it. After the pairing is successfully used for the first time, there is no need to perform this operation later. 1. turn on Bluetooth in Settings->Bluetooth, wait for Nokia Proximity Sensor to appear, then click pairing, the PIN code is 0000. As shown in Figure 2 below.

figure 2

After connecting, we can create an application.

4. Create an application

    Regarding the application processing of Nokia Treasure Tag, you can refer to the course " Building Great Bluetooth Apps for Windows Phone " at this year's Build conference . You can see this video on Channel9 at present. The code corresponding to this video can also be found on the code sample webpage of msdn: Keep The Keys (Bluetooth LE) . The source code project contains three projects: KeepTheKeys, KeepTheKeysBackground and KeepTheKeysCommon.

The following points need to be paid attention to:

4.1 In the Package.appxmanifest file of the application, add the following Capabilities, because this is related to the Bluetooth communication of the Treasure Tag:


<m2:DeviceCapability Name="bluetooth.genericAttributeProfile">

<m2:Device Id="any">

<m2:Function Type="serviceId:1803"/>




4.2 Background tasks

Regarding the task of Treasure Tag, it runs in the background. This project is a winmd project.

4.3 In the main project, you need to add a reference to this background task, as shown in Figure 3 below.

image 3

4.4 In the Application of the Package.appxmanifest file, set "Toast capable" to "Yes", because the application uses Toast messages, as shown in Figure 4 below.

Figure 4

4.5 In the Declarations of the Package.appxmanifest file, add the item "Background Task" and set its EntryPoint to "KeepTheKeysBackground.KeyFobTask", as shown in Figure 5 below.

Figure 5

4.6 The service provided in the Treasure Tag is the standard LinkLoss service in GATT Service, and does not include other services such as TxPower.

After the application runs, the main page displays the device page, which is the current BLE 4 device that Bluetooth can search for, as shown in Figure 6 below.

Figure 6

Click Nokia Proximity Sensor among them to set the alarm. As shown in Figure 7 below.

Figure 7

After the Tag is far away from the mobile phone, the Tag terminal will emit a voice prompt. A message will also appear in the Action Center on the mobile phone, as shown in Figure 8 below.

Figure 8


1. Channel 9: Building Great Bluetooth Apps for Windows Phone

2. MSDN Code Sample: Keep The Keys (Bluetooth LE)

3. Windows Store: Nokia Treasure Tag

Reference: Windows Phone 8.1 Bluetooth Low Energy Development-Nokia Treasure Tag-Cloud + Community-Tencent Cloud