Introduction to Bluetooth support on Windows Phone 8
This article aims to briefly explain the current WP8 Bluetooth capabilities and later focuses on exploring the near future opportunities that a WP8 developer should keep in mind with regards to Bluetooth 4.0 and more specifically Bluetooth Low Energy feature.
Article Metadata
Contents |
Introduction
Bluetooth is a wireless communication technology through which devices within 10-meter proximity can communicate with each other. It is a simple, secure, and widely adopted technology. It can handle both data and voice for wireless communication which facilitates its real world application in various areas from hands-free headsets, file transfers, health sensors,printing, synchronizing desktop and mobile phones, and the list goes on.
Windows Phone always had this technology inbuilt but was having limited Bluetooth capabilities. But with WP8 this scene has changed dramatically and it adds much more functionality to the Bluetooth stack.
Why Bluetooth when NFC is around?
NFC is relatively a new technology to Bluetooth and WP8 developers are more enthusiastic in exploring its features. Well certainly this is great and we must explore NFC capabilities, but at the same time we should not ignore the opportunities that Bluetooth 4.0 and especially BLE will be offering.
In upcoming 4-6 months the market will be flooded with sensor devices enabled with BLE due to its 'unique' low energy communication, efficiency and cheap production. WP8 developers should keep an eye on this and be ready to make use of the opportunity and 'Time It Correctly' to the market of Smart Bluetooth Ready devices like WP8.
WP8 Bluetooth communication
WP8 supports two Bluetooth communication scenarios: app to app, and app to device. The communication is established using a StreamSocket connection.
App to App
In this communication, one phone will be a “server” — listening to incoming requests and responding to them — and another phone will be the “client” — connecting to the server and issuing requests. When both apps accept the connection, a stream socket is opened between them, through which the apps communicate.
Example code can be found on the below link which is developed by Windows Phone SDK Team and demonstrates basics of app to app communication: Bluetooth-app-to-app-sample
App to Device
In this communication, an app uses Bluetooth to find a device that is offering a service that the app wants to access. When both the app and device accept the connection, a stream socket is opened between them, through which the app and the device communicate.
Example code can be found on the below link which is developed by Windows Phone SDK Team and demonstrates basics of app to device communication: Bluetooth-app-to-device
For more information on Bluetooth API, see Bluetooth for Windows Phone 8
Serial Port Profile (SSP)
A Native SSP API doesn’t exist out of the box in WP8 SDK as of now, but that doesn’t limit the developers from using SSP. Developer needs to push a bit more and can built a self-implementation of SSP using RFCOMM and getting a socket via peerfinder.
Although the focus of this article is about understanding the WP8 & BLE opportunities, the below small code snippet will help developers in avoiding a common mistake while implementing SSP:
STEP 1: Connect to the desired device over RFCOMM
PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = "";
var available_devices = await PeerFinder.FindAllPeersAsync();
if (available_devices.Count == 0)
{
return false;
}
else
{
PeerInformation pi= // Get the required device using
// index or searching for the device name
}
StreamSocket socket = new StreamSocket();
await socket.ConnectAsync(pi.HostName, "1");
STEP 2: Direct winsock to perform an SPP lookup
await socket.ConnectAsync(pi.HostName, pi.ServiceName);
Example:
await socket.ConnectAsync(pi.HostName, "{21EC2020-3AEA-1069-A2DD-08002B30309D}");
WP8 and Bluetooth 4.0
Currently Windows Phone 8 supports Bluetooth 3.1 and includes compatibility with following profiles:
- Advanced Audio Distribution Profile (A2DP 1.2)
- Audio/Video Remote Control Profile (AVRCP 1.4
- Hands Free Profile (HFP 1.5)
- Phone Book Access Profile (PBAP 1.1)
- Object Push Profile (OPP 1.1)
- Out of Band (OOB) and Near Field Communications (NFC)
But the good news for the developers is that both the Lumia 820 and 920 will support Bluetooth 4.0 as per Bluetooth.org. Bluetooth WCN3660 chipset exists in Lumia 820 and 920 which not only has Bluetooth 4 capabilities but also has an FM transceiver, so it’s just the matter of time that WP8 will get a stack update. And due to its real world need and demand Microsoft will certainly put the required update soon.
There are two important terms that need to be understood:
Bluetooth Smart Ready Devices
These devices that receive data sent from Bluetooth/ Bluetooth Smart devices and with the help of sophisticated software mechanism transform this data into useful information.
So when our WP devices will receive the BT 4.0 support they will fall in this bucket and be known as Bluetooth Smart Ready Devices.
Bluetooth Smart Devices
These are the devices which gather the raw data and sent it to Smart Ready devices for further processing of the retrieved raw data.
Examples: Heart-rate monitors, blood-pressure meters, sport gadgets, etc.
WP8 and Bluetooth Low Energy (BLE)
Bluetooth 4.0 includes various improvements (like fast speed) but most significant feature is the support for Bluetooth Low Energy (BLE) devices. It will enable to aggregate data from various Smart Bluetooth devices, like heart rate monitors, sport gadgets, thermometers, etc. Devices using BLE are expected to consume much less power and faster set-up time as compared to the older Bluetooth devices. Now with BT 4.0, your Bluetooth devices are expected to work for years using the small button battery.
The Lumia devices are specified to have BLE capabilities and as mentioned above we expect a stack upgrade coming to WP8 and then the WP8 devices will be ‘Bluetooth Smart Ready’. Once this is done it will open immense opportunities for WP8 developers to interact with a lot of ‘Bluetooth Smart’ devices which will change the way people interact with objects in real world.
Let’s have a look at the various kinds of WP8 applications that can be developed to take benefit of this technology:
Home Automation & Security
It will be cheap and easy for companies to add the wireless connectivity to home appliances and all those smart devices can connect to your WP8 Smart Ready devices to take the appropriate actions as specified by the users.
Following WP8 apps can be developed:
- Morning TeaMaker - An app that will trigger the TeaMaker once the morning alarm in your phone is activated.
- Home Security – An app will receive data from web cam for movement and triggers alerts based on that. The same app can also receive data from door (equipped with Bluetooth chipset) movements.
- Auto Lights on/off - An app that will trigger the lights of lamps inside your room as you enter or leave the room.
- Room Temperature control - An app that reads from thermometer and sends appropriate adjustment signals to you Air conditioner.
- Multimedia control – An app to control your T.V/Music/Radio systems. Now all have just a single common remote control i.e WP8 device. App can also be programmed smartly to auto shutdown media devices at a specific time at night.
Health Monitoring
Health segment will be the most important market that WP8 developers should target. In a study, analysts predicts that Global Wearable Wireless Sensors market to grow at a CAGR of 110% over the period 2010–2014. WP8 apps can receive data from this body sensors and process the data.
- Heart Rate monitor – An app that tracks your heart rate through the Heart rate sensor device.
- Glucose meter - An app that tracks your glucose level through the Glucose level sensor device.
- Calorie Tracker - An app that tracks your calorie burned through Trade Mills, cycling, etc.
- Blood pressure monitor - An app that tracks your blood pressure through the Blood-pressure sensor device.
Sports Monitoring
Athletes and sports professionals take their sports activities very seriously and technology is striving to help them to track their improvements and activities to give them concrete results to analyze their performance.
- Pedometer - An app to track daily exercise.
- GPS Activity Tracker - An app to track how far you can walk, run or cycle and store your daily records.
- Heart Rate monitor – An app that tracks your heart rate through the Heart rate sensor device.
And even as we speak, we can see some great gadgets already in market manufactured by leading sports company – Nike.
- Nike+ basketball and training shoes
- Running Tracker
All the above App development scenarios are just a few samples; possibilities and real world opportunities are endless.
Summary
BLE has a lot of potential to change the way we interact with devices and the way devices interact with each other. With Smart Ready WP8 we can make life of common man even better and in a cost effective way.
References:
Bluetooth for Windows Phone 8
Bluetooth
Nokia_Lumia_920_and_820_certified for Bluetooth 4.0



Contents
R2d2rigo - Validity of the first two sections
I have found that the "Introduction" and "WP8 Bluetooth communication" sections are a reworded version of http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007(v=vs.105).aspx . I don't know if this conflicts with the wiki's license or content guidelines, perhaps a moderator can shed some light in this?r2d2rigo 23:49, 9 December 2012 (EET)
Hamishwillee - Does it value add?
R2d2rigo - thanks for pointing this out. We are concerned with issues of plagiarism and copyright. Copyright is a legal matter about ownership of content and ideas. The law for copyright is complex (at least to me!) but most cases some content can be reproduced for educational purposes (or with permission). Plagiarism is more a "moral" matter, that you don't use someone else's content without acknowledgement - I take this quite seriously, particularly in a competition.
So as a rule I'm OK with small copies of information provided they aren't direct copies, that they add value to a "bigger story" and that the origin is attributed (ie I read this article to get my source material). I think that in this case they do need to attribute the source articles used - then it is clear that what this article does is pull together an overview of the bluetooth story for WP8 from a number of sources, and what those sources are.
Aady, R2d2rigo Does that make sense?
(and as an aside, the introduction at least is pretty much a "public domain" description of Bluetooth - ie this sort of wording is used everywhere.)
As an article I don't find the structure convincing - it partially covers code about working with the APIs but does not do so anywhere near completely enough to use. On the other hand, if it was more complete then it would be a more direct copy of the document you pointed to - and there is no point in the duplication.
Where I see its values is as a technical but non-code overview of:
So suggest remove the code - briefly explain the operations that can be done and point to the article. This of this as a product change guide, not as a "how to".
Again, hope that makes sense
Regards
Hamishhamishwillee 08:45, 10 December 2012 (EET)
Aady - Thanks R2d2rigo for ur feedback
I wont agree with you on that, but may be Hamish can guide appropriately on this, I will wait for his review. And thanks for you continuous feedback , which motivates me to improvise my articles and make them more perfect...
Warm Regards,
AadyAady 08:46, 10 December 2012 (EET)
Aady - Thanks for ur feedback & suggestion
Hi Hamish, Thanks for your review.
There is a reason behind this kind of article structure. Its completeness should not be defined in terms of coding capabilities of WP8 and bluetooth as that is already covered in DevCenter and i have provided links to MSDN examples. As you correctly mentioned, article's main focus is to give a quick info about the past, present techniques (in short) and mainly focuses on what the developers should be looking forward for and give focus on the bluetooth technology and its capabilities. As i could see many of the developers are too much more focused about NFC being a new explorable technology compared to bluetooth.
The reason i added the small code spinet and from my perspective it is a added value cause, the regular coding approaches are already defined in MSDN devcenter: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007%28v=vs.105%29.aspx
But there is a common area where the developers get confused and my code section just ensures that the developers dont get stuck at that point and wonder why the code as given on MSDN dont work.
Let me know if you still have a different view or any other suggestion.
Regards,
AadyAady 09:11, 10 December 2012 (EET)
Hamishwillee - Rename/warning
Hi Aady
The article title is a problem for me because it implies support for a feature we don't support - BLE. This is confusing for users, who might only read the title and also deceptive because we don't know when the support will come. I have changed the name to be more general (and indeed be more accurate for what is covered by this article), and also added explicit warning that we don't support the feature yet. Please change the introduction in line with this more general title. If you strongly disagree then I would prefer not to host this article on the wiki at all.
To me the new title now makes the article make sense - you have a description of the BT support, you make clear we support BT 4.0. You talk about BLE support, but its not the main feature.
With respect to my previous comments I stand by them.
Regards
Hamishhamishwillee 00:35, 11 December 2012 (EET)
Aady - Sounds good to me
1. Article title change - no issues 2. Warning image on top - gr8 waz never aware of this feature.. 3. Link to reference - this was already added in below the section. 4. Code removal - will consider on that suggestion.
Thanks & Regards,
AadyAady 08:11, 12 December 2012 (EET)
SmithDouglasJ - WP8 and Bluetooth 4.0 (BLE)
This is the best discussion I have found between forums on devices that would benefit from or require BLE usage (FitBit) or Microsoft's own forum. I am interested in using devices for Health and Sports monitoring, but no such devices make apps for WindowsPhone because of Microsoft's failure to integrate Bluetooth 4.0 into WindowsPhone OS.
I have a Nokia Lumia 822 (Verizon) and I love it, but the apps are just not there. Big business is not making their apps for WindowsPhone, and this is just one of the OS's shortcomings. When will Microsoft fix this? I have had the phone for six months, bought with the expectation that after a few months, developers would start making apps for a Microsoft product, but no luck. Now I realize it's because the platform is inferior? Disgusting.
Please, those in the tech community, pass on these concerns to Microsoft. Their OS is failing me.SmithDouglasJ 00:10, 21 May 2013 (EEST)
Hamishwillee - The right place to report feedback to Microsoft
Is herehamishwillee 03:30, 21 May 2013 (EEST)