Академический Документы
Профессиональный Документы
Культура Документы
C
Monday 12.15pm
Computer Science Capstone Course
Northwestern Polytechnic University, Fremont, CA 94539
FINAL Report
SPRING 2017
Prof. Ahmed Banafa
1
Abstract
In developing countries with high crime rates per capita, personal safety especially for children
and women is a serious problem. The lack of 911 like all comprehensive helpline, inadequate
and inefficient police patrolling coverage, high population density, lack of stationary
infrastructure of CCTV cameras or manpower to execute it are some of the reasons the
ensuring of public safety is a big problem. This project aims to solve that problem using next
ubiquitous technology that drones are. It ensures safety by assigning the devices and tracking
the activity.
2
Introduction
This project is divided into four scenarios. User, Android App, Server and Hardware.
App: Register User details, get current location details and provide Droid/Drone details.
User who wants to ensure safety register to the app and request for Droid/Drone for assistant.
The assisted droid follows the user using WIFI/BLUETOOTH link. If user meets any uncalled
situation, stress call facility is provided which tells Droid/Drone to get alert. Droid/Drone start
alarming nearby passerby using siren and contacts to the police services.
3
Block Diagram
4
Flow Diagram
5
User Side Coding Structure
Registration Page
This page is about Registration. A Sign-up form ask user to input the details, checks for
validations and save the details in database.
Field Names:
name = (EditText)findViewById(R.id.etName);
phoneNo = (EditText)findViewById(R.id.etPhone);emailId =
(EditText)findViewById(R.id.etFEmailId);password =
(EditText)findViewById(R.id.etFPassword); confrimPassword =
(EditText)findViewById(R.id.etFConfrimPassword); register = (Button)
findViewById(R.id.btRegister);
//Validations:
}else{//insert data
register(nameValue,phoneNoValue,emailIdValue,passwordValue,confrimPassValue);
6
Login Page
This page asks user to login with registered details, check the input from database and logins.
Field Names:
Validations:
/*on click goes to location activity * check login details* check validations*/
signIn.setOnClickListener(new View.OnClickListener() {
@Override
} });
//Intent - takes us to the requested activity. Here register is the requested activity
startActivity(registerIntent); }
});
startActivity(forgotIntent); } });
7
Forgot Password Page
This page allows user to update or change the password using email id.
Field Names:
frgtEmailId = (EditText)findViewById(R.id.etFEmailId);
Validations:
if(!isValidEmail(emialIdValue)){
frgtEmailId.requestFocus();
frgtPassword.requestFocus();
frgtConfrimPassword.requestFocus();
//insert data
forgotPassword(emialIdValue,passwordValue,confrimPassword); }
8
Get Location Button Code
This code gets the current user location details
if(gps.canGetLocation()){
try {
adresses = geocoder.getFromLocation(latitude,longitude,1);
address = adresses.get(0).getAddressLine(0);
city = adresses.get(0).getLocality();
state = adresses.get(0).getAdminArea();
country = adresses.get(0).getCountryName();
postalCode = adresses.get(0).getPostalCode();
knownName = adresses.get(0).getFeatureName();
/*tvLocation.setText("Longitude:" +Double.toString(longitude)+
"\nLatitude:" +Double.toString(latitude));*/
} catch (IOException e) {
e.printStackTrace();
}
Request Droid Button Code
Socket socket = null;
DataOutputStream dataOutputStream = null;
DataInputStream dataInputStream = null;
try{
socket = new Socket("192.168.1.93", 5554);
dataOutputStream = new DataOutputStream(socket.getOutputStream());
dataInputStream = new DataInputStream(socket.getInputStream());
dataOutputStream.writeUTF(String.valueOf(lng));
dataOutputStream.writeUTF(String.valueOf(lat));
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
9
Track Location Button Code
This code calls the map activity to trace route
Intent adressIntent = new Intent(LocationActivity.this,MapsActivity.class);
adressIntent.putExtra("Address", address);
adressIntent.putExtra("City", city);
adressIntent.putExtra("State", state);
adressIntent.putExtra("Country", country);
startActivity(adressIntent);
Track Location Code
This code shows origin (user current location) and destination (droid location), track the route,
shows the distance and time between points.
Bundle extras = getIntent().getExtras();
if (extras != null)
{
String adressParam = extras.getString("Address");
String cityParam = extras.getString("City");
String stateParam = extras.getString("State");
String countryParam = extras.getString("Country");
etOrigin.setText(adressParam+","+cityParam+","+stateParam+","+countryParam);
}
10
polylinePaths.add(mMap.addPolyline(polylineOptions));
Alert Droid Arrived Code
This code shows an alert box on droid arrival to user location
dialog.setTitle("Alert");
dialog.setMessage("Droid Has Arrived to you.");
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent bluetoothIntent = new Intent(MapsActivity.this, ClientBluetooth.class);
startActivity(bluetoothIntent);
dialog.dismiss();
}
});
dialog.setCancelable(false);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
MediaPlayer mediaPlayer = MediaPlayer.create(MapsActivity.this,
R.raw.useralert);
mediaPlayer.start();
dialog.show();
}
}, 1000 * 60 * 1);
This code looks for droid Bluetooth and pairs to the droid
pairedDeviceArrayList = new ArrayList<BluetoothDevice>();
listViewPairedDevice.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
BluetoothDevice device =
(BluetoothDevice)parent.getItemAtPosition(position);
Toast.makeText(ClientBluetooth.this,
"Name: " + device.getName() + "\n"
11
+ "Address: " + device.getAddress() + "\n"
+ "BondState: " + device.getBondState() + "\n"
+ "BluetoothClass: " + device.getBluetoothClass() + "\n"
+ "Class: " + device.getClass(),
Toast.LENGTH_LONG).show();
//textStatus.setText("start ThreadConnectBTdevice");
myThreadConnectBTdevice = new ThreadConnectBTdevice(device);
myThreadConnectBTdevice.start();
}});
if(success){
//connect successful
final String msgconnected = "\nconnect successful:\n"
+ "\nBluetoothSocket: " + bluetoothSocket + "\n"
+ "\nBluetoothDevice: " + bluetoothDevice;
runOnUiThread(new Runnable(){
@Override
public void run() {
//textStatus.setText(msgconnected);
listViewPairedDevice.setVisibility(View.GONE);
inputPane.setVisibility(View.VISIBLE);
}});
startThreadConnected(bluetoothSocket);
}else{
//fail
}
12
Droid Side Coding Structure
Droid location and tracking is same as user part.
Droid Bluetooth socket code
This code pairs to the user device and starts capturing video of user activity
try {
bluetoothSocket = bluetoothServerSocket.accept();
//connected
runOnUiThread(new Runnable(){
@Override
public void run() {
//textStatus.setText(strConnected);
inputPane.setVisibility(View.VISIBLE);
//video
Intent camera_intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File video_file = getFilePath();
Uri video_uri = Uri.fromFile(video_file);
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, video_uri);
camera_intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY,1);
startActivityForResult(camera_intent, VIDEO_REQUEST_CODE);
}});
startThreadConnected(bluetoothSocket);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
13
Police siren and call service code
MediaPlayer mediaPlayer = MediaPlayer.create(StressActivity.this, R.raw.policesiren);
mediaPlayer.start(); // no need to call prepare(); create() does that for you
//voicemail
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("6504229567", null, "sms message", null, null);
Toast.makeText(getApplicationContext(), "SMS sent.",
Toast.LENGTH_LONG).show();
14
Server Programming
This is about sending user location details to the grid system and checking for nearest droid to
user.
Client Side:
Server Side:
public final static int defaultPort = 5554;//port no of the device DataOutputStream output;
15
Writing and Reading to Excel Files
This page sends user latitude and longitude details to excel file to plot a graph of user
intersection and to get nearest droid.
Write to excel:
cell = sheet.getRow(1).getCell(0);cell.setCellValue(latitude);cell =
sheet.getRow(1).getCell(1);cell.setCellValue(longitude);//Row row =
sheet.getRow(0);inputStream.close();FileOutputStream outFile = new FileOutputStream(new
File(excelFilePath)); workbook.write(outFile);
outFile.close();
16
Database Files
Database:
Registration:
Login:
Forgot password:
17
App Output
Login Registration
18
Forgot Password Get Location
19
Droid Result Track Location
20
Alert Dialog Bluetooth connection
21
Stress Call
22
Droid Output
Video Calling Service
23
Plot Graph
This graph show which droid is near to user location. There are 10 droids plot in this graph. User
location is shown by intersecting lines.
24
References
https://exotel.in/blog/single-number-helpline-for-india/
https://www.quora.com/India-What-is-it-like-to-dial-100-in-India-Is-
it-as-responsive-as-dialling-911-in-USA
http://www.vogella.com/tutorials/android.html
http://www.excel-easy.com/data-analysis/charts.html
25