Reader small image

You're reading from  Learning BeagleBone

Product typeBook
Published inDec 2014
Publisher
ISBN-139781783982905
Edition1st Edition
Right arrow
Author (1)
Hunyue Yau
Hunyue Yau
author image
Hunyue Yau

Hunyue Yau is an electrical engineer who graduated from the California Institute of Technology. He has worked with Linux since the early '90s, starting with the Soft Landing System. He created one of the first embedded Linux devices in 1996 with a custom-made distribution. He has worked on various products such as embedded Linux appliances, embedded BSD-based devices, and embedded Linux mobile devices. As an active member of the BeagleBoard community, he has volunteered at numerous community events, from Maker Faire to Google Summer of Code mentoring. Today, Hunyue synergizes his electrical engineering skills with embedded Linux software skills to provide turnkey embedded Linux consulting services through HY Research LLC (http://www.hy-research.com/), a company founded by him.
Read more about Hunyue Yau

Right arrow

Chapter 5. Connecting the BeagleBone to Mobile Devices

The BeagleBone is a naturally interconnected device. Out of the box, it comes with USB networking and the Ethernet. In the previous chapter, we put together a simple network-controlled user interface for our LED flasher. In this chapter, we will look at the options to connect a BeagleBone to a mobile device. Connecting to a mobile device is an advanced task, and this chapter provides an overview of this advanced task whereas the specific details will not be covered.

In this chapter, we will cover the following topics:

  • Physical connectivity options

  • Android devices versus Apple iOS devices

  • Phone carrier limitations

  • Additional hardware

  • Bluetooth Low Energy (BLE) and USB

  • Bluetooth classic profiles (PAN/DUN)

  • BLE options

  • Near Field Communication (NFC)

  • NFC options

Mobile devices


Mobile devices are a very diverse category of devices. Even the devices with the same name can be different when purchased through different sources. It is very important for anyone connecting a BeagleBone to a mobile device to never forget the diversity and evolving nature of mobile devices. A mobile device can have physical differences or adaptations specific to mobile networks or even software customizations done at the request of mobile network operators. Due to these differences, connection strategies tend to only work with a specific subset of devices; working with many devices will require multiple strategies.

Connectivity options


The BeagleBone is a very flexible device and offers many options to connect to a mobile device, such as a phone. One should not assume that connection means a full network connection; there are levels of connectivity. Connectivity can be divided into two general groups. The first is the full network connectivity and the second group is protocol-specific connectivity. There are benefits and drawbacks to each group. Most options will require additional hardware on the BeagleBone.

Full network connection options


A full network connection to a mobile device generally means a full TCP/IP connection to the mobile device. This option has the following benefits:

  • A full TCP/IP connection, with the cooperation of the mobile device, can be expanded to provide Internet connectivity. It can provide access to cloud services, or with the right amount of cooperation, it can also provide services to the outside world.

  • Since a TCP/IP connection looks the same to most of the applications as the USB networking and Ethernet, it can simplify software development. Any program written to work with IP networking can work with a full TCP/IP network through a mobile device almost as it is. Again, the caveat is that the mobile device and the carrier it is using need to cooperate. Under Linux, the physical connectivity is largely transparent to the application. For example, our LED flasher from Chapter 4, Refining the LED Flasher, can be made accessible to a mobile device with no changes other...

Protocol-specific connectivity


With less flexibility, having a protocol-specific method of connectivity can provide connectivity to a wider range of devices. The BeagleBone hardware is extremely flexible. The following are the options that can work without additional hardware:

  • The BeagleBone has an onboard hardware for the USB device mode. With the right protocols, all that is needed is a cable. For device connectivity, the cable needed is the same as the one currently used to connect to a laptop/desktop but an additional adapter is needed to match the connector used on the mobile device. This requires the mobile device to support the USB host mode. Within the USB realm, things can be divided into two categories. The two categories differ in the amount of system configuration and software that needs to be written. For example, the BeagleBone system software supports the emulation of a USB serial port when the BeagleBone is connected as a USB device, so only a little configuration is needed...

Mobile device connections


At the time of writing this book, mobile devices can be roughly divided into two common groups, namely, Android and iOS devices. The other less common mobile devices work similarly. The biggest difference is the connectivity options offered by the device. This book will focus on discussing iOS and Android devices. The choice of mobile connectivity will be strongly influenced by the combination of mobile devices that your BeagleBone project targets.

Android devices

The core part of Android is the Android open source project built on top of Linux. As such, it has a lot of similar options and limitations as the BeagleBone. Android, acting as the system software for the phone, has built-in policy-level limitations. These limitations originate from either the design of a particular version of Android itself or from a policy of the device supplier. An added complication unique to Android devices is that the hardware can vary wildly. Android devices are built by many different...

Carrier limitations


The most interesting mobile devices to connect to the BeagleBone are phones. The network of a mobile device is subjected to specific terms, which can severely limit the options with the BeagleBone, as the terms will vary greatly from country to country and plan to plan even within the same network carrier. The following are a few issues faced:

  • Restrictions on connecting another device under the same plan. This is often described as tethering. This often manifests itself as the tethering options being disabled or removed entirely from a phone. However, it can also be a contractual term. Attempting to bypass this can result in the service being suspended or terminated! It is a good idea to consult the contract terms prior to connecting the BeagleBone to a mobile device.

  • TCP/IP filtering from the carrier can break applications. Included in this category are the following:

    • Port-based filtering: This attempts to connect to a nonstandard port for a cloud service might be blocked...

