1*8caefee3SMatthias Ringwald\documentclass[a4paper,titlepage,oneside,12pt]{amsart} %amsart 2*8caefee3SMatthias Ringwald\usepackage{graphicx} 3*8caefee3SMatthias Ringwald\usepackage{hyperref} 4*8caefee3SMatthias Ringwald%\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots. 5*8caefee3SMatthias Ringwald\usepackage[margin=1.3in]{geometry} 6*8caefee3SMatthias Ringwald\geometry{a4paper} % or letter or a5paper or ... etc 7*8caefee3SMatthias Ringwald% \geometry{landscape} % rotated page geometry 8*8caefee3SMatthias Ringwald\usepackage{ifthen} 9*8caefee3SMatthias Ringwald 10*8caefee3SMatthias Ringwald% See the ``Article customise'' template for come common customisations 11*8caefee3SMatthias Ringwald\usepackage[usenames,dvipsnames]{color} 12*8caefee3SMatthias Ringwald 13*8caefee3SMatthias Ringwald\definecolor{lightgray}{RGB}{245, 245, 245} 14*8caefee3SMatthias Ringwald\definecolor{bkblue}{RGB}{18, 47, 76} 15*8caefee3SMatthias Ringwald\definecolor{bklightblue}{RGB}{102, 131, 158} 16*8caefee3SMatthias Ringwald\definecolor{mygreen}{rgb}{0,0.6,0} 17*8caefee3SMatthias Ringwald\definecolor{orange}{RGB}{255,153,0} 18*8caefee3SMatthias Ringwald 19*8caefee3SMatthias Ringwald\usepackage{opensans} 20*8caefee3SMatthias Ringwald\usepackage{setspace} 21*8caefee3SMatthias Ringwald\usepackage{booktabs} \newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}} 22*8caefee3SMatthias Ringwald 23*8caefee3SMatthias Ringwald\usepackage{color} 24*8caefee3SMatthias Ringwald\newcommand{\todo}[1]{\colorbox{yellow}{#1}} 25*8caefee3SMatthias Ringwald\newcommand{\toread}[1]{{\color{bklightblue} #1}} 26*8caefee3SMatthias Ringwald 27*8caefee3SMatthias Ringwald\usepackage{listings} 28*8caefee3SMatthias Ringwald\lstset{ % 29*8caefee3SMatthias Ringwaldlanguage=C, % choose the language of the code 30*8caefee3SMatthias Ringwaldbasicstyle=\footnotesize, % the size of the fonts that are used for the code 31*8caefee3SMatthias Ringwald%numbers=left, % where to put the line-numbers 32*8caefee3SMatthias Ringwald%numberstyle=\footnotesize, % the size of the fonts that are used for the line-numbers 33*8caefee3SMatthias Ringwald%stepnumber=1, % the step between two line-numbers. If it is 1 each line will be numbered 34*8caefee3SMatthias Ringwald%numbersep=5pt, % how far the line-numbers are from the code 35*8caefee3SMatthias Ringwaldbackgroundcolor=\color{lightgray}, % choose the background color. You must add \usepackage{color} 36*8caefee3SMatthias Ringwaldshowspaces=false, % show spaces adding particular underscores 37*8caefee3SMatthias Ringwaldshowstringspaces=false, % underline spaces within strings 38*8caefee3SMatthias Ringwaldshowtabs=false, % show tabs within strings adding particular underscores 39*8caefee3SMatthias Ringwaldframe=single, % adds a frame around the code 40*8caefee3SMatthias Ringwaldframerule=0.2pt, 41*8caefee3SMatthias Ringwaldtabsize=2, % sets default tabsize to 2 spaces 42*8caefee3SMatthias Ringwaldcaptionpos=b, % sets the caption-position to bottom 43*8caefee3SMatthias Ringwaldbreaklines=true, % sets automatic line breaking 44*8caefee3SMatthias Ringwaldbreakatwhitespace=false, % sets if automatic breaks should only happen at whitespace 45*8caefee3SMatthias Ringwaldescapeinside={\%*}{*)}, % if you want to add a comment within your code 46*8caefee3SMatthias Ringwaldbelowcaptionskip=5em, 47*8caefee3SMatthias Ringwaldbelowskip=1em, 48*8caefee3SMatthias Ringwaldaboveskip=1.8em, 49*8caefee3SMatthias Ringwaldcommentstyle=\itshape\color{mygreen}, 50*8caefee3SMatthias Ringwaldkeywordstyle=\bfseries\color{black}, 51*8caefee3SMatthias Ringwaldidentifierstyle=\color{black}, 52*8caefee3SMatthias Ringwaldstringstyle=\color{blue}, 53*8caefee3SMatthias Ringwaldmorekeywords={*, } 54*8caefee3SMatthias Ringwald} 55*8caefee3SMatthias Ringwald 56*8caefee3SMatthias Ringwald\newcommand{\versionNr}{0.1} 57*8caefee3SMatthias Ringwald\newcommand{\authorMila}{Dr. sc. Milanka Ringwald} 58*8caefee3SMatthias Ringwald\newcommand{\authorMatthias}{Dr. sc. Matthias Ringwald} 59*8caefee3SMatthias Ringwald\newcommand{\bkContact}{\href{[email protected]}{[email protected]}} 60*8caefee3SMatthias Ringwald\newcommand{\barWidth}{0.3cm} 61*8caefee3SMatthias Ringwald 62*8caefee3SMatthias Ringwald\makeatletter 63*8caefee3SMatthias Ringwald\renewcommand{\maketitle}{ 64*8caefee3SMatthias Ringwald \begin{titlepage} 65*8caefee3SMatthias Ringwald \fosfamily 66*8caefee3SMatthias Ringwald \begin{center} 67*8caefee3SMatthias Ringwald \begin{minipage}[b]{\textwidth} 68*8caefee3SMatthias Ringwald \begin{minipage}[b]{.1\textwidth} 69*8caefee3SMatthias Ringwald \color{bkblue}\rule{\barWidth{}}{22cm} 70*8caefee3SMatthias Ringwald \end{minipage} 71*8caefee3SMatthias Ringwald \hfill\begin{minipage}[b]{.8\textwidth}\begin{flushright} 72*8caefee3SMatthias Ringwald {\color{bkblue}VERSION \versionNr{} \\ 73*8caefee3SMatthias Ringwald \today \\} 74*8caefee3SMatthias Ringwald \vspace*{7.5cm} 75*8caefee3SMatthias Ringwald \hfill\includegraphics[width=0.95\textwidth]{../../../docs/manual/picts/bklogo.pdf} 76*8caefee3SMatthias Ringwald \vspace*{1.5cm} 77*8caefee3SMatthias Ringwald \begin{spacing}{2} 78*8caefee3SMatthias Ringwald {\huge \color{bkblue} \@title} \\ 79*8caefee3SMatthias Ringwald {\Large \color{bklightblue} Getting Started} 80*8caefee3SMatthias Ringwald \end{spacing} 81*8caefee3SMatthias Ringwald \vspace*{1.5cm} 82*8caefee3SMatthias Ringwald {\color{bkblue}\large \authorMila \\ 83*8caefee3SMatthias Ringwald \large \authorMatthias \\ 84*8caefee3SMatthias Ringwald \large \bkContact\\ } 85*8caefee3SMatthias Ringwald \end{flushright}\end{minipage} 86*8caefee3SMatthias Ringwald \vfill 87*8caefee3SMatthias Ringwald \begin{minipage}[b]{\textwidth} 88*8caefee3SMatthias Ringwald \color{bklightblue}\rule{\barWidth{}}{\barWidth{}} 89*8caefee3SMatthias Ringwald \end{minipage} 90*8caefee3SMatthias Ringwald \end{minipage} 91*8caefee3SMatthias Ringwald 92*8caefee3SMatthias Ringwald 93*8caefee3SMatthias Ringwald \end{center} 94*8caefee3SMatthias Ringwald \end{titlepage} 95*8caefee3SMatthias Ringwald} 96*8caefee3SMatthias Ringwald\makeatother 97*8caefee3SMatthias Ringwald 98*8caefee3SMatthias Ringwald\title[] {BTstack for RugGear/MediaTek Chipsets} 99*8caefee3SMatthias Ringwald\author{Copyright \copyright 2014 BlueKitchen GmbH} 100*8caefee3SMatthias Ringwald 101*8caefee3SMatthias Ringwald%%% BEGIN DOCUMENT 102*8caefee3SMatthias Ringwald\begin{document} 103*8caefee3SMatthias Ringwald 104*8caefee3SMatthias Ringwald\maketitle 105*8caefee3SMatthias Ringwald 106*8caefee3SMatthias Ringwald\tableofcontents 107*8caefee3SMatthias Ringwald\pagebreak 108*8caefee3SMatthias Ringwald 109*8caefee3SMatthias Ringwald\newcommand{\urlfoot}[2]{\href{#1}{{\color{blue} #2}}\footnote{#1}} 110*8caefee3SMatthias Ringwald\newcommand{\BTstack}{\urlfoot{http://bluekitchen-gmbh.com/btstack}{BTstack}{}} 111*8caefee3SMatthias Ringwald\newcommand{\CydiaImpactor}{\urlfoot{http://www.cydiaimpactor.com}{Cydia Impactor}{}} 112*8caefee3SMatthias Ringwald\newcommand{\CydiaImpactorURL}{\href{http://www.cydiaimpactor.com}{\color{blue} Cydia Impactor}} 113*8caefee3SMatthias Ringwald 114*8caefee3SMatthias Ringwald\newcommand{\ADT}{\urlfoot{http://developer.android.com/tools/index.html}{Android Developer Tools}{}} 115*8caefee3SMatthias Ringwald\newcommand{\nio}{\urlfoot{https://www.bluenio.com/products/accessories/niotag}{nio Tag}{}} 116*8caefee3SMatthias Ringwald\newcommand{\PacketLogger}{\urlfoot{http://adcdownload.apple.com/Developer\_Tools/hardware\_io\_tools\_for\_xcode\_\_june\_2014/hardwareiotools\_june\_2014.dmg}{PacketLogger}{}} 117*8caefee3SMatthias Ringwald\newcommand{\Wireshark}{\urlfoot{http://www.wireshark.org}{Wireshark}{}} 118*8caefee3SMatthias Ringwald\newcommand{\Cygwin}{\urlfoot{https://www.cygwin.com}{Cygwin}{}} 119*8caefee3SMatthias Ringwald\newcommand{\MSYS}{\urlfoot{www.mingw.org/wiki/msys}{MSYS}{}} 120*8caefee3SMatthias Ringwald\newcommand{\adb}{\urlfoot{http://developer.android.com/tools/help/adb.html}{Android Debug Bridge}{}} 121*8caefee3SMatthias Ringwald 122*8caefee3SMatthias RingwaldThis documents describes how \BTstack{} can be installed and used on RugGear devices with MediaTek chipset. It also presents measurements of the reception of Advertising reports from a remote devices, e.g. beacons or peripherals, as this is the crucial step for discovering and connecting to them. 123*8caefee3SMatthias Ringwald 124*8caefee3SMatthias Ringwald\section{Hardware Setup} 125*8caefee3SMatthias RingwaldTo install BTstack on a RugGear mobile phone, connect the RugGear device to a Mac or Linux system using a micro USB cable. The installation might also work on Windows with \Cygwin{} and/or \MSYS{} installed. The RugGear device is connected to an USB port during setup and development. 126*8caefee3SMatthias Ringwald 127*8caefee3SMatthias Ringwald\section{General Tools} 128*8caefee3SMatthias Ringwald 129*8caefee3SMatthias Ringwald\begin{itemize} 130*8caefee3SMatthias Ringwald\item \CydiaImpactor{} to get root access. 131*8caefee3SMatthias Ringwald\item Google's \ADT{} (ADT) to develop an Android LE Client. 132*8caefee3SMatthias Ringwald\item The \adb{} (adb) to communicate with a connected Android device via a command line. It comes as a part of the Android Developer Tools. 133*8caefee3SMatthias Ringwald\item Apple's \PacketLogger{} (available to the registered developers as part of the Hardware IO Tools for Xcode download) or \Wireshark{} to look and analyze Bluetooth packet logs. 134*8caefee3SMatthias Ringwald\item Some LE devices that send Advertising reports to test your LE Client. Here, we used the \nio{} and a BTstack-based LE Peripheral on a desktop machine using the BCM20702A0 module. 135*8caefee3SMatthias Ringwald\end{itemize} 136*8caefee3SMatthias Ringwald 137*8caefee3SMatthias Ringwald\section{Rooting the RugGear Device} 138*8caefee3SMatthias RingwaldThere are various ways to root an Android device. We recommend the \CydiaImpactorURL{} tool. It is available for all major platforms, it works with most Android devices and it comes from a trustworthy source\footnote{It was created by Jay Freeman, who has supporting the use iOS devices outside of Apple's walled garden since the device came out}. 139*8caefee3SMatthias Ringwald 140*8caefee3SMatthias RingwaldTo root the device, start Impactor, and press the "Start" button as shown in Fig.\ref{fig:cydiaimpactor} 141*8caefee3SMatthias Ringwald 142*8caefee3SMatthias Ringwald\begin{figure}[htbp] 143*8caefee3SMatthias Ringwald\begin{center} 144*8caefee3SMatthias Ringwald \includegraphics[width=\textwidth]{picts/cydiaimpactor.png} 145*8caefee3SMatthias Ringwald\caption{Cydia Impactor running on OS X.} 146*8caefee3SMatthias Ringwald\label{fig:cydiaimpactor} 147*8caefee3SMatthias Ringwald\end{center} 148*8caefee3SMatthias Ringwald\end{figure} 149*8caefee3SMatthias Ringwald 150*8caefee3SMatthias Ringwald\section{Installing BTstack on RugGear devices with MediaTek Chipsets} 151*8caefee3SMatthias Ringwald 152*8caefee3SMatthias RingwaldFirst, extract the provided \path{btstack-android-mtk-VERSION.tar.gz} archive. Please make sure that the path to the extracted archive does not contain spaces as the installer may fail in this case. Then, start the provided \path{./installer.sh} in the \path{mtk} folder. This should look similar to this listing. 153*8caefee3SMatthias Ringwald 154*8caefee3SMatthias Ringwald\begin{lstlisting} 155*8caefee3SMatthias Ringwald$ mkdir btstack 156*8caefee3SMatthias Ringwald$ tar -zxvf btstack-android-mtk.tar.gz -C btstack 157*8caefee3SMatthias Ringwald$ ls btstack 158*8caefee3SMatthias Ringwaldjava mtk 159*8caefee3SMatthias Ringwald$ cd btstack/mtk 160*8caefee3SMatthias Ringwald$ ./installer.sh 161*8caefee3SMatthias RingwaldBTstack Installer for RugGear/Mediatek devices 162*8caefee3SMatthias Ringwaldfrom: . 163*8caefee3SMatthias Ringwald- /system mounted as read/write 164*8caefee3SMatthias Ringwald- stopping Bluetooth daemon 165*8caefee3SMatthias Ringwald- transfer files to device 166*8caefee3SMatthias Ringwald9192 KB/s (279736 bytes in 0.029s) 167*8caefee3SMatthias Ringwald2949 KB/s (6188 bytes in 0.002s) 168*8caefee3SMatthias Ringwald7753 KB/s (62360 bytes in 0.007s) 169*8caefee3SMatthias Ringwald4184 KB/s (11316 bytes in 0.002s) 170*8caefee3SMatthias Ringwald3201 KB/s (6592 bytes in 0.002s) 171*8caefee3SMatthias Ringwald5348 KB/s (11720 bytes in 0.002s) 172*8caefee3SMatthias Ringwald- put files in place 173*8caefee3SMatthias Ringwald- start BTstack daemon 174*8caefee3SMatthias RingwaldDONE 175*8caefee3SMatthias Ringwald\end{lstlisting} 176*8caefee3SMatthias Ringwald 177*8caefee3SMatthias RingwaldIf BTstack was installed properly, we can have a look at its packet log. 178*8caefee3SMatthias Ringwald 179*8caefee3SMatthias Ringwald\begin{lstlisting} 180*8caefee3SMatthias Ringwald$ make hci_dump 181*8caefee3SMatthias Ringwaldkillall PacketLogger 182*8caefee3SMatthias Ringwaldadb shell su root chmod 666 /data/btstack/hci_dump.pklg 183*8caefee3SMatthias Ringwaldadb pull /data/btstack/hci_dump.pklg 2> /dev/null 184*8caefee3SMatthias Ringwaldopen hci_dump.pklg 185*8caefee3SMatthias Ringwald\end{lstlisting} 186*8caefee3SMatthias Ringwald 187*8caefee3SMatthias RingwaldThe \path{make} \path{hci_dump} command assumes that the underlying system is OS X and that PacketLogger is already running. The two\path{adb} commands, shown in the following Listing, are used to fetch the packet log (hci\_dump.pklg) and it can be run on any platform. Wireshark can then be used to open the packet log. 188*8caefee3SMatthias Ringwald 189*8caefee3SMatthias Ringwald\begin{lstlisting} 190*8caefee3SMatthias Ringwald$ adb shell su root chmod 666 /data/btstack/hci_dump.pklg 191*8caefee3SMatthias Ringwald$ adb pull /data/btstack/hci_dump.pklg 2> /dev/null 192*8caefee3SMatthias Ringwald\end{lstlisting} 193*8caefee3SMatthias Ringwald 194*8caefee3SMatthias RingwaldThe initial packet log should look like in Figure \ref{fig:firstLog}. 195*8caefee3SMatthias Ringwald 196*8caefee3SMatthias Ringwald\begin{figure}[htbp] 197*8caefee3SMatthias Ringwald\begin{center} 198*8caefee3SMatthias Ringwald \includegraphics[width=\textwidth]{picts/ruggear_initial_hci_dump.pdf} 199*8caefee3SMatthias Ringwald\caption{hci\_dump.pklg right after BTstack daemon was installed.} 200*8caefee3SMatthias Ringwald\label{fig:firstLog} 201*8caefee3SMatthias Ringwald\end{center} 202*8caefee3SMatthias Ringwald\end{figure} 203*8caefee3SMatthias Ringwald 204*8caefee3SMatthias Ringwald\section{Running the First Example} 205*8caefee3SMatthias Ringwald 206*8caefee3SMatthias RingwaldAs first, make sure that BTstack was installed properly and it is running, i.e. by checking the packet log as explained in the previous section. Now, let's do an LE Scan using a test program written in C against libBTstack. 207*8caefee3SMatthias Ringwald 208*8caefee3SMatthias Ringwald\begin{lstlisting} 209*8caefee3SMatthias Ringwald$ adb shell 210*8caefee3SMatthias Ringwald$ le_scan 211*8caefee3SMatthias Ringwaldle_scan started 212*8caefee3SMatthias Ringwald- connecting to BTstack Daemon 213*8caefee3SMatthias Ringwald- connected 214*8caefee3SMatthias Ringwald- send power on 215*8caefee3SMatthias Ringwald- btstack state 1 216*8caefee3SMatthias Ringwald- btstack state 2 217*8caefee3SMatthias Ringwald- start LE scan 218*8caefee3SMatthias Ringwald- ADV: 3E 0F 02 01 00 01 F2 01 8F 45 16 66 03 02 01 1A B3 219*8caefee3SMatthias Ringwald\end{lstlisting} 220*8caefee3SMatthias Ringwald 221*8caefee3SMatthias RingwaldThe \path{le\_scan} just dumps the data of each received advertisement. It uses the default parameters used by iOS, which are scan window 30 ms, scan interval 300 ms. More on these parameters is in Section \ref{ss:measurements}. The packet log looks like in Figure \ref{fig:leScan}. 222*8caefee3SMatthias Ringwald 223*8caefee3SMatthias Ringwald\begin{figure}[htbp] 224*8caefee3SMatthias Ringwald\begin{center} 225*8caefee3SMatthias Ringwald \includegraphics[width=\textwidth]{picts/scan_parameters_hci_dump.png} 226*8caefee3SMatthias Ringwald\caption{HCI dump of the le\_scan program.} 227*8caefee3SMatthias Ringwald\label{fig:leScan} 228*8caefee3SMatthias Ringwald\end{center} 229*8caefee3SMatthias Ringwald\end{figure} 230*8caefee3SMatthias Ringwald 231*8caefee3SMatthias Ringwald\section{BTstack Java API} 232*8caefee3SMatthias Ringwald 233*8caefee3SMatthias RingwaldBTstack on RugGear/MediaTek provides its own Bluetooth stack and its own interface for using it. While BTstack has been certified for Classic SPP and LE Peripheral, it does not provide a complete Java API for this. At the moment, the functionality to turn Bluetooth on/off, scan for LE devices, connect, and make use of Services and Characteristics is provided. This covers the use of BTstack as LE Central. Please note that the Security Manager is not implemented yet. Use of the Security Manager is necessary when devices require explicit pairing before some services can be used. 234*8caefee3SMatthias Ringwald 235*8caefee3SMatthias Ringwald The Java classes that make up the BTstack API are split into three folders. Please add all of them to your Android Java project: 236*8caefee3SMatthias Ringwald 237*8caefee3SMatthias Ringwald \begin{enumerate} 238*8caefee3SMatthias Ringwald\item \path{java/src} - main code for BTstack client, i.e., socket communication with BTstack server that runs as a daemon. 239*8caefee3SMatthias Ringwald\item \path{java/android} - Android specific Client/Server communication. 240*8caefee3SMatthias Ringwald\item \path{java/gen} - code for available commands and events, auto-generated from the BTstack C source. 241*8caefee3SMatthias Ringwald\end{enumerate} 242*8caefee3SMatthias Ringwald 243*8caefee3SMatthias Ringwald\subsection{BTstack GATT Client for Android example} 244*8caefee3SMatthias RingwaldMore documentation on the Java API is needed. For now, please have a look at the Anrdoid example in \path{java/example/com/bluekitchen/GATTClientTest.java}. It connects to BTstack Server and turns Bluetooth on. On success, it starts an LE Scan for devices. When it finds a device, it connects to it and queries the available Services. Then, it requests the list of Characteristics for the first service. Finally, it performs some read/write operations on the found Characteristics. 245*8caefee3SMatthias Ringwald 246*8caefee3SMatthias RingwaldBTstack server runs as a daemon. In the event of a crash, the Java client will get notified and can restart the daemon, to provide a continuous use of the Bluetooth services. 247*8caefee3SMatthias Ringwald 248*8caefee3SMatthias Ringwald\section{BCM20702A0 and RugGear RG500 Reception of Advertisements} 249*8caefee3SMatthias Ringwald\label{ss:measurements} 250*8caefee3SMatthias Ringwald 251*8caefee3SMatthias RingwaldDuring the first tests of BTstack on RugGear/MediaTek, we have seen that it receives less Advertisements than other devices. 252*8caefee3SMatthias Ringwald 253*8caefee3SMatthias RingwaldAdvertisements serve three main purposes: 254*8caefee3SMatthias Ringwald\begin{enumerate} 255*8caefee3SMatthias Ringwald\item They provide information that a particular device is in range and turned on. 256*8caefee3SMatthias Ringwald\item They can provide some information without connecting to a particular device (e.g. its name, provided services, or even manufacturer specific data). 257*8caefee3SMatthias Ringwald\item They allow to connect to a particular device, i.e., an LE device listens for incoming connection requests only a short moment after sending an Advertisement (to save energy). 258*8caefee3SMatthias Ringwald\end{enumerate} 259*8caefee3SMatthias Ringwald 260*8caefee3SMatthias RingwaldA setup with one device that sends Advertisements and one device that receives them, can be completely described by three parameters: 261*8caefee3SMatthias Ringwald\begin{enumerate} 262*8caefee3SMatthias Ringwald\item the \emph{Advertisement Interval} - the period between two consecutive Advertisements being sent. 263*8caefee3SMatthias Ringwald\item the \emph{Scan Interval} - it determines how frequent the receiving device listens for Advertisements. 264*8caefee3SMatthias Ringwald\item the \emph{Scan Window} - the time window in which the receiving device listens for Advertisements. 265*8caefee3SMatthias Ringwald\end{enumerate} 266*8caefee3SMatthias Ringwald 267*8caefee3SMatthias Ringwald\subsection{Setup} To evaluate the MediaTek Bluetooth chipsets used in the RugGear RG500, we compared them to a common Bluetooth USB Dual-Mode Dongle that uses the Broadcom BCM20702A0. We used two LE Peripherals. As the first LE Peripheral, we setup another device with the BCM20702A0 and configured it to advertise every 30 ms. This is very often, but it helps to establish how good Advertisements are received, if they occur frequently. As a second more real-world example, we used the nio Tag without further configuration. Based on the measured results, the nio Tag advertises roughly every second. 268*8caefee3SMatthias Ringwald 269*8caefee3SMatthias RingwaldWe measured two cases: 270*8caefee3SMatthias Ringwald\begin{enumerate} 271*8caefee3SMatthias Ringwald\item continuous scanning (Scan Window 30ms, Scan Interval 30ms), 272*8caefee3SMatthias Ringwald\item intermittent scanning (Scan Window 30ms, Scan Interval 300ms) as performed by iOS. 273*8caefee3SMatthias Ringwald\end{enumerate} 274*8caefee3SMatthias Ringwald 275*8caefee3SMatthias Ringwald\subsection{Process} 276*8caefee3SMatthias RingwaldFor the continuous and intermittent scanning measurements on the RugGear, we used the \path{le_scan} test. We let it run for 15 minutes in continuous, and then 15 min in intermittent scanning setup. For each of the two measurement, we retrieved the packet logs from the device. We processed it an analyzed it using two Python scripts \path{process_scan.py} and \path{plot_scan.py}. The measurements with the BCM module have been carried out with the GATT Browser example of BTstack on OS. Hence, we have up to four experiments for each setup: 277*8caefee3SMatthias Ringwald\begin{itemize} 278*8caefee3SMatthias Ringwald\item BCM/BCM - BCM20702A0 receives Advertisements from second BCM 20702A0 module 279*8caefee3SMatthias Ringwald\item BCM/nio - BCM20702A0 receives Advertisements from nio tag 280*8caefee3SMatthias Ringwald\item RugGear/BCM - RugGear RG500 receives Advertisements from BCM 20702A0 module 281*8caefee3SMatthias Ringwald\item RugGear/nio - RugGear RG500 receives Advertisements from nio tag 282*8caefee3SMatthias Ringwald\end{itemize} 283*8caefee3SMatthias Ringwald 284*8caefee3SMatthias Ringwald\subsection{Measurements with continuous scanning} 285*8caefee3SMatthias RingwaldFor this experiment with set the Scan Interval to 30 ms and the Scan Windows to 30 ms, which translates to continuous scanning. 286*8caefee3SMatthias Ringwald 287*8caefee3SMatthias RingwaldThe plot in Figure \ref{fig:accumulatedAds} shows how many Advertisements have been received for both receivers from the two senders. In the BCM/BCM combination, 27 out of max 33 (1s /30 ms) Advertisements have been received. On the RugGear device, only about 1 in 15 Advertisements have been received. 288*8caefee3SMatthias Ringwald 289*8caefee3SMatthias RingwaldFigure \ref{fig:delayHist} shows the distribution of the time between two received Advertisements over the full range. 290*8caefee3SMatthias Ringwald 291*8caefee3SMatthias RingwaldAll setups but the RugGear vs. nio Tag, received an Advertisement every second, which is sufficient for most interactive applications. We further analyzed the RugGear vs. nio Tag setup in more detail. For this setup, we calculated the expected delay between the start of a scan and the first received Advertisement based on the previous measurements as shown in Figure \ref{fig:expectedDelay}. An alternative and easier to read representation of the same is given in Figure \ref{fig:cdfExpectedDelay}. From this Figure we can, for example, see that we have 20 percent probability of receiving an Advertisement with less then 1 second. 292*8caefee3SMatthias Ringwald 293*8caefee3SMatthias Ringwald\subsection{Measurements with normal scanning} 294*8caefee3SMatthias RingwaldFor this experiment with set the Scan Interval to 300 ms and the Scan Windows to 30 ms, which translates to scanning for 1/10 of the time. As the scanning time is reduced by a factor of 10, we also expect the number of received Advertisements to be lower by 1/10. We didn't had the nio Tag around this time. 295*8caefee3SMatthias Ringwald 296*8caefee3SMatthias RingwaldThe plot in Figure \ref{fig:accumulatedNormalAds} shows the number of Advertisements received for both receivers. The BCM/BCM received 2.9 Advertisements per second (adv/s) which is roughly 1/10 of the 27 adv/s received in the continuous scanning experiment. For the RugGear/BCM combination, we received 0.6 adv/s, which is roughly 1/3 of the 1.8 adv/s received in the continuous scanning experiment and is unexpected. 297*8caefee3SMatthias Ringwald 298*8caefee3SMatthias RingwaldWe conclude from this data, that the MediaTek chipset didn't do continuous scanning in the first experiment. Instead, it looks like it was scanning for only 1/3 of the time, potentially due to internal resource limitations or scheduling problems. In the intermittent scanning setup, the RugGear device received 1/5 of the Advertisements received by the BCM chipset. 299*8caefee3SMatthias Ringwald 300*8caefee3SMatthias Ringwald 301*8caefee3SMatthias Ringwald \begin{figure}[htbp] 302*8caefee3SMatthias Ringwald \begin{center} 303*8caefee3SMatthias Ringwald \includegraphics[width=0.9\textwidth]{picts_experiments/nio_acc_number_of_advertisements_continuous_scanning.pdf} 304*8caefee3SMatthias Ringwald \caption{Advertising reports accumulated over time, continuous scanning.} 305*8caefee3SMatthias Ringwald \label{fig:accumulatedAds} 306*8caefee3SMatthias Ringwald \end{center} 307*8caefee3SMatthias Ringwald \end{figure} 308*8caefee3SMatthias Ringwald 309*8caefee3SMatthias Ringwald \begin{figure}[htbp] 310*8caefee3SMatthias Ringwald \begin{center} 311*8caefee3SMatthias Ringwald \includegraphics[width=0.9\textwidth]{picts_experiments/nio_histogram_advertisements_time_delay.pdf} 312*8caefee3SMatthias Ringwald \caption{Time delay histogram, continuous scanning.} 313*8caefee3SMatthias Ringwald \label{fig:delayHist} 314*8caefee3SMatthias Ringwald \end{center} 315*8caefee3SMatthias Ringwald \end{figure} 316*8caefee3SMatthias Ringwald 317*8caefee3SMatthias Ringwald \begin{figure}[htbp] 318*8caefee3SMatthias Ringwald \begin{center} 319*8caefee3SMatthias Ringwald \includegraphics[width=0.9\textwidth]{picts_experiments/nio_ruggear_expected_scan_response.pdf} 320*8caefee3SMatthias Ringwald \caption{Expected time until first Advertisement, continuous scanning.} 321*8caefee3SMatthias Ringwald \label{fig:expectedDelay} 322*8caefee3SMatthias Ringwald \end{center} 323*8caefee3SMatthias Ringwald \end{figure} 324*8caefee3SMatthias Ringwald 325*8caefee3SMatthias Ringwald \begin{figure}[htbp] 326*8caefee3SMatthias Ringwald \begin{center} 327*8caefee3SMatthias Ringwald \includegraphics[width=0.9\textwidth]{picts_experiments/nio_ruggear_cdf.pdf} 328*8caefee3SMatthias Ringwald \caption{Cumulative distribution of expected time until first Advertisement, continuous scanning.} 329*8caefee3SMatthias Ringwald \label{fig:cdfExpectedDelay} 330*8caefee3SMatthias Ringwald \end{center} 331*8caefee3SMatthias Ringwald \end{figure} 332*8caefee3SMatthias Ringwald 333*8caefee3SMatthias Ringwald \begin{figure}[htbp] 334*8caefee3SMatthias Ringwald \begin{center} 335*8caefee3SMatthias Ringwald \includegraphics[width=0.9\textwidth]{picts_experiments/nio_acc_number_of_advertisements_normal_scanning.pdf} 336*8caefee3SMatthias Ringwald \caption{Advertising reports accumulated over time, normal scanning.} 337*8caefee3SMatthias Ringwald \label{fig:accumulatedNormalAds} 338*8caefee3SMatthias Ringwald \end{center} 339*8caefee3SMatthias Ringwald \end{figure} 340*8caefee3SMatthias Ringwald 341*8caefee3SMatthias Ringwald%\end{minipage} 342*8caefee3SMatthias Ringwald 343*8caefee3SMatthias Ringwald 344*8caefee3SMatthias Ringwald\end{document}