GopherCon 2014

Go embebido y bluetooth de bajo consumo para crear PayPal Beacon

Josh Bleecher Snyder  · 
go

Presentación

HTML (pincha para descargar)

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

so Rob commented this morning that go was meant for server-side not for embedded work oops fortunately hardware is still cheaper than software developer time and perhaps more relevantly it's easier to hire hardware than it is to hire software developers

so so one of the things that I've been working on a PayPal is PayPal beacon under the shiny industrial design and exterior is pretty much just an LED a Wi-Fi ble chip a fairly low powered arm chip and a Linux OS and the main service that runs on it is

written in go so I'm gonna tell you some of the lessons I learned from writing embedded go but before we do that actually wanna talk a little bit about Bluetooth Bluetooth Low Energy is the new hotness along with go unfortunately that hasn't translated

into a lot of good documentation on the web about it which means that you're interested in it it's incredibly hard to get started so I'm gonna give you a quick overview and then we're you something something fun with it as demo so ble is the

fourth generation of the Bluetooth protocol like all the previous Bluetooth protocols it runs on the same spectrum namely Wi-Fi it uses the same Bluetooth radio however everything else about the protocol has been scrapped and redesigned from the beginning

to focus single-mindedly on being low energy usage and the idea is that you should be able to create a ble device say a thermometer or a heart rate monitor that can run for years on a little button battery and everything about the protocol is dominated by

the desire for low energy usage so first of all it's very simple this is a requirement if you do anything complicated that uses CPU and they do just battery so it's got to be simple as a consequence of being simple it's actually really low cost

it typically costs manufacturer a couple of pennies to add ble support to a Bluetooth chip and as a result pretty much everyone has done it so it's ubiquitous that's part of the reason everyone's really sited about it it's very low bandwidth

we'll talk about that again in a bit but also interestingly and importantly there's an asymmetry built into the protocol so ble uses funny words for everything you have to get used to it so I'm gonna bring up to speed quickly in this talk in the

ble world there are peripherals and there are centrioles and a peripheral you can think of as a server if the thing that is going to be low energy usage a typical peripheral is a thermometer your central using something that's going to be connecting to

your peripherals and inquiring for information from them typically that's gonna be your phone and the asymmetry is there's an assumption that your peripherals are extremely starved for resources they have little or no CPU on they can't consume

much battery your centrioles however are going to be fairly rich your phone has a pretty hefty CPU it's got a battery and anytime you can split up the work and make the central your client do more work really makes you do that ok because it's low energy

incredibly low energy you can have it be always-on in any device and that turns out to be very useful and I'm gonna stop with the overview here there's a lot more to say if you're really curious about it there's a very well-written book by

Robin Hayden pick it up so as a developer if you're gonna actually use ble you're gonna write something on it the level of which you interact with it is called GATT the generic attribute profile forget about that the idea here is here's what's

going on peripherals advertised services so your thermometer says hey I'm a thermometer it actually sends out advertising packets saying I'm a thermometer and these services that it advertises are nothing more than a sort of semantically group set

of characteristics what's a characteristic they did promise I did promise that's worse here we go cell phone huit thanks for us so I promise lots of new terminology a characteristic is just a value plain and simple you can read the value you can write

the value you can request notifications when the value changes and the other interesting thing my Care Trust is their small thing typically like 20 bytes so characteristics are values they're grouped up into services and peripherals provide services I

did say it was simple you're now an expert the problem is of course like I said it hasn't translated a lot of good documentation on the web it also hasn't translated it into easy accessibility for developers so if you want to actually go build

something you end up mucking around in low level firmware which is what I've spent too much of my life doing fortunately in the last two weeks I scrambled to pull together a nice package for you guys as a go for con special so if you want to write a ble

peripheral you can now go do it and go and I'm gonna add central support but didn't have time yet and for that reason the API is not yet stable but it's getting pretty good for now for your central you can use your phone so this package for the

moment it's gonna expand for the moment it works with blue z which is the kernel module that comes with linux for working with bluetooth learning devices so it works on the linux right now and pretty much any flavor you can run it on a Raspberry Pi you

can run it on a VM which we'll see here so let's take a look at actually using this package we're gonna have a server we're gonna give it a name something memorable and then we're gonna add a service to it everything in the ble world everything

[ ... ]

Nota: se han omitido las otras 2.820 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.