Sie sind auf Seite 1von 5

07/07/13

LabVIEW Android Interface [LabVIEW Hacker]

skip to content

User Tools
Login

Site Tools
Tools

Home Libraries AR.Drone Arduino LabVIEW Hacker Build-Tools Projects LabVIEW Android Interface LabVIEW EZ430-Chronos Interface LabVIEW Emotiv Epoc Interface LabVIEW iRobot Create Interface LabVIEW Kinect Interface LabVIEW Leap Interface LabVIEW Neato LDS Interface LabVIEW Twitter Interface LabVIEW MindShark LabVIEW VEX Interface LabVIEW Wiimote Interface Waterloo Labs: Science Fair Mash Up Learn LabVIEW & GitHub Setup Git Starting a New Project Contributing to a LVH Project

LabVIEW Android Interface

download the LabVIEW library


1. install JKI's VI package manager -> JKI's VI package manager 2. download the android package -> labviewhacker_lib_android_bluetooth_library-1.0.0.9.vip 3. install the package using JKI's package manager other downloads: SendSensor.apk

technical specifications
the sensors available on an android platform -> http://developer.android.com/reference/android/hardware/Sensor.html int int int int int int TYPE_ACCELEROMETER A constant describing an accelerometer sensor type. TYPE_ALL A constant describing all sensor types.

TYPE_GRAVITY A constant describing a gravity sensor type. TYPE_GYROSCOPE A constant describing a gyroscope sensor type

TYPE_LIGHT A constant describing an light sensor type. TYPE_LINEAR_ACCELERATION A constant describing a linear acceleration sensor type.
1/5

labviewhacker.com/doku.php?id=projects:lv_android_interface:lv_android_interface

07/07/13

LabVIEW Android Interface [LabVIEW Hacker]

int int int int int int

TYPE_MAGNETIC_FIELD A constant describing a magnetic field sensor type. TYPE_ORIENTATION This constant is deprecated. use SensorManager.getOrientation() instead. TYPE_PRESSURE A constant describing a pressure sensor type TYPE_PROXIMITY A constant describing an proximity sensor type. A constant describing a rotation vector sensor type.

TYPE_ROTATION_VECTOR

TYPE_TEMPERATURE A constant describing a temperature sensor type

LabVIEW running on a PC communicates with the android platform using bluetooth. The relationship between two Bluetooth devices is known as a client and server or master and slave. (a collection of these devices), there can be one server and 7 clients communicating with it at one time. For our purposes the computer running LabVIEW is the server and the android phon client.

Before transmission of data can happen the following three events must occur.

1. Discovering a. The server makes a discovery request. b. Clients within Bluetooth range (<30ft) that are set to the discoverable mode will respond to this request with a set of information about themselves such as device name, class, MAC address. [Note: The discovery request can also be initiated by a client. In this case the server and all other devices within range will respond to this request]. c. When the server chooses a client to pair with, a request for pairing is automatically sent to that specific client. 2. Pairing a. The server and the client share a link-key which is used for authentication between the two. b. Once the two devices are paired the server and client share more security sensitive information required for an encrypted connection. 3. Connecting a. The server opens a Bluetooth server socket and broadcasts a set of services identified by their channel numbers, names, descriptions and most importantly unique Universally U Identifiers (UUID). [Note: The UUID is a user defined string and can be anything as long as it stays within its standardized 128-bit format.] b. The server waits and listens for incoming connection requests. c. The client performs a Service Discovery Protocol (SDP) lookup during which it searches the services provided by the server to find the one it wants to communicate with. The this by going through the UUIDs the server is providing and tries to match one of them with the UUID it has. d. Upon finding a match, the client requests to communicate on that specific channel. e. The server hears this request and replies with a confirmation or a rejection. If the request is confirmed, the server shares the requested RFCOMM channel with the client. f. The two devices can now be considered connected and are ready for data transmission. Data transmission happens until connection is lost or the server or client terminates the

hacking with LabVIEW


Here, you will get to set up your android phone and computer to transmit sensor data from the phone to LabVIEW. Hardware you will need: 1. 2. 3. 4. A computer with LabVIEW. A Bluetooth adapter. (This is required if you computer does not have a built-in Bluetooth card. My laptop does not, so I use the IOGear Bluetooth 2.1 USB Micro Adapter.) An android phone with Bluetooth capability (e.g. Samsung Galaxy, HTC, Droid, etc.) USB cable to connect phone to computer.

Software you will need: (Download the following onto your computer) 1. 2. 3. 4. 5. LabVIEW 2010 or above Drivers for your Bluetooth adapter download the android package (see above) Android Example.vi (the package in step 3 will install here, C:\Program Files\National Instruments\LabVIEW 20XX\vi.lib\LabVIEWhacker\Android and run Android Example.vi) SendSensor.apk(See Above)

