Upload
ledien
View
235
Download
5
Embed Size (px)
Citation preview
MOVERIO Pro Developer's Guide (Rev.1.5)
BT-2000/2200
Developer's Guide
SEIKO EPSON CORPORATION
MOVERIO Pro Developer's Guide (Rev.1.5)
Revision history
Revision Item Mainly revised content
Rev.1.3 4.1 Adding caution when changing key assign
6 Adding EDof mode and auto exposure function
11 Adding GPS Assist
Rev.1.4 - Adding description to support BT-2200
Rev.1.5 2.4 Revised Vendor ID setting
5.7 Changed the position of “Default supported words”
8.10 Adding “Recording using Bluetooth headsets”
Cautions
BT-2000 and BT-2200 use common system software. This document will be described
hereafter by only BT-2000, but please be aware that it is also common to BT-2200.
MOVERIO Pro Developer's Guide (Rev.1.5)
Note the following points when using this guide.
The content of this guide may change without prior notice.
1. Reprinting part or all of this guide without prior permission from Seiko Epson, or reprinting for any other purposes is
strictly prohibited.
2. Programs and usage instructions used in this guide are for reference only, Seiko Epson cannot be held responsible for
any infringements (including industrial property rights) or damage caused to third parties. Furthermore, this guide
does not imply consent to licensing for third parties or industrial property rights for Seiko Epson.
3. This document does not relate to products that require a high level of reliability, such as life support equipment.
Epson accepts no responsibility if this product is used for such circumstances.
©Seiko Epson Corporation 2017. All right reserved.
MOVERIO Pro Developer's Guide (Rev.1.5)
Contents
1. Introduction _______________________________________________________ 1
1.1. Product Summary and Functions _________________________________________________________ 2
1.2. Main System Specifications ______________________________________________________________ 3
1.3. Basic Information for App Development ___________________________________________________ 4
1.4. Other Main Functions ___________________________________________________________________ 5
2. Developing Apps ___________________________________________________ 6
2.1. Pre-Caution for Developing Apps _________________________________________________________ 7
2.2. Summary of Developing Apps ____________________________________________________________ 8
2.3. Introduction to the Android SDK _________________________________________________________ 9
2.4. ADB driver settings ____________________________________________________________________ 12
2.5. Connecting the BT-2000 to a computer ___________________________________________________ 18
2.6. Including the SDK provided by EPSON __________________________________________________ 20
3. Display control ___________________________________________________ 24
3.1. Display control summary _______________________________________________________________ 25
3.2. Full screen display function _____________________________________________________________ 26
3.3. Switch between 2D/3D display function __________________________________________________ 27
3.4. Backlight control ______________________________________________________________________ 29
3.5. Mute function _________________________________________________________________________ 30
3.6. See-through function ___________________________________________________________________ 32
4. UI control ________________________________________________________ 33
4.1. UI control summary ___________________________________________________________________ 34
4.2. Application interface list _______________________________________________________________ 38
4.3. Application interface details ____________________________________________________________ 39
5. Voice commands __________________________________________________ 41
5.1. Pre-cautions for developing Voice commands Apps _________________________________________ 42
5.2. Voice commands summary ______________________________________________________________ 43
5.3. Application interface function summary __________________________________________________ 44
5.4. Application interface list _______________________________________________________________ 45
5.5. Application interface details ____________________________________________________________ 47
MOVERIO Pro Developer's Guide (Rev.1.5)
5.6. Sample code __________________________________________________________________________ 55
5.7. Default Supported Words _______________________________________________________________ 57
5.8. Others _______________________________________________________________________________ 58
6. Camera control ___________________________________________________ 65
6.1. Pre-cautions for developing camera Apps _________________________________________________ 66
6.2. Function summary _____________________________________________________________________ 67
6.3. Available parameters __________________________________________________________________ 68
6.4. Image organization and format __________________________________________________________ 69
6.5. Depth data characteristics ______________________________________________________________ 70
6.6. Application interface function summary __________________________________________________ 72
6.7. Application interface list _______________________________________________________________ 73
6.8. Application interface details ____________________________________________________________ 75
6.9. Depth Information Acquisition Flow Details _____________________________________________ 105
6.10. Sample Code _______________________________________________________________________ 107
6.11. Remarks ___________________________________________________________________________ 110
6.12. Android standard camera API Camera.Parameters Class _______________________________ 111
7. Sensor control ___________________________________________________ 114
7.1. Sensor control summary _______________________________________________________________ 115
7.2. Using the sensor ______________________________________________________________________ 118
7.3. Using SensorEventListener ____________________________________________________________ 119
7.4. Sample code _________________________________________________________________________ 121
8. Bluetooth/BLE __________________________________________________ 122
8.1. Pre-cautions for developing Apps using BLE _____________________________________________ 123
8.2. Summary ____________________________________________________________________________ 124
8.3. Usage method ________________________________________________________________________ 126
8.4. Remarks & Restrictions for BLE App Development _______________________________________ 132
8.5. Import module _______________________________________________________________________ 133
8.6. Application interface list ______________________________________________________________ 134
8.7. Supported GATT procedure table _______________________________________________________ 136
8.8. Application interface details ___________________________________________________________ 137
8.9. BLE Processing Sample Code __________________________________________________________ 169
8.10. Recording using Bluetooth headsets __________________________________________________ 179
9. Power control ___________________________________________________ 180
MOVERIO Pro Developer's Guide (Rev.1.5)
9.1. Power control summary _______________________________________________________________ 181
9.2. Acquiring Battery Information _________________________________________________________ 182
10. Self-diagnostic function ___________________________________________ 183
10.1. Self-diagnostic function _____________________________________________________________ 184
11. GPS Assist ______________________________________________________ 187
11.1. GPS Assist function summary ________________________________________________________ 188
11.2. Precaution and limitation of using /developing GPS Assist function _______________________ 189
11.3. How to use _________________________________________________________________________ 190
11.4. Setting method _____________________________________________________________________ 191
11.5. Application interface function summary _______________________________________________ 192
11.6. Application interface detail __________________________________________________________ 193
11.7. How to use API for GPS assist _______________________________________________________ 195
MOVERIO Pro Developer's Guide (Rev.1.5)
1
1. Introduction
MOVERIO Pro Developer's Guide (Rev.1.5)
2
1.1. Product Summary and Functions
The BT-2000/2200 is a smart headset for business use. The same optical see-through
technology as the consumer orientated MOVERIO BT-200 has been adopted. This allows
information to be displayed across a wide viewing area while keeping eye movement to a
minimum, thereby reducing fatigue and making it suitable for use at work. This also allows you
to view your surroundings while projecting an image, which adds an aspect of safety.
The weight of the product is supported by the entire head, allowing you to work for long periods
of time without feeling fatigued. You can work while checking images in a hands-free
environment.
MOVERIO Pro Developer's Guide (Rev.1.5)
3
1.2. Main System Specifications
Item Specifications
Model number MOVERIO Pro BT-2000/2200
Main processor OMAP4460 (dual core ARM Cortex A9)
System clock Max 1.2 GHz (Auto adjusts according to the system load and
temperature)
System software Android 4.0.4
Internal storage (emmc) 8 GB (2 GB reserved for the system)
Main memory 1 GB
Power Battery operated/AC power operated
External memory MicroSD/MicroSDHC supported (32 GB max.)
No. of pixels in LCD panel 960x540 (QHD)/16:9/Refresh rate 60 Hz
Virtual screen size 80" (for virtual viewing distance of 5 m)
Color reproduction 24 bit full color (16,770,000 colors)
3D display Available (only for side by side)
User interface Audio commands: supports Japanese and English
Hardware keys: Power, lock, D-pad/OK key and A, B, X, Y keys
Others: Headset tap input function
Camera Built-in headset, stereo camera
Sensor IMU (Gyro/acceleration)/geomagnetic built-in headset
Wi-Fi IEEE 802.11a/b/g/n, Wi-Fi Direct
Wi-Fi Security WEP
WPA – Enterprise, Personal
WPA2 – Enterprise, Personal
EAP Types
EAP-TLS
EAP-TTLS/MSCHAPv2
PEAPv0/EAP-MSCHAPv2
PEAPv1/EAP-GTC
VPN PPTP
Bluetooth A2DP, HSP, HID, OPP, SPP, BLE support
GPS GPS function, GPS Assist function
*Safety shield is applying ANSI/ISEA Z87.1 (2015 version).
MOVERIO Pro Developer's Guide (Rev.1.5)
4
1.3. Basic Information for App Development
Item Description
CPU/ABI ARMv7 armeabi
Android API level 15
Device screen density mdpi
Screen type Tablet UI
Screen orientation Fixed at Landscape (without sensor rotation)
USB vendor ID 0x04B8
■ HOME, MENU, and BACK keys are supported by hardware keys
■ Touch screen and track pad are not used
■ Except for Wi-Fi, data communication, such as 3G, is not supported
■ This is not a Google Certified device, meaning the following services which require Google
Certification are not available:
- Google Play
- Google location information service
- Additional services only available on Google Certified devices.
MOVERIO Pro Developer's Guide (Rev.1.5)
5
1.4. Other Main Functions
BT-2000 can use below functions. As well as the standard Android API, there are functions that
need EPSON original API. Please refer below charts.
Chart1.4.1 Table of each function and which API to use
Function Android standard API EPSON original API
3.Display control ✔
4.UI control ✔ ✔
5.Voice command ✔
6.Camera control ✔ ✔
7.Sensor control ✔
8.Bluetooth/BLE ✔
9.Power control ✔
10.Self-Diagnostic ✔
11.GPS Assist ✔
The following chapters explain how to use these from an app.
For EPSON original API that needs special caution, please refer Chapter 2.1. Pre-Caution for
Developing Apps.
MOVERIO Pro Developer's Guide (Rev.1.5)
6
2. Developing Apps
MOVERIO Pro Developer's Guide (Rev.1.5)
7
2.1. Pre-Caution for Developing Apps
BT-2000 is using Android platform, but considering the product’s use purpose, it is applying own
functions. Therefore it is necessary to control by EPSON own API. There are some cases that
Android emulator or Android applications that operated with Android Smartphones may not
operate. Please take attention when transplanting APK or diverting source code. Below API needs
attention specially, please refer details at each chapter.
Module lists that need attention for developing Apps.
Camera ・・・ Chapter 6 Camera control
BLE ・・・ Chapter 8 Bluetooth/BLE
MOVERIO Pro Developer's Guide (Rev.1.5)
8
2.2. Summary of Developing Apps
The BT-2000 has adopted Android as the system software. Therefore, you can develop apps for
the BT-2000 in the same environment as developing apps for Android smartphones. However,
when connecting the BT-2000 with the app development computer, or when using functions
unique to the BT-2000, you need to have the PC settings compatible with BT-2000.
This chapter explains the following procedures necessary to develop apps for the BT-2000.
■ Introduction to the Android SDK
■ ADB driver settings
■ Connecting the BT-2000 to a computer
■ Including the SDK provided by EPSON
MOVERIO Pro Developer's Guide (Rev.1.5)
9
2.3. Introduction to the Android SDK
The introduction to the Android SDK assumes the following steps will be performed in a
Windows7 environment.
2.3.1. Acquiring Android Studio
Download Android Studio from the following Website.
https://developer.android.com/sdk/index.html
2.3.2. Acquiring and installing JDK
Download the JDK (7 or later) from the following Website, and then install.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
(Not sure if it’s a good idea to include the link above as it may change over time)
2.3.3. Installing Android Studio
Follow the directions provided by the installer to install Android Studio.
Example) C:\Users\User name\AppData\Local\Android\sdk
* From here on, instructions assume Android Studio is installed in the folder above.
MOVERIO Pro Developer's Guide (Rev.1.5)
10
2.3.4. Installing Platform-tools, SDK Platform, and USB Driver
Execute "C:\Users\User name\AppData\Local\Android\sdk\SDK Manager.exe".
* When you start SDK Manager, the dialog "No packages found" may be displayed.
This occurs when the proxy is not set correctly, and information cannot be updated.
Close all dialogs except for "Android SDK Manager", and then set the proxy in [Tools] -
[Options]. When Proxy settings are unknown, please contact network administrator for
“Connecting method to external network using Proxy”
MOVERIO Pro Developer's Guide (Rev.1.5)
11
Select the following necessary files in the SDK Manager, and then install.
■ [Tools] - [Android SDK Platform-tools]
■ [Android 4.0.3] - [SDK Platform]
■ [Extras] - [Google USB Driver」
Select the above, click [Install], and then select ‘Accept’ all.
This completes the introduction to the Android SDK.
Next, we will explain how to connect the BT-2000 to the app development computer, and setting
up the ADB driver.
MOVERIO Pro Developer's Guide (Rev.1.5)
12
2.4. ADB driver settings
Here we will explain how to connect the BT-2000 to the app development computer, and set the
ADB driver.
When using Windows8 OS or later, it is required to operate by test mode to install ADB driver.
When using Windows7 OS or before, proceed to “2.4.2 When using Windows7 OS or before”.
2.4.1. When using Windows8 OS or later
2.4.1.1. Operate by test mode
1) Run the command prompt as administrator, and run below command.
※When below error occur by running above command, please refer to
”2.4.1.2 When failing test mode command”.
2) Select 「Setting」→「Change PC Setting」 from the charm.
3) Select 「Update and recovery」→「Recovery」→「Restart now」.
4) Select 「Trouble shoot」→「Advanced options」 from the menu.
> bcdedit -set testsigning on
Select→
Select→
Select→
MOVERIO Pro Developer's Guide (Rev.1.5)
13
5) It will reboot after selecting Windows [Startup Settings].
6) [Startup Settings] screen will show after reboot, so select [Disable Driver Signature
Enforcement].
For procedure from here, please proceed to next chapter“2.4.2When using Windows 7 OS or
before”.
Select→
MOVERIO Pro Developer's Guide (Rev.1.5)
14
2.4.1.2. When failing test mode command
Test mode command failure is due to lock by Secure Boot.
Please disable Secure Boot by below method.
1)Select 「Settings」→「Change PC Settings」 from charm.
2)Select 「Update and recovery」→「Recovery」→「Restart now」.
3)Select 「Trouble shoot」→「Advanced options」→「UEFI firmware Settings」.
4) Find Secure Boot Control and change to Disabled.
Select→
Select→
Select→
Select→
MOVERIO Pro Developer's Guide (Rev.1.5)
15
5) Save the change and reboot
6) After PC rebooted, operate command prompt by Administrator privileges and run test mode
command.
To make Secure Boot on again, please set by below procedure.
1) Proceed procedure 1) ~ 3) when disabled the setting.
2) Find Secure Boot control and change to Enabled.
3) Save the change and reboot.
7) Execute the procedure of 2.4.1.1 agin.
MOVERIO Pro Developer's Guide (Rev.1.5)
16
2.4.2. When using Windows 7 OS or before
2.4.2.1. Editing the Google USB Driver
Settings for the BT-2000 are added to the Google USB Driver installed in the previous item.
Open [C:\Users\User name\AppData\Local\Android\sdk\extras\google\usb_driver\android_winusb.inf]
in a text editor, and then add the following 6 lines to 2 points in the [Google.NTx86] and the
[Google.NTamd64].
;EPSON MOVERIO BT-2 series MTP
%SingleAdbInterface% = USB_Install, USB¥VID_04B8&PID_0C06
%CompositeAdbInterface% = USB_Install, USB¥VID_04B8&PID_0C06&MI_01
; EPSON MOVERIO BT-2 series PTP
%SingleAdbInterface% = USB_Install, USB¥VID_04B8&PID_0C07
%CompositeAdbInterface% = USB_Install, USB¥VID_04B8&PID_0C07&MI_01
MOVERIO Pro Developer's Guide (Rev.1.5)
17
2.4.2.2. Vendor ID setting
Set ADB as the vendor ID.
1. Create new file “adb_usb.ini” in “C:/Users/<user name>/.android”.
2. Open this file (adb_usb.ini) in notepad, and add the vendor ID (0x04B8) as shown below.
This completes setting up the ADB driver in the app development environment.
The next section explains how to connect the BT-2000 to a computer.
0x04B8
Omit
Omit
MOVERIO Pro Developer's Guide (Rev.1.5)
18
2.5. Connecting the BT-2000 to a computer
This section explains how to connect the BT-2000 to a computer after the ADB driver setting has
been completed.
2.5.1.1. BT-2000 settings
Start the BT-2000, and then select "Settings" - "Developer options" - "USB debugging".
2.5.1.2. Install the BT-2000 driver
Connect a USB cable to the computer on which the BT-2000 is running and the ADB driver
settings are complete.
If the computer does not respond, disconnect the USB cable, restart the BT-2000, and then
reconnect the USB cable.
When "New device detected" is displayed on the computer, select [Control Panel] - [Hardware
and Sound] - [Device Manager].
Right-click [bt2pro] from [Other devices], and then select Update Driver Software.
MOVERIO Pro Developer's Guide (Rev.1.5)
19
Select [Browse my computer for driver software].
Select the driver from the following path.
“C:\Users\User name\AppData\Local\Android\sdk\extras\google\usb_driver”
When [Android Composite ADB Interface] is displayed in [Android Device] as shown below, ADB
connection is available.
2.5.1.3. Checking the connection
You can check if the computer and the BT-2000 are connected by using the ADB check
command.
Start the command prompt, run "cd C:\Users\ User name \AppData\Local\Android\sdk\tools ", and
move the folder.* It is useful to maintain the environment variable path mentioned above.
When you execute "adb devices" the message "0123456789ABCDEF2 device" is displayed. ADB
connection is complete.
* If this is not displayed, reconnect the BT-2000 to the USB port, and rerun the "adb devices"
command.
MOVERIO Pro Developer's Guide (Rev.1.5)
20
2.6. Including the SDK provided by EPSON
2.6.1. Cautions for using SDK provided by EPSON
Please make sure to confirm the version of SDK provided by EPSON and the version of system
software inside BT-2000.
If the version of SDK provided by EPSON used for Apps development and the version of system
software is not matching, due to the difference of API included, developed Apps may not operate.
※User using system software version R1.0.4
When updating OS from R1.0.4 to R1.2.1 or later, adding callback API process which is newly
added is required.
This phenomenon may occur in below Apps.
・Apps using Voice command class(VoiceCommandClientCallbacks)
If it happens, please solve by below procedure.
1) Change the SDK of Apps development environment to SDK that matching system
software version.
2) Revise the source code according to SDK and re-build.
MOVERIO Pro Developer's Guide (Rev.1.5)
21
2.6.2. How to use SDK provided by EPSON
The following procedures assume app development in Android Studio.
1) Display Project View of Android Studio, and then create “libs” folder from
[File]-[New]-[Directory].
2) C:\Users\<user name>\AndroidStudioProjects\<application name>\app\libs will be
created, and put H725Ctrl.jar to this folder.
(When created project folder is C:\Users\<user name>\AndroidStudioProjects)
※ Explanation from now on is based on that project is at C:\Users\<user
name>\AndroidStudioProjects\<application name>.
3) Press Sync Project with Gradle Files button where it is above of AndroidStudio, reflect
Gradle change to the project.
4) Open build.gradle(Project: <application name>) in the left window of AndroidStudio,
and then edit as below.
allprojects { repositories { jcenter() } gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs.add('-Xbootclasspath/p:C:/Users/<user name>/AndroidStudioProjects/<application name>/app/libs/H725Ctrl.jar') } }
}
MOVERIO Pro Developer's Guide (Rev.1.5)
22
5) Once, run Clean Project from Build items of AndroidStudio.
SDK settings are completed by above.
On edit display, EPSON original API like getSupportedEpsonCameraModes() are still not solved,
but please ignore and run app, and install application to the equipment. Unsolved method will
operate normally.
MOVERIO Pro Developer's Guide (Rev.1.5)
23
2.6.3. To solve unsolved situation by Android Studio
By below method, you can solve the unsolved situation temporary and use code completion
function.
1) Open C:\Users\<user name>\AndroidStudioProjects\<application name>\app\app.iml
2) Move line of
<orderEntry type="library" exported="" name="H725Ctrl" level="project" />
to the line above
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK"/>
This will increase the priority of H725Ctrl.jar in AndroidStudio, and can solve the unsolved
situation temporary and use code completion function.
■Limited items
Due to AndroidStudio specification, after running like rebuild and update gradle contents,
app.iml will be updated too and EPSON original API will return to unsolved situation. Please
proceed above 1), 2) again. Run after build will not be affected.
MOVERIO Pro Developer's Guide (Rev.1.5)
24
3. Display control
MOVERIO Pro Developer's Guide (Rev.1.5)
25
3.1. Display control summary
This chapter explains the display control function for the BT-2000.
The BT-2000 is a smart headset with an optical see-through
function.
You can overlay information on the display using an optical
technique that provides clear images, without disturbing the
view of the user's surroundings. It is also possible to project more information since the device
uses a see-through system allowing images to be projected for both eyes, as opposed to the
single image one-eye type. The advantage with this device is that eye movement is kept to a
minimum, thereby reducing fatigue and making it suitable for use at work.
You can also flip-up the MOVERIO Pro display, which allows you to set the display section by
holding it with one hand when you want to superimpose video or images on your current work
space.
The following section explains the functions and usage methods available.
■ Full screen display function
■ Switch between 2D/3D display function (API)
■ Mute function (API)
■ Backlight control
■ See-through function
MOVERIO Pro Developer's Guide (Rev.1.5)
26
3.2. Full screen display function
The MOVERIO Pro BT-2000 is based on Android 4.0 Tablet UI. This specification does not
normally allow full display in applications in Android 4.0 Tablet UI; however, you can follow the
steps below to enable full display by specifying a unique flag in the app.
■ Executing full screen in applications
Execute the following process in onCreate() for each Activity.
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
winParams.flags 0x80000000
win.setAttributes(winParams);
For apps with multiple Activities, execute the above process for each Activity.
■ Add an import definition
import android.view.Window;
import android.view.WindowManager;
Enable full screen
display
(hide status bar)
Disable full screen
display
(show status bar)
MOVERIO Pro Developer's Guide (Rev.1.5)
27
3.3. Switch between 2D/3D display function
The BT-2000 allows you to display 3D content using Side by side.
The side by side method places images on the left and right of the screen.
When realizing the side by side system with QHD size screen, you need to arrange images from
left to right by reducing 960 x 540 by half(480 x 540 pixels) to create one frame of a QHD
image.
You can use the following interface to separate images for the left and right eyes in the side by
side system, and output each display.
■Inport file
jp.epson.moverio.H725.DisplayControl
■Constructor
DisplayControl(Context context)
Left eye image Right eye image
Total 960
pixels 480 pixels 480 pixels
540 pixels
MOVERIO Pro Developer's Guide (Rev.1.5)
28
■ Interface
int setMode(int DisplayMode, Boolean toast)
■ Parameter
DisplayMode : 2D/3D mode situation
2D Mode : DisplayControl.DISPLAY_MODE_2D
3D Mode : DisplayControl. DISPLAY_MODE_3D
toast : Switch display/un-display of OSD of 2D/3D
Display : true
Un-display : false
MOVERIO Pro Developer's Guide (Rev.1.5)
29
3.4. Backlight control
3.4.1. Adjust backlight brightness
When changing the backlight display built-into the headset, you can change the transparency of
the displayed image.
When the brightness is low, the image is more transparent, and when the brightness is high, the
image is more opaque.
■Import file
jp.epson.moverio.H725.DisplayControl
■Constructor
DisplayControl(Context context)
■ Interface
Display brightness settings
int setBacklight(int backlight)
Display brightness acquisition
int getBacklight()
■ Parameter
backlight: Brightness level 0 (dark) to 20 (bright)
■Return value
Run result 0 (Success), -1(Failure)
MOVERIO Pro Developer's Guide (Rev.1.5)
30
3.5. Mute function
3.5.1. Display mute
The mute function allows you to temporarily stop displaying images.
Use the following interface to activate and then deactivate mute.
■ Import file
jp.epson.moverio.H725.DisplayControl
■Constructor
DisplayControl(Context context)
■ Interface
int setMute(boolean mute)
■ Parameter
mute: Mute ON (TRUE)/OFF (FALSE)
■ Return value
Execution result 0 (normal value), any other value (error)
MOVERIO Pro Developer's Guide (Rev.1.5)
31
3.5.2. Audio mute
The audio mute function allows you to temporarily stop outputting audio.
Use the following interface to activate and then deactivate mute.
■ Import file
jp.epson.moverio.H725. AudioControl
■ Interface
int setMute(boolean mute)
■ Parameter
mute: Mute ON (TRUE)/OFF (FALSE)
■ Return value
Execution result 0 (normal value), any other value (error)
■Attentions
When using int setMute(boolean mute), designate below permission to the Manifest file of App.
<uses-permission
android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
MOVERIO Pro Developer's Guide (Rev.1.5)
32
3.6. See-through function
MOVERIO Pro is a device that uses projection technology.
Projection is displayed by reflecting light through an Active Matrix LCD panel into a light-guided
panel. It is possible to create a half-mirror version (whereby not all the pixels are needed)
allowing images to be arranged over a real-life scene giving a sense of transparency, and creating
a more vivid augmented reality experience.
To create this transparent background effect, so visual elements (text, graphics…) stand out
vividly, the background will need to be set to black when drawing on the projection, so you
display the target section overlapping with the actual images.
(In this situation, we recommend that you do not use the shade.)
The following steps allow you to create this AR effect using the see-through function.
1) Execute full screen support.
To reduce the feeling of being in a screen, remove everything except for the necessary image
(status bar etc…).
2) Make the background black.
Make everything black except for the object you want to display.
In theory, the black section should keep out external light.
Object you want to display Displayed scene
Real scene view
MOVERIO Pro Developer's Guide (Rev.1.5)
33
4. UI control
MOVERIO Pro Developer's Guide (Rev.1.5)
34
4.1. UI control summary
The user interface for the BT-2000 is composed of 11 hardware buttons; power, key lock, A, B, X,
Y, D-pad (up, down, left, right), and the select/OK key. This section explains the functions called
when these buttons are pressed, as well as the key assignment change function that is unique to
the BT-2000.
4.1.1. Hardware button types and functions
The BT-2000 comes with the hardware buttons shown in figure 4-1. The functions for each
button are shown in table 4-1.
Figure 4-1 BT-2000 built-in hardware button
Table 4-1 Button name and its function
Button name Function
Power Turn the device ON/OFF
Key lock Enable/disable button input
A button Back
B button Home
X button Menu
Y button MultiFunctionOSD display (See table 4-2)
D-pad up Upper input
D-pad down Lower input
D-pad left Left input
D-pad right Right input
Select/OK key Confirm
LED indicator
Key lock button
D-pad (up, down, left, right)
D-pad (select/OK)
Power button
A button
B button
X button
Y button
MOVERIO Pro Developer's Guide (Rev.1.5)
35
Table 4-2: MultiFunctionOSD display function
MultiFunction operations
Number of times
button pressed
Function Adjustment method
Press once adjust volume D-pad up/right: Volume Up
D-pad down/left: Volume Down
Press twice Adjust brightness D-pad up/right: Increase screen brightness
D-pad down/left: Decrease screen
brightness
Press three times Switch between 2D/3D D-pad up/right: Set 2D
D-pad down/left: Set 3D
4.1.2. Software keyboard
BT-2000 has iWnnIME as standard character input function. When inputting character, below
keyboard will be displayed and can control by D-pad key.
English keyboard
■Limited items
「SYM」 key cannot be used by D-pad key. Please connect and use mouse for using 「SYM」 key.
MOVERIO Pro Developer's Guide (Rev.1.5)
36
4.1.3. BT-2000 change key assignment function
The BT-2000 allows you to change the functions assigned to the hardware buttons mentioned
above. The standard hardware button assignments are applied in Default mode, the changed
hardware button assignments are applied in User mode.
Default mode User mode
Button name Function Button name Function
Power Turn the device
ON/OFF
Power Turn the device ON/OFF
Key lock Enable/disable
button input
Key lock Enable/disable button
input
A button Back A button F1
B button Home B button F2
X button Menu Change
mode
X button F3
Y button Multi Function OSD
Display
Y button F4
D-pad up Move up D-pad up Move up
D-pad down Move down D-pad down Move down
D-pad left Move left D-pad left Move left
D-pad right Move right D-pad right Move right
select/OK key Confirm select/OK key Confirm
■Events called when buttons are pressed
The following key events are generated.
Hardware button Default mode Key event User mode Key event
A button KeyEvent.KEYCODE_BACK KeyEvent.KEYCODE_F1
B button KeyEvent.KEYCODE_HOME KeyEvent.KEYCODE_F2
X button KeyEvent.KEYCODE_MENU KeyEvent.KEYCODE_F3
Y button ( Reserved in the system ) KeyEvent.KEYCODE_F4
D-pad up KeyEvent.KEYCODE_DPAD_UP
D-pad down KeyEvent.KEYCODE_DPAD_DOWN
D-pad left KeyEvent.KEYCODE_DPAD_LEFT
D-pad right KeyEvent.KEYCODE_DPAD_RIGHT
select/OK key KeyEvent.KEYCODE_DPAD_CENTER
MOVERIO Pro Developer's Guide (Rev.1.5)
37
■Using the change function for key assignments
By changing the key assignments, the key codes called when you press the A, B, X, or Y buttons
are not the standard Back, Home, or Menu buttons in Android, instead, the key codes are
changed to F1 to F4.
Therefore, you can include optional functions to the F1 to F4 codes making use of the A, B, X,
and Y buttons as with the application's original function.
■ Specifications for status transitions in key assignment mode
Status transitions (where the value of the key is changed) for the key assignment mode cannot
be set in the app; they should be set in the system. Management of key assignment mode must
be done by last application before switched. For example, when the key assignment mode for
application A is set to User mode, and then a different application B is started, the key
assignment mode for application B is also set to User mode.
■Specifications for status transitions in key assignment mode when using iWnnIME
The BT-2000 is equipped with a standard iWnnIME text input system. This system uses the
Back, Menu, and D-pad keys for input, and automatically changes the key assignments to
Default mode when starting up the BT-2000. When closing an app, the key assignment mode
changes to the mode set in iWnnIME for the last app that was started, however operations are
not guaranteed when an error occurs or if the app does not close normally.
When an app is constructed with multiple source calls, and calls that apply not just iWnnIME, we
recommend managing the key assignment status according to each app that is started.
■Notes on switching key assignment during key operation
Switching key assignment during pressing and holding the key may cause the wrong key events
to be recognized as it pressed. Don’t call the switching API when the key is pressed for a long
time.
■Notes on function assignment to the simultaneous key press
If you hold down "up"+"down"+"OK" or "left"+"right"+"OK" at the same time, the key lock will
operate. Please do not assign function to press this button simultaneously.
MOVERIO Pro Developer's Guide (Rev.1.5)
38
4.2. Application interface list
Tables 4-3 provide a list of application interfaces for changing key assignments.
You also need to import the following models to use each API.
android.btutil.KeyAssign
Table 4-3 android.btutil.KeyAssign for application interface list
NO. Function name Function summary Notes
1 getKeyAssignMode Acquires the mode for the current key
assignment.
2 setKeyAssignMode Set and apply a key assignment mode.
MOVERIO Pro Developer's Guide (Rev.1.5)
39
4.3. Application interface details
4.3.1. getKeyAssignMode
Function
Acquire the mode for the current key assignment.
Format
Parameter
None.
Return value
Model Explanation
Int - KEYASSIGN_MODE_DEFAULT: Default mode
- KEYASSIGN_MODE_USER: User mode
Usage procedure
static int getKeyAssignMode (void);
int mode; /*Acquire the current mode*/
mode = KeyAssign.getKeyAssignMode ();
if (mode == KeyAssign.KEYASSIGN_MODE_USER) {
/*Process*/ }
MOVERIO Pro Developer's Guide (Rev.1.5)
40
4.3.2. setKeyAssignMode
Function
Set key assignment mode and apply to the system.
Format
Parameter
Model name Explanation
int mode Key assignment mode to be set. You can specify the value
using a macro for the following android.btutil.KeyAssign
classes.
- KEYASSIGN_MODE_DEFAULT (or 0)
- KEYASSIGN_MODE_USER (or 1)
Return value
true: setting succeeded
false: setting failed
Use procedure 1
boolean setKeyAssignMode(int mode);
/*Set user mode*/
KeyAssign.setKeyAssignMode (KeyAssign.KEYASSIGN_MODE_USER);
MOVERIO Pro Developer's Guide (Rev.1.5)
41
5. Voice commands
MOVERIO Pro Developer's Guide (Rev.1.5)
42
5.1. Pre-cautions for developing Voice commands Apps
Please make sure to confirm the version of SDK provided by EPSON and the version of system
software inside BT-2000.
If the version of SDK provided by EPSON used for Apps development and the version of system
software is not matching, due to the difference of API included, developed Apps may not operate.
※User using system software version R1.0.4
When updating OS from R1.0.4 to R1.2.1 or later, adding callback API process which is newly
added is required.
This phenomenon may occur in below Apps.
・Apps using Voice command class(VoiceCommandClientCallbacks)
If it happens, please solve by below procedure.
1) Change the SDK of Apps development environment to SDK that matching system software
version.
2) Revise the source code according to SDK and re-build.
MOVERIO Pro Developer's Guide (Rev.1.5)
43
5.2. Voice commands summary
The BT-2000 voice command will select the voice information file(lms file), and recognizes the
voice included in this information, and returns the corresponding ID. Voice is inputted using a
microphone, and the device recognizes the voice that has been registered*.
By mounting a process in the application for each ID acquired by callback, voice input can be used
as a trigger.
* Only vocabulary that is included in the voice information file can be recognized, this differs from
the standard sound recognition software that uses network access to confirm words.
MOVERIO Pro Developer's Guide (Rev.1.5)
44
5.3. Application interface function summary
You can use the following functions by using audio command API.
(1) Connect to a service class that provides audio command functions.
(2) Disconnect from a service class that provides audio command functions.
(3) Acquire an interface to control audio commands.
(4) Register a callback.
(5) Cancel a callback.
(6) Set parameters used for the audio recognition start conditions.
(7) Enable audio input status.
(8) Disable audio input status.
(9) Receive the recognition result of voice commands
(10) Receive the situation of if voice commands can receive the input
To use API, execute VoiceCommandClient.bindToRemoteRunningService() first and connect to a
service class that provides a voice command function. Next, execute
VoiceCommandClient.registerCallback() to register a callback to receive recognition results.
When connection to the service is complete, execute getVoiceCommandSystemInterface() to
acquire the interface for controlling the voice command function.
MOVERIO Pro Developer's Guide (Rev.1.5)
45
5.4. Application interface list
Tables 5-1 and 5-2 provide a list of application interfaces for using the voice command function.
You also need to import the following models to use each API.
android.media.epson.IVoiceCommandInterface
android.media.epson.IVoiceCommandServiceCallbacks
android.media.epson.VoiceCommandClient
android.media.epsonVoiceCommandClientCallbacks
Table 5-1 android.media.epson.IVoiceCommandInterface for application interface list
NO. Function name Function summary
1 setSnr Set parameters used for the voice recognition start
conditions. Set the recognition start conditions according to
the amount (S/N ratio) of surrounding voice (noise)
compared with the input voice.
2 getSnr Acquire the current value for the set S/N ratio.
3 setAmp Set parameters used for the voice recognition start
conditions. Set the recognition start conditions according to
the amplitude for the input voice.
4 getAmp Acquire the setting for the amplitude of the current input
voice.
5 start Enable voice input.
6 stop Disable voice input.
Table 5-2 android.media.epson. VoiceCommandClient for application interface list
NO. Function name Function summary
1 registerCallback Register a callback to acquire the recognition
results for a voice command.
2 unRegisterCallback Cancel a callback to acquire the recognition
results for a voice command.
3 getVoiceCommandSystemInterface Acquire an IVoiceCommandInterface class as
the interface to control voice commands.
4 bindToRemoteRunningService Connect to a service class of voice commands.
5 unBindFromRemoteRunningService Disconnect from a service class of voice
commands.
MOVERIO Pro Developer's Guide (Rev.1.5)
46
Table5-3 android.media.epson. VoiceCommandClientCallbacks application interface list
NO. Function name Function summary
1 onServiceConnected Called after connection to service class
implementing callback of voice command
function has completed.
2 onServiceDisconnected Called when service controlling voice
command is stopped for some reasons.
3 onVoiceCommand Callback for receiving voice command
recognition result.
4 onSpeakable Callback for receiving if voice command
system is accepting voice input or not
MOVERIO Pro Developer's Guide (Rev.1.5)
47
5.5. Application interface details
5.5.1. setSnr
Function
Set parameters used for the voice recognition start conditions. Set the recognition start
conditions according to the amount (S/N ratio) of voice (noise) being input in the usage
environment.
Format
Parameter
Value of the S/N ratio to be set. Minimum: 0, Maximum: 255.99, default: 10.0
If the value is too large, the app should not be influenced by surrounding noise,
however the user will need to talk loudly to trigger a response.
For recommended value, refer to 5.8.2 Recommended value of voice recognition
starting condition.
Return value
Model Explanation
boolean Success: true, Failure: false
5.5.2. getSnr
Function
Acquire the set S/N ratio.
Format
Parameter
None.
Return value
Model Explanation
float The current S/N ratio value used as the recognition start condition.
boolean setSnr (float snr) throws RemoteException;
float getSnr() throws RemoteException;
MOVERIO Pro Developer's Guide (Rev.1.5)
48
5.5.3. setAmp
Function
Set parameters used for the voice recognition start conditions. Set the amplitude value as
one of the recognition start conditions.
Format
Parameter
Value of the amplitude to be set. Minimum: 0, Maximum: 32767, default: 1024
If the value is too large, the app should not be influenced by surrounding noise,
however the user will need to talk loudly to trigger a response.
For recommended value, refer to 5.8.2 Recommended value of voice recognition
starting condition.
Return value
Model Explanation
boolean Success: true, Failure: false
boolean set Amp (int amp) throws RemoteException;
MOVERIO Pro Developer's Guide (Rev.1.5)
49
5.5.4. getAmp
Function
Acquire the set amplitude value.
Format
Parameter
None.
Return value
Model Explanation
Int Receive the value for the amplitude as the input voice recognition
start condition.
5.5.5. start
Function
Enable voice input status.
Format
Parameter
Absolute path to the lms file. When null is specified, the lms file stored in the system is
automatically selected and set (the default lms file will be used) based on the region
information for the operating system of the BT-2000.
Return value
Model Explanation
boolean Success: true, Failure: false
int getAmp() throws RemoteException;
boolean start(String path) throws RemoteException;
MOVERIO Pro Developer's Guide (Rev.1.5)
50
5.5.6. stop
Function
Disable voice input.
Format
Parameter
None.
Return value
Model Explanation
boolean Success: true, Failure: false
5.5.7. registerCallback
Function
Register a callback to acquire the recognition results for a voice command.
Format
Parameter
VoiceCommandClientCallbacks class object
Return value
None
boolean stop(void) throws RemoteException;
void registerCallback(VoiceCommandClientCallbacks cb)
MOVERIO Pro Developer's Guide (Rev.1.5)
51
5.5.8. unRegisterCallback
Function
Cancel a callback to acquire the recognition results for a voice command.
Format
Parameter
None.
Return value
None.
5.5.9. getVoiceCommandSystemInterface
Function
Acquire a class as the interface to control voice commands.
Format
Parameter
None.
Return value
Model Explanation
IVoiceCommandInterface Interface for voice command control
Cautions
Execute inside or after VoiceCommandClientCallbacks.onServiceConnected().
void unRegisterCallback()
IVoiceCommandInterface getVoiceCommandSystemInterface()
MOVERIO Pro Developer's Guide (Rev.1.5)
52
5.5.10. bindToRemoteRunningService
Function
Connect to a service class that provides voice command functions.
Format
Parameter
An Activity object connected to the voice command service.
Return value
None.
5.5.11. unBindFromRemoteRunningService
Function
Disconnect from a voice command service.
Format
Parameter
An Activity object connected to the voice command service.
Return value
None.
void bindToRemoteRunningService(Activity activity);
void unBindFromRemoteRunningService(Activity activity)
MOVERIO Pro Developer's Guide (Rev.1.5)
53
5.5.12. onVoiceCommand
Function
When detecting word that voice command system detected, callback returning ID of
the word and character string.
Format
Parameter
Model Explanation
int id ID number of the detected word
String word Character string of the detected word
Return value
None
void onVoiceCommand(int id, String word)
MOVERIO Pro Developer's Guide (Rev.1.5)
54
5.5.13. onSpeakable
Function
Callback noticed when voice command system voice receiving situation has changed.
Format
Parameter
Model Explanation
boolean on true: Voice input acceptable situation false: Voice input
not acceptable situation
Return value
None
void onSpeakable(boolean on)
MOVERIO Pro Developer's Guide (Rev.1.5)
55
5.6. Sample code
package com.epson.moverio.bt2pro.sample.vcmd; import android.media.epson.IVoiceCommandInterface; import android.media.epson.VoiceCommandClient; import android.media.epson.VoiceCommandClientCallbacks; import android.os.Bundle; import android.os.RemoteException; import android.app.Activity; import android.content.Context; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends Activity implements VoiceCommandClientCallbacks { private Context mContext = null; private Button mStartButton = null; private Button mStopButton = null; private VoiceCommandClient mVoiceCommandClient = null; private IVoiceCommandInterface mVoiceCommandSystem; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = getApplicationContext(); mVoiceCommandClient = new VoiceCommandClient(); mVoiceCommandClient.bindToRemoteRunningService(this); mStartButton = (Button) findViewById(R.id.start); mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { mVoiceCommandSystem.start("/system/vendor/bin/epe_au01_j1.lms"); } catch (RemoteException e) { e.printStackTrace(); } } }); mStopButton = (Button) findViewById(R.id.stop); mStopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { mVoiceCommandSystem.stop(); } catch (RemoteException e) { e.printStackTrace(); } } }); } @Override protected void onResume() { super.onResume(); mVoiceCommandClient.registerCallback(this); } @Override protected void onPause() {
MOVERIO Pro Developer's Guide (Rev.1.5)
56
super.onPause(); mVoiceCommandClient.unRegisterCallback(); } @Override protected void onDestroy() { super.onDestroy(); mVoiceCommandClient.unBindFromRemoteRunningService(this); } @Override public void onServiceConnected() { mVoiceCommandSystem = mVoiceCommandClient.getVoiceCommandSystemInterface(); } @Override public void onServiceDisconnected() { } @Override public void onVoiceCommand(int id, String word) { Toast.makeText(MainActivity.this, "MainActivity ID:"+id+"
"+word, Toast.LENGTH_SHORT).show(); } @Override public void onSpeakable(boolean speakable){ Toast.makeText(MainActivity.this, "RA: " + speakable, Toast.LENGTH_SHORT).show(); } }
MOVERIO Pro Developer's Guide (Rev.1.5)
57
5.7. Default Supported Words
5.7.1. Voice information files (lms file) list and vocabulary list
- /system/vendor/bin/epe_au01_E1.lms default lms file(For English)
- /system/vendor/bin/epe_au01_E2.lms
・epe_au01_E1.lms
IDnumber Voice input IDnumber Voice input IDnumber Voice input
2 Menu 19 Display Off 33 Action 3
3 Next 21 Blue 34 Action 4
4 Return 22 Red 35 Action 5
5 Enter 23 Green 51 Zoom In
6 Start 24 Yellow 52 Zoom Out
7 Stop 31 Action1 101 Version
18 Display On 32 Action 2
・epe_au01_E2.lms
IDnumber Voice input IDnumber Voice input IDnumber Voice input
1 Home 15 Go Left 42 Item 2
8 Try again 16 Go Up 43 Item 3
9 Finish 17 Go Down 44 Item 4
10 Connect 21 Blue 45 Item 5
11 Shoot 22 Red 101 Version
12 Rotate 23 Green
13 Setting 24 Yellow
14 Go Right 41 Item1
MOVERIO Pro Developer's Guide (Rev.1.5)
58
5.8. Others
5.8.1. Timing for reflecting the setting for the voice recognition start conditions
When audio input recognition switches from disabled to enabled, the voice recognition start
conditions are reflected in the system.
Therefore, if you change the recognition start conditions when audio input is enabled, once call
IVoiceCommandInterface.stop(), disable audio input and call IVoiceCommandInterface.setSnr() to
set the voice recognition starting condition. After IVoiceCommandInterface.start() is called,
setting is then reflected by the system.
5.8.2. Recommended value of voice recognition starting condition
When recognition errors occur often due to noise of using environment, recognition errors can be
reduced by changing the voice recognition starting condition according to the noisiness(noise
level).
Recommended value for each noise level is as below. This parameter is a setting value to have
better voice recognition under white noise or machine noise. Optimum value is different by the
noise type, so please set according to the actual used environment. For setting method, refer to
5.4 Application interface list.
Noise level(dB) Noisiness S/N ratio Amplitude
35dB Silent 10 1000
55dB Little noisy 15 1500
70dB Noisy 15 2500
For default value, refer to 5.5.1 setSnr and 5.5.3 setAmp.
S/N ratio Amplitude
Default value 10 1024
MOVERIO Pro Developer's Guide (Rev.1.5)
59
5.8.3. Running voice command and video recording together
Due to Android 4.0 specification, voice command and video recording cannot run together.
For video recording, please finish voice command.
MOVERIO Pro Developer's Guide (Rev.1.5)
60
5.8.4. Voice command API usage flow example
See the sample source for voice commands for more details.
5.8.5. Callback onSpeakable for receiving speaking timing
In voice command system, when noise is inputted and judged as speech from S/N ratio or
Amplitude value (Amp value), it enters into recognition process, and will not accept voice input
for a moment. Also after recognizable word is detected, it will be in transferring process to be in
recognition acceptable situation again, so there is a period that cannot accept voice input. By
showing this period as GUI, it can improve voice command convenience. In details, , implement
VoiceCommandClientCallbacks interface of
Android.media.epson.VoiceCommandClientCallbacksand define onSpeakable(), then can receive
speech acceptable timing.
■Application to set S/N ratio and amplitude(AMP value) accorded to the environment
If onSpeakable is called when there is no speech situation, three is a possibility of reacting to
surround noise. Therefore, using onSpeakble receiving value as index, set S/N ratio and Amp
value to make value received from onSpeakable becomes always true while not speaking. By this
way, it is possible to set S/N, amplitude (AMP value) more suitable for using environment.
MOVERIO Pro Developer's Guide (Rev.1.5)
61
5.8.6. Sample App
This chapter explains about voice command sample App that is pre-installed inBT-2000.
1. App information
App name:VoiceCommandSample.apk
Icon image
2. Summary
BT-2000 has function to recognize voice inputted from voice input equipment like headset
microphone included, judge applicable word exist or not inside registered voice information
file(lms), and notice ID and character string to App according to the judgment. This App is a
sample App using this voce command function.
MOVERIO Pro Developer's Guide (Rev.1.5)
62
3. Function
ⅰ.Voice information(lms)file change
BT-2000 has voice information file written in 5.7.1Voice information files (lms file) list and
vocabulary list and vocabulary list inside the system.By specifying these, it is available to
detect registered word of selected file from inputted voice.f
ⅱ.Voice detection, receiving detected word and ID by App
When voice is inputted by microphone and applicable voice is detected, ID number related
to the detected word will be noticed to the App. App will display ID and character string of
the detected word to the display by toast.
ⅲ.Voice command parameter setting
Voice command function has a threshold as a parameter to decide whether inputted voice is
am speech by human or a noise. Parameter has 2 series, S/N ratio and AMP value. By
adjusting these, it is available to use voice command function where noise level is high.
・S/N ratio setting
Compared to surround noise, how much bigger sound inputted to be decided as a speech
(Unit dB).
Min value 0 Max value 255.99 Initial setting 10.0
・AMP value setting
Sound pressure level of inputted voice to be decided as a speech.
Min value 0 Max value 32767 Initial setting 1024
MOVERIO Pro Developer's Guide (Rev.1.5)
63
4. Sample App operation method
① S/N ratio setting
Display S/N ratio setting value that is currently applied.
② S/N ratio changing UI
Can set value by selecting up arrow or down arrow or the value
Left 3 figures are integer figure, right 2 figures are decimal figure.
③ OK button(For S/N ratio setting)
Set the value selected by ② to the voice command system.
④ AMP setting value
Display AMP value that is currently applied.
⑤ AMP setting value changing UI
Can set value by selecting up arrow or down arrow or the value
⑥ OK button(For AMP value setting)
Set the value selected by ⑤ to the voice command system.
⑦ Start button, Stop button
Start button:Apply S/N ratio value, AMP value , voice information(lms) to the voice
command system and make voice detection effective.
Stop button:Invalid voice detection.
⑧ Display voice information(lms)file
Display voice information (lms) file that currently selected.
When App started, it displays ”lms file name”. In this situation, when you make ⑦ voice
detection effective, it operates as default voice information (lms) hold inside system as the
word recognition list.
⑨ Voice information(lms) file changing file dialog button
Display file dialog for selecting voice information(lms)file.
A GUI to display situation whether the voice command system accept voice input or not.
When blue microphone is displayed, voice input is acceptable. When red microphone is
displayed, voice input is not acceptable.
①
② ③
④
⑤ ⑥
⑦
⑧
A
MOVERIO Pro Developer's Guide (Rev.1.5)
64
・Remarks
At timing of Start button pressed, data necessary for system operation like S/N ratio and lms
file will be applied to the system. While voice command is in operation(When voice detection
is available), setting value like S/N ratio that changed by the App does not apply when
pressing the Start button. In this situation, press Stop button once, stop the voice command
and then change again the setting value and press the Start button.
5. Voice information(lms)file
Use Voice information (lms) that is stored inside BT-2000 system. For detail, refer to chapter
5.7.1Voice information files (lms file) list and vocabulary list.
MOVERIO Pro Developer's Guide (Rev.1.5)
65
6. Camera control
MOVERIO Pro Developer's Guide (Rev.1.5)
66
6.1. Pre-cautions for developing camera Apps
As BT-2000 is adopting own camera function, take below cautions for developing App using
camera.
To use BT-2000 camera function of 5M、Depth、Side-by-Side and EDof, it is required to switch
camera settings.
Therefore, different from normal Android equipment, it is adopting concept of camera mode.
Available setting of camera resolution and frame rate is different by each camera mode. Please
specify resolution and frame rate which the applied camera mode is supporting. For details,
refer to 6.3 Available parameters.
MOVERIO Pro Developer's Guide (Rev.1.5)
67
6.2. Function summary
This chapter explains the available camera functions for the BT-2000.
The headset section of the BT-2000 is equipped with a stereo camera which offers a wide
variety of uses including the following three types of camera image.
1) Standard camera images
2) Stereo images using the compound camera
3) Depth (distance) images using the compound camera
You need to change the camera to the target mode. For image combinations supported in each
mode, see table 6-1 , 6-2 and 6-3.
Table 6-1 Camera mode
Camera mode Explanation
single-through-vga Normal still image shooting mode by 640x480 resolution
single-through-720p Normal still image shooting mode by 1280x720 resolution
single-through-1080p Normal still image shooting mode by 1920x1080 resolution
single-through-5m Normal still image shooting mode by 2576x1936 resolution
depth-only Mode to receive depth information only
side-by-side Mode for host to create depth information. Can receive the
image together from 2 camera sensors by 4096x1936
resolution
EDof
Mode to receive normal still image shooting and depth
information at same time
※By each camera mode, shooting area(viewing angle) and aspect ratio of preview and still
image shooting is different.
Especially for single-throgh-1080p camera mode, shooting area is narrow compared to other
camera mode.
MOVERIO Pro Developer's Guide (Rev.1.5)
68
6.3. Available parameters
A list of available parameters is provided in table 6-2 and 6-3.
Table 6-2 List of available parameters
Parameter name Setting region Default value
Camera Mode single-through-vga / single-through-720p /
single-through-1080p / single-through-5m /
depth-only / side-by-side / EDof
Single-through-720p
Preview resolution*1 1080p / 720p / VGA 720p
Video resolution 720p/VGA -
Depth ON/OFF*1 OFF/ON OFF
Frame rate*1 60/30/15/7.5 15
Exposure
comensation*2
-5 to +6 0
White balance*2 Daylight/ Fluorescent/ Warm florescent Fluorescent
Sharpness -3 to +3 0
Contrast -3 to +3 0
*1: The available range varies depending on the mode. See table 6-3 for more information.
*2: Auto exposure works from system software version R1.4.0, and will automatically change the exposure setting
according to surround brightness. If the result of auto exposure is too bright or toodark, please compensate the
brightness by exposure compensation.
*3: White balance is set manually. Make setting according to your usage environment.
Table 6-3 List of main parameter combinations
Camera Mode Still image
resolution
Preview resolution Frame rate
single-through-vga 640x480 640x480 7.5fps
15fps
30fps
60fps
single-through-720p 1280x720 640x480
1280x720
7.5fps
15fps
30fps
single-through-1080p 1920x1080 640x480
1280x720
1920x1080
7.5fps
15fps
single-through-5m 2576x1936 640x480
1280x720
1920x1080
7.5fps
depth-only - - 7.5fps
15fps
side-by-side side-by-side 4096x1936 640x480
EDof 2576x1936
640x480
1280x720
7.5fps
MOVERIO Pro Developer's Guide (Rev.1.5)
69
6.4. Image organization and format
You can acquire the following three types of data using API in the BT-2000.
・ Standard images (NV21)
・ Side by Side images (NV21)
・ Depth (distance) data (8bit Gray Scale)
Figure 6-1 Example of standard images
Figure 6-2 Example of side by side images
Depth data is explained in the next section.
MOVERIO Pro Developer's Guide (Rev.1.5)
70
6.5. Depth data characteristics
Depth data is managed using 8 bit gray scale data, whereby the data values (brightness)
indicate the distance.
The higher the depth value brings the depth data distance closer, and reducing the value makes
it further away. When converting the brightness as gray scale data, the highest value of 255
brings the distance closer, and the lowest value of 0 makes it further away.
Figure 6-3 Shooting depth images
Furthermore, use data inferred in this way as the correct value is not provided in the product
specifications for depth data with a 50 pixel edge.
Figure 6-4 Available range for depth data
Far Near
Except for surrounding 50
pixels,
the 540x380 area is available
50pixel
50pixel
MOVERIO Pro Developer's Guide (Rev.1.5)
71
For the relationship between the distance and depth data, see the following table. Note that
changes and calculation errors in the shooting environment for the depth data may also occur.
Equation 6-1 Distance: Distance = 10 × 255 𝐷𝑒𝑛𝑠𝑖𝑡𝑦⁄ [𝑐𝑚]
※As Depth data is received by Java byte type, it is shown by -128~127. So to handle Depth
data as Density, it is required to cast to int type and convert to 0~255.
Java Code ex.) int intDencity = byteDepthData & 0xFF;
MOVERIO Pro Developer's Guide (Rev.1.5)
72
6.6. Application interface function summary
The following explains how to use API to achieve the following three functions.
1) Set the camera mode, frame rate, preview resolution, and camera resolution for the
BT-2000, and display a preview.
2) Process the image data in the app.
3) Acquire depth information with the application.
Note that the API specification explained in this section is not thread safe in compliance with the
specifications compared to android.hardware.Camera, and therefore cannot be used at the
same time for multiple threads.
The following 13 APIs are used in (1).
1-1 getSupportedEpsonCameraMode
1-2 setEpsonCameraMode
1-3 getEpsonCameraMode
1-4 setPreviewFpsRange
1-5 setPreviewSize
1-6 getSupportedSharpnessMin
1-7 getSupportedSharpnessMax
1-8 getSharpness
1-9 setSharpness
1-10 getSupportedContrastMin
1-11 getSupportedContrastMax
1-12 getContrast
1-13 setContrast
The following 5 APIs are used in (2).
2-1 onPreviewFrame
2-2 setPreviewCallback
2-3 setOneShotPreviewCallback
2-4 setPreviewCallbackWithBuffer
2-5 addCallbackBuffer
The following 4 APIs are used in (3).
3-1 onDepthMap
3-2 setDepthCallback
3-3 startDepthStreaming
3-4 stopDepthStreaming
MOVERIO Pro Developer's Guide (Rev.1.5)
73
6.7. Application interface list
Tables 6-4 and 6-5 provide a list of application interfaces for using the following functions.
1) You can change the camera mode, frame rate, and preview resolution for the BT-2000, and
display a preview.
2) Acquire preview data with the application.
You also need to import the following models to use each API.
android.hardware.Camera
Table 6-4 Camera.Parameters application interface list
NO. Function name Function summary Notes
1 getSupportedEpsonCameraMod
e
Acquire a list of modes supported by the
camera.
Epson original API
2 setEpsonCameraMode Set the camera mode. Epson original API
3 getEpsonCameraMode Acquire the current camera mode setting. Epson original API
4 setPreviewFpsRange Set the frame rate range. Standard Android API
5 setPreviewSize Set the preview resolution. Standard Android API
6 getSupportedSharpnessMin Acquire the minimum available sharpness value. Epson original API
7 getSupportedSharpnessMax Acquire the maximum available sharpness
value.
Epson original API
8 getSharpness Acquire the current sharpness value. Epson original API
9 setSharpness Set the sharpness value. Epson original API
10 getSupportedContrastMin Acquire the minimum available contrast value. Epson original API
11 getSupportedContrastMax Acquire the maximum available contrast value. Epson original API
12 getContrast Acquire the current contrast value. Epson original API
13 setContrast Set the contrast value. Epson original API
Table 6-5 Callbackinterface list when using camera
NO. Function name Function summary Notes
1 Camera.PreviewCallback.onPre
viewFrame
Describes processing content when acquiring
image data.
Standard Android API
2 Camera.setPreviewCallback Register the image data acquisition callback
method. Called repeatedly when image data is
acquired.
Standard Android API
3 Camera.setOneShotPreviewCall
back
Register the image data acquisition callback
method. Calls once for each image data
registered.
Standard Android API
4 Camera.setPreviewCallbackWit
hBuffer
Register the image data acquisition callback
method. You can raise the processing efficiency
by specifying a buffer.
Standard Android API
5 Camera.addCallbackBuffer Register the buffer used in
setPreviewCallbackWithBuffer.
Standard Android API
MOVERIO Pro Developer's Guide (Rev.1.5)
74
By using the API provided by the BT-2000, you can display a preview and handle image data.
In either situation, you need to set the camera parameters. You can change the camera mode,
frame rate, preview resolution, and camera resolution. However, when setting the camera
parameters, you need to stop the previews temporarily by using stopPreview. Also, make sure
you use pre-established parameter combinations.
Note that values larger than 1080p set for the preview will not be displayed.
When handling image data, you need to register the image data acquisition callback method.
Figure 6-5 shows an example of the flow for the API used in this guide.
After starting the camera, the camera mode is set and the preview starts. During a preview, you
can register the image acquisition callback method as necessary, and acquire images. Execute
processing for the acquired images in the app.
* Because the API in this guide does not comply with the android.hardware.Camera
specifications and thread safe are not available, do not handle multiple threads at the same
time.
Figure 6-5 Example of API usage flow
(1) Set Mode
(2) Receive the images
Camera.open
Camera.getParameters
Camera.Parameters. setEpsonCameraMode
Camera.startPreview
Camera.stopPreview
Camera.setParameters
Camera. setPreviewCallback
Camera.PreviewCallback. onPreviewFrame
If the callback is registered...
Register callback method
MOVERIO Pro Developer's Guide (Rev.1.5)
75
6.8. Application interface details
6.8.1. getSupportedEpsonCameraModes
Function
Acquire a list of camera modes supported by the BT-2000 camera.
Format
Parameter
None.
Return value
Model Explanation
List<String> Acquire the current camera mode set in the BT-2000.
Camera mode list
Camera mode Explanation
single-through-vga Normal still image shooting mode by 640x480 resolution
single-through-720p Normal still image shooting mode by 1280x720 resolution
single-through-1080p Normal still image shooting mode by 1920x1080
resolution
single-through-5m Normal still image shooting mode by 2576x1936
resolution
depth-only Mode to receive depth information only
side-by-side Mode for host to create depth information. Can receive
the image together from 2 camera sensors by 4096x1936
resolution.
EDof Mode to receive normal still image shooting and depth
information at same time. Camera resolution and
shooting resolution are 2576x1936.
List<String> getSupportedEpsonCameraMode (void);
MOVERIO Pro Developer's Guide (Rev.1.5)
76
Procedure (camera is a Camera class object)
/*Start camera*/ camera = Camera.open(); /*Acquire current parameters*/ Camera.Parameters params = camera.getParameters(); /*Acquire provided camera mode*/ List<String> Supported = params.getSupportedEpsonCameraMode();
MOVERIO Pro Developer's Guide (Rev.1.5)
77
6.8.2. setEpsonCameraMode
Function
Set the BT-2000 camera mode.
Format
Parameter
Model name in/out Explanation
String mode in Set camera mode. Set using macros for the following seven
Camera.Parameters classes.
- EPSON_CAMERA_MODE_SIDE_BY_SIDE
- EPSON_CAMERA_MODE_SINGLE_THROUGH_VGA
- EPSON_CAMERA_MODE_SINGLE_THROUGH_720P
- EPSON_CAMERA_MODE_SINGLE_THROUGH_1080P
- EPSON_CAMERA_MODE_SINGLE_THROUGH_5M
- EPSON_CAMERA_MODE_DEPTH_ONLY
- EPSON_CAMERA_MODE_EDOF
Return value
None.
Measurement table for macro and camera mode
Macro Camera mode
EPSON_CAMERA_MODE_SIDE_BY_SIDE side-by-side
EPSON_CAMERA_MODE_SINGLE_THROUGH_VGA single-through-vga
EPSON_CAMERA_MODE_SINGLE_THROUGH_720P single-through-720p
EPSON_CAMERA_MODE_SINGLE_THROUGH_1080P single-through-1080p
EPSON_CAMERA_MODE_SINGLE_THROUGH_5M single-through-5m
EPSON_CAMERA_MODE_DEPTH_ONLY depth-only
EPSON_CAMERA_MODE_EDOF EDof
void setEpsonCameraMode ( String mode );
MOVERIO Pro Developer's Guide (Rev.1.5)
78
Use procedure 1 (when side by side is set)
Use procedure 2 (when preview has already started)
Remarks
After setting the camera mode in setEpsonCameraMode, be sure to perform
setParameters. Changed content is not reflected in the camera device until
setParameters is executed.
When the preview has already started, use stopPreview to temporarily stop the
preview, and then set the camera mode.
Each camera mode has a limited combination of preview resolutions and frame rates.
Note that a run-time exception will occur in setParameters for combinations that
exceed the limit.
The parameters for associated frame rates and preview resolutions will not change
even if you set the camera mode in setEpsonCameraMode. Application developers
should set these parameters using appropriate combinations before executing
setParameters. Please refer to Table 6-4 for available setting parameters.
Capturing resolution is fixed by each mode. Change setting by using setPictureSize
which is Android standard API is not available.
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Set camera mode to side by side*/
params.setEpsonCameraMode(Camera.Parameters.EPSON_CAMERA_MO
DE_SIDE_BY_SIDE);
/*Reflect camera setting in camera device*/
camera.setParameters(params);
/*Start preview*/
camera.startPreview();
/*Stop preview*/
camera.stopPreview();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*From here on, use procedure 1*/
MOVERIO Pro Developer's Guide (Rev.1.5)
79
6.8.3. getEpsonCameraMode
Function
Acquire the current camera mode.
Format
Parameter
None.
Return value
Model Explanation
String You can acquire the current camera mode as a return value.
”side-by-side”
”single-through-vga”
“single-through-720p”
“single-through-1080p”
“single-through-5m”
”depth-only”
“edof”
Usage procedure
String getEpsonCameraMode (void);
/*Start camera*/
camera = Camera.open();
/*Acquire current parameters*/
Camera.Parameters params = camera.getParameters();
/*Acquire the current camera mode*/
String mode = params.getEpsonCameraMode();
MOVERIO Pro Developer's Guide (Rev.1.5)
80
6.8.4. setPreviewFpsRange
Function
Set the minimum and maximum values for the frame rate.
You need to set the maximum and minimum values to same values that can be
acquired in getSupportedPreviewFpsRange().
Table 6-3 List of main parameter combinations shows the framerate that can be set
for each camera mode.
Format
Parameter
Model name in/out Explanation
int min in Minimum value for preview FPS (Set the value in multipliers
of 1000, so 7.5 fps would be 7500)
int max in Maximum value for preview FPS (Set the value in
multipliers of 1000)
Return value
None.
Use procedure 1 (set the fps to 7.5)
void setPreviewFpsRange ( int min, int max );
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Set camera mode to side by side*/
params.setPreviewFpsRange(7500, 7500);
/*Reflect camera setting in camera device*/
camera.setParameters(params);
/*Start preview*/
camera.startPreview();
MOVERIO Pro Developer's Guide (Rev.1.5)
81
Use procedure 2 (when preview has already started)
Remarks
After setting the frame rate in setPreviewFpsRange, be sure to perform
setParameters. Changed content is not reflected in the camera device until
setParameters is executed.
When the preview has already started, use stopPreview to temporarily stop the
preview.
Each frame rate has a limited combination of preview resolutions and camera
modes. Note that a run-time exception will occur in setParameters for
combinations that exceed the limit.
/*Stop preview*/
camera.stopPreview();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*From here on, use procedure 1*/
MOVERIO Pro Developer's Guide (Rev.1.5)
82
6.8.5. setPreviewSize
Function
Set the preview resolution.
Table 6-3 List of main parameter combinations shows the preview resolutions that can
be set for each camera mode.
Format
Parameter
Model name in/out Explanation
int width in Width of preview image
int height in Height of preview image
Return value
None.
void setPreviewSize ( int width, int height );
MOVERIO Pro Developer's Guide (Rev.1.5)
83
Use procedure 1 (Set the camera mode to single-through-5m and the preview resolution
to VGA)
In this example, the width and height of the image are reduced to approximately 1/4 and
displayed in a preview.
Use procedure 2 (when preview has already started)
Remarks
After setting the preview resolution in setPreviewSize, be sure to perform
setParameters. Changed content is not reflected until setParameters is executed.
When the preview has already started, use stopPreview to temporarily stop the
preview.
Each preview resolution has a limited combination of frame rates and camera
modes. Note that a run-time exception will occur in setParameters for
combinations that exceed the limit.
You cannot set single-through-5m or side-by-side as the preview resolution. If
you want to acquire images in single-through-5M or side-by-side, perform
shooting by using takePicture.
The resolution set for preview resolution uses image data acquired in
PreviewCallback.
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Set camera mode to single-through-5m*/
params.setEpsonCameraMode(Camera.Parameters.EPSON_CAMERA_MODE_SINGLE_THROU
GH_5M);
/*Set preview resolution to VGA*/
params.setPreviewSize(640, 480);
/*Set frame rate to 7.5fps*/
params.setPreviewFpsRange(7500, 7500);
/*Reflect camera setting in camera device*/
camera.setParameters(params);
/*Start preview*/
camera.startPreview();
/*Stop preview*/
camera.stopPreview();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*From here on, use procedure 1*/
MOVERIO Pro Developer's Guide (Rev.1.5)
84
6.8.6. getSupportedSharpnessMin/getSupportedSharpnessMax
Function
Acquire the minimum/maximum available sharpness value.
Format
Parameter
None.
Return value
Model Explanation
int Return the minimum/maximum available sharpness value.
For the BT-2000, these are -3 and +3.
int getSupportedSharpnessMin ();
int getSupportedSharpnessMax ();
MOVERIO Pro Developer's Guide (Rev.1.5)
85
6.8.7. getSharpness
Function
Acquire the current sharpness value.
Format
Parameter
None.
Return value
Model Explanation
int Return the current sharpness value.
For the BT-2000, this is -3 to +3.
int getSharpness ();
MOVERIO Pro Developer's Guide (Rev.1.5)
86
6.8.8. setSharpness
Function
Set the sharpness value.
Format
Parameter
None.
Return value
Model Explanation
int Set the sharpness value.
For the BT-2000, you can set -3 to +3.
Usage procedure
Important points
After setting the sharpness value in setSharpness, be sure to perform
setParameters. Changed content is not reflected until setParameters is executed.
void setSharpness (int);
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Acquire the current sharpness value*/
int sharpness = params.getSharpness();
sharpness++;
/*When the sharpness value enters an available setting range, it is
set*/
if (sharpness <= params.getSupportedSharpnessMax() &&
sharpness >= params.getSupportedSharpnessMin() ) {
params.setSharpness(sharpness);
camera.setParameters(params);
}
MOVERIO Pro Developer's Guide (Rev.1.5)
87
6.8.9. getSupportedContrastMin/getSupportedContrastMax
Function
Acquire the minimum/maximum available contrast value.
Format
Parameter
None.
Return value
Model Explanation
int Return the minimum/maximum available contrast value.
For the BT-2000, these are -3 and +3.
int getSupportedContrastMin ();
int getSupportedContrastMax ();
MOVERIO Pro Developer's Guide (Rev.1.5)
88
6.8.10. getContrast
Function
Acquire the current contrast value.
Format
Parameter
None.
Return value
Model Explanation
int Return the current contrast value.
For the BT-2000, this is -3 to +3.
int getContrast ();
MOVERIO Pro Developer's Guide (Rev.1.5)
89
6.8.11. setContrast
Function
Set the contrast value.
Format
Parameter
None.
Return value
Model Explanation
int Set the contrast value.
For the BT-2000, you can set -3 to +3.
Usage procedure
Remarks
After setting the contrast value in setContrast, be sure to perform setParameters.
Changed content is not reflected until setParameters is executed.
void setContrast (int);
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Acquire the current contrast value.*/
int contrast = params.getContrast();
contrast++;
/*When the contrast value enters an available setting range, it is
set*/
if (contrast <= params.getSupportedContrastMax() &&
contrast >= params.getSupportedContrastMin() ) {
params.setContrast(contrast);
camera.setParameters(params);
}
MOVERIO Pro Developer's Guide (Rev.1.5)
90
6.8.12. onPreviewFrame
Function
Use the standard Android API.
Describe processing content when acquiring image data.
Format
Parameter
Model name in/out Explanation
byte[] data in Image data acquired from a camera. The default is
NV21 format.
Camera
camera
in Camera service object.
Return value
None.
Usage procedure
void onPreviewFrame (
byte[] data
Camera camera
);
// App developer applies processing when acquiring image data private Camera.PreviewCallback mPreviewCB = new
Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte data[], Camera camera) {
Log.d(TAG, "Save preview image");
synchronized (lockObject) {
savePreviewData(data);
}
}
};
//Register the callback method at the optimal time
camera.setPreviewCallback(mPreviewCB);
MOVERIO Pro Developer's Guide (Rev.1.5)
91
Remarks
PreviewCallback cannot guarantee the actual time of image acquisition. If there
are a high volume of calculations being performed in onPreviewFrame, and these
are not completed by the time of the next image data acquisition, the next image
data will be corrupted. We recommend acquiring image data through a
sub-thread.
You can use the following three APIs as the API that registers the callback method.
MOVERIO Pro Developer's Guide (Rev.1.5)
92
6.8.13. setPreviewCallback
Function
When the callback method described in 6.8.12 is registered, it is called each time
image data is acquired. The registered callback method is executed repeatedly while
previewing.
Format
Parameter
Model name in/out Explanation
Camera.PreviewCallback cb in Callback object that receives image data.
Return value
None.
Usage procedure
Remarks
To cancel image data acquisition, register null as the callback method.
void setPreviewCallback (
Camera.PreviewCallback cb
);
// App developer applies processing when acquiring image data
private Camera.PreviewCallback mPreviewCB = new
Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte data[], Camera camera) {
Log.d(TAG, "Save preview image");
synchronized (lockObject) {
savePreviewData(data);
}
}
};
//Register the callback method at the optimal time
camera.setPreviewCallback(mPreviewCB);
・・・・・・
// When you remove the callback method, register null
camera.setPreviewCallback(null);
MOVERIO Pro Developer's Guide (Rev.1.5)
93
6.8.14. setOneShotPreviewCallback
Function
When the callback method described in 6.8.12 is registered, it is called when image
data is acquired. This registered callback method is only executed once.
Format
Parameter
Model name in/out Explanation
Camera.PreviewCallback
cb
in Callback object that receives a preview image.
Return value
None.
Usage procedure
The same as the previous section. However, setOneShotPreviewCallback is used as
the registered callback method.
void setOneShotPreviewCallback (
Camera.PreviewCallback cb
);
MOVERIO Pro Developer's Guide (Rev.1.5)
94
6.8.15. setPreviewCallbackWithBuffer
Function
When the callback method described in 6.8.12 is registered, it is called when image
data is acquired. The registered callback method is executed repeatedly while
previewing. You can secure buffer processing by specifying a dedicated buffer for
image data processing.
Format
Parameter
Model name in/out Explanation
Camera.PreviewCallback
cb
in Callback object that receives image data.
Return value
None.
void setPreviewCallbackWithBuffer (
Camera.PreviewCallback cb
);
MOVERIO Pro Developer's Guide (Rev.1.5)
95
Usage procedure
Remarks
You need to reserve the buffer region from the application.
This provides high-speed processing when compared to setPreviewCallback or
setOneShotPreviewCallback by securing and opening the memory.
The application developer needs to describe the buffer management process.
Specifically, the following processes are necessary.
Register the buffer to be used in addCallbackBuffer described later.
Calculate the size of the buffer to be registered as the width x height x byte
per 1pixel. The width and the height should both be higher than their
respective resolutions.
Each time onPreviewFrame is called, you need to re-register the buffer.
If no buffer is registered, the frame is corrupted and is not called by the
callback method.
You can register multiple buffers.
// App developer applies processing when acquiring image data
private Camera.PreviewCallback mPreviewCB = new
Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte data[], Camera camera) {
Log.d(TAG, "Save preview image");
synchronized (lockObject) {
savePreviewData(data);
}
// Register the buffer to be used camera.addCallbackBuffer(mPreviewData);
}
};
// Register the buffer to be used camera.addCallbackBuffer(mPreviewData);
//Register the callback method at the optimal time
camera.setPreviewCallbackWithBuffer(mPreviewCB);
MOVERIO Pro Developer's Guide (Rev.1.5)
96
6.8.16. addCallbackBuffer
Function
The API for registering the buffer used in setPreviewCallbackWithBuffer.
Format
Parameter
Model name in/out Explanation
byte[]
callbackBuffer
in Buffer to be registered
Return value
None.
Usage procedure
void setPreviewCallbackWithBuffer (
byte[] callbackBuffer
);
// App developer applies processing when acquiring image data
private Camera.PreviewCallback mPreviewCB = new
Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte data[], Camera camera) {
Log.d(TAG, "Save preview image");
synchronized (lockObject) {
savePreviewData(data);
}
// Register the buffer to be used camera.addCallbackBuffer(mPreviewData);
}
};
// Register the buffer to be used camera.addCallbackBuffer(mPreviewData);
//Register the callback method at the optimal time
camera.setPreviewCallbackWithBuffer(mPreviewCB);
MOVERIO Pro Developer's Guide (Rev.1.5)
97
Remarks
Only necessary when using setPreviewCallbackWithBuffer. Buffers are
automatically secured for setPreviewCallback and setOneShotPreviewCallback.
If the buffer size you register is smaller than the image data, null is returned for
data.
If a registered buffer region is not secured in the application, an error log is output
when addCallbackBuffer is executed. Errors and exceptions do not occur.
MOVERIO Pro Developer's Guide (Rev.1.5)
98
6.8.17. startDepthStreaming
Function
Start depth information acquisition.
Format
Parameter
None.
Return value
None.
Exception
Exception
occurred
Explanation
RuntimeException An exception occurs under the following two
conditions.
(1) A preview has not started.
(2) The camera is in a mode that does not output
depth information (side by side or single through).
void startDepthStreaming()
MOVERIO Pro Developer's Guide (Rev.1.5)
99
Usage procedure
Remarks
If this method is used after executing startPreview, you can execute by selecting
your own timing.
When resuming a preview using stopPreview -> startPreview, make sure you
execute this method to resume depth information acquisition.
When resuming a preview startPreview after executing takePicture, make sure
you execute this method to resume depth information acquisition.
You need to restart the application if the application closes in a RuntimeException.
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Set the camera mode to depth-only*/
params.setEpsonCameraMode(Camera.Parameters.EPSON_CAMERA_MODE_DEP
TH_ONLY);
/*Reflect camera setting in camera device*/
camera.setParameters(params);
/*Start preview*/
camera.startPreview();
/*Start depth information acquisition*/ camera.startDepthStreaming();
MOVERIO Pro Developer's Guide (Rev.1.5)
100
6.8.18. stopDepthStreaming
Function
Stop depth information acquisition.
Format
Parameter
None.
Return value
None.
Usage procedure
Important points
If depth information acquisition has not stopped when stopPreview is executed,
stopDepthStreaming is executed as part of the stopPreview process.
void stopDepthStreaming()
/*Start camera*/
camera = Camera.open();
/*Acquire current parameter (or default value)*/
Camera.Parameters params = camera.getParameters();
/*Set the camera mode to depth-only*/
params.setEpsonCameraMode(Camera.Parameters.EPSON_CAMERA_MODE_DEP
TH_ONLY);
/*Reflect camera setting in camera device*/
camera.setParameters(params);
/*Start preview*/
camera.startPreview();
/*Start depth information acquisition*/ camera.startDepthStreaming();
・・・・・・
/*End Depth information acquisition*/ camera.stopDepthStreaming();
/*Stop preview*/
camera.stopPreview();
MOVERIO Pro Developer's Guide (Rev.1.5)
101
6.8.19. onDepthMap
Function
The process executed is written during depth information acquisition.
Format
Parameter
Model name in/out Explanation
byte[] data in Depth information. VGA size, RAW 8 format,
300 K byte data.
Camera
camera
in Camera service object
Return value
None.
Usage procedure
void onDepthMap( byte[] data, Camera camera )
// App developer applies processing when acquiring depth information private Camera.DepthCallback mDepthCB = new Camera.DepthCallback() {
@Override
public void onDepthMap(byte data[], Camera camera) {
Log.d(TAG, "Save depth map");
synchronized (lockObject) {
saveDepthMap(data);
}
}
};
//Register the callback method at the optimal time
camera.setDepthCallback(mDepthCB);
MOVERIO Pro Developer's Guide (Rev.1.5)
102
Remarks:
To use the depth information application, you need to describe the process in
onDepthMap.
To execute onDepthMap, you need to meet all of the following conditions.
(1) The camera mode is set by either EdoF mode or depth-only mode.
(2) startPreview is executed.
(3) startDepthStreaming is executed.
(4) A callback method is registered in setDepthCallback.
In EDof mode, receiving depth information, display preview and receiving preview
data can be executed in parallel.
For depth-only mode, preview display is unavailable. To display depth data as an
image, you need to convert the data captured to image format to display images.
MOVERIO Pro Developer's Guide (Rev.1.5)
103
6.8.20. setDepthCallback
Function
Register the callback method executed during depth information acquisition.
Format
Parameter
Model name in/out Explanation
Camera.DepthCallback
cb
in Callback object that processes depth information.
Return value
None.
Usage procedure
void setDepthCallback( Camera.DepthCallback cb )
// App developer applies processing when acquiring depth information private Camera.DepthCallback mDepthCB = new Camera.DepthCallback() {
@Override
public void onDepthMap(byte data[], Camera camera) {
Log.d(TAG, "Save depth map");
synchronized (lockObject) {
saveDepthMap(data);
}
}
};
//Register the callback method at the optimal time
camera.setDepthCallback(mDepthCB);
・・・・・・
// When you remove the callback method, register null
camera.setDepthCallback(null);
MOVERIO Pro Developer's Guide (Rev.1.5)
104
Remarks
To cancel depth information acquisition, set null as the callback method.
This method can be executed regardless of the preview status or camera mode,
you can execute by selecting your own timing.
Registration is only canceled if null is registered as the callback method, or the
object is removed. Note that the callback method is not canceled by canceling the
preview or depth information acquisition.
MOVERIO Pro Developer's Guide (Rev.1.5)
105
6.9. Depth Information Acquisition Flow Details
Figure 6-6 shows the mechanical status for the camera application (camera app) when
acquiring depth information. You need to perform the following five steps to acquire depth
information.
(1) Set the camera mode to depth-only.
(2) The preview starts after step (1).
(3) Depth information acquisition starts after step (2).
(4) Register the depth callback method at the optimal time.
The camera app sets the camera mode, resolution, preview starts and transfers to preview
status.
Just after the preview starts, depth information acquisition is stopped. Start depth
information acquisition (startDepthStreaming) to transfer to the depth information acquisition
status. The depth information acquisition can be used when the camera is in the mode that
can receive depth information. (In EDof mode or depth-only mode)
If the camera is in a mode that cannot acquire depth information (side by side or
single-through), an exception is generated. If depth callback has already been registered
during depth information acquisition, then this can be processed based on the depth
information in the callback function. For registering depth callback, use the onDepthMap API
for setDepthCallback and processing depth information.
When returning to a depth information acquisition stop status, you will need to stop the depth
information acquisition (stopDepthStreaming). When stopping a preview during the depth
information acquisition, the depth information acquisition will be processed at the same time.
MOVERIO Pro Developer's Guide (Rev.1.5)
106
Figure 6-6 Mechanical status figure for depth information acquisition
For depth-only mode, preview display is unavailable. Availability of depth information
acquisition and previews is shown in the following table.
Table 6-6 Depth information acquisition and preview availability
Camera mode Depth
information
acquisition
Preview
display
Preview data
acquisition
Notes
single-through-vga × △ ○ Preview only
single-through-720p
single-through-1080p
single-through-5m
depth-only ○ × × Depth information only
side-by-side × △ ○ Preview only
EDof ○ △ ○ Simultaneous
processing available
△: Indicates that preview display may not be available depending on the resolution.
not ready previewing
Receiving depth active
Receiving and treating depth data
Receiving depth inactive ready to preview
exception
Exit preview
Exit preview start to receive stop to receive
start preview
set parameters
MOVERIO Pro Developer's Guide (Rev.1.5)
107
6.10. Sample Code
This sample code is for preview data acquisition while displaying a preview at 1080p in
single-through-5m mode.
package jp.epson.moverio.bt2pro.sample.cameratest;
import android.app.Activity;
import android.hardware.Camera;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;
import java.io.IOException;
public class CameraTestActivity extends Activity {
private String TAG = this.getClass().getName();
private Camera camera = null;
private SurfaceHolder mHolder = null;
private byte[] mPreviewData = new byte[1920 * 1080 * 3 / 2];
private byte[] mPreviewBuf = new byte[1920 * 1080 * 3 / 2];
private Object lockObject = new Object();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera_test);
// Full Screen
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(0x80000000);
// Camera preview
SurfaceView cameraPreview = (SurfaceView) findViewById(R.id.preview);
mHolder = cameraPreview.getHolder();
mHolder.addCallback(previewCallback);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
MOVERIO Pro Developer's Guide (Rev.1.5)
108
/* Image data acquisition callback */
private Camera.PreviewCallback mPreviewCB = new Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte data[], Camera camera) {
synchronized (lockObject) {
mPreviewData = data;
}
camera.addCallbackBuffer(mPreviewBuf);
}
};
private SurfaceHolder.Callback previewCallback =
new SurfaceHolder.Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG, "surfaceDestroyed");
camera.stopPreview();
camera.release();
camera = null;
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "surfaceDestroyed");
try {
camera = Camera.open();
camera.setPreviewDisplay(holder);
} catch (RuntimeException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
camera.addCallbackBuffer(mPreviewBuf);
camera.setPreviewCallbackWithBuffer(mPreviewCB);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
camera.stopPreview();
Camera.Parameters params = camera.getParameters();
/* Set camera mode to single-through-5m mode*/
MOVERIO Pro Developer's Guide (Rev.1.5)
109
params.setEpsonCameraMode(Camera.Parameters.EPSON_CAMERA_MODE_SINGLE_THROUGH_5M);
/* Set preview resolution to 1080p */
params.setPreviewSize(1920, 1080);
/* Set frame rate to 7.5fps */
params.setPreviewFpsRange(7500, 7500);
/* Reflect parameter change to camera device */
camera.setParameters(params);
camera.addCallbackBuffer(mPreviewData);
camera.setPreviewCallbackWithBuffer(mPreviewCB);
try {
camera.startPreview();
} catch (RuntimeException e) {
e.printStackTrace();
}
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_camera_test, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
MOVERIO Pro Developer's Guide (Rev.1.5)
110
6.11. Remarks
1) After closing the camera app, the system executes reallocation processing in the background
for the camera. If the camera is used again soon after, an error may occur. Make sure that the
camera is not reconnected within three seconds of camera reallocation.
2) After setting the camera mode, frame rate, preview resolution, sharpness value, and contrast
value, be sure to perform setParameters. Changed content is not reflected in the camera device
until setParameters is executed.
3) White balance is set manually. As this cannot be set automatically, make settings according to
your usage environment by the App.
4) The parameters for associated frame rates and preview resolutions will not change even if you
set the camera mode in setEpsonCameraMode. Set these parameters using appropriate
combinations before executing setParameters.
5) When the preview has already started, use stopPreview to temporarily stop the preview, and
then execute setParameters.
6) Each camera mode has a limited combination of preview resolutions and frame rates. Note
that a run-time exception will occur in setParameters for combinations that exceed the limit.
7) You cannot set single-through-5m or side by side as the preview resolution. If you want to
acquire images in single-through-5m or side by side, perform shooting by using tekePicture.
8) PreviewCallback cannot guarantee the actual time of image acquisition. If there are a high
volume of calculations being performed in onPreviewFrame, and these are not completed by
the time of the next image data acquisition, the next image data will be corrupted. We
recommend acquiring image data through a sub-thread.
9) You need to restart the application if the application closes in a RuntimeException
10) Do not call takePicture() while acquiring depth information in depth-only mode or EDof
mode. If you call it, the system may become unstable.
MOVERIO Pro Developer's Guide (Rev.1.5)
111
6.12. Android standard camera API Camera.Parameters Class
Below shows Android standard camera API (Camera.Parameters Class) that can use in
BT-2000
For details of each API, please refer to Android API level 15 specifications.
No. Android standard API(Camera.Parameters) Can use in BT-2000
1 flatten()
2 get(String key)
3 getAntibanding()
4 getAutoExposureLock()
5 getAutoWhiteBalanceLock()
6 getColorEffect()
7 getExposureCompensation() ✔
8 getExposureCompensationStep()
9 getFlashMode()
10 getFocalLength() ✔
11 getFocusAreas()
12 getFocusDistances(float[] output)
13 getFocusMode()
14 getHorizontalViewAngle() ✔
15 getInt(String key)
16 getJpegQuality()
17 getJpegThumbnailQuality()
18 getJpegThumbnailSize()
19 getMaxExposureCompensation() ✔
20 getMaxNumDetectedFaces() ✔
21 getMaxNumFocusAreas() ✔
22 getMaxNumMeteringAreas() ✔
23 getMaxZoom() ✔
24 getMeteringAreas()
25 getMinExposureCompensation() ✔
26 getPictureFormat()
27 getPictureSize()
28 getPreferredPreviewSizeForVideo() ✔
29 getPreviewFormat()
30 getPreviewFpsRange(int[] range)
31 getPreviewFrameRate()
32 getPreviewSize()
33 getSceneMode()
34 getSupportedAntibanding() ✔
35 getSupportedColorEffects() ✔
MOVERIO Pro Developer's Guide (Rev.1.5)
112
No. Android standard API(Camera.Parameters) Can use in BT-2000
36 getSupportedFlashModes() ✔
37 getSupportedFocusModes() ✔
38 getSupportedJpegThumbnailSizes() ✔
39 getSupportedPictureFormats() ✔
40 getSupportedPictureSizes() ✔
41 getSupportedPreviewFormats() ✔
42 getSupportedPreviewFpsRange() ✔
43 getSupportedPreviewFrameRates() ✔
43 getSupportedPreviewFrameRates() ✔
44 getSupportedPreviewSizes() ✔
45 getSupportedSceneModes() ✔
46 getSupportedVideoSizes()
47 getSupportedWhiteBalance()
48 getVerticalViewAngle()
49 getVideoStabilization()
50 getWhiteBalance()
51 getZoom()
52 getZoomRatios() ✔
53 isAutoExposureLockSupported() ✔
54 isAutoWhiteBalanceLockSupported() ✔
55 isSmoothZoomSupported()
56 isVideoSnapshotSupported() ✔
57 isVideoStabilizationSupported()
58 isZoomSupported()
59 remove(String key)
60 removeGpsData()
61 set(String key, int value)
62 set(String key, String value)
63 setAntibanding(String antibanding) ✔
64 setAutoExposureLock(boolean toggle) ✔
65 setAutoWhiteBalanceLock(boolean toggle) ✔
66 setColorEffect(String value) ✔
67 setExposureCompensation(int value) ✔
68 setFlashMode(String value) ✔
69 setFocusAreas(List<Camera.Area> focusAreas)
70 setFocusMode(String value) ✔
71 setGpsAltitude(double altitude)
MOVERIO Pro Developer's Guide (Rev.1.5)
113
No. Android standard API(Camera.Parameters) Can use in BT-2000
72 setGpsLatitude(double latitude)
73 setGpsLongitude(double longitude)
74 setGpsProcessingMethod(String processing_method)
75 setGpsTimestamp(long timestamp)
76 setJpegQuality(int quality) ✔
77 setJpegThumbnailQuality(int quality) ✔
78 setJpegThumbnailSize(int width, int height) ✔
79 setMeteringAreas(List<Camera.Area> meteringAreas)
80 setPictureFormat(int pixel_format) ✔
81 setPictureSize(int width, int height) ✔
82 setPreviewFormat(int pixel_format) ✔
83 setPreviewFpsRange(int min, int max) ✔
84 setPreviewFrameRate(int fps) ✔
85 setPreviewSize(int width, int height) ✔
86 setRecordingHint(boolean hint)
87 setRotation(int rotation)
88 setSceneMode(String value) ✔
89 setVideoStabilization(boolean toggle)
90 setWhiteBalance(String value) ✔
91 setZoom(int value) ✔
92 unflatten(String flattened)
MOVERIO Pro Developer's Guide (Rev.1.5)
114
7. Sensor control
MOVERIO Pro Developer's Guide (Rev.1.5)
115
7.1. Sensor control summary
The BT-2000 is equipped with an IMU (high precision, high stability inertia measurement unit), a
geomagnetic sensor, and an ALS (ambient light sensor). Tap detection and azimuth detection are
also available.
7.1.1. IMU and the geomagnetic sensor
The BT-2000 is equipped with an IMU and a geomagnetic sensor. The IMU can detect tri-axis
acceleration and tri-axis angular velocity. The IMU allows high precision stance detection. There is
also a built-in tri-axis geomagnetic sensor which combined with the IMU allows for azimuth
calculations.
IMU sensor data can be received same as normal sensors by using Android standard API.
The following shows the specifications for the IMU and the geomagnetic sensor.
Sampling rate Range
IMU Acceleration Max. 125 Hz ±5.8 G
Angular velocity Max. 125 Hz ±450 deg/s
Geomagnetic sensor Max. 100 Hz ±1200 μT
+Y
+X +Z
MOVERIO Pro Developer's Guide (Rev.1.5)
116
7.1.2. ALS
The BT-2000 is equipped with an ALS (ambient light sensor). This sensor allows the device to
acquire the ambient light for the user's surroundings. Also, the BT-2000 is equipped by standard
with automatic optics that auto adjust the display brightness according to the user's surroundings.
To activate, open [Settings] apps and [Display][Screen brightness], and check the [Brightness
automatically control].
The following shows the specifications for the ALS.
Sampling rate Range
ALS Approx. 1[Hz] 0 to 65528 lx
MOVERIO Pro Developer's Guide (Rev.1.5)
117
7.1.3. Headset tap detection
The headset for the BT-2000 is equipped with a tap detection function. The headset's tap
detection function acts as an input device for the user. For example, this can be used to change
screen information.
Sensor to detect tap is installed by headset headpad parts. So when using, tap below point by
finger.
For sample code to detect tap, refer to 7.4 sample code.
MOVERIO Pro Developer's Guide (Rev.1.5)
118
7.2. Using the sensor
The sensor uses the standard Android API, SensorEventListener. The following lists the available
sensor types and usage examples.
7.2.1. Sensor type
The BT-2000 can use the following sensors. The following sensor types are also defined in the
Android Sensor class.
Sensor type ID (Hex) Constant name
IMU Accelerometer 0x00000001 TYPE_ACCELEROMETER
Gyroscope 0x00000004 TYPE_GYROSCOPE
Geomagnetic sensor Geomagnetic sensor 0x00000002 TYPE_MAGNETIC_FIELD
ALS Sensor Illumination 0x00000005 TYPE_LIGHT
Others Tap detection 0x00002001 TYPE_HEADSET_TAP
Azimuth detection 0x00000003 TYPE_ORIENTATION
* You can acquire the above from the Android Sensor class.
7.2.2. Import module
To use sensors, import below module.
android.hardware.Sensor
android.hardware.SensorEvent
android.hardware.SensorEventListener
MOVERIO Pro Developer's Guide (Rev.1.5)
119
7.3. Using SensorEventListener
It is necessary to implement SensorEventListener for sensors using Activity or Service.
Example: Implementing SensorEventListener in Activity
public class SampleActivity extends Activity implements SensorEventListener
7.3.1. Registering sensors being used When using a sensor, you need to register a sensor listener. Example) Registering an accelerometer
//System sensor service acquisition
SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);
//Registering an accelerometer (TYPE_ACCELEROMETER)
Sensor s = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sm.registerListener(this, s, SensorManager.SENSOR_DELAY_NORMAL);
7.3.2. Acquiring a sensor value You can use the sensor value by acquiring a sensor event in onSensorChanged for SensorEventListener.
Example) Acquiring a sensor value for the accelerometer
@Override
public void onSensorChanged(SensorEvent event) {
//Acquiring the accelerometer value (display log)
if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
Log.d("Sample","ax="+event.values[0]+",ay="+event.values[1]+",az="+event.values[2]);
}
}
MOVERIO Pro Developer's Guide (Rev.1.5)
120
Sensor value that can be received by onSensorChanged is different by sensor type used.
SensorEvent array element numbers supporting each sensor type are shown below.
Sensor type Unit Sensor value SensorEvent
Array index
TYPE_ACCELEROMETER m/s2 X axis 0
Y axis 1
Z axis 2
TYPE_GYROSCOPE rad/s X axis 0
Y axis 1
Z axis 2
TYPE_MAGNETIC_FIELD uT X axis 0
Y axis 1
Z axis 2
TYPE_LIGHT Lux Illuminance 0
TYPE_HEADSET_TAP - When tap:1 0
TYPE_ORIENTATION degree Azimuth
0 ~ 359 degree
0 :north
90 :east
180 :south
270 :west
0
Inclination angle
-180~180 degree
1
Rotation angle
-90 ~ 90 degree
2
MOVERIO Pro Developer's Guide (Rev.1.5)
121
7.4. Sample code
Sample code of using sensor type TYPE_HEADSET_TAP, and show Toast when tap is detected.
package jp.epson.moverio.bt2pro.sample.TapSample; import android.app.Activity; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends Activity implements SensorEventListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE); Sensor sensor = sm.getDefaultSensor(Sensor.TYPE_HEADSET_TAP); sm.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } @Override public void onSensorChanged(SensorEvent event) { if(event.sensor.getType() == Sensor.TYPE_HEADSET_TAP){ // if tap event occurs, show Toast Toast.makeText(this, "tap event!", Toast.LENGTH_SHORT).show(); } } @Override protected void onPause() { super.onPause(); SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE); if (sm != null) { sm.unregisterListener(this); } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } }
MOVERIO Pro Developer's Guide (Rev.1.5)
122
8. Bluetooth/BLE
MOVERIO Pro Developer's Guide (Rev.1.5)
123
8.1. Pre-cautions for developing Apps using BLE
BT-2000 is adopting EPSON original BLE control API, so you cannot use BLE control API provided
by Google. Therefore you cannot divert App or source code that is operating with other Android
equipment. For detail limited items, please refer to chapter 8.4.Remarks & Restrictions for BLE
App Development
MOVERIO Pro Developer's Guide (Rev.1.5)
124
8.2. Summary
This chapter explains the Bluetooth/BLE function built into the MOVERIO Pro BT-2000.
The BT-2000 supports Bluetooth 4.0 LE, and in addition to the conventional Bluetooth 3.0+HS
function, it also supports LowEnergy. For convenience, this section describes the Bluetooth
3.0+HS Bluetooth Legacy and the LowEnergy BLE.
8.2.1. Supported specifications
8.2.1.1. Bluetooth Legacy specifications
This describes the Bluetooth Legacy specifications for the BT-2000.
Table 8-1 Bluetooth Legacy module and protocol stack
Item Specifications
Module specifications Bluetooth3.0 + HS (Bluetooth Class2)
Protocol stack specifications Based on Core Spec Version 3.0
Table 8-2 Bluetooth Legacy protocol support
Profile Role Version
Headset Profile(HSP) Audio Gateway 1.1
Advanced Audio Distribution Profile(A2DP) Source 1.2
Human Interface Device(HID) Host 1.0
Object Push Profile(OPP) Client/Server 1.1
Serial Port Profile(SPP) Device A/Device B 1.2
Audio/Video Remote Control Profile(AVRCP) Target 1.0
Audio/Video Control Transport Protocol(AVCTP) Target 1.3
Audio/Video Distribution Transport Protocol(AVDTP) Source/Acceptor/Initiator 1.2
Generic Audio Video Distribution Profile(GAVDP) Acceptor/Initiator 1.0
MOVERIO Pro Developer's Guide (Rev.1.5)
125
8.2.1.2. BLE specifications
This describes the BLE specifications for the BT-2000.
Table 8-3 BLE protocol stack specifications
Item Specifications
Protocol stack specifications Based on Core Spec Version 4.1 (Low Energy Host)
Table 8-4 BLE protocol support
Profile Role Version
Find Me Profile(FMP) Locator 1.0
Proximity Profile(PXP) Monitor 1.0
* New profiles can be supported through applications you develop for the user.
BLE Beacon function
The BLE Beacon function detects Beacon devices within communication range using the
Advertise function for GAP (General Access Profile), not the function described in the BLE
profile.
When the BT-2000 is within the Bluetooth communication area for a Beacon device, the
Beacon device is detected using Advertise data being broadcast by the Beacon device (note 1),
and then calculates the distance from the Beacon device using the strength of the radio waves.
Note 1)
If the Beacon device supports the iBeacon standards, the device can determine Immediate/Near/Far from the
RSSI value. If the device does not support the iBeacon standards, the distance need to be calculated from the
RSSI value.
Figure 8-1 Image of BLE Beacon usage
Bluetooth communication area Beacon
device
Beacon
device
MOVERIO Pro Developer's Guide (Rev.1.5)
126
8.3. Usage method
This section describes how to use Bluetooth Legacy and BLE.
8.3.1. Using Bluetooth Legacy
You can use Bluetooth Legacy for the BT-2000 from [Bluetooth] in the [Settings] app.
Figure 8-2 Bluetooth Legacy Settings screen
8.3.1.1. Turning Bluetooth Legacy ON/OFF
To turn on the Bluetooth Legacy function, move your cursor over the ON/OFF switch (2), and
then press the select button.
8.3.1.2. Searching using Bluetooth Legacy
Press the [Search for Devices] button to search for Bluetooth Legacy devices in the area.
8.3.1.3. Connecting using Bluetooth Legacy
You can select the device you want to connect to in [Available Devices], and then perform
pairing.
8.3.1.4. Disconnecting using Bluetooth Legacy
You can select the device you want to disconnect from in [Paired Devices], and then
disconnect.
ON/OFF switch (1)
ON/OFF switch (2)
MOVERIO Pro Developer's Guide (Rev.1.5)
127
8.3.2. Using BLE
To test the BLE function for the BT-2000, sample BLEBeacon and PXP/FMP applications have
been preinstalled. Refer to these sample applications when developing a BLE application for the
user.
The following explains how to use the sample applications.
8.3.2.1. Using the BLEBeacon sample application
Select the BLEBeacon icon from the app list.
Figure 8-3 BLEBeacon icon
BLE turns on automatically when the app starts, and the BLE icon is displayed in the notification
area.
Figure 8-4 BLEBeacon app screen
Table 8-5 BLEBeacon app screen composition
Item Explanation
Scan Start Starts scanning for the BLE Beacon.
Scan Stop Stops scanning for the BLE Beacon.
Address Displays the Bluetooth Device Address.
Device Name(m/n) Displays the Device Name and the Major/Minor numbers.
* Depends on the Advertise data configuration from the Beacon.
Distance Displays the determined distance and RSSI value. Note 2)
Note 2) Determining distance for the BLEBeacon
You need to perform distance determination for the BT-2000 and the Beacon in the app.
Distance determination is calculated based on the Measured Power included in the Advertise
data by the BLEBeacon app.
Since Measured Power support varies depending on the Beacon manufacturer, you will need to
MOVERIO Pro Developer's Guide (Rev.1.5)
128
decide whether or not ("Use" or "Do not use") to use the distance determination based on
Measured Power supplied by the company identifier in the BLEBeacon app. Distance is
determined from the Measured Power and RSSI value as shown below.
Table 8-6 Determining distance for the BLEBeacon app
Determination result RSSI value (when Measured Power for the Beacon is set to -70)
Immediate 127 to -70 (=Measured Power)
Near -51 to -90 (=Measured Power - 20)
Far -91 to 128
Unknown
Could not receive Advertise data for more than three seconds
Or the company identifier was not Apple (0x004C) or Nordic
(0x0059).
MOVERIO Pro Developer's Guide (Rev.1.5)
129
8.3.2.2. Using the FMP_PXP sample application
Select the FMP_PXP icon from the app list.
*This application still includes some Japanese language. Please reference the following translation notes as your
reference when you use this application.
Figure 8-5 FMP_PXP icon
Check the ON/OFF status for the BLE when the app starts, and then displays a confirmation
dialog if BLE is not ON.
Figure 8-6 BLE confirmation dialog
Bluetooth Low Energy is not enabled.
Do you want to enable Bluetooth Low Energy?
MOVERIO Pro Developer's Guide (Rev.1.5)
130
Figure 8-7 FMP_PXP app Scan screen composition
Table 8-7 FMP_PXP app Scan screen composition
Item Explanation
Scan Start Starts scanning for the BLE device.
Scan Stop Stops scanning for the BLE device.
Connect Starts connecting.
Disconnect Starts disconnecting.
Clear Clears the list.
Authentication method
Select the authentication method.
- Just Works
- Passkey Entry
Select search service
Select the service that you want to use to search from the
services included with the connected device.
- Immediate Alert Service
- Tx Power Service
- Link Loss Service
DiscPriSrvByUUID From the list of services on the connected device, select the
Service you want from [Select search service].
DiscAllPriSrv Displays all services for the connected device.
ProfileActivity Displays ProfileActivity based on information for the
connected device.
Please push “Scan Start” button.
Authentication method
Target connection
device
Target service selection
MOVERIO Pro Developer's Guide (Rev.1.5)
131
Authenticating using Passkey Entry
When connecting to a BLE device that requires password authentication, execute Connect in
Passkey Entry.
One of the following pairing dialogs is displayed depending on the Passkey Entry connection.
Figure 8-8 FMP_PXP app Profile screen composition
Table 8-8 FMP_PXP app Profile screen composition
Item Explanation
Set Alert Level Set one of the following as the BLE Device Alert Level.
No Alert/Mid Alert/High Alert
Select Sub-procedure You can read the value for the selected sub-procedure.
Current Alert Level You can read the value set for the current Alert Level.
Pairing setting request of BLE
If you want to set the PasskeyInput
DeviceName as pairs, please enter the
passkey necessary to the device.
6-digit number (000000-999999) is
acceptable only.
If you want the next device to pair,
PasskeyDisplay DeviceName
Please enter the following passkey to Remote Device.
Alert level setting Current Alert level
Sub-Procedure setting
MOVERIO Pro Developer's Guide (Rev.1.5)
132
8.4. Remarks & Restrictions for BLE App Development
■ BLE interface
The BLE interface for the BT-2000 uses an original API that does not support the standard
Android API.
Therefore, when developing an application that uses BLE, use the SDK and original API
provided by Epson.
■ BLE ON/OFF
BLE differs from Bluetooth Legacy in that the ON/OFF switch is not installed on the system (OS)
in BLE.
In applications that use BLE on the BT-2000, design so that the BLE function can be turned
ON/OFF using EPSON original API.
■ BLE API access from multiple applications
Avoid designs that allow multiple BLE applications to access the BLE API at the same time.
Data may not be exchanged depending on the timing.
■ Using the BLE API
We do not recommend designs in which the BLE API is called in the Advertise notification
callback function (onScanResult).
MOVERIO Pro Developer's Guide (Rev.1.5)
133
8.5. Import module
To use EPSON original BLE control API, use SDK for BT-2000 provided by EPSON, and import the
following modules.
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeChipCode;
import android.bluetooth.BluetoothLeErrorCodeDescription;
import android.bluetooth.BluetoothLeGapCallback;
import android.bluetooth.BluetoothLeGapCallback.AddrType;
import android.bluetooth.BluetoothLeGapCallback.AuthType;
import android.bluetooth.BluetoothLeGapEvtAuthStatus;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
import android.bluetooth.BluetoothLeGattService;
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapCallback.PassKeyType;
MOVERIO Pro Developer's Guide (Rev.1.5)
134
8.6. Application interface list
Tables 8-9, 8-10, and 8-11 provide a list of application interfaces.
Table 8-9 android.bluetooth.BluetoothLeAdapterManager for application interface list
NO. Function name Function summary
1 getInstance Acquires instance.
2 isEnable Acquires enable/disable status for BLE.
3 enable Enables BLE.
4 disable Disables BLE.
5 startScan Starts scanning for the BLE.
6 stopScan Stops scanning for the BLE.
7 getDeviceName Acquires the local device name.
8 getBdAddress Acquires the local BD device.
9 connect Starts connecting to the BLE device.
10 connectCancel Cancels connecting to the BLE device.
11 disconnect Disconnects from the BLE device.
12 setAuthType Sets the authentication type.
13 notifyInputPasskey Sets the Pad Key entry.
14 setGapCallback Registers a callback for the GAP function.
15 discPriSrv(char) Searches for the Primary Service for the BLE device.
16 discChar Searches for the Characteristic for the BLE device.
17 discCharDesc Searches for the Characteristic Description for the BLE device.
18 readGatt Acquires the Characteristic Value and the Characteristic
Descriptor.
19 readUuidGatt Acquires the Characteristic Value for the set UUID.
20 writeWithoutRspGatt Writes the Characteristic Value (without a response)
21 writeGatt Writes the Characteristic Value and the Characteristic
Descriptor.
22 confirmation Executes an Indication response.
23 setGattCallback Registers a callback for the GAP function.
MOVERIO Pro Developer's Guide (Rev.1.5)
135
Table 8-10 android.bluetooth.BluetoothLeGapCallback for application interface list
NO. Callback function
name.
Function summary
24 onScanResult Callback function for scan results (Advertise data)
reception.
25 onConnectResult Callback function for connection results reception.
26 onDisconnectResult Callback function for disconnection results reception.
27 onPasskeyInput Callback function for Pass Key input results reception.
28 onPasskeyDisplay Callback function for Pass Key display results reception.
Table 8-11 android.bluetooth.BluetoothLeGattCallback for application interface list
NO. Callback function name. Function summary
29 onDiscPriSrvResult Callback function for search results reception for Primary
Service.
30 onDiscCharResult Callback function for search results reception for
Characteristic.
31 onDiscCharDescResult Callback function for search results reception for
Characteristic Descriptor.
32 onReadGattResult Callback function for acquisition results reception for
Characteristic Value.
33 onReadUuidGattResult Callback function for acquisition results reception for
Characteristic Value.
34 onWriteGattResult Callback for writing results reception for Characteristic
Value.
35 hvxEvt Callback function for reception of Indication/Notification
MOVERIO Pro Developer's Guide (Rev.1.5)
136
8.7. Supported GATT procedure table
The following shows a list of Bluetooth GATT procedures and supported BLE API procedures.
Table 8-12 Supported GATT procedure for BLE API table
GATT Procedure GATT Sub-Procedure Functions that
support BLE API
Server Configuration Exchange MTU Not supported
Primary Service Discovery
Discover All Primary Services discPriSrv(char)
Discover Primary Services By Service UUID discPriSrv(char,
byte[])
Relationship Discovery Find Included Services Not supported
Characteristic Discovery Discover All Characteristic of a Service discChar
Discover All Characteristic by UUID Not supported
Characteristic Descriptor Discovery Discover All Characteristic Descriptors discCharDesc
Characteristic Value Read
Read Characteristic Value readGatt(char)
Read Using Characteristic UUID readUuidGatt
Read Long Characteristic Values readGatt(char, char)
Read Multiple Characteristic Values Not supported
Characteristic Value Write
Write Without Response writeWithoutRspGat
t
Signed Write Without Response Not supported
Write Characteristic Value writeGatt
Write Long Characteristic Values Not supported
Characteristic Value Reliable Writes Not supported
Characteristic Value Notification Notifications BluetoothLeGattCall
back.hvxEvt
Characteristic Value Indication Indications
BluetoothLeGattCall
back.hvxEvt,
confirmation
Characteristic Descriptor Value
Write
Write Characteristic Descriptors writeGatt
Write Long Characteristic Descriptors Not supported
MOVERIO Pro Developer's Guide (Rev.1.5)
137
8.8. Application interface details 8.8.1. getInstance
Function
Acquire instances in the BluetoothLeAdapterManager class.
Format
Parameters
None
Return value
Model Explanation
BluetoothLeAdapterManager Except for NULL: Instances in the
BluetoothLeAdapterManager class.
NULL: Fails to acquire instance.
8.8.2. isEnable
Function
Acquire BLE status (enabled or disabled).
Format
Parameters
None
Return value
Model Explanation
boolean true: BLE enable
false: BLE disable
BluetoothLeAdapterManager BluetoothLeAdapterManager getInstance(void);
boolean isEnable(void);
MOVERIO Pro Developer's Guide (Rev.1.5)
138
8.8.3. enable
Function
Enable BLE.
Format
Parameters
None
Return value
Model Explanation
boolean true: success
false: fail
8.8.4. disable
Function
Disable BLE.
Format
Parameters
None
Return value
Model Explanation
boolean true: success
false: fail
boolean enable(void);
boolean disable(void);
MOVERIO Pro Developer's Guide (Rev.1.5)
139
8.8.5. startScan
Function
Start the BLE scan (Advertise reception).
Format
Parameters
None
Return value
None
Usage method
To receive scan results (Advertise data), you need to register the callback function in
setGapCallback in advance.
The following callback function sends a notification for received Advertise data.
BluetoothLeGapCallback.onScanResult
8.8.6. stopScan
Function
Stop the BLE scan (Advertise reception).
Format
Parameters
None
Return value
None
void startScan(void);
void stopScan(void);
MOVERIO Pro Developer's Guide (Rev.1.5)
140
8.8.7. getDeviceName
Function
Acquire the local device name.
Format
Parameters
None
Return value
Model Explanation
String Except for NULL: local device name.
NULL: Fail
8.8.8. getBdAddress
Function
Acquire the local BD device.
Format
Parameters
None
Return value
Model Explanation
String Except for NULL: local BD device.
(Text strings that include colons in the
format: ”11:22:33:44:55:66”)
NULL: Fail
String getDeviceName(void);
String getBdAddress (void);
MOVERIO Pro Developer's Guide (Rev.1.5)
141
8.8.9. connect
Function
Specify the partner BD address (remote BD address), connection timeout, and the number
of times to retry, and then connect.
Format
Parameter
Model name Explanation
AddrType addrType Remote BD address classification
*See "BD address classification" for more details
String Remote BD address
int timeout Timeout time (ms)
Set from 120 to 32000 ms in increments of 10 ms.
int retryReconnect Number of retry times
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid remote BD address
BluetoothLeChipCode.BaseError.NO_MEM: maximum connections
BluetoothLeChipCode.BaseError.BUSY: system busy status
Usage method
To receive connection processing results, you need to register the callback function in
setGapCallback in advance.
The following callback function sends a notification for connection processing results.
BluetoothLeGapCallback.onConnectResult
BD address classification
Value Explanation
BluetoothLeGapCallback.AddrType.PUBLIC Public
BluetoothLeGapCallback.AddrType.RANDOM_STATIC Random
BluetoothLeGapCallback.AddrType.RANDOM_PRIVATE_RESOLVABLE
BluetoothLeGapCallback.AddrType.RANDOM_PRIVATE_NON_RESOLVABLE
int connect(AddrType addrType, String addr, int timeout, int retryReconnect);
MOVERIO Pro Developer's Guide (Rev.1.5)
142
8.8.10. connectCancel
Function
Connection canceled while connecting to the BLE device.
Format
Parameter
Model name Explanation
None ―
Return value
Model Explanation
Int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
int connectCancel(void);
MOVERIO Pro Developer's Guide (Rev.1.5)
143
8.8.11. disconnect
Function
Specify the partner BD address (remote BD address), connection timeout, and the number
of times to retry, and then connect.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
* Specify the connection handle (ConnectedHandle) in the
connected status (connStatus) acquired in onConnectResult.
byte hci_status_code Status code
Normally, the following is specified.
BluetoothLeErrorCodeDescription.SigDefinition.
REMOTE_USER_TERMINATED_CONNECTION
* Specify the following if there is a connection parameter that
is not allowed.
BluetoothLeErrorCodeDescription.SigDefinition.
CONN_INTERVAL_UNACCEPTABLE
Return value
Mode
l
Explanation
Int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Usage method
To receive disconnection processing results, you need to register the callback function in
setGapCallback in advance.
The following callback function sends a notification for disconnection processing results.
BluetoothLeGapCallback.onDisconnectResult
int disconnect(char connectedHandle , byte hci_status_code)
MOVERIO Pro Developer's Guide (Rev.1.5)
144
8.8.12. setAuthType
Function
Set authentication classification.
Format
Parameter
Model name Explanation
AuthType authType Authentication classification
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Authentication classification
Value Explanation
BluetoothLeGapCallback.AuthType.JUSTWORKS Omit pin code
BluetoothLeGapCallback.AuthType.PASSKEYENTRY PIN code authentication
boolean setAuthType(AuthType authType);
MOVERIO Pro Developer's Guide (Rev.1.5)
145
8.8.13. notifyInputPasskey
Function
Register a pass key.
Format
Parameter
Model name Explanation
PassKeyType passKeyType Passkey type
String passKey Key string
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Pass key type
Value Explanation
BluetoothLeGapCallback.PassKeyType.NONE None
BluetoothLeGapCallback.PassKeyType.PASSKEY PIN code
int notifyInputPasskey(PassKeyType passKeyType, String passKey);
MOVERIO Pro Developer's Guide (Rev.1.5)
146
8.8.14. setGapCallback
Function
Register the BluetoothLeGapCallback class where the callback function used for GAP
functions is mounted.
Format
Parameter
Model name Explanation
BluetoothLeGapCallback callback Callback class
Return value
None
Callback function used for GAP functions
See the callback function descriptions in 8.8.24 to 8.8.28 for information on the callback
function for GAP functions that can be registered to the BluetoothLeGapCallback class.
void setGapCallback(BluetoothLeGapCallback callback);
MOVERIO Pro Developer's Guide (Rev.1.5)
147
8.8.15. discPriSrv
Function
Start searching the connected BLE device for a Primary Service.
Use format -2 when specifying a UUID and searching for the Primary Service.
Format -1
Format -2
Parameter
Model name Explanation
char connectedHandle Connection handle
char findStartHandle Handle location for starting the search
byte[] uuid UUID for search target
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid
connection handle
Usage method
To receive search results, you need to register the callback function in setGattCallback in
advance.
The following callback function sends a notification for search results.
BluetoothLeGattCallback.onDiscPriSrvResult
int discPriSrv(char connectedHandle, char findStartHandle);
int discPriSrv(char connectedHandle, char findStartHandle, byte[] uuid);
MOVERIO Pro Developer's Guide (Rev.1.5)
148
8.8.16. discChar
Function
Start searching the connected BLE device for Characteristics.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
char startHandle Handle location for starting the search
char endHandle Handle location for ending the search
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE:invalid connection
handle
Usage method
To receive search results, you need to register the callback function in setGattCallback in
advance.
The following callback function sends a notification for search results.
BluetoothLeGattCallback.onDiscCharResult
int discChar(char connectedHandle, char startHandle, char endHandle);
MOVERIO Pro Developer's Guide (Rev.1.5)
149
8.8.17. discCharDesc
Function
Start searching the connected BLE device for Characteristic Descriptors.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
char startHandle Handle location for starting the search
char endHandle Handle location for ending the search
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Usage method
To receive search results, you need to register the callback function in setGattCallback in
advance.
The following callback function sends a notification for search results.
BluetoothLeGattCallback.onDiscCharDescResult
int discCharDesc(char connectedHandle, char startHandle, char endHandle);
MOVERIO Pro Developer's Guide (Rev.1.5)
150
8.8.18. readGatt
Function
Start acquiring Characteristic Values/Characteristic Descriptors for the connected BLE
device.
Use format -2 when handling Characteristic Values/Characteristic Descriptors with a long
data length.
Format -1
Format -2
Parameter
Model name Explanation
char connectedHandle Connection handle
char handle Handle location for Characteristic Value
char offset Reading location for the value
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Usage method
To receive search results, you need to register the callback function in setGattCallback in
advance.
The following callback function sends a notification for search results.
BluetoothLeGattCallback.onReadGattResult
int readGatt(char connectedHandle, char handle);
int readGatt(char connectedHandle, char handle, char offset);
MOVERIO Pro Developer's Guide (Rev.1.5)
151
8.8.19. readUuidGatt
Function
Start acquiring Characteristic Values for the connected BLE device according to the
specified UUID.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
byte[] uuid UUID for acquisition target Characteristic
char startHandle Handle location for starting the search
char endHandle Handle location for ending the search
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Usage method
To receive search results, you need to register the callback function in setGattCallback in
advance.
The following callback function sends a notification for search results.
BluetoothLeGattCallback.onReadUuidGattResult
int readUuidGatt(char connectedHandle,byte[] uuid, char startHandle,
char endHandle);
MOVERIO Pro Developer's Guide (Rev.1.5)
152
8.8.20. writeWithoutRspGatt
Function
Write to for the Characteristic Value specified with the handle.
No result notification through a callback.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
char handle Handle location for Characteristic Value
byte[] value Written value
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.DATA_SIZE: exceeded data size
BluetoothLeChipCode.BaseError.NO_TX_BUFFERS: exceeded buffer capacity
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
int writeWithoutRspGatt(char connectedHandle, char handle, byte[] value);
MOVERIO Pro Developer's Guide (Rev.1.5)
153
8.8.21. writeGatt
Function
Write to for the Characteristic Value specified with the handle.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
char handle Handle location for Characteristic Value
byte[] value Written value
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_ADDR: invalid memory address
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.BaseError.BUSY: system busy status
BluetoothLeChipCode.BaseError.INVALID_PARAM: invalid parameter
BluetoothLeChipCode.BaseError.DATA_SIZE: exceeded data size
BluetoothLeChipCode.BaseError.NO_TX_BUFFERS: exceeded buffer capacity
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
Usage method
To receive search results, you need to register the callback function in setGattCallback in
advance.
The following callback function sends a notification for search results.
BluetoothLeGattCallback.onWriteGattResult
int writeGatt(char connectedHandle, char handle, byte[] value);
MOVERIO Pro Developer's Guide (Rev.1.5)
154
8.8.22. confirmation
Function
Response to Indication.
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
char handle Handle location for Characteristic Value
Return value
Model Explanation
int BluetoothLeChipCode.SUCCESS: success
BluetoothLeChipCode.BaseError.INVALID_STATE: invalid status
BluetoothLeChipCode.STKError.INVALID_CONN_HANDLE: invalid connection
handle
BluetoothLeChipCode.STKError.INVALID_ATTR_HANDLE: invalid attribute
handle
int confirmation(char connectedHandle, char handle);
MOVERIO Pro Developer's Guide (Rev.1.5)
155
8.8.23. setGattCallback
Function
Register the BluetoothLeGattCallback class where the callback function used for GATT
functions is mounted.
Format
Parameter
Model name Explanation
BluetoothLeGattCallback callback Callback class
Return value
None
Callback function for the GATT function
See the callback function descriptions in 8.8.29 to 8.8.35 for information on the callback
function for GATT functions that can be registered to the BluetoothLeGattCallback.
void setGattCallback(BluetoothLeGattCallback callback);
MOVERIO Pro Developer's Guide (Rev.1.5)
156
8.8.24. BluetoothLeGapCallback.onScanResult
Function
Provide an interface for the callback function to receive scan results (Advertise data).
Use format -2 to acquire the scan response and the advertise type.
Related API: startScan/stopScan
Format -1
Format -2
Parameter
Model name Explanation
AddrType addrType Remote BD address classification
String addr Remote BD address
int rssi Received radio wave strength (dBm)
boolean scan_rsp Scan response data
true: Received PDU is SCAN_RSP
false: Received PDU is anything except for SCAN_RSP
AdvType adv_type Advertise type
AdvType.ADV_IND
AdvType.ADV_DIRECT_IND
AdvType.ADV_SCAN_IND
AdvType.ADV_NONCONN_IND
AdvType.SCAN_RSP
AdvType.UNKNOWN
byte[] adv_data Advertise data (31octet)
void onScanResult(AddrType addrType, String addr, int rssi, byte[] adv_data);
void onScanResult(AddrType addrType, String addr, int rssi, boolean scan_rsp,
AdvType adv_type, byte[] adv_data);
MOVERIO Pro Developer's Guide (Rev.1.5)
157
8.8.25. BluetoothLeGapCallback.onConnectResult
Function
Provide an interface for the callback function to receive connection results for BLE.
Related API: connect
Format
Parameter
Model name Explanation
byte response Connection information
BluetoothLeGapEvtConnected
connStatus
Connection complete status
Since connection fails if a CONNECTION_TIMEOUT
occurs, the value is undefined.
BluetoothLeGapEvtAuthStatus
authStatus
※Not supported. Do not use as value is undefined.
Connection information
Connection information
BluetoothLeErrorCodeDescription.SUCCESS
BluetoothLeErrorCodeDescription.SigDefinition.CONNECTION_TIMEOUT
BluetoothLeErrorCodeDescription.SigDefinition.REMOTE_USER_TERMINATED_CONNECTION
BluetoothLeErrorCodeDescription.SigDefinition.CONNECTION_TERMINATED_BY_LOCAL_HOST
BluetoothLeErrorCodeDescription.SigDefinition.LMP_LL_RESPONSE_TIMEOUT
BluetoothLeErrorCodeDescription.SigDefinition.CONN_INTERVAL_UNACCEPTABLE
BluetoothLeErrorCodeDescription.ChipDefinition.AUTHENTICATE_TIME_OUT
BluetoothLeErrorCodeDescription.ChipDefinition.AUTHENTICATE_PDU_INVALID
BluetoothLeErrorCodeDescription.ChipDefinition.CONNECTION_TIMEOUT
BluetoothLeErrorCodeDescription.ChipDefinition.PASSKEY_ENTRY_FAILED
BluetoothLeErrorCodeDescription.ChipDefinition.OUT_OF_BAND_KEY_NOT_AVAILABLE
BluetoothLeErrorCodeDescription.ChipDefinition.AUTHENTICATION_REQUIREMENTS_NOT_MET
BluetoothLeErrorCodeDescription.ChipDefinition.CONFIRM_VALUE_FAILED
BluetoothLeErrorCodeDescription.ChipDefinition.PAIRING_NOT_SUPPORTED
BluetoothLeErrorCodeDescription.ChipDefinition.ENCRYPTION_KEY_SIZE
BluetoothLeErrorCodeDescription.ChipDefinition.UNSUPPORTED_SMP_COMMAND
BluetoothLeErrorCodeDescription.ChipDefinition.UNSPECIFIED_REASON
BluetoothLeErrorCodeDescription.ChipDefinition.TOO_LITTLE_TIME_ELAPSED_SINCE_LAST_ATTEMPT
BluetoothLeErrorCodeDescription.ChipDefinition.INVALID_PARAMETERS
BluetoothLeErrorCodeDescription.ChipDefinition.AUTHENTICATE_API_CALL_ERROR
BluetoothLeErrorCodeDescription.ChipDefinition.RECEIVED_DISCONNECT_IN_AUTHENTICATING
void onConnectResult(byte response, BluetoothLeGapEvtConnected connStatus,
BluetoothLeGapEvtAuthStatus authStatus);
MOVERIO Pro Developer's Guide (Rev.1.5)
158
Connection complete status (class BluetoothLeGapEvtConnected)
Member's name Explanation
char connectedHandle Connection handle
byte addrType BD address classification
byte[] addr BD address
BleConnectParams params Connection parameter
MOVERIO Pro Developer's Guide (Rev.1.5)
159
8.8.26. BluetoothLeGapCallback.onDisconnectResult
Function
Provide an interface for the callback function to receive disconnection results for BLE.
Related API: disconnect
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
byte response Disconnection reason
boolean reconnecting Flag during reconnecting
true: During reconnecting
false: not reconnecting
Disconnection reason
Disconnection reason
BluetoothLeErrorCodeDescription.SigDefinition.CONNECTION_TIMEOUT
BluetoothLeErrorCodeDescription.SigDefinition.CONNECTION_TERMINATED_BY_LOCAL_HOST
BluetoothLeErrorCodeDescription.SigDefinition.LMP_LL_RESPONSE_TIMEOUT
are the main values.
For details on other values,
see "Specification of the Bluetooth System v4.1, Vol. 2, Part D : Error Code Descriptions"
void onDisconnectResult(char connectedHandle, byte response,
boolean reconnecting);
MOVERIO Pro Developer's Guide (Rev.1.5)
160
8.8.27. BluetoothLeGapCallback.onPasskeyInput
Function
Provide an interface for the callback function to confirm pass key input reception.
Format
Parameter
Model name Explanation
PassKeyType passKeyType Pass key type
Pass key type
Value Explanation
BluetoothLeGapCallback.PassKeyType.NONE None
BluetoothLeGapCallback.PassKeyType.PASSKEY PIN code
8.8.28. BluetoothLeGapCallback.onPasskeyDisplay
Function
Provide an interface for the callback function to display pass key reception.
Format
Parameter
Model name Explanation
String passKey Key string
void onPasskeyInput(PassKeyType passKeyType);
void onPasskeyDisplay(String passKey);
MOVERIO Pro Developer's Guide (Rev.1.5)
161
8.8.29. BluetoothLeGattCallback.onDiscPriSrvResult
Function
Provide an interface for the callback function to receive search results for the Primary
Service.
Related API: discPriSrv
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
BluetoothLeGattService[] data Service information
Search results
BluetoothLeChipCode.GattStatus definition
public static class GattStatus {
/** Success. */
public static final int BLE_GATT_STATUS_SUCCESS = 0x0000;
/** Unknown or not applicable status. */
public static final int BLE_GATT_STATUS_UNKNOWN = 0x0001;
/** ATT Error: Invalid Error Code. */
public static final int BLE_GATT_STATUS_ATTERR_INVALID = 0x0100;
/** ATT Error: Invalid Attribute Handle. */
public static final int BLE_GATT_STATUS_ATTERR_INVALID_HANDLE = 0x0101;
/** ATT Error: Read not permitted. */
public static final int BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED = 0x0102;
/** ATT Error: Write not permitted. */
public static final int BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED = 0x0103;
/** ATT Error: Used in ATT as Invalid PDU. */
public static final int BLE_GATT_STATUS_ATTERR_INVALID_PDU = 0x0104;
/** ATT Error: Authenticated link required. */
public static final int BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION = 0x0105;
/** ATT Error: Used in ATT as Request Not Supported. */
public static final int BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED = 0x0106;
/** ATT Error: Offset specified was past the end of the attribute. */
public static final int BLE_GATT_STATUS_ATTERR_INVALID_OFFSET = 0x0107;
/** ATT Error: Used in ATT as Insufficient Authorization. */
public static final int BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION = 0x0108;
/** ATT Error: Used in ATT as Prepare Queue Full. */
public static final int BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL = 0x0109;
/** ATT Error: Used in ATT as Attribute not found. */
public static final int BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND = 0x010A;
void onDiscPriSrvResult(char connectedHandle, int status ,
BluetoothLeGattService[] data);
MOVERIO Pro Developer's Guide (Rev.1.5)
162
/** ATT Error: Attribute cannot be read or written using read/write blob requests. */
public static final int BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG = 0x010B;
/** ATT Error: Encryption key size used is insufficient. */
public static final int BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE = 0x010C;
/** ATT Error: Invalid value size. */
public static final int BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH = 0x010D;
/** ATT Error: Very unlikely error. */
public static final int BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR = 0x010E;
/** ATT Error: Encrypted link required. */
public static final int BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION = 0x010F;
/** ATT Error: Attribute type is not a supported grouping attribute. */
public static final int BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE = 0x0110;
/** ATT Error: Encrypted link required. */
public static final int BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES = 0x0111;
/** ATT Error: Reserved for Future Use range #1 begin. */
public static final int BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN = 0x0112;
/** ATT Error: Reserved for Future Use range #1 end. */
public static final int BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END = 0x017F;
/** ATT Error: Application range begin. */
public static final int BLE_GATT_STATUS_ATTERR_APP_BEGIN = 0x0180;
/** ATT Error: Application range end. */
public static final int BLE_GATT_STATUS_ATTERR_APP_END = 0x019F;
/** ATT Error: Reserved for Future Use range #2 begin. */
public static final int BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN = 0x01A0;
/** ATT Error: Reserved for Future Use range #2 end. */
public static final int BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END = 0x01DF;
/** ATT Error: Reserved for Future Use range #3 begin. */
public static final int BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN = 0x01E0;
/** ATT Error: Reserved for Future Use range #3 end. */
public static final int BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END = 0x01FC;
/** ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly
configured. */
public static final int BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR = 0x01FD;
/** ATT Common Profile and Service Error: Procedure Already in Progress. */
public static final int BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG = 0x01FE;
/** ATT Common Profile and Service Error: Out Of Range. */
public static final int BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE = 0x01FF;
};
Service information (class BluetoothLeGattService)
Member's name Explanation
byte[] uuid UUID (16bit only)
char startHandle Start handle location
char endHandle End handle location
MOVERIO Pro Developer's Guide (Rev.1.5)
163
8.8.30. BluetoothLeGattCallback.onDiscCharResult
Function
Provide an interface for the callback function to receive search results for the
Characteristic.
Related API: discChar
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
BluetoothLeGattChar[] data Characteristic information
Characteristic information (class BluetoothLeGattChar)
Member's name Explanation
byte[] uuid UUID (16bit only)
char handleDecl Handle for Characteristic Declaration
char handleValue Handle for Characteristic Value
CharacteristicProperties properties Characteristic setting information
Characteristic setting information (class BluetoothLeGattChar.CharacteristicProperties)
Function name Explanation
boolean IsBrodcast() Determine if anything is broadcast
boolean IsRead() Determine readGatt/readUuidGatt
IsWriteWoResp() Determine writeWithoutRspGatt
IsWrite() Determine writeGatt
IsNofify() Determine Notification
IsIndicate() Determine Indication
void onDiscCharResult(char connectedHandle, int status,
BluetoothLeGattChar[] data);
MOVERIO Pro Developer's Guide (Rev.1.5)
164
8.8.31. BluetoothLeGattCallback.onDiscCharDescResult
Function
Provide an interface for the callback function to receive search results for the Characteristic
Descriptor.
Related API: discCharDesc
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
BluetoothLeGattDesc[] data Characteristic Descriptor information
Characteristic Descriptor information (class BluetoothLeGattDesc)
Member's name Explanation
byte[] uuid Characteristic Descriptor UUID
char handle Handle for Characteristic Descriptor
void onDiscCharDescResult(char connectedHandle, int status,
BluetoothLeGattDesc[] data);
MOVERIO Pro Developer's Guide (Rev.1.5)
165
8.8.32. BluetoothLeGattCallback.onReadGattResult
Function
Provide an interface for the callback function for acquisition results reception of
Characteristic Value using readGatt API.
Related API: readGatt
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
BluetoothLeGattEvtReadRsp data Read Response data
Read Response data (class BluetoothLeGattEvtReadRsp)
Member's name Explanation
byte[] data Read Response data
char handle Handle
char offset Data offset
void onReadGattResult(char connectedHandle, int status,
BluetoothLeGattEvtReadRsp data);
MOVERIO Pro Developer's Guide (Rev.1.5)
166
8.8.33. BluetoothLeGattCallback.onReadUuidGattResult
Function
Provide an interface for the callback function for acquisition results reception of
Characteristic Value using readUuidGatt API.
Related API: readUuidGatt
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
byte[] data Characteristic Value data
void onReadUuidGattResult(char connectedHandle, int status, byte[] data);
MOVERIO Pro Developer's Guide (Rev.1.5)
167
8.8.34. BluetoothLeGattCallback.onWriteGattResult
Function
Provide an interface for the callback function for writing results reception of Characteristic
Value using writeGattRes API.
Related API: writeGattRes
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
BluetoothLeGattEvtWriteRsp data Write Response data
Write Response data (class BluetoothLeGattEvtWriteRsp)
Member's name Explanation
byte[] data Write data
char handle Handle
char offset Data offset
byte writeOp Write operation code
void onWriteGattResult(char connectedHandle, int status,
BluetoothLeGattEvtWriteRsp data);
MOVERIO Pro Developer's Guide (Rev.1.5)
168
8.8.35. BluetoothLeGattCallback.hvxEvt
Function
Provide an interface for the callback function to receive Indication/Notification using
confirmation API.
Related API: confirmation
Format
Parameter
Model name Explanation
char connectedHandle Connection handle
int status Search results
* Returns the value defined in
BluetoothLeChipCode.GattStatus
hvxEvtType type Indication/Notification classification
byte[] data Characteristic handle value
void hvxEvt(char connectedHandle, int status, char handle,
hvxEvtType type, byte[] data);
MOVERIO Pro Developer's Guide (Rev.1.5)
169
8.9. BLE Processing Sample Code
When developing a BLE app, describe the sample code used in the BLE API.
8.9.1. Enabling BLE
Call isEnable() and acquire the current status.
Since BLE is disabled when this function returns false, call enable() to enable BLE.
// Instance acquisition for the BLE manager class
BluetoothLeAdapterManager mManager = BluetoothLeAdapterManager.getInstance();
if ( ! mManager.isEnable() ) {
// BLE Off
if ( ! mManager.enable() ) {
//Error processing: display error message for BLE-On failure
}
} else {
// BLE On
}
8.9.2. Disabling BLE
Call isEnable() and acquire the current status.
Since BLE is enabled when this function returns true, call disable() to disable BLE.
// Instance acquisition for the BLE manager class
BluetoothLeAdapterManager mManager = BluetoothLeAdapterManager.getInstance();
if ( mManager.isEnable() ) {
// BLE On
if ( ! mManager.disable() ) {
//Error processing: display error message for BLE-Off failure
}
} else {
// BLE Off
}
MOVERIO Pro Developer's Guide (Rev.1.5)
170
8.9.3. Registering scan start and callback
To start the Beacon function, register the callback function using setGapCallback() to receive
Advertise from the Beacon device, and start scanning using startScan().
import android.widget.Toast;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GAP function provided
mManager.setGapCallback(mLeGapCallback);
}
private void scanLe(final boolean enable) {
if ( enable ) {
//Start scanning
mManager.starScan();
} else {
//Stop scanning
mManager.stopScan();
}
}
Receive scan results using the following callback, and output the received signal strength to a
log.
private BluetoothLeGapCallback mLeGapCallback = new BluetoothLeGapCallback(){
@Override
public void onScanResult(AddrType addrType, String addr, int rssi
, byte[] adv_data) {
Log.i(“DEBUG”, “rssi=” + rssi);
}
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
171
8.9.4. Connecting and Disconnecting BLE
The following provides an example of the processing for connecting and disconnecting BLE.
Connecting: Enable GAP callback registration and scanning before connecting. Connect using
information in (addrType, addr) in the scan results (onScanResult()).
Disconnecting: Disconnect using the connection handle (connStatus.connectedHandle) in the
connection results (onConnectResult()).
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
private boolean mConnectingFlg = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GAP function provided
mManager.setGapCallback (mLeGapCallback);
}
private void connectLe(final boolean enable) {
if ( enable ) {
//BLE connect
//Set the addrType and addr acquired in onScanResult
mManager.connect(addrType, addr, 1000, 0);
} else {
//BLE disconnect
//Set the connection handle ConnectedHandle in connected event status
connStatus acquired in onConnectResult
mManager.disconnect(ConnectedHandle,
REMOTE_USER_TERMINATED_CONNECTION);
}
}
MOVERIO Pro Developer's Guide (Rev.1.5)
172
Use the following callback to output logs when connecting and disconnecting.
private BluetoothLeGapCallback mLeGapCallback = new BluetoothLeGapCallback() {
@Override
public void onConnectResult(byte response,
final BluetoothLeGapEvtConnected connStatus,
BluetoothLeGapEvtAuthStatus authStatus) {
Log.i(“DEBUG”, “connectedHandle=“
+ connStatus.connectedHandle);
};
@Override
public void onDisconnectResult(char connectedHandle,
byte response, boolean reconnecting) {
Log.i(“DEBUG”, “Disconnect“);
};
};
MOVERIO Pro Developer's Guide (Rev.1.5)
173
8.9.5. Searching for Primary Service
You can search for the Primary Service on a connected BLE device by executing the callback
function setGattCallback() and Primary Service search using discPriSrv().
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GATT function provided
mManager.setGattCallback(mLeGattCallback);
//Searching for Primary Service
//Set the connection handle ConnectedHandle in connected event status
connStatus acquired in onConnectResult
mManager.discPriSrv(ConnectedHandle, (char) 1);
}
Use the following callback to output logs when a Primary Service is detected.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
public void onDiscPriSrvResult(char connectedHandle,
int status, BluetoothLeGattService[] data) {
for (int cnt=0; cnt<data.length; cnt++) {
Log.i(“DEBUG”, “startHandle=” +
data[cnt].startHandle + “ endHandle=” +
data[cnt].endHandle);
}
};
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
174
8.9.6. Searching for Characteristic
You can search for the Characteristics on a connected BLE device by executing the callback
function setGattCallback() and Characteristic search using discChar().
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GATT function provided
mManager.setGattCallback(mLeGattCallback);
//Searching for Characteristic
//Set StartHandle and EndHandle from the Service information
acquired in onDiscPriSrvResult
mManager.discChar (ConnectedHandle, StartHandle, EndHandle);
}
Use the following callback to output logs when a Characteristic is detected.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
public void onDiscCharResult(char connectedHandle,
int status, BluetoothLeGattChar[] data) {
for (int cnt=0; cnt<data.length; cnt++) {
Log.i(“DEBUG”, “HandleValue=” +
data[cnt].handleValue+ “ uuid=” +
data[cnt].uuid);
}
};
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
175
8.9.7. Searching for Characteristic Descriptor
You can search for the Characteristic Descriptor on a connected BLE device by
executing the callback function setGattCallback() and Characteristic Descriptor search using
discCharDesc().
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GATT function provided
mManager.setGattCallback(mLeGattCallback);
//Searching for Characteristic Descriptor
//Set StartHandle and EndHandle from the acquired onDiscPriSrvResult
mManager.discCharDesc (ConnectedHandle, StartHandle, EndHandle);
}
Use the following callback to output logs when a Characteristic Descriptor is detected.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
public void onDiscCharDescResult (char connectedHandle,
int status, BluetoothLeGattChar[] data) {
for (int cnt=0; cnt<data.length; cnt++) {
Log.i(“DEBUG”, “HandleValue=” + data[cnt].handleValue
+ “ CharacteristicUuid=” + data[cnt].uuid);
}
};
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
176
8.9.8. Acquiring Characteristic Value by Specifying a Handle
You can acquire the Characteristic Value on a connected BLE device byexecuting the callback
function setGattCallback() and Characteristic Value acquisition using readGatt().
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GATT function provided
mManager.setGattCallback(mLeGattCallback);
//Acquire (READ) Characteristic Value
//Set the handle HandleValue in Characteristic Value from the Characteristic
//information acquired in onDiscCharResult()
mManager.readGatt(ConnectedHandle, HandleValue)
}
Use the following callback to output logs when a Characteristic Value is acquired.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
public void onReadGattResult (
char status, BluetoothLeGattEvtReadRsp data) {
Log.i(“DEBUG”, “Characteristic Value=” + data.data);
}
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
177
8.9.9. Acquiring Characteristic Value by Specifying a UUID
You can acquire the Characteristic Value on a connected BLE device by specifying a UUID. To do
this execute the callback function registration using setGattCallback() and Characteristic Value
acquisition using readUuidGatt().
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GATT function provided
mManager.setGattCallback(mLeGattCallback);
//Acquire (READ) Characteristic Value
//Set StartHandle and EndHandle from the acquired onDiscPriSrvResult
//Set the UUID for the Characteristic information acquired in
// onDiscCharDescResult
mManager.readUuidGatt(ConnectedHandle, Uuid, StartHandle, EndHandle);
}
Use the following callback to output logs when a Characteristic Value is acquired.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
onReadUuidGattResult(char connectedHandle, int status,
BluetoothLeGattEvtReadUuidRsp[] data) {
Log.i(“DEBUG”, “Characteristic Value=” + data.data);
}
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
178
8.9.10. Writing a Characteristic Value
You can write the Characteristic Value to a connected BLE device by
executing the callback function setGattCallback() and Characteristic Value writing using
writeGatt().
import android.bluetooth.BluetoothLeAdapterManager;
import android.bluetooth.BluetoothLeGapEvtConnected;
import android.bluetooth.BluetoothLeGattCallback;
public class MainActivity extends Activity {
private BluetoothLeAdapterManager mManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
//Instance acquisition for the BLE manager class
mManager = BluetoothLeAdapterManager.getInstance();
//Register a callback for the GATT function provided
mManager.setGattCallback(mLeGattCallback);
//Writing a Characteristic Value
//Set the handle HandleValue in Characteristic Value from the Characteristic
// information acquired in onDiscCharResult()
mManager.writeGatt(ConnectedHandle, HandleValue, 0x01);
}
Use the following callback to output logs when a Characteristic Value is written.
private BluetoothLeGattCallback mLeGattCallback =
new BluetoothLeGattCallback() {
@Override
public void onWriteGattResult(char connectedHandle, int status,
BluetoothLeGattEvtWriteRsp data) {
//Since the value written in writeGatt is returned for confirmation,
// no processing is performed
Log.i(“DEBUG”, “write ok”);
}
};
}
MOVERIO Pro Developer's Guide (Rev.1.5)
179
8.10. Recording using Bluetooth headsets
In order to record with the application using the Bluetooth headset, implement the following
process.
■Permission setting
Set the following permissions in AndroidManifest.xml.
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
■Implementation in source code
Implement the next source code in the java file.
private AudioManager mAudioManager;
// do this after pairing is completed
mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
mAudioManager.startBluetoothSco();
mAudioManager.setBluetoothScoOn(true);
■Precaution
Please do the above processing after pairing is completed, otherwise recording is not possible.
MOVERIO Pro Developer's Guide (Rev.1.5)
180
9. Power control
MOVERIO Pro Developer's Guide (Rev.1.5)
181
9.1. Power control summary
You have two batteries in the BT-2000 and acquire power supply information.
■ Power supply information
The following power supply information types are defined in the Android BatteryManager class.
Power supply type Battery
information
type
Constant
Power status Overall status of batteries
A/B
int EXTRA_STATUS
Amount of power
remaining
Amount of power remaining
in batteries A/B [%]
int EXTRA_LEVEL
AC adapter connection Info. on AC adapter
connected/disconnected
int EXTRA_PLUGGED
Battery A status Status String EXTRA_STATUS_A
Battery A installed Battery installed boolean EXTRA_PRESENT_A
Amount of power
remaining in battery A
Power remaining [%] int EXTRA_LEVEL_A
Battery A current Current [mA] int EXTRA_CURRENT_A
Battery A voltage Voltage [mV] int EXTRA_VOLTAGE_A
Battery A temperature Temperature [deg C] int EXTRA_TEMPERATURE_A
Battery B status Status String EXTRA_STATUS_B
Battery B installed Battery installed boolean EXTRA_PRESENT_B
Amount of power
remaining in battery B
Power remaining [%] int EXTRA_LEVEL_B
Battery B current Current [mA] int EXTRA_CURRENT_B
Battery B voltage Voltage [mV] int EXTRA_VOLTAGE_B
Battery B temperature Temperature [deg C] int EXTRA_TEMPERATURE_B
MOVERIO Pro Developer's Guide (Rev.1.5)
182
9.2. Acquiring Battery Information
Use the Filter intent broadcast by the operating system, and acquire the battery information.
Usage examples are displayed below.
■ Register the receiver of the battery information broadcast by the app
IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); registerReceiver(mBroadcastReceiver, filter);
■ Acquire broadcast battery information
Example: Acquiring the amount of power remaining, status, and installation status for battery A
@Override public void onReceive(Context context, Intent intent){ int level_a = intent.getIntExtra(BatteryManager.EXTRA_LEVEL_A, 0); String status_a = intent.getStringExtra(BatteryManager.EXTRA_STATUS_A); boolean present_a = intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT_A, false);
MOVERIO Pro Developer's Guide (Rev.1.5)
183
10. Self-diagnostic function
MOVERIO Pro Developer's Guide (Rev.1.5)
184
10.1. Self-diagnostic function 10.1.1. Self-diagnostic function summary
The BT-2000 is equipped with a self-diagnostic function to check the status of internal devices. You
can check the following devices and content using the self-diagnostic function.
Table 10-1 Confirmation items using the self-diagnostic function
Device type Display name Diagnostic method
CPU CPU Error check
Power control IC PMIC Check power supply status
Main memory (RAM) DDR Check RAM data
Data memory (Flash) eMMC Reading and writing to data region
Wireless LAN module WLAN Check communication with device
Bluetooth 3.0 Bluetooth Check communication with device
Bluetooth Low Energy BLE Check communication with device
Audio IC Audio IC Reading device information
characteristics
Audio commands IC Voice Command Reading device information
characteristics
Sensor Sensor MCU Communication check
IMU sensor IMU Acquire sensor data
Sensor Illumination Sensor Illumination Acquire sensor data
Charger IC A Charger IC A Check status
Charger IC B Charger IC B Check status
Battery A Battery A Check status
Battery B Battery B Check status
The self-diagnostic function is a basic diagnostic tool. Be aware that it may not be able to locate
faults in individual functions in the device. And some functions are not available.
MOVERIO Pro Developer's Guide (Rev.1.5)
185
10.1.2. Using the self-diagnostic function
The self-diagnostic function is provided as an app. Start "SelfDiagnosis" from the app list.
Figure 10-1 Start SelfDiagnosis app
When the app starts, click the "Start" button at the top of the screen to start the diagnostic
procedure.
Figure 10-2 Start SelfDiagnosis app screen
MOVERIO Pro Developer's Guide (Rev.1.5)
186
When the diagnosis has been performed, the results for each device are displayed. See table 10-1
above for details about the target items and the checking method.
Figure 10-3 SelfDiagnosis check results
MOVERIO Pro Developer's Guide (Rev.1.5)
187
11. GPS Assist
MOVERIO Pro Developer's Guide (Rev.1.5)
188
11.1. GPS Assist function summary
BT-2000 has GPS assist function to reduce initial positioning time (Time To First Fix: TTFF) of
cold start when it takes long GPS positioning time. By downloading GPS satellite orbit prediction
data in advance and write in the BT-2000, it will reduce download time of satellite data and
reduce TTFF as a result.
Figure 11-1 EPO Data download image
Access point
EPO Data
Delivery
server
Internet
Intranet
WirelessLAN
Smartphone
Tethering
MOVERIO Pro Developer's Guide (Rev.1.5)
189
11.2. Precaution and limitation of using /developing GPS Assist
function
■GPS Assist function Effect
To fully demonstrate GPS Assist function effect, it is required to capture 4 GPS satellites.
There are some cases that cannot fully demonstrate the effect under condition that cannot
capture or hard to capture the GPS satellites.
■GPS cold start
To start GPS positioning, there are hot start using satellite data of last time, warm start and
cold start when you cannot use positioning data of last time.
GPS assist function is a function to demonstrate effect in cold start. It does not have effect to
reduce TTFF in hot start and warm start.
■Setting time
It uses time information to simulate GPS satellite position. So it is necessary to set the system
time accurately.
■Downloading EPO data
EPO data validity period is 30 days. But as the GPS assist function effect is higher by using new
data, so please re-download the EPO data by 1 week as a guide.
■EPO data delivery server
BT-2000 can download EPO data by internet from EPSON EPO data delivery server.
When you cannot use internet or using GPS assist function by local internet, copy EPO data
from EPSON data delivery server and place at local internet.
To set EPO data delivery server in BT-2000, write delivery server URL at ”internal
storage\agps\agps.conf”.
■GPS assist function API
BT-2000 GPS assist function API is using EPSON own API.
To develop an App using GPS assist function, install SDK provided by EPSON and use EPSON
own API.
MOVERIO Pro Developer's Guide (Rev.1.5)
190
11.3. How to use
This section describes how to use GPS assist function.
11.3.1. Downloading EPO data
・ Turn Wi-Fi function ON to access to EPO delivery server.
Internet environment is required to access to EPSON EPO data delivery server.
When placing EPO data to intranet, connection to intranet is required.
・ Open [Setting] App and select [Position information service].
・ Turn [GPS function] ON and select [AGPS data update].
11.3.2. Writing EPO data
While writing EPO data to BT-2000, the icon will be displayed in system bar.
Writing is completed after the icon disappears.
11.3.3. Using EPO data
・ Start App using GPS. GPS assist functions automatically operate at cold start.
MOVERIO Pro Developer's Guide (Rev.1.5)
191
11.4. Setting method
This section describes about setting for writing EPO data.
Setting file will be located at “internal storage\agps\agps.conf”.
Locate created file according to below list.
11.4.1. Setting file agps.conf
File path: /mnt/sdcard/agps/agps.conf
Default: None It is generated with the default value when [Settings]-[AGPS data update] is
executed.
File format: Conform to notation of java.util.Properies
Use ”\:” to write colon
Table 11-1 Setting items in agps.conf
No Item Explanation
1 EPO_URL Set URL of EPO data delivery server.
Default value is” https://tech.moverio.epson.com/epo/data.bin”
2 EPO_NUM_SEGS Set EPO writing segment number(1~28).
1 segment =6 hours.
Default value is 28(6 hours ×28=7 days)
3 LAST_MOD Shows download time of last time.
Not need for setting.
MOVERIO Pro Developer's Guide (Rev.1.5)
192
11.5. Application interface function summary
This section describes API of EPO data download and writing to BT-2000.
1) Download EPO data from EPO data delivery server
2) Write downloaded EPO data to BT-2000 GPS module
To use each API, import below module.
com.epson.moverio.bt2000.agpsctl
Table 11-2 Interface list of AGPSControl class
NO. Function name Function summary Note
1 downloadEpo Download EPO data by setting according to
agps.conf setting file.
EPSON original
API
2 downloadEpo_url Download EPO data from URL specified by
argument
EPSON original
API
3 writeEpo Write EPO data to BT-2000 by setting
according to agps.conf setting file.
EPSON original
API
4 writeEpo_segs Write EPO data of specified segment by
argument to BT-2000
EPSON original
API
MOVERIO Pro Developer's Guide (Rev.1.5)
193
11.6. Application interface detail
11.6.1. downloadEpo
Function
Download EPO data according to setting written in Setting file (/sdcatd/agps.conf).
EPO data will be delivered from EPSON data delivery server(Update every day at 0 :10 UTC)
Format
Parameter
None
Return value
Always 0
Broadcast Intent
Intent Status
AGPS_DOWNLOAD_COMPLETED download completed
AGPS_DOWNLOAD_ERROR download error
AGPS_CONF_ERROR agps.conf error(agps.conf not exist, or defect in
EPO_URL)
AGPS_NETWORK_ERROR Error by Wi-Fi OFF
AGPS_FILE_NOT_UPDATED No update in server file
11.6.2. downloadEpo_url
Function
Download EPO data from the URL of parameter).
Format
Parameter
Type name Explanation
String arg0 URL of EPO data delibery server
Return value
Always 0
Broadcast Intent
Same as downloadEpo
int downloadEpo(void);
int downloadEpo(String arg0);
MOVERIO Pro Developer's Guide (Rev.1.5)
194
11.6.2.1. writeEpo
Function
Write EPO data to BT-2000 GPS module by agps.conf setting.
Format
Parameter
None
Return value
Always 0
Broadcast Intent
Intent Status
AGPS_WRITE_COMPLETED write the data completed
AGPS_WRITE_ERROR Write the data error
AGPS_CONF_ERROR agps.conf error (No agps.conf, or the number of
EPO_NUM_DAYS is not crrect)
AGPS_FILE_EXPIRED EPO file is old. (Expired at the present time, there
is no data for the specified period.)
11.6.2.2. writeEPO_segs
Function
Writes EPO data for the number of segments specified by the argument to the GPS module of
BT-2000.
One segment means the 6 hours.
Format
Parameter
R
Broadcast Intent
Same as writeEPO
Type name Explanation
int arg0 Writing segment number
int writeEPpo();
int writeEPO_segs(int arg0);
MOVERIO Pro Developer's Guide (Rev.1.5)
195
11.7. How to use API for GPS assist 11.7.1. Download of EPO data
Create the instance of AGPSControl and call API for download.
■Implementation example for download
public void execDownload(View view) {
Log.d(TAG, "exec Download");
try {
AGPSControl ctl = new AGPSControl();
ctl.downloadEpo();
} catch (Exception ex) {
ex.printStackTrace();
}
}
MOVERIO Pro Developer's Guide (Rev.1.5)
196
11.7.2. Intent reception method
As download and writing process are done asynchronously, return value cannot be referred
directly.
So, receive the process result by using Broadcast Intent.
For each Broadcast Intent value issued by each API, refer to the item of Broadcast intent of
each API.
This section describes about the intent reception method.
11.7.2.1. At start
Set intent filter and receiver at the start of application.
■Implementation example
private MyReceiver receiver = new MyReceiver();
private IntentFilter filter = new IntentFilter();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
filter.addAction(AGPSControl.AGPS_CONF_ERROR);
filter.addAction(AGPSControl.AGPS_DOWNLOAD_COMPLETED);
filter.addAction(AGPSControl.AGPS_DOWNLOAD_ERROR);
filter.addAction(AGPSControl.AGPS_FILE_EXPIRED);
filter.addAction(AGPSControl.AGPS_FILE_NOT_UPDATED);
filter.addAction(AGPSControl.AGPS_NETWORK_ERROR);
filter.addAction(AGPSControl.AGPS_WRITE_COMPLETED);
filter.addAction(AGPSControl.AGPS_WRITE_ERROR);
getApplicationContext().registerReceiver(receiver, filter);
}
MOVERIO Pro Developer's Guide (Rev.1.5)
197
■Intent receiver example
class MyReceiver extends BroadcastReceiver {
public MyReceiver() {
super();
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(AGPSControl.AGPS_CONF_ERROR)) {
Toast.makeText(getApplicationContext(), "AGPS_CONF_ERROR",
Toast.LENGTH_LONG).show();
Log.d(TAG, "Intent Received | AGPS Conf Error");
}
if (intent.getAction().equals(AGPSControl.AGPS_DOWNLOAD_COMPLETED)) {
Toast.makeText(getApplicationContext(), "AGPS_DOWNLOAD_COMPLETED",
Toast.LENGTH_LONG).show();
Log.d(TAG, "Intent Received | AGPS Download Completed");
}
~~~~~(Omit other intent)~~~~~
}
}
11.7.2.2. Re-setting of receiver due to application situation transition
Cancel intent receiver when application situation transit like becoming background.
■Receiver cancellation example
@Override
protected void onPause() {
super.onPause();
getApplicationContext().unregisterReceiver(receiver);
}
When returning to application again, re-register the intent receiver.
■Re-register example
@Override
protected void onResume() {
super.onResume();
getApplicationContext().registerReceiver(receiver, filter);
}
MOVERIO Pro Developer's Guide (Rev.1.5)
198
― Memo ―