 Felly, gynch e again welcome to everyone I am stressing the welcome, not just because I am like that But because I know there are all sorts of very interesting talks you could be at But you're here so thanks a lot for coming So, I'm Martin Oooh things happening behind me That's a bit disconcerting I'm Martin and I work for the Bluetooth special interest group We are the standards organisation behind Bluetooth technology Importantly we don't make things, we are not a manufacturer of any sort We don't make products, we don't make commercial software apart from a few tools people use to progress their products through our processes. I'm going to talk about Bluetooth and location related stuff today but largely because Bluetooth 5.1 core specification to give it its full name, released earlier this year around January I think it was, has a new thing in it relating to location which is quite interesting. I'm largely looking to talk about that. I don't know that it's necessarily in Linux at this stage because it's quite new, but history tells us that the Blue Z guys tend to adopt new Bluetooth features, so I'm hoping we'll see it, but hopefully you'll find an interesting topic anyway, and if not most of you at least got a sticker. My primary responsibility is sticker distribution. Anyway, let's make a start. So, bluetooth has been used for location-related stuff, actually for quite a long time. I'm not sure what it's the first thing people think of when they think about bluetooth, it almost certainly isn't. But we see the world of location-related services as depicted by the slide. Possibly we got this from industry analysts, I'm not quite sure. Two major groupings of use case, proximity solutions per the name, all about being near to things and detecting that. i ddim yn diwyliadau. Roedd beth oedd ymddangos o'r ei wneud o'r gweithio. Rwy'r holl o'r hyn sylweddau o'r cyflwyddau i weld y nifer o gyflwyddau a'r cyflcefyddo. Rwy'n eich cyflwyddau o'r cyflwyddau, yno, ddim o'n ddwybod o'r cerddur o'r cyflwyddau. Rwy'n eich cyflwyddau o'r cyflwyddau, a'r gweithio'r cyflwyddau o'r cyflwyddau o'r cyflwyddau o'r cyflwyddau, mae'n cyflwyddau o'r cyflwyr, o wneud o ddweud o'i llwybod, fraywch hwn yn facultydd o'i sgol i ddeithas o'r ystyried rhagor, o ph reprwn o'r ymdryg o'i ddweud. Rydw i wedi gael llawer o'r arlenni ar y Llyfrgell. Yn oedd y byddai'n cael ei holleg y ffordd o'r ardalon, o bryd o brydio'r byddai i weithio. Mae oedd yn oed i ddwylo gwir i fodraethiaid y ddweud, mailluio mewn gwahog o'i gyffredin iawn o decheg, a'r hyn o gweineidio cyfrannu olaf o bobledion o'r cyfrannu olaf sy'n ffuraf, byddwch ym mher yn ei gweinio'i amhael o'r rhagorau, at gwahanol o'r cyfrannu o'r rhai o'r informatio. Rwy'n cael o'r cyfrannu o fanaf, yn dwi'n fflu gemodd y byd. Mae'r bwysig arnyn nhw'n ei wneud ar hyn oherwydd o'r circh a chyfrannu cael o'r le pleidiau. A'r cwymau sy'n cyfrannu erfyd phob argoffol hyn, Please. Thank you. The fact is we've had Bluetooth capabilities largely in the form of profiles that sort of fall under some of these headings for a long time. So we've got the proximity profile and the find me profile. They're variations on the same thing. The find me profile is to do with finding lost objects that have tags connected to them, things like keys. Normally is the example cited in the proximity profile is like that, but it can do more than that. It kind of keeps you close to things you don't want to get far away from. Profiles, if you're not clear, are specifications that tell you how Bluetooth should be used in a given context for a certain product type. And we have the core specification, which is this is how Bluetooth works, how Bluetooth stack works. That's the difference between the core spec and profiles. Profiles are about particular applications. We've got the indoor positioning profile, which, per the name, is all about being able to figure out where someone is indoors. But in the middle, the big success story, I guess, is not something which was standardised by the Bluetooth Special Interest Group or even invented necessarily by us. And that's the beacon. I mean, raise your hand if you know what a Bluetooth beacon is. That was rather than, you know, highlight the people who've never heard of beacons. But most of you have. So beacons are actually really simple devices. I think, you know, we can credit Apple with being the first to sort of drive the beacon, the beacon revolution. Is that like a marketing guy now? So Bluetooth Low Energy has a capability called advertising. I think its kind of predominant purpose was to allow devices to be discovered. Really its connection was broadcasting of small amounts of data. Packets are structured. You can't just put anything in there. There are some rules to follow. But typically a device will be advertising so that some other device can find it and connect to it. Along came Apple. I think this is the story and decided that they could put some other stuff in those advertising packets. Not be concerned about things connecting. In fact, you don't have to allow connections to take place. And thus arrived on the scene, this thing called iBeacon. So iBeacon is Apple's kind of message format, if you like, that sits inside Bluetooth advertising packets. And on the whole, it basically contains a unique ID. So with an application on your, let's say, mobile device, you can be walking along and the phone starts to receive these kind of beaconing packets. The application will have a look at the unique ID, match it against the database of these numbers and go, aha, we're in range of beacon number one, two, three, four long number. Therefore the user must be in this place. So that's how beacons work. And, you know, by adjusting signal strength, you can make that more or less accurate, low signal strength. You have to be pretty near to that beacon to receive its advertising packets. Stronger signal strength, you're going to be further away and so the accuracy is lower, but, you know, it depends what your requirements are. So beacons arrived, Google followed with their own format called Eddystone. And there are in all sorts of places now, one of my local airports in London has something like two and a half thousand beacons deployed in it. And some services for phones provided by the airport authority that run that airport. So beacons have been quite a success really and perhaps the best known of the location services that Bluetooth has today. However, one of the limitations is that if I receive an advertising packet from a beacon of some sort, let's say, on my phone, all I know is that it's somewhere in range. It could be behind me. It could be it's over there. I don't know anything about where this thing actually is. Likewise, with the earlier sort of generations of things like keyfinders, I don't know what direction these things are in. I only know that I'm somewhere near to them. And so the grey area on my slide kind of tells me, you know, that I'm somewhere in that kind of doughnut shape, but I really don't know where on that circle I am because I've got no way of knowing the direction that that signal is coming from. If I did, then I'd have a much better idea of where I am per the thrilling slide, what I made. So things like, you know, item finding, I've lost my keys, become quite amusing and remind me of a game I used to play as a child. I'm always wary of kind of volunteering this personal information to complete strangers in case you're thinking, what a weirdo? What was he doing, spending his time doing that sort of stuff as a child? But we did used to play a game where a thing would be hidden, you'd have to try and find it and friends or family would be saying, Warb or warmer as you got closer, colder, colder if you walked in the wrong direction. Tell me, did anyone else play this game or was it just, I'm amongst friends, fellow weirdos perhaps. And that's how things work with the kind of current generation of keyfinder things. You know, you really don't know what direction you're in but you'll have an application that will be using colour coding or something to tell you, you know, you're walking in the wrong direction so you'll walk back and eventually you'll find the thing. But if only we knew the direction, the signal from the key finding tag was being transmitted from, we'd walk straight towards it, much better user experience. And in fact, with direction, new things become possible as well. So one of the use cases we're thinking about and anticipating kind of arriving on the scene in mobile applications is what we call directional discovery. So you point your phone at specific things over there and you get information about those specific things because your phone plus the Bluetooth direction finding capability I'm going to talk to you about knows what you're pointing out rather than I'm in a room full of paintings by Picasso or someone French even, Renoir, I don't know. You know, I'm pointing at that specific painting so I get information about that. So new things become possible with direction finding and that's precisely what the Bluetooth 5.1 specification delivers a new capability that allows data from which very precise angles can be calculated so you can build all sorts of new products and applications. So I'm not going to talk about that and start here. So in terms of methods and kind of architectures, there are two ways in which you can use this new Bluetooth technology to arrive at an angle which tells you where a signal is being transmitted from. The first is called angle of arrival. And in angle of arrival, the receiving device has more than one antenna. It has an array of antenna, an antenna array even, we could say it that way. Whereas the transmitter just has one. So the transmitter is transmitting a special signal called a direction finding signal I'll tell you more about what that really is in a few slides time but this other device has an antenna array and through some magic can use that to figure out directions. There is of course no magic. Nobody's crying, that's good, you're all engineers so I'll talk to you about the stuff that isn't magic as well. So the other way of doing this is that architecture is angle of departure and it's the transmitting device that has the antenna array and it's the receiver that has to figure out the direction the signal is coming from using data that's in the signal and some knowledge it has of the transmitting device. Those are the two fundamental choices available to you. This one we see being used as the basis window positioning system so those you could almost think of as Beacons generation 2 almost indoor GPS with devices installed all around airports and big buildings you're walking along with your smartphone that only has one antenna in it but thanks to the angle of departure capability it can figure out where that signal is coming from therefore that beacon is over there and we can get much more precise locations calculated accordingly. An antenna array is kind of outside the scope of this talk and very much outside my knowledge as well and it's in various shapes and form as you can see and these are kind of implementation decisions that manufacturers who are into the hardware side of things will be left to figure out for themselves. Accuracy of course is a question about this kind of thing so if we go back to generation 1 beacon those things that just broadcast a kind of unique number I beacon, Eddystone, whatever they are you know you read different reports about how accurate people believe their solutions to be but from my own personal experimentation I'd say you know you're kind of pushing it to get better than a couple of metres accuracy and again you don't know anything about direction but you can use signal strength and a path loss calculation to estimate how far you are from something so still within that donuts region that I talked about there's still quite a significant margin of error which might not matter it all depends on your requirements it's all about fit for purpose solutions of course with the new direction finding capability though you can get way better results and you know we have companies we know who are already using the techniques I'm in the process of describing to you and they will tell you they get 10cm accuracy under the best conditions lots of variables inside buildings, materials and walls and stuff all can have an impact on just how accurate you can be but that leads you into a whole kind of design methodology for your system as a whole as opposed to the stuff relating to the technology which is my fields the potential though is there to get very very accurate and you know calling it indoor GPS actually seems quite a reasonable idea it's way better than GPS in fact in terms of accuracy if I remember my GPS figures correctly so one thing to know make sure you've got on screen what I've got on screen suddenly paranoid that you're not seeing what I'm seeing one of the things, one of the tricks of the trade if you like is this in some solutions you will deploy direction finding beacons around your buildings they'll have a two dimensional antenna array in them and one of the things you'll do from things like smart phone applications or whatever other devices you're tracking is calculate two angles from that one signal you can calculate a signal which is relative to a horizontal plane and an angle which is relative to a vertical plane because these things will be on the ceiling so I know it's over there towards the AV guys but I also know it's up there so you end up with two lines and where they cross that's where we get the most accurate calculations of angle where those two signal directions cross in space so I want to tell you how this stuff works because that's where of course it always gets interesting I've just studied physics at school or college or what have you I've got a few physicists in the audience that's quite worrying who's seen the TV show The Big Bang Theory Le Thierry Grom, I don't know who did French at school for me, I'm sorry so you all know enough physics here because we actually have to drop down into the world of physics to understand how this stuff works the fundamental basis of Bluetooth direction finding capability has been around since the middle of the last century radio communications has been around since the 1890s of course so we haven't invented this technique with standardising the way that it should be used with a Bluetooth radio so here we go waves could have shown particles of course but for our purposes we need to consider radio energy to be waves again you've all seen Big Bang Theory which is great so as you know waves kind of look like that they are repeating, let's say they're all sine waves they kind of go up and then down and then that repeats that's called a wave cycle and there is a wavelength wavelength is not an abstract idea it is a physical length Bluetooth, the wavelength is around 12.5 centimetres but it depends on the frequency the wavelength will vary according to the exact frequency being used and Bluetooth uses lots of different frequencies 74 when two devices are connected with a Bluetooth low energy link so lots of different frequencies involved the wavelength will vary slightly according to the one in use at a particular time we hop around, do lots of different frequencies through a process called adaptive frequency hopping another concept for you to know as we lead towards understanding how this works is phase, this is a really important one so consider a wave passing across an antenna at any point in time we are part way through that wave cycle we may be exactly at the start in which case we say the phase is zero measured or expressed as an angle maybe we're half way through it in which case we'll say we are pyradians the phase is pyradians or it's 180 degrees depending on your preferred units of measuring angle so it's 360 degrees is a full cycle of your wave got it, physics lesson didn't know this was going to happen did you the doors are locked, we're good so for a given fixed frequency which therefore gives us a fixed wavelength the following becomes true if you imagine a transmitter in a fixed location and it's transmitting sometimes attempting to think of radio transmissions as kind of going we're kind of transmitting from here to here in actual fact it's more like dropping a stone in a pond the energy is ripples resonating outwards from the point of entry of that stone in the pond same with radio communications if we place two antenna to receiving antennas at exactly the same distance or rather on the circumference of one of those ripples they are therefore exactly the same distance from the transmitter agree my ripples are circular that's basic geometry and maths consequently if I was to measure the phase of the wave as it passes over those two antennas at exactly the same time I'll get exactly the same value it's the same wavelength because it's the same frequency therefore I absolutely must get the same phase value and this becomes useful because wavelengths we know around 12-12.5cm if I'm halfway through that wave cycle in other words my phase is pyrageons 180 degrees that's 6.25cm from the beginning of the wave suddenly we've got a way of deriving distance information from transmitter from this phase thing and again this stuff comes from the beginning of last century we didn't just make it up sorry come on laptop it's refusing to work so if we look at it on its side it kind of looks like this so oh I know why it's because I did something wrong there what an amateur so next stage in the explanation had I not done it wrong is this if I move one of my receivers so it's a little bit nearer to the transmitter as long as I do that by a delta that is not an exact multiple of the wavelength then if I measure the phase at exactly the same time on the two at the two antenna I'll get a different value now okay agree make sense lots of nodding please okay there will be a test and if we look at that sideways on it kind of looks like this okay so if one of my antenna is X from the transmitter we'll get a phase value of pi if another one is further away that's my distance why on the slide there I'm going to get three pi over two had to check that one three quarters of the way into the wave cycle you get the idea this information becomes useful for us and is the basis for calculating angles because if I have multiple receivers and with an antenna array that's what's going on in my system the calculation of angles becomes basic trigonometry now I'm not going to I mean you'll run screaming from the room if we go into the formula on screen here but that's copied and pasted from the Bluetooth course specification we all did trigonometry at school I guess apart from you guys that did arts nothing but arts but then changed course in later life right so trigonometry is not difficult maths so that's the whole purpose of this slide under the hood there's some phase difference related calculations going on using some basic trigonometry we can now derive an angle and that's what we're looking for that was the holy grail now one further thing to tell you what is it that's measuring these phase values from radio waves flowing over antenna well the process is called IQ sampling which I'm guessing most of you have heard of who's heard of IQ sampling approximately 52% of the room very good so IQ sampling I think is used in lots of applications it's probably used in audio isn't it sampling of certain sorts is it's just measuring amplitude and phase values from some form of signal at certain intervals so IQ sampling is the process that the Bluetooth stack will use if it's asked to to start to measure phase and amplitude values from signals incident upon its antenna that's what's going on behind the scene now this stuff is I would acknowledge because I was perhaps where you are today a year ago a nightmare to visualise is it not it's hard enough to explain in words nevermind pictures so me being me I did decided I really need to see what's going on visualise this stuff so I wrote something to help me kind of understand what on earth was happening here and you can't see it because PowerPoint still has I wondered why actually it's not PowerPoints AV team I have a slight problem could you please make my web browser appear on screen is it ah it's because we have an extended monitor going on here computers such a nightmare excuse me mouse control problems now or windows doing annoying things so I'm going to talk to myself and you're going to hear it all on the mic should be music this is real pain I don't know if I changed a single like not extended monitor whether I'm going to break the entire AV setup I'm going to do it anyway and if you don't get to see my amazing um visualisation thing then that's just unfortunate really maybe that's that work I'm like an AV guy's nightmare now doing this live on stage for that work I shouldn't have done this now let's try two then I know we should have tested this yeah I can't even see this now let's revert yeah I think you're going to have to just imagine my incredible visualisation which is a shame because it really is quite remarkable duplicates will that work who knows windows I don't know what I'm doing oh promising let's kill that let's go to here God I hate computers so let's pretend none of that happened and that none of it was videos please edit that out so what we got here then is it's just a web page actually in some javascript I kind of knocked up so we've got the white thing is meant to be an antenna we have a radio wave passing across it massively slowed down from the speed of light the red number and the blob is the radio phase varying from 0 to 360 degrees okay as the radio wave passes over it if I add another antenna and another and because I've carefully placed my antenna at distances that are not exact multiples of the wavelength you can see that I'm getting different phase values at a given point in time can you all see that after all the trouble I went to please say yes now if I switch on IQ sampling this is what's going on if you watch the yellow number that's me sampling from this antenna then this antenna then this antenna I'm kind of moving through my antenna array according to a strict sequence and timing and I'm sampling values from each antenna as the radio wave passes over it that's fundamentally what's going to be going on when you enable the direction finding stuff let's move back to power points which I've decided is in fact my friend there we go so you have a good mental image now so there's one other thing to know about so we're relying here on using phase measurements and their correspondence with wavelength to give us distances from which we can do some trigonometry which gives us an angle that's kind of the building blocks of how the system works but there is one other issue I mentioned that we use lots of different frequencies so when two different devices Bluetooth devices are connected they do something called adaptive frequency hopping there are 37 radio channels that they will hop through but a channel is a frequency range it's not a frequency, it's a range of frequencies radio is analog but we need to encode digital information in it where modulation schemes come in and the way it works with Bluetooth is this here's my channel with a lower frequency and an upper frequency somewhere in the middle of those two things there's a kind of central baseline frequency so we define something called a frequency deviation which is a number to represent a zero we subtract the frequency deviation from that central frequency so frequencies less than that central value represents zero to represent a one frequency deviation so we do change the frequency within a channel to represent our ones and zeros from the digital world that's how it works which is great but for direction finding of course we need to know what the wavelength is it needs to be static we can cope with the frequency deviation thing but it complicates things a little bit so I've used the phrase direction finding signal these are signals which have appended to them some special data which essentially is a load of ones they're all ones therefore the frequency stays the same therefore the wavelength is a static quantity we can do our sampling on and derive our direction calculations from that's what we do here so that special thing is called the CTE the constant tone extension if it was audible it would be a constant tone do it don't worry it's like that though and direction finding signals have a CTE appended to them and this is all defined in the bluetooth 5.1 specification you can see those of you who here is familiar enough with bluetooth to know what packets look like some of you for sure so just gets tacked on the end after the CRC you know about whitening we don't apply whitening to the CTE because that would kind of mess it up so let's talk about where this is in the bluetooth stack now you've had all the physics the big bang theory stuff let's go back to bluetooth now which we kind of had started to do so there are various configurations of bluetooth stack that you can use so your smartphones have a stack that looks like this control a component at the bottom which sits on top of the radio itself other layers in the host components on top of that the one you're seeing now which is GAP plus some other layers so what phones use to talk to peripheral devices like activity trackers and smartwatches and so on I talked about bluetooth mesh this morning if you're in that talk you'll know that we have an entirely different host stack that sits on top of the bluetooth low energy controller when you're doing mesh communication mesh and direction finding are not related at all at this stage the stuff we've delivered is only about the stack configuration on the left now in terms of what we've delivered so far which is my my hint that there's actually a little bit more to come we've delivered core specification version 5.1 it only defines what's going on in the controller all stuff to do with IQ sampling and the timing of IQ for example to talking about one or two microsecond timing slots here very precise timing rules but we've also defined if you see sitting in the middle there between the host and the controller we have a layer actually an interface called the host controller interface which per the brilliantly selected name is how the host part talks to the controller part and sends it commands and receives things back from it called events so we've extended the host controller interface so that the host can say to the controller I want you to start giving me direction finding signals in other words I want the constant tone extension please and here are some parameters to do with timing and stuff like that the host can tell the controller what it wants once it's done that the controller will start to perform IQ sampling depending on which end of the relationship between transmitter and receiver we are but essentially that's what we're going to do configure the controller and then enable sampling or the processing of samples so here's an example you can use this in either connection oriented situations where two devices are connected or connection-less so where one device is advertising so that's a connection-less broadcasted data and other devices are scanning for information there's just no synchronisation of the timing of these operations you can use bluesy direction finding in either of these two scenarios okay the way it works if is of course and in fact you're going to need to have a bluetooth 5 stack to be able to use this in sorry let me start again you've got to have a bluetooth 5.1 anyway for direction finding but we're leveraging something that became capable possible in bluetooth 5 which is advertising that has kind of agreed timing if that doesn't sound like a contradiction in terms before bluetooth 5.0 all advertising just happened according to the frequency you told it to happen to and devices that wanted to receive advertising packets just had to try their best to be listening when they were being transmitted and if they weren't listening when they were transmitted they wouldn't receive them so there was no way of synchronising the two bluetooth 5 actually lets you do something called periodic advertising where the timing is agreed or is actually broadcast to other devices so I'm going to advertise every 200ms and all the other devices are okay right I'll start listing at the rights interval and because of the timing specific nature of the direction finding and IQ something stuff that's going on the connections communication that's what you have to use what's shown on the slide here though is a sequence diagram of the connection oriented situation not going to go through the detail here but essentially there are some new host controller interface commands that lets the the two hosts talk to their controllers and switch on IQ sampling maybe give some parameters and then across the link there's a PDU called LL CTE Rec so that's LL is the link layer CTE of course you already know is constant tone extension well done class fantastic and obviously request is me sending something down a link saying please reply with something containing constant tone extension so something's taking place excuse me and I'm going to get a response to that what you actually get back across the host controller interface are not individual samples because we're talking about microsecond timing slots now but I'm actually going to get an array of IQ samples of amplitude and phase measurements after which at this stage because we still have some profile specifications to release it's over to you so a lot of responsibility is still in the host and application layers to decide what to do with that raw material the very basics are quite straightforward there's that trigonometry formula in the spec so you're going to use that I think we're never going to go too far in defining exactly how you do the calculations to derive direction finding from different designs of antenna array we see that as a place where competitors can get the edge over each other but that's where we are right now so that almost ends the talk let me tell you where you can go next if you want to know more in terms of actual stuff on market it's still really really new I haven't really been watching to see what devices are out there there are, well I'm going to say there is at least one developer board that comes with an antenna array that lets you start to develop bluetooth 5.1 direction finding stuff there may be, in fact I heard about another one at lunch so there may be several out there now that will accelerate that's what normally happens end months after the release of spec there's nothing, because people are implementing or still planning and then you start to see stuff arrive and then it accelerates so what can you do, you could read the core spec it's only 3,000 pages oh go on you don't need to read all of it of course but we do have some other stuff which we try to position as educational resources for developers and other technical roles which will help bridge you into the spec the spec can be challenging sometimes it's certainly big so if you go to bluetooth.com www.bluetooth.com not hard to remember click on resources you'll find that we've got lots of stuff in there we've got papers which are for reading like the stuff on screen and things we call study guides which will give you hands on experience as well we don't have a study guide for direction finding yet that will doubtless come as developer boards hit the market um the technical overview on the left is probably the place to start good summary of what it's all about and there's some other stuff some of it from third parties as well the one on the right is by silicon labs who are a member of the bluetooth special interest group and maker of bluetooth stuff and that my friends is all I have to say to you on the subject of bluetooth and location services and direction finding thank you for listening I hope that was alright enjoy the sticker if not thank you