Bluetooth wireless technology


Bluetooth wireless technology is a wireless, short-range protocol used to interconnect devices. It can offer services that range from audio transfer to networking to a higher-level object transfer. These services make Bluetooth an ideal protocol to interface the BeagleBone to a mobile device. Due to the demand for hands-free phone functionality driven by laws, most modern phones will have a built-in Bluetooth functionality. While the BeagleBone can utilize almost all aspects of the Bluetooth wireless technology, we will focus on a few common uses of it in the context of the mobile connectivity for the BeagleBone.

Note

Anything called Bluetooth has to be approved by the Bluetooth SIG. Refer to www.bluetooth.org on approval requirements.

Bluetooth versions

Bluetooth wireless technology has gone through numerous revisions of the specification. At the time of writing this book, there are four major approved revisions. The versions up to 3 describe enhancements that...

Profiles


The Bluetooth functionality is described in terms of profiles defined by the Bluetooth Special Interest Group (SIG). There are two main profiles of interest to us and one profile is worth mentioning. There are two different profiles that offer network connectivity, namely, Personal Area Networking (PAN) and Dial-up Networking (DUN). They both offer TCP/IP connectivity but in a different manner. It is important to repeat that network connectivity is offered by either of these options; this does not necessarily imply Internet connectivity.

Some mobile devices support the DUN or PAN profiles as a means of obtaining Internet connectivity and not exporting it. Despite this, it can still be used to provide connectivity between the device and the BeagleBone.

While we won't discuss it, it is worth mentioning Serial Port Profile (SPP). SPP emulates a serial port over Bluetooth at both the BeagleBone end and the mobile device end. If TCP/IP connectivity is not needed, SPP can provide a simple...

BLE options


The simplest wireless method of connecting to an iOS-based mobile device is to use BLE. Unlike Bluetooth Classic, BLE connectivity is not restricted on iOS devices. As an added benefit, Android Version 4.3 can also support BLE, provided the device has the hardware and is supported by the manufacture for BLE connectivity. BLE is not currently supported by existing mobile devices for TCP/IP connectivity.

In order to provide BLE connectivity to a mobile device, the BeagleBone needs to be configured to act as a GATT server. BlueZ contains examples of how to implement a GATT server. Refer to the BlueZ source code and documentation for more detail.

Note

Generic Attribute Profile (GATT) is a standard BLE profile used by a large portion of current BLE devices. This is one of the BLE profiles supported by the Android 4.3 API.

Unfortunately, at the time of writing this book, there are no simple examples of a GATT server for BlueZ.

However, if the goal is to connect to a mobile device that...

Near Field Communication and the BeagleBone


Near Field Communication (NFC) is a way for new mobile devices to interact with other mobile devices, NFC tags, or to authenticate communications. NFC is not a peer-to-peer protocol. For more information on NFC, visit https://en.wikipedia.org/wiki/Near_Field_Communication.

Briefly, NFC works by creating a field with a low-power radio frequency transmitter on the master or server side and then monitoring it. When another NFC device or slave comes close enough to the master end, the master will see a change in the field. The roles of the master and slave can be swapped but is not necessary. Both ends communicate by controlling the way the changes occur. The following are a few key characteristics:

  • NFC works over short distances. There is no numeric value for the distance as the distance depends on the antennas used by both ends. Changing the antenna has a large effect on the distance the NFC will work.

  • The field provided by the transmitter can provide...

Summary


In this chapter, we discussed the options and limitations of connecting the BeagleBone to a mobile device. We started by looking at the TCP/IP connection options versus non-TCP/IP options. The TCP/IP options can allow simple network interfaces similar to what we used for the LED flasher to work with minimal to no changes, whereas a non-TCP/IP option is likely to require, at the very least, application-level changes and possibly systemsoftware-level changes.

Then, we looked at options that require additional hardware on the BeagleBone and options that did not. We also covered Bluetooth wireless technology as a way of connecting to both Android- and iOS-based mobile devices. An important detail is that mobile devices are highly varied and connecting to different devices will most likely require multiple connection strategies.

In the next chapter, we will look at something more practical, such as recovering from mistakes. While no user would want their device to break, mistakes do happen...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning BeagleBone
Published in: Dec 2014Publisher: ISBN-13: 9781783982905
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Hunyue Yau

Hunyue Yau is an electrical engineer who graduated from the California Institute of Technology. He has worked with Linux since the early '90s, starting with the Soft Landing System. He created one of the first embedded Linux devices in 1996 with a custom-made distribution. He has worked on various products such as embedded Linux appliances, embedded BSD-based devices, and embedded Linux mobile devices. As an active member of the BeagleBoard community, he has volunteered at numerous community events, from Maker Faire to Google Summer of Code mentoring. Today, Hunyue synergizes his electrical engineering skills with embedded Linux software skills to provide turnkey embedded Linux consulting services through HY Research LLC (http://www.hy-research.com/), a company founded by him.
Read more about Hunyue Yau