@@ -73,17 +73,10 @@ public class ParagonMainActivity extends ActionBarActivity {
7373 public BuiltInRecipeSettingsInfo selectedBuiltInRecipe = null ;
7474 Toolbar toolbar ;
7575 private String TAG = ParagonMainActivity .class .getSimpleName ();
76- private String REQUEST_METHOD_READ = "READ" ;
77- private String REQUEST_METHOD_NOTIFICATION = "NOTIFICATION" ;
7876 // Bluetooth adapter handler
7977 private BluetoothAdapter bluetoothAdapter = null ;
8078 private ParagonSteps currentStep = ParagonSteps .STEP_NONE ;
81- // private float currentTemp;
82- // private byte batteryLevel;
83- // private byte burnerStatus = INITIAL_VALUE;
84- // private byte cookMode = INITIAL_VALUE;
85- // private byte probeConnection = ParagonValues.PROBE_NOT_CONNECT;
86- // private Queue requestQueue = new LinkedList();
79+
8780 private boolean isCheckingCurrentStatus = false ;
8881 // Thread handler for checking the connection with Paragon Master.
8982 private Handler handlerCheckingConnection ;
@@ -176,13 +169,6 @@ public void onServicesDiscovered(String address, List<BluetoothGattService> bleG
176169 super .onServicesDiscovered (address , bleGattServices );
177170
178171 Log .d (TAG , "[onServicesDiscovered] address: " + address );
179-
180- // TODO: blocked.
181- // BleManager.getInstance().displayGattServices(address);
182-
183- // // Get Initial values.
184- // BleManager.getInstance().readCharacteristics(ParagonValues.CHARACTERISTIC_OTA_VERSION);
185- // BleManager.getInstance().setCharacteristicNotification(ParagonValues.CHARACTERISTIC_OTA_COMMAND, true);
186172 }
187173
188174 @ Override
@@ -247,40 +233,14 @@ public void onDescriptorWrite(String address, String uuid, byte[] value) {
247233 Log .d (TAG , "[onDescriptorWrite] address: " + address + ", uuid: " + uuid );
248234 }
249235 };
236+
250237 private int checkingCountDown ;
251238
252- // public byte getCookMode() {
253- // return cookMode;
254- // }
255239
256240 public MaterialDialog getDialogOtaProcessing () {
257241 return dialogOtaProcessing ;
258242 }
259243
260- // private void nextCharacteristicRead() {
261- //
262- // String nextRequest = (String) requestQueue.poll();
263- //
264- // if (nextRequest != null) {
265- // String method = nextRequest.split("/")[0];
266- // String characteristic = nextRequest.split("/")[1];
267- //
268- // if (method.equals(REQUEST_METHOD_READ)) {
269- // BleManager.getInstance().readCharacteristics(characteristic);
270- // }
271- // else if (method.equals(REQUEST_METHOD_NOTIFICATION)) {
272- // BleManager.getInstance().setCharacteristicNotification(characteristic, true);
273- // }
274- // else {
275- //
276- // }
277- //
278- // }
279- // }
280-
281- // public float getCurrentTemp() {
282- // return currentTemp;
283- // }
284244
285245 private void onReceivedData (String uuid , byte [] value ) {
286246
@@ -359,7 +319,6 @@ else if (fragment instanceof MultiStageStatusFragment) {
359319 case ParagonValues .CHARACTERISTIC_BURNER_STATUS :
360320 Log .d (TAG , "CHARACTERISTIC_BURNER_STATUS :" + String .format ("%02x" , value [0 ]));
361321 productInfo .setErdBurnerStatus (byteBuffer .get ());
362- // checkInitialStatus();
363322 break ;
364323
365324
@@ -380,7 +339,6 @@ else if (fragment instanceof MultiStageStatusFragment) {
380339 case ParagonValues .CHARACTERISTIC_COOK_MODE :
381340 Log .d (TAG , "CHARACTERISTIC_COOK_MODE :" + String .format ("%02x" , value [0 ]));
382341 productInfo .setErdCurrentCookMode (byteBuffer .get ());
383- // checkInitialStatus();
384342
385343 new Thread (new Runnable () {
386344 @ Override
@@ -454,51 +412,8 @@ public void run() {
454412 }
455413 }
456414
457- private void checkInitialStatus () {
458- Log .d (TAG , "checkInitialStatus" );
459- if (currentStep == ParagonSteps .STEP_CHECK_CURRENT_STATUS ) {
460- ProductInfo product = ProductManager .getInstance ().getCurrent ();
461-
462- if (product .getErdBurnerStatus () != INITIAL_VALUE &&
463- product .getErdCurrentCookMode () != INITIAL_VALUE ) {
464-
465- dialogWaiting .dismiss ();
466-
467- if (product .getErdBurnerStatus () == ParagonValues .BURNER_STATE_START &&
468- product .getErdCurrentCookMode () == ParagonValues .CURRENT_COOK_MODE_RAPID ) {
469- nextStep (ParagonSteps .STEP_COOK_STATUS );
470- }
471- else {
472- nextStep (ParagonSteps .STEP_COOKING_MODE );
473- }
474- }
475- else {
476- Log .d (TAG , "checkInitialStatus Error State 1------------!!" );
477- // show timer icon and popup "connecting..."
478- }
479- }
480- else {
481- Log .d (TAG , "checkInitialStatus Error State 2------------!!" );
482- // do nothing
483- }
484- }
485-
486- // /**
487- // * @param value
488- // */
489- // private void onCookConfiguration(byte[] value) {
490- // RecipeInfo newRecipe = new RecipeInfo(value);
491- //
492- // if (newRecipe.numStage() > 0) {
493- // RecipeManager.getInstance().setCurrentRecipe(newRecipe);
494- // RecipeManager.getInstance().setCurrentStage(0);
495- //
496- // }
497- // }
498415
499416 private void onCookStage () {
500- final int newStage = (int ) ProductManager .getInstance ().getCurrent ().getErdCookStage ();
501-
502417 new Thread (new Runnable () {
503418 @ Override
504419 public void run () {
@@ -529,7 +444,7 @@ private void onCookState() {
529444 final byte state = ProductManager .getInstance ().getCurrent ().getErdCookState ();
530445
531446 if (state == ParagonValues .COOK_STATE_OFF ) {
532- // nextStep(ParagonMainActivity.ParagonSteps.STEP_COOKING_MODE);
447+ nextStep (ParagonMainActivity .ParagonSteps .STEP_COOKING_MODE );
533448 }
534449 else {
535450 new Thread (new Runnable () {
@@ -562,7 +477,6 @@ else if (fragment instanceof GetReadyFragment) {
562477 }
563478
564479 private void onElapsedTime () {
565- // final int elapsedTimeValue = elapsedTime;
566480
567481 new Thread (new Runnable () {
568482 @ Override
@@ -606,11 +520,6 @@ public void nextStep(ParagonSteps step) {
606520 case STEP_COOKING_MODE :
607521 loadRecipesFromAsset ();
608522
609- // BleManager.getInstance().setCharacteristicNotification(productInfo.bluetoothDevice,
610- // ParagonValues.CHARACTERISTIC_CURRENT_TEMPERATURE, false);
611- // BleManager.getInstance().setCharacteristicNotification(productInfo.bluetoothDevice,
612- // ParagonValues.CHARACTERISTIC_ELAPSED_TIME, false);
613-
614523 getFragmentManager ().popBackStack (null , FragmentManager .POP_BACK_STACK_INCLUSIVE );
615524
616525 fragment = new SelectModeFragment ();
@@ -796,9 +705,6 @@ protected void onCreate(Bundle savedInstanceState) {
796705
797706 OtaManager .getInstance ().readImageFile (ParagonMainActivity .this );
798707
799- // Initialize ble manager
800- // BleManager.getInstance().initBleManager(this);
801-
802708 // Add ble event listener
803709 BleManager .getInstance ().addListener (bleListener );
804710
@@ -1212,7 +1118,7 @@ protected void onResume() {
12121118
12131119 if (disconnectDialog .isShowing ()) {
12141120 Log .d (TAG , "Try to reconnect again" );
1215- BleManager .getInstance ().connect (ProductManager .getInstance ().getCurrent ().address );
1121+ // BleManager.getInstance().connect(ProductManager.getInstance().getCurrent().address);
12161122 }
12171123 else {
12181124 Log .d (TAG , "disconnectDialog is not Showing" );
0 commit comments