diff --git a/Blinker/.classpath b/Blinker/.classpath
deleted file mode 100644
index 40e5aab..0000000
--- a/Blinker/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/Blinker/.project b/Blinker/.project
deleted file mode 100644
index 4b1a487..0000000
--- a/Blinker/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
- Blinker
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/Blinker/.settings/org.eclipse.jdt.core.prefs b/Blinker/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index b080d2d..0000000
--- a/Blinker/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/Blinker/AndroidManifest.xml b/Blinker/AndroidManifest.xml
deleted file mode 100644
index e2874c8..0000000
--- a/Blinker/AndroidManifest.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Blinker/ant.properties b/Blinker/ant.properties
deleted file mode 100644
index ee52d86..0000000
--- a/Blinker/ant.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is used to override default values used by the Ant build system.
-#
-# This file must be checked in Version Control Systems, as it is
-# integral to the build system of your project.
-
-# This file is only used by the Ant script.
-
-# You can use this to override default values such as
-# 'source.dir' for the location of your java source folder and
-# 'out.dir' for the location of your output folder.
-
-# You can also use it define how the release builds are signed by declaring
-# the following properties:
-# 'key.store' for the location of your keystore and
-# 'key.alias' for the name of the key to use.
-# The password will be asked during the build when you use the 'release' target.
-
diff --git a/Blinker/bin/AndroidManifest.xml b/Blinker/bin/AndroidManifest.xml
deleted file mode 100644
index e2874c8..0000000
--- a/Blinker/bin/AndroidManifest.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Blinker/build.xml b/Blinker/build.xml
deleted file mode 100644
index 4967f03..0000000
--- a/Blinker/build.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Blinker/default.properties b/Blinker/default.properties
deleted file mode 100644
index e2e8061..0000000
--- a/Blinker/default.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-8
diff --git a/Blinker/proguard.cfg b/Blinker/proguard.cfg
deleted file mode 100644
index b1cdf17..0000000
--- a/Blinker/proguard.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native ;
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public (android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/Blinker/project.properties b/Blinker/project.properties
deleted file mode 100644
index f049142..0000000
--- a/Blinker/project.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-10
diff --git a/Blinker/res/drawable-hdpi/blinker_connection_connected.png b/Blinker/res/drawable-hdpi/blinker_connection_connected.png
deleted file mode 100644
index f5c4ee2..0000000
--- a/Blinker/res/drawable-hdpi/blinker_connection_connected.png
+++ /dev/null
diff --git a/Blinker/res/drawable-hdpi/blinker_connection_disconnected.png b/Blinker/res/drawable-hdpi/blinker_connection_disconnected.png
deleted file mode 100644
index 4cf5215..0000000
--- a/Blinker/res/drawable-hdpi/blinker_connection_disconnected.png
+++ /dev/null
diff --git a/Blinker/res/drawable-hdpi/blinker_light_off.png b/Blinker/res/drawable-hdpi/blinker_light_off.png
deleted file mode 100644
index 3c1f492..0000000
--- a/Blinker/res/drawable-hdpi/blinker_light_off.png
+++ /dev/null
diff --git a/Blinker/res/drawable-hdpi/blinker_light_on.png b/Blinker/res/drawable-hdpi/blinker_light_on.png
deleted file mode 100644
index 560a3a9..0000000
--- a/Blinker/res/drawable-hdpi/blinker_light_on.png
+++ /dev/null
diff --git a/Blinker/res/drawable-hdpi/icon.png b/Blinker/res/drawable-hdpi/icon.png
deleted file mode 100644
index aaed9f0..0000000
--- a/Blinker/res/drawable-hdpi/icon.png
+++ /dev/null
diff --git a/Blinker/res/drawable-ldpi/icon.png b/Blinker/res/drawable-ldpi/icon.png
deleted file mode 100644
index 58be3a2..0000000
--- a/Blinker/res/drawable-ldpi/icon.png
+++ /dev/null
diff --git a/Blinker/res/drawable-mdpi/icon.png b/Blinker/res/drawable-mdpi/icon.png
deleted file mode 100644
index aaed9f0..0000000
--- a/Blinker/res/drawable-mdpi/icon.png
+++ /dev/null
diff --git a/Blinker/res/drawable/connected_indicator.xml b/Blinker/res/drawable/connected_indicator.xml
deleted file mode 100644
index 96e836b..0000000
--- a/Blinker/res/drawable/connected_indicator.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Blinker/res/drawable/gradient.xml b/Blinker/res/drawable/gradient.xml
deleted file mode 100644
index e0c35bb..0000000
--- a/Blinker/res/drawable/gradient.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/Blinker/res/drawable/led.xml b/Blinker/res/drawable/led.xml
deleted file mode 100644
index 0c47df1..0000000
--- a/Blinker/res/drawable/led.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/Blinker/res/layout/list_item.xml b/Blinker/res/layout/list_item.xml
deleted file mode 100644
index e642aaf..0000000
--- a/Blinker/res/layout/list_item.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Blinker/res/layout/main_activity.xml b/Blinker/res/layout/main_activity.xml
deleted file mode 100644
index f37d65b..0000000
--- a/Blinker/res/layout/main_activity.xml
+++ /dev/null
@@ -1,236 +0,0 @@
-
-
-
-
-
-
-
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Blinker/res/layout/set_device_activity.xml b/Blinker/res/layout/set_device_activity.xml
deleted file mode 100644
index 211752d..0000000
--- a/Blinker/res/layout/set_device_activity.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Blinker/res/raw/blinker.json b/Blinker/res/raw/blinker.json
deleted file mode 100644
index 8cdcb7c..0000000
--- a/Blinker/res/raw/blinker.json
+++ /dev/null
@@ -1 +0,0 @@
-{"resources":{"$schemaHash":{"id":-6,"align":1,"attributes":{"readonly":true},"type":"A16:u1","access":"r","size":16},"$eapProtocolLevel":{"id":-3,"align":2,"attributes":{"readonly":true},"type":"u2","access":"r","size":2},"cmd":{"id":1,"align":1,"attributes":{"writeonly":true},"type":"E:demos@emmoco.com.Blinker/Cmd","access":"w","size":1},"$mcmProtocolLevel":{"id":-2,"align":2,"attributes":{"readonly":true},"type":"u2","access":"r","size":2},"count":{"id":2,"align":2,"attributes":{"readwrite":true},"type":"i2","access":"rw","size":2},"$schemaUuid":{"id":-1,"align":1,"attributes":{"readonly":true},"type":"A16:u1","access":"r","size":16},"delay":{"id":3,"align":2,"attributes":{"readwrite":true},"type":"N:0.500000,2.000000,0.100000,3/u2","access":"rw","size":2},"$eapBuildDate":{"id":-4,"align":1,"attributes":{"readonly":true},"type":"A8:u1","access":"r","size":8},"$resourceCount":{"id":-7,"align":1,"attributes":{"readonly":true},"type":"S:system@emmoco.com.System/ResourceCount","access":"r","size":2},"ledState":{"id":4,"align":1,"attributes":{"indicator":true,"readonly":true},"type":"E:demos@emmoco.com.Blinker/LedState","access":"ir","size":1},"$fileIndexReset":{"id":-5,"align":2,"attributes":{"writeonly":true},"type":"i2","access":"w","size":2}},"resourceNamesSys":["$eapBuildDate","$eapProtocolLevel","$fileIndexReset","$mcmProtocolLevel","$resourceCount","$schemaHash","$schemaUuid"],"manifest":{"protocolLevel":7,"hash":[193,64,14,198,222,65,254,73,231,195,236,98,124,34,224,251],"name":"Blinker","uuid":[243,78,78,150,58,146,163,180,255,66,64,107,112,96,163,80],"build":[228,142,35,113,54,1,0,0],"date":"2012-04-01T22:40:17","maxAlign":2,"maxSize":16,"version":"1.0.0"},"resourceNames":["cmd","count","delay","ledState","$schemaUuid","$mcmProtocolLevel","$eapProtocolLevel","$eapBuildDate","$fileIndexReset","$schemaHash","$resourceCount"],"attributes":{"description":"Blinker, the hello world program for mobile control","owner":"demos@emmoco.com","uuid":"50a36070-6b40-42ff-b4a3-923a964e4ef3","version":"1.0.0"},"types":{"system@emmoco.com.System/ResourceCount":{"align":1,"type":"S:system@emmoco.com.System/ResourceCount","size":2,"fields":[{"align":1,"name":"app","type":"u1","size":1},{"align":1,"name":"sys","type":"u1","size":1}]},"std:i2":{"align":2,"size":2},"demos@emmoco.com.Blinker/LedState":{"values":["LED_OFF","LED_ON"],"align":1,"type":"E:demos@emmoco.com.Blinker/LedState","size":1},"std:u1":{"align":1,"size":1},"std:u2":{"align":2,"size":2},"demos@emmoco.com.Blinker/Cmd":{"values":["START_CMD","STOP_CMD"],"align":1,"type":"E:demos@emmoco.com.Blinker/Cmd","size":1}},"resourceNamesApp":["cmd","count","delay","ledState"],"imports":{"demos@emmoco.com.Blinker":true}}
\ No newline at end of file
diff --git a/Blinker/res/values/colors.xml b/Blinker/res/values/colors.xml
deleted file mode 100644
index 70dbe5d..0000000
--- a/Blinker/res/values/colors.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- #000000
- #FFF
-
- #000000
- #2e82a2
-
-
-
-
diff --git a/Blinker/res/values/dimensions.xml b/Blinker/res/values/dimensions.xml
deleted file mode 100644
index 193c5d7..0000000
--- a/Blinker/res/values/dimensions.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
- 15dp
- 15dp
- 15dp
-
-
-
diff --git a/Blinker/res/values/strings.xml b/Blinker/res/values/strings.xml
deleted file mode 100644
index 042f690..0000000
--- a/Blinker/res/values/strings.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- Blinker Demo
-
-
-
- Device
- Delay
- Repeat
- Blink
- Choose Target Device"
- Connect
- Disconnect
- Cancel
- Scan
-
- ON
- OFF
-
-
-
-
- Emmoco Target Device Connected
- Emmoco Target Device Disconnected
- Emmoco Target Device Connection Timeout
- Emmoco Target Device Connection Cancelled
- Emmoco Target Device Connection Failure
- Connection Failure. The Target Device Is Not Using The Blinker Schema
- Connecting
- Cancelling connection...
-
-
-
- Incompatible Schema
- The schema that is on the device you\'re connecting to isn\'t the same
- as the one you\'re viewing currently. Attempting to read or write resources will probably fail.
-
-
-
-
diff --git a/Blinker/res/values/styles.xml b/Blinker/res/values/styles.xml
deleted file mode 100644
index 537fe51..0000000
--- a/Blinker/res/values/styles.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
diff --git a/Blinker/src/com/emmoco/example/blinker/MainActivity.java b/Blinker/src/com/emmoco/example/blinker/MainActivity.java
deleted file mode 100644
index 96a4333..0000000
--- a/Blinker/src/com/emmoco/example/blinker/MainActivity.java
+++ /dev/null
@@ -1,567 +0,0 @@
-package com.emmoco.example.blinker;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.text.InputType;
-import android.view.View;
-import android.widget.*;
-import com.emmoco.android.*;
-
-
-/**
- * This example application uses the Emmoco Framework to connect to a target running the Blinker schema
- * It allows the users to control the target by setting the blink counter, the blink delay and start the LED blinker
- * application running on the target.
- *
- * This application will receive indicators from the target when the LED changes state (on or off) and the app will
- * update an on-screen LED to match the state of the target's LED
- *
- *
- */
-public class MainActivity extends Activity {
-
- // The connection states track the app's connection to the target device
- public enum ConnectionState {
- CONNECTED, DISCONNECTED
- };
-
- private final static String TAG = "Blinker";
-
- private String mCurrentDevice;
- private ResourceSchema mServiceSchema;
- private TargetConnection mTargetConnection;
-
- private ResourceValue mCmdResourceValue;
- private ResourceValue mLedStateResourceValue;
- private ResourceValue mCountResourceValue;
- private ResourceValue mDelayResourceValue;
-
- private ImageView mLedImage;
- private ImageView mIndicator;
- private TextView mCountTextView;
- private TextView mDelayTextView;
- private TextView mIndTextView;
- private Button mConnectButton;
- private ToggleButton mOnOffButton;
- private Button mPlusButton;
- private Button mMinusButton;
- private Button mSetDevice;
-
- private ConnectionState mConnectionState = ConnectionState.DISCONNECTED;
- private long mScaledStep;
- private String mDelayFormat;
- private SeekBar mSlider;
- private StickyProgressDialog mProgress;
- private int mLocalCount;
-
-
- /**
- * Standard Android onCreate method. This will setup all the layout and save references to the UI elements
- * that will be modified during the course of the program
- *
- * @param savedInstanceState
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
-
- // Setup and retrieve view references
- setContentView(R.layout.main_activity);
- mLedImage = (ImageView) findViewById(R.id.led_image);
- mIndicator = (ImageView) findViewById(R.id.connected_indicator);
- mCountTextView = (TextView) findViewById(R.id.repeat_count);
- mIndTextView = (TextView) findViewById(R.id.indicator_count);
- mConnectButton = (Button) findViewById(R.id.connect_button);
- mOnOffButton = (ToggleButton) findViewById(R.id.on_off_button);
- mPlusButton = (Button) findViewById(R.id.plus_button);
- mMinusButton = (Button) findViewById(R.id.minus_button);
- mSetDevice = (Button) findViewById(R.id.setdevice_button);
-
- // Create a ProgressDialog spinner to use during connection
- mProgress = new StickyProgressDialog(this);
- mProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- mProgress.setButton(getResources().getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- // Cancel the connect attempt by closing it
- mTargetConnection.closeSync();
- mProgress.setMessage(getResources().getString(R.string.notice_cancelling));
- mProgress.show();
- return;
- }
- });
-
- // Setup Emmoco specific items
- initializeEmmoco();
-
- // set the slider for entering the delay value
- setup_slider();
-
- // Update the UI elements to show that the we are not connected to the target
- updateUiState(false);
-
-
- }
-
-
-
- /**
- * Standard Android onDestroy. Here we will make sure that we are disconnected from the target on Activity
- * destruction.
- */
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (mTargetConnection != null)
- mTargetConnection.closeSync();
- }
-
-
- /**
- * Do all the work loading the schema and setting up the references to the Emmoco Target's Resources
- */
- private void initializeEmmoco() {
-
- // load the schema that was downloaded from em-hub. We include the schema as part of the app resources
- mServiceSchema = Framework.current().createSchemaFromRaw(this, R.raw.blinker);
-
- // get the device to connect to from the users preferences
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- mCurrentDevice = prefs.getString(SetDeviceActivity.PREF_DEVICE_NAME, TargetConnection.MOCK_BLINKER_PRE);
-
- // initialize the Emmoco the resources
- mCmdResourceValue = mServiceSchema.newValue("cmd");
- mLedStateResourceValue = mServiceSchema.newValue("ledState");
- mCountResourceValue = mServiceSchema.newValue("count");
- mDelayResourceValue = mServiceSchema.newValue("delay");
-
-
- }
-
- /**
- * Update the UI elements based on whether we are connected or disconnected from the target
- *
- * If we are connected, we enable all the UI controls.
- * If we are disconnected, we disable all the UI controls that require talking to the target to operate
- *
- * @param connected
- */
- private void updateUiState(boolean connected){
-
- // indicator light
- mIndicator.setEnabled(connected);
-
- // delay slider
- mSlider.setEnabled(connected);
-
- // on/off toggle
- mOnOffButton.setEnabled(connected);
-
- if (mConnectionState == ConnectionState.DISCONNECTED){
- // Change text on connect button
- mConnectButton.setText(R.string.label_connect);
- }else{
- mConnectButton.setText(R.string.label_disconnect);
- }
-
- // Repeat section buttons
- mMinusButton.setEnabled(connected);
- mPlusButton.setEnabled(connected);
- mCountTextView.setEnabled(connected);
-
- // The device button is only active when not connected
- mSetDevice.setEnabled(!connected);
-
- // When connect or disconnect happens, the toggle button is not checked
- mOnOffButton.setChecked(false);
-
- // Clear the local counter
- mIndTextView.setText("");
-
-
- }
-
-
- /**
- * Emmoco Reactor used to handle the connection requests to the target
- *
- * Reactors are listeners that are called when the target device state changes, read/writes complete, or the target
- * sends an indicator.
- *
- * Reactors are called from the context of the UI thread.
- *
- * This reactor will be called back during the connection and disconnection phases of the example.
- *
- * This will set the UI elements to certain values based on connection and disconnection states
- *
- */
- enum Connection { CONNECT_DONE, DISCONNECT_DONE };
- private Reactor mConnectionReactor = new Reactor() {
- public void exec(Connection action, int status, Bundle data) {
- Toast msg;
- int notice;
-
- switch (action) {
- case CONNECT_DONE:
-
- if (status == TargetConnection.STATUS_OK) {
- //
- // Connection completed successfully
- //
- mConnectionState = ConnectionState.CONNECTED;
- notice = R.string.notice_connected;
-
- // bind to catch if the far end disconnects
- mTargetConnection.bindHangupEvent(mConnectionReactor.event(Connection.DISCONNECT_DONE));
-
- // read and display the current value of count
- mTargetConnection.read(mCountResourceValue, mCountReactor.event(CountAction.READ_COMPLETE));
-
- // read and display the current value of delay
- mTargetConnection.read(mDelayResourceValue, mDelayReactor.event(DelayAction.READ_COMPLETE));
-
- // Now update all the UI elements
- updateUiState(true);
- } else if (status == TargetConnection.STATUS_UUID_MISMATCH) {
- mConnectionState = ConnectionState.DISCONNECTED;
- notice = R.string.notice_uuid_mismatch;
- } else if (status == TargetConnection.STATUS_CONNECTION_TIMEOUT) {
- mConnectionState = ConnectionState.DISCONNECTED;
- notice = R.string.notice_timeout;
- } else if (status == TargetConnection.STATUS_CONNECTION_CANCELLED) {
- mConnectionState = ConnectionState.DISCONNECTED;
- notice = R.string.notice_cancelled;
- } else {
- // Connection attempt failed. Display a message
- notice = R.string.notice_failure;
- mConnectionState = ConnectionState.DISCONNECTED;
- }
-
- // Show a quick toast with the status of the connection
- msg = Toast.makeText(getApplicationContext(), notice, Toast.LENGTH_LONG);
- msg.show();
-
- // Dismiss the dialog only when connect result comes back
- mProgress.dismissManually();
-
- break;
-
- case DISCONNECT_DONE:
- // no need to check the status, disconnect always completes by leaving us
- // in the disconnected state
- mConnectionState = ConnectionState.DISCONNECTED;
- msg = Toast.makeText(getApplicationContext(), R.string.notice_disconnected, Toast.LENGTH_SHORT);
- msg.show();
-
- updateUiState(false);
-
- break;
- }
- }
- };
-
-
- /**
- * Reactor used to handle the writes and indicators for the blinker schema. This reactor will be called back
- * after each write (where we do not need to do anything at all) and the firing of the indicator. When the
- * indicator is fired, it signals when the LED changes, so we can use that indicator to trigger our UI LED and
- * countdown value to change
- */
- enum Action { WRITE_CMD_COMPLETE, INDICATOR };
- private Reactor mLedReactor = new Reactor() {
- public void exec(Action action, int status, Bundle data) {
- switch (action) {
- case WRITE_CMD_COMPLETE:
- // nothing to do
- break;
- case INDICATOR:
- // update the virtual led display based on the value that gets updated when the indicator is fired.
- // We registered this value after connection occurred with bindIndicatorValue()
- if (mLedStateResourceValue.toString().equals("LED_OFF")) {
- mLedImage.setSelected(false);
- if (mLocalCount == 0){
- // Reached the end, we disable some UI elements
- mIndTextView.setText("");
- mOnOffButton.setChecked(false);
- }
- } else {
- mLedImage.setSelected(true);
- mLocalCount--;
- mIndTextView.setText(String.valueOf(mLocalCount));
- }
- break;
- }
- }
- };
-
-
- /**
- * Reactor used for count value. When the count value is read back from the target, the UI value is updated with
- * the new value that is read back
- */
- enum CountAction { READ_COMPLETE, WRITE_COMPLETE };
- private Reactor mCountReactor = new Reactor() {
- public void exec(CountAction action, int status, Bundle data) {
- Long count;
- switch (action) {
- case READ_COMPLETE:
- count = new Long(mCountResourceValue.toLong());
- mCountTextView.setText(count.toString());
- break;
- case WRITE_COMPLETE:
- mTargetConnection.read(mCountResourceValue,mCountReactor.event(CountAction.READ_COMPLETE));
- break;
- }
- }
- };
-
-
- /**
- * Reactor used for delay resource. When the delay resource is read or written, the seek bar value is moved (on
- * read) and the display value is updated
- */
- enum DelayAction { READ_COMPLETE, WRITE_COMPLETE };
- private Reactor mDelayReactor = new Reactor() {
- public void exec(DelayAction action, int status, Bundle data) {
- double delay;
- long delayOrd;
- switch (action) {
- case READ_COMPLETE:
- delay = mDelayResourceValue.toDouble();
- delayOrd = mDelayResourceValue.toLong();
- mDelayTextView.setText(String.format(mDelayFormat, delay));
-
- // set the progress bar position based on the ordinal value. We use the ordinal value
- // to determine where to position the seek on the 0 to 100 scale of the seekbar.
- int progress;
- if (delayOrd == mDelayResourceValue.numMaxOrdinal()) {
- progress = 100;
- } else {
- progress = (int) (delayOrd * mScaledStep);
- }
- mSlider.setProgress(progress);
- break;
- case WRITE_COMPLETE:
- // Nothing to do
- break;
- }
- }
- };
-
-
-
-
-
-
- /**
- * The set-device button has been pressed, start the sub-activity which will change the device preference
- */
- final private int DEVICE_SELECT = 1;
- public void onSetDeviceClick(View v) {
- Intent i = new Intent(this, SetDeviceActivity.class);
- startActivityForResult(i, DEVICE_SELECT);
- }
-
- /**
- * Process the result from the set-device sub activity
- *
- * @param requestCode
- * @param resultCode
- * @param data
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode){
- case DEVICE_SELECT:
- // If the device value string has changed, update our local copy
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- String device = prefs.getString(SetDeviceActivity.PREF_DEVICE_NAME, TargetConnection.MOCK_BLINKER_PRE);
-
- // If device has changed we need to disconnect if connected, then the user can reconnect
- // manually to the new device
- if (!mCurrentDevice.contentEquals(device)){
- mCurrentDevice = device;
-
- if ((mTargetConnection != null) &&(mTargetConnection.isConnected())){
- onConnectToggleClick(null);
- }
- }
- break;
- }
- }
-
- /**
- * Handler function for when the on/off button is press. In this handler, depending on the current state,
- * the command is sent to start or stop the blinker on the target
- *
- * @param v unused
- */
- public void onToggleOnOff(View v) {
-
- String command;
-
- ToggleButton b = (ToggleButton)v;
-
- // Determine which command to send
- if (b.isChecked()){
- // We have been turned on
- command = "START_CMD";
-
- // Set up the local count value so we can count down
- mLocalCount = mCountResourceValue.toInt();
- ((TextView)findViewById(R.id.indicator_count)).setText(String.valueOf(mLocalCount));
-
- }else{
- // We have been turned off
- command = "STOP_CMD";
- }
-
- // Send command
- mCmdResourceValue.assignEnum(command);
- mTargetConnection.write(mCmdResourceValue, mLedReactor.event(Action.WRITE_CMD_COMPLETE));
-
- }
-
-
- /**
- * Handler for the connect toggle button
- *
- * Normally in an app the user doesn't worry about connecting or disconnecting, we
- * simply connect when the main activity becomes visible and disconnect
- * when another activity comes to the front, but this handler is used to
- * give the user the ability to toggle the connect state by touching the
- * connect/disconnect button
- *
- * @param v unused
- */
- public void onConnectToggleClick(View v) {
-
- // toggle connect or disconnect
- switch (mConnectionState) {
- case DISCONNECTED:
-
- // Show Connection spinner
- mProgress.setMessage(getResources().getString(R.string.notice_connecting));
- mProgress.setCancelable(false);
- mProgress.show();
-
- // configure the generic mock device if it is being used with some default values
- if (mCurrentDevice.equals(TargetConnection.MOCK_PRE)) {
- MockTargetDevice.reset();
- MockTargetDevice.current().setTickRate(500);
- MockTargetDevice.current().setAccessDelay(2);
- }
-
- // connect to the device using the schema
- mTargetConnection = new TargetConnection(mCurrentDevice, getApplicationContext());
- mTargetConnection.bindSchema(mServiceSchema);
- mTargetConnection.bindIndicatorValue("ledState", mLedReactor.event(Action.INDICATOR),mLedStateResourceValue);
-
- mTargetConnection.open(mConnectionReactor.event(Connection.CONNECT_DONE));
-
- break;
- case CONNECTED:
- mTargetConnection.close(mConnectionReactor.event(Connection.DISCONNECT_DONE));
- break;
- }
- }
-
- /**
- * handler for the minus Button
- * the minus button decrements the count resource and writes it to blinker
- *
- * @param v
- */
- public void onMinusButtonClick(View v) {
- long count = Long.parseLong(mCountTextView.getText().toString());
- if (count > 0) {
- count--;
- }
- mCountResourceValue.assignInt(count);
- mTargetConnection.write(mCountResourceValue, mCountReactor.event(CountAction.WRITE_COMPLETE));
- }
-
- /**
- * Handler for the plus Button
- * The plus button increments the count resource and writes it to blinker
- *
- * @param v
- */
- public void onPlusButtonClick(View v) {
- long count = Long.parseLong(mCountTextView.getText().toString());
- if (count < mCountResourceValue.intMax()){
- count++;
- }
- mCountResourceValue.assignInt(count);
- mTargetConnection.write(mCountResourceValue, mCountReactor.event(CountAction.WRITE_COMPLETE));
- }
-
-
-
-
-
- /**
- * Sets up the seekbar to be used as the input for changing the target's delay values. This must be called
- * after the schema and resource values are set up, We need to do some math here to split the 0 to 100 range of the
- * seekbar into the number of distinct values we can set the delay resource, and map those parts of the seekbar
- * into values that are set.
- *
- */
- private void setup_slider() {
- // calculate scaled step
- mScaledStep = 100 / mDelayResourceValue.numMaxOrdinal();
- mDelayFormat = "%.1f";
-
- mDelayTextView = (TextView) findViewById(R.id.delay);
- mDelayTextView.setRawInputType(InputType.TYPE_CLASS_NUMBER);
- mSlider = (SeekBar) findViewById(R.id.slider);
-
- // initializeEmmoco slider listener
- mSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
-
- public void onStopTrackingTouch(SeekBar seekBar) {
- // they took their finger off the bar, so write to the device
- Double delay = Double.parseDouble(mDelayTextView.getText().toString());
- mDelayResourceValue.assignNum(delay);
- mTargetConnection.write(mDelayResourceValue, mDelayReactor.event(DelayAction.WRITE_COMPLETE));
- }
-
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- long ord = progress / mScaledStep;
- mDelayResourceValue.assignNum(ord);
- mDelayTextView.setText(String.format(mDelayFormat, mDelayResourceValue.toDouble()));
- }
- });
- }
-
-
- /**
- * Android UI tweak.
- * Normally a progress dialog disappears when you hit a button (like cancel), but we want our dialog to stick around
- * until our background task has completed the cancellation phase. The easiest way is to override the dismiss() so
- * the dialog does not automatically close
- */
- private class StickyProgressDialog extends ProgressDialog {
- private StickyProgressDialog(Context context) {
- super(context);
- }
-
- @Override
- public void dismiss() {
- // do nothing
- }
- public void dismissManually() {
- super.dismiss();
- }
- }
-}
-
diff --git a/Blinker/src/com/emmoco/example/blinker/SetDeviceActivity.java b/Blinker/src/com/emmoco/example/blinker/SetDeviceActivity.java
deleted file mode 100644
index c604e53..0000000
--- a/Blinker/src/com/emmoco/example/blinker/SetDeviceActivity.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.emmoco.example.blinker;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.BaseAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-import com.emmoco.android.TargetConnection;
-
-import java.util.ArrayList;
-
-/**
- * This activity manages a screen where the user can choose from a list of target devices. These devices include
- * the Bluetooth paired devices and the Emmoco mock devices used for testing.
- *
- * This activity maintains a simple listview. There is an option to jump to the Settings->Bluetooth-Scan activity
- * When this activity returns, it refreshes the paired bluetooth device list in case it has changed
- *
- * This uses a custom Listview Adapter to show a checkmark next to the currently saved device
- *
- * The devices is stored using standard Android SharedPreferences
- *
- */
-public class SetDeviceActivity extends Activity{
- final static private String TAG="SetDeviceActivity";
-
- private String mCurrentDevice;
- private ListView mDeviceList;
- private DeviceArrayAdapter mAdapter;
-
- final public static String PREF_DEVICE_NAME = "DEVICE";
- final public static String MOCK_DEVICE_LABEL = "Mock Blinker Device";
-
-
- /**
- * Internal class that adapts our array of device strings to a listview. Current choice is highlighted with
- * a checkmark
- */
- private class DeviceArrayAdapter extends BaseAdapter {
-
- ArrayList mList;
- Activity mContext;
-
- DeviceArrayAdapter(Activity context, ArrayList arrayList) {
- mList = arrayList;
- mContext = context;
- }
-
- public int getCount() {
- return mList.size();
- }
-
- public Object getItem(int i) {
- return mList.get(i);
- }
-
- public long getItemId(int i) {
- return i;
- }
-
- /**
- * Returns a new view constructed from a simple layout. The layout has a textview for the name of the device
- * and a checkmark graphic that is visible or not.
- *
- * @param i
- * @param view
- * @param viewGroup
- * @return
- */
- public View getView(int i, View view, ViewGroup viewGroup) {
- LayoutInflater inflator = mContext.getLayoutInflater();
- view = inflator.inflate(R.layout.list_item, null);
-
- String name = (String)getItem(i);
- String label = name;
-
- // Translate the URI for the device into a pretty label for display in the listview
-
- // If Mock device, use mock label
- if (name.contentEquals(TargetConnection.MOCK_BLINKER_PRE)){
- label = MOCK_DEVICE_LABEL;
- }
- if (name.startsWith(TargetConnection.BT_PRE)) {
- // If Bluetooth, remove prefix
- label = name.substring(TargetConnection.BT_PRE.length());
- }
-
-
- // Set the label in the view
- ((TextView)view.findViewById(R.id.item_label)).setText(label);
-
- // If the current one, show the checkbox
- if (mList.get(i).contentEquals(mCurrentDevice)){
- view.findViewById(R.id.checkmark).setVisibility(View.VISIBLE);
- }else{
- view.findViewById(R.id.checkmark).setVisibility(View.INVISIBLE);
- }
- return view;
- }
-
- // Replace the list with a new one and trigger a redraw on the screen
- public void updateList(ArrayList list){
- mList = list;
- notifyDataSetInvalidated();
- }
- }
-
- /**
- * Standard Android method called at start of activity.
- *
- * Save the
- * @param savedInstanceState
- */
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.set_device_activity);
-
-
- mDeviceList = (ListView)findViewById(R.id.device_list_view);
-
- mAdapter = new DeviceArrayAdapter(this,TargetConnection.deviceList(true,false));
- mDeviceList.setAdapter(mAdapter);
-
- // get the device to connect to from the users preferences
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- mCurrentDevice = prefs.getString(PREF_DEVICE_NAME, TargetConnection.MOCK_BLINKER_PRE);
-
-
- // Register a handler when one of the list items is clicked. This handler will set the
- // preference to use the new device, and finish this activity so we go back to the main activity
- mDeviceList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
-
- String newDeviceName = (String)mAdapter.getItem(i);
-
- // Save changed name to preferences
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SetDeviceActivity.this);
- SharedPreferences.Editor edit = prefs.edit();
- edit.putString(PREF_DEVICE_NAME, newDeviceName);
- edit.commit();
-
- // Set the result so the calling activity know we have changed the device
- setResult(RESULT_OK);
- finish();
- }
- } );
-
- }
-
- @Override
- protected void onResume() {
- // If we are resuming after going to Settings-->Bluetooth, the device list may have changed so update
- mAdapter.updateList(TargetConnection.deviceList(true,false));
-
- super.onResume();
- }
-
-
-
- /**
- * Use an intent to call the Android bluetooth settings for scanning bluetooth devices
- * @param v
- */
- public void onScanDeviceClick(View v) {
- Intent i = new Intent();
- i.setAction(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
- startActivity(i);
- }
-
-}