Skip to content

Commit

Permalink
added some toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrio committed Feb 22, 2014
1 parent 1c01ab0 commit adf39f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class BluetoothLeService extends Service {
private static final UUID SIMPLE_KEYS_SERVICE_UUID = UUID.fromString("0000ffe0-0000-1000-8000-00805f9b34fb");
private static final UUID SIMPLE_KEYS_DATA_UUID = UUID.fromString("0000ffe1-0000-1000-8000-00805f9b34fb");
private BluetoothGattCharacteristic keyCharacteristic;

private static SimpleKeysStatus previousStatus;

private BluetoothDevice sensorTag;

Expand Down Expand Up @@ -101,27 +101,22 @@ public void onCharacteristicChanged (BluetoothGatt gatt, BluetoothGattCharacter

SimpleKeysStatus newValue = SimpleKeysStatus.values()[encodedInteger % 4];
Log.i(TAG, "newValue " + newValue.toString());
if (newValue == SimpleKeysStatus.OFF_ON){
AudioManager mAudioManager = (AudioManager) getSystemService(BluetoothLeService.this.AUDIO_SERVICE);

if(mAudioManager.isMusicActive()) {
Intent i = new Intent(SERVICECMD);
i.putExtra(CMDNAME , CMDNEXT );
BluetoothLeService.this.sendBroadcast(i);
}
}
else if (newValue == SimpleKeysStatus.ON_OFF){
AudioManager mAudioManager = (AudioManager) getSystemService(BluetoothLeService.this.AUDIO_SERVICE);

if(mAudioManager.isMusicActive()) {
Intent i = new Intent(SERVICECMD);
i.putExtra(CMDNAME , CMDPREVIOUS);
BluetoothLeService.this.sendBroadcast(i);
}
}
AudioManager mAudioManager = (AudioManager) getSystemService(BluetoothLeService.this.AUDIO_SERVICE);
Intent i = new Intent(SERVICECMD);
if(mAudioManager.isMusicActive()) {
if (newValue == SimpleKeysStatus.OFF_ON){
i.putExtra(CMDNAME , CMDNEXT );
}
else if (newValue == SimpleKeysStatus.ON_OFF){
i.putExtra(CMDNAME , CMDPREVIOUS);
}
BluetoothLeService.this.sendBroadcast(i);
previousStatus = newValue;
}

}
}

}
@Override
// New services discovered
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.util.Log;

public class MainActivity extends Activity {
Expand Down Expand Up @@ -42,6 +43,7 @@ public void onLeScan(final BluetoothDevice device, int rssi,
public void run() {
Log.i(TAG,"Found device " + device.getName());
if (device.getName().contains("SensorTag") ){
Toast.makeText(MainActivity.this, "SensorTag found! ", Toast.LENGTH_SHORT).show();
Log.i(TAG,"Starting service...");
mBluetoothAdapter.stopLeScan(mLeScanCallback);
Intent intent = new Intent(MainActivity.this, BluetoothLeService.class);
Expand Down Expand Up @@ -108,6 +110,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
}

private void scanLeDevice(final boolean enable) {
Toast.makeText(MainActivity.this, "Start scanning for BLE... ", Toast.LENGTH_SHORT).show();
Log.i(TAG, "starting scanLeDevice");
mScanning = true;
mBluetoothAdapter.startLeScan(mLeScanCallback);
Expand Down

0 comments on commit adf39f2

Please sign in to comment.