labviewhacker.com/doku.php?id=projects:lv_android_interface:lv_android_interface

2/5

07/07/13

LabVIEW Android Interface [LabVIEW Hacker]

Bluetooth communication between computer and your phone 1. Confirm your computer has bluetooth connection. (this hack was tested using the IOGear Bluetooth 2.1 USB Micro Adapter)

Adding your android phone as a device to which your computer can connect to: (These instruction are for Windows Vista, but similar step should be taken for any other versions of W 2. Go to Control Panel > Hardware and Sound > Bluetooth Device, and under Options tab you will see a section titled "Discovery." Check the box that says "Allow Bluetooth computer". BEFORE clicking OKAY 3. At the same place, in another tab called Devices you will see an "Add..." button. Click. "Add Bluetooth Device Wizard" will begin. BEFORE proceeding the phone needs to be discoverable.

4. On your android phone turn on Bluetooth. Then go to settings > Wireless & networks > Bluetooth settings, and check the box next to "Discoverable." Your phone will be discoverab minutes, during which you can complete the pairing process from your computer. BACK on the computer 5. 6. 7. 8. 9.

click next in the BT wizard. Select your specific phone and click next. When it asks you "Do you need a pass key to add this device?" choose "Let me choose my own pass key" and enter a code (e.g. 0101) and click next. On your android phone you will see a pop up window titled "Bluetooth pairing request," input the same code you created on your computer and press okay. Back on your computer, a window will pop up saying something like "Windows needs to install driver software for your Bluetooth Peripheral Device." Choose "Locate and install dri Windows is unable to find driver software for "Bluetooth Peripheral Devices," do not worry. Proceed by clicking "Finish" in the BT wizard.) 10. You should now be able to see your phone as a device under the Devices tab in Control Panel > Hardware and Sound > Bluetooth Device. (Your phone should now be paired with computer. This does not mean your phone is connected to your computer yet.) Put Android Application on your phone 1. 2. 3. 4. 5. Connect android phone to computer as "USB Mass Storage." From your computer, open the android folder and copy SendSensor.apk onto the SD card. Disconnect phone so to have the SD card recognized by the phone. On your phone, find "Files" in the applications folder. Click on "phone files" and find SendSensor.apk. Click and Install. Press Done.

Run LabVIEW Application on your computer 1. 2. 3. 4. Navigate to C:\Program Files\National Instruments\LabVIEW 20XX\vi.lib\LabVIEWhacker\Android and run Android Example.vi On the front panel find 'My Bluetooth Address' and make a note of the value underneath it (e.g. 00:02:43:7b:8c:2a). On your android phone, find and press on SendSensor (application with a fuchsia logo and a black compass). When you are asked for Bluetooth Device ID, type in the "My Bluetooth Address" value.

BEFORE clicking Ok, press and hold the dialog box and select "Copy all." This is so you can simply paste the address if you restart the application). 1. 2. 3. 4. 5. Now press okay. Press "Search BT Devices" in the android application. Press on the Bluetooth device that has your computer Bluetooth name and address (this option will also have the fuchsia logo next to it as opposed to a Bluetooth logo). In the application the screen will change from the "Search" tab to the "Control" tab. You should now be transmitting data to your VI.

Code Review

labviewhacker.com/doku.php?id=projects:lv_android_interface:lv_android_interface

3/5

07/07/13

LabVIEW Android Interface [LabVIEW Hacker]

1. 'Bluetooth Name and Address' identifies the Bluetooth adapter used by the computer. 2. 'Android Initialize' creates a channel with user defined UUID and service name. This new channel is added on to the end of the services provided by the server. Thus, the channel num user defined and depends on how long that list is. It then hangs the server vi until there is an incoming connection request from a client. When this request is received the vi continues i matches the one in the Client's request. 3. 'Android Data' reads in 144 bytes over the connection. The format the android application prepares the sensor values requires this specification. We then parse the incoming string ba we have packaged it on the android side using the various parsing vi

projects/lv_android_interface/lv_android_interface.txt Last modified: 2013/04/29 14:43 by samkristoff

Page Tools
Show pagesource Old revisions Backlinks Back to top Except where otherwise noted, content on this wiki is licensed under the following license: BSD 2-Clause License

labviewhacker.com/doku.php?id=projects:lv_android_interface:lv_android_interface

4/5

07/07/13

LabVIEW Android Interface [LabVIEW Hacker]

labviewhacker.com/doku.php?id=projects:lv_android_interface:lv_android_interface

5/5

Das könnte Ihnen auch gefallen