Sei sulla pagina 1di 51

PROGRESS REPORT

PHASE -1 DATE :16 MAR 2012

Vehicle Automation On

ANDROID Phone BY
USING BLUETOOTH

PROJECT GUIDE :Thejaswini

Theju.

Lecturer, Dept. of ECE, JSSATE Project Associates :


HARSHA RAJU.
DILIP KUMAR. SANJAY KUMAR.K. Najib Farooq.

Progress Report-1

ANDROID SIDE APP DESIGNING BLUETOOTH ANDROID APP ACTUATOR SIDE TESTING

HARSHA SANJAY NAJIB & DILIP

ABSTRACT
Android is a software stack for mobile devices that includes an operating system, middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language. Mobile phones have almost become an integral part of us serving multiple needs of humans. This application makes use of the Bluetooth features of mobile phone as a solution for vehicle automation

Controllerarea network (CAN or CAN-bus) is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer. In our project we are going to implement CAN based vehicle automation by using Bluetooth for user security.

ANDROID ARCHITECTURE

BLOCK DIAGRAM
GPS GSM ANDROID MOBILE WITH OMAP44A PROCESS OR

ZIGBEE wireless BLUETOOTH Actuator BLUETOOTH ARM 7 BOARD CAN

HARDWARE REQUIREMENTS Android mobile ARM 7 Board Controller Area Network (CAN)

Bluetooth
SOFTWARE REQUIREMENTS Android SDK

Eclipse SDK
Linux Kernel Keil version 3

TECHNOLOGY USED
Bluetooth

Android Development

Android is an operating system based on Linux with a Java programming interface.


The Android Software Development Kit (Android SDK) provides all necessary tools to develop Android applications. This includes a compiler, debugger and a device emulator, as well as its own virtual machine to run Android programs. Android is currently primarily developed by Google.

Dalvik Virtual Machine


The Android system uses a special virtual machine, i.e. the Dalvik Virtual Machine to run Java based applications. Dalvik uses an own bytecode format which is different from Java bytecode.

Therefore you cannot directly run Java class files on Android, they need to get converted in the Dalvik bytecode format.

Eclipse: Eclipse is created by an Open Source community and is used in several different areas, e.g. as a development environment for Java or Android applications. Eclipse roots go back to 2001. Most people know Eclipse as an integrated development environment (IDE) for Java. Today it is the leading development environment for Java with a market share of approx. 65%.

Installation:

Eclipse requires an installed Java Runtime.Recommend to use Java 7 (also known as Java 1.7) or Java 6. Java comes in two flavors, the Java Runtime Environment (JRE) and the Java Development Kit (JDK). The JRE contains only the necessary functionality to start Java programs, while the JDK contains in addition the development tools. Eclipse contains its own development tools, e.g. Java compiler. To install Eclipse download the package "Eclipse IDE for Java Developers" from the websitehttp://www.eclipse.org/downloads and unpack it to a local directory.

How to Install a specific Android version The Android SDK Manager allows you to install specific versions of Android. SelectWindow Android SDK Manager from the Eclipse menu.

Android virtual device - Emulator

The Android Development Tools (ADT) includes an emulator to run an Android system. The emulator behaves like a real Android device and allows you to test your application without having a real device.
You can configure the version of the Android system you would like to run, the size of the SD card, the screen resolution and other relevant settings. You can define several of them with different configurations.

Create an Android Virtual Device

To define an Android Virtual Device (ADV) open the "AVD Manager" via Windows AVD Manager and press "New"

To Create Our Android App

Select File New Other Android Android Project and create the Android project harsha.android.bluetooth". Enter the following

Select the required sdk

next

After selecting the next button the following directory will be created in eclipse

The Android SDK allows the developer to define certain artifacts, e.g. strings and UI's, in two ways: via a rich editor, and directly via XML. The following description tries to use the rich UI but for validation the resulting XML is also displayed. You can switch between both things by clicking on the tab on the lower part of the screen.

To create attributes

Android allows you to create attributes for resources, e.g. for strings or colors. These attributes can be used in your UI definition via XML or in your Java source code. Select the file "res/values/string.xml" and press "Add". Select "Color" and enter "myColor"

Once the attributes are chosen we can start adding the UI Elements. We have to select res/layout/main.xml" and open the Android editor via a double-click. This editor allows you to create the UI via drag and drop or via the XML source code. You can switch between both representations via the tabs at the bottom of the editor. For changing the position and grouping elements you can use the outline view.

The following shows a screenshot of the Palette view from which you can drag and drop new UI elements into your layout.

From the Palette section Form Widgets, drag a Button object onto the layout.

BLUETOOTH
This document describes how to use the Android Bluetooth APIs to accomplish the four major tasks necessary to communicate using Bluetooth: setting up Bluetooth, finding devices that are either paired or available in the local area, connecting devices, and transferring data between devices. All of the Bluetooth APIs are available in the android.bluetooth package. Here's a summary of the classes and interfaces you will need to create Bluetooth connections:

BluetoothAdapter
Represents the local Bluetooth adapter (Bluetooth radio). The BluetoothAdapter is the entry-point for all Bluetooth interaction. Using this, you can discover other Bluetooth devices, query a list of bonded (paired) devices, instantiate aBluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for communications from other devices.

