Skip to content

Commit

Permalink
Working
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrosado committed May 19, 2017
1 parent 611fa49 commit d326db4
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 642 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,44 +79,6 @@ public void onReceive(Context context, Intent intent) {
}
};

/**
* Broadcast Receiver for changes made to bluetooth states such as:
* 1) Discoverability mode on/off or expire.
*/
private final BroadcastReceiver mBroadcastReceiver2 = new BroadcastReceiver() {

@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();

if (action.equals(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED)) {

int mode = intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothAdapter.ERROR);

switch (mode) {
//Device is in Discoverable Mode
case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
Log.d(TAG, "mBroadcastReceiver2: Discoverability Enabled.");
break;
//Device not in discoverable mode
case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
Log.d(TAG, "mBroadcastReceiver2: Discoverability Disabled. Able to receive connections.");
break;
case BluetoothAdapter.SCAN_MODE_NONE:
Log.d(TAG, "mBroadcastReceiver2: Discoverability Disabled. Not able to receive connections.");
break;
case BluetoothAdapter.STATE_CONNECTING:
Log.d(TAG, "mBroadcastReceiver2: Connecting....");
break;
case BluetoothAdapter.STATE_CONNECTED:
Log.d(TAG, "mBroadcastReceiver2: Connected.");
break;
}

}
}
};




Expand Down
1 change: 0 additions & 1 deletion LocMessClient/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
</intent-filter>
</receiver>

<activity android:name=".BluetoothPairingActivity"></activity>
</application>

</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.widget.ArrayAdapter;

import java.util.AbstractMap;
import java.util.ArrayList;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class ServicesDataHolder {
private boolean killThread = false;

private static final ServicesDataHolder ourInstance = new ServicesDataHolder();
private ArrayAdapter bleAdapter;

public static ServicesDataHolder getInstance() {
return ourInstance;
Expand All @@ -55,6 +57,10 @@ private ServicesDataHolder() {

}

public void setBleAdapter(ArrayAdapter bleAdapter) {
this.bleAdapter = bleAdapter;
}

public ArrayList<String> getRemovedLocations() {
return removedLocations;
}
Expand Down Expand Up @@ -180,4 +186,7 @@ public void setKillThread(boolean killThread) {
this.killThread = killThread;
}

public ArrayAdapter getBleAdapter() {
return bleAdapter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.bluetooth.BluetoothDevice;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
Expand All @@ -26,16 +25,13 @@
import android.widget.TextView;

import pt.ulisboa.tecnico.cmu.tg14.locmessclient.DataObjects.ServicesDataHolder;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Exceptions.PublisherNotFoundException;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Services.BluetoothOperations;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Services.BluetoothService;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Services.DBService;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Services.GPSService;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Services.MasterService;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Services.WifiService;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Utils.FeedReaderDbHelper;

import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Utils.Network.ServerActions;
import pt.ulisboa.tecnico.cmu.tg14.locmessclient.Utils.ServiceManager;


Expand Down Expand Up @@ -132,8 +128,6 @@ public boolean onOptionsItemSelected(MenuItem item) {

//noinspection SimplifiableIfStatement
if (id == R.id.action_connect_mule) {
Intent intent = new Intent(this,BluetoothPairingActivity.class);
startActivity(intent);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)){
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
//Log.d(TAG, "onReceive: addr:"+device.getAddress());
Log.d(TAG, "onReceive: addr:"+device.getAddress());
mService.onBleReceived(device);
}else if(BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)){
mService.clearBluetoothList();
Expand Down
Loading

0 comments on commit d326db4

Please sign in to comment.