BluetoothDevice Represents a remote Bluetooth device. Use this to request a connection with a remote device through aBluetoothSocket or query information about the device such as its name, address, class, and bonding state.

BluetoothSocket Represents the interface for a Bluetooth socket (similar to a TCP Socket). This is the connection point that allows an application to exchange data with another Bluetooth device via InputStream and OutputStream.

BluetoothServerSocket Represents an open server socket that listens for incoming requests (similar to a TCP ServerSocket). In order to connect two Android devices, one device must open a server socket with this class. When a remote Bluetooth device makes a connection request to the this device, the BluetoothServerSocket will return a connectedBluetoothSocket when the connection is accepted.

BluetoothClass
Describes the general characteristics and capabilities of a Bluetooth device. This is a read-only set of properties that define the device's major and minor device classes and its services. However, this does not reliably describe all Bluetooth profiles and services supported by the device, but is useful as a hint to the device type. BluetoothProfile An interface that represents a Bluetooth profile. A Bluetooth profile is a wireless interface specification for Bluetooth-based communication between devices. An example is the Hands-Free profile.

Bluetooth Permissions
In order to use Bluetooth features in your application, you need to declare at least one of two Bluetooth permissions:BLUETOOTH and BLUETOOTH_ADMIN.
You must request the BLUETOOTH permission in order to perform any Bluetooth communication, such as requesting a connection, accepting a connection, and transferring data. You must request the BLUETOOTH_ADMIN permission in order to initiate device discovery or manipulate Bluetooth settings. Most applications need this permission solely for the ability to discover local Bluetooth devices. The other abilities granted by this permission should not be used, unless the application is a "power manager" that will modify Bluetooth settings upon user request. Note: If you use BLUETOOTH_ADMIN permission, then must also have the BLUETOOTH permission.

To Declare the Bluetooth permission(s) in your application manifest file: <manifest ... > <uses-permission android:name="android.permission.BLUET OOTH" /> ... </manifest>

Here is a basic example of a thread that initiates a Bluetooth connection:


private class ConnectThread extends Thread { private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; public ConnectThread(BluetoothDevice device) { // Use a temporary object that is later assigned to mmSocket, // because mmSocket is final BluetoothSocket tmp = null; mmDevice = device; // Get a BluetoothSocket to connect with the given BluetoothDevice try { // MY_UUID is the app's UUID string, also used by the server code tmp = device.createRfcommSocketToServiceRecord(MY_UUID); } catch (IOException e) { } mmSocket = tmp;

public void run() { // Cancel discovery because it will slow down the connection mBluetoothAdapter.cancelDiscovery(); try { // Connect the device through the socket. This will block // until it succeeds or throws an exception mmSocket.connect(); } catch (IOException connectException) { // Unable to connect; close the socket and get out try { mmSocket.close(); } catch (IOException closeException) { } return; } // Do work to manage the connection (in a separate thread) manageConnectedSocket(mmSocket);

/** Will cancel an in-progress connection, and close the socket */ public void cancel() { try { mmSocket.close(); } catch (IOException e) { } }

Managing a Connection
private class ConnectedThread extends Thread { private final BluetoothSocket mmSocket; private final InputStream mmInStream; private final OutputStream mmOutStream; public ConnectedThread(BluetoothSocket socket) { mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the input and output streams, using temp objects because // member streams are final try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { } mmInStream = tmpIn; mmOutStream = tmpOut;

public void run() { byte[] buffer = new byte[1024]; // buffer store for the stream int bytes; // bytes returned from read() // Keep listening to the InputStream until an exception occurs while (true) { try { // Read from the InputStream bytes = mmInStream.read(buffer); // Send the obtained bytes to the UI activity mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer) .sendToTarget(); } catch (IOException e) { break; } }

/* Call this from the main activity to send data to the remote device */ public void write(byte[] bytes) { try { mmOutStream.write(bytes); } catch (IOException e) { } } /* Call this from the main activity to shutdown the connection */ public void cancel() { try { mmSocket.close(); } catch (IOException e) { } }

Actuator

This actuator can move the metal hook shown in this photo to the left or right. When mounted in the car, it is vertical, so the hook can move up or down. It mimics your motions when you pull the knob up or push it down. The power-door-lock actuator is a pretty straight forward device

Inside the Actuator

This system is quite simple. A small electric motor turns a series of spur gears that serve as a gear reduction. The last gear drives a rack-and-pinion gearset that is connected to the actuator rod. The rack converts the rotational motion of the motor into the linear motion needed to move the lock. One interesting thing about this mechanism is that while the motor can turn the gears and move the latch, if you move the latch it will not turn the motor. This is accomplished by a neat centrifugal clutch that is connected to the gear and engaged by the motor.

Fitting of Actuator in Vehicle

Next on list:

PROGRAMMING OF ARM 7 PROCESSOR. BLUETOOTH RECIEVER CONFIGRATION. ANDROID APP INSTALLATION AND TESTING ON A REAL DEVICE. TPMS SENSORS AND DISPLAY UNIT.

Potrebbero piacerti anche