Skip to content

Commit 777734c

Browse files
author
Hollis Kim
committed
Merge pull request #2 from FirstBuild/feature/Hollis_multidevice
Parsing configuration data.
2 parents 3b6aeb6 + 6c9558f commit 777734c

File tree

14 files changed

+97
-398
lines changed

14 files changed

+97
-398
lines changed

app/src/main/java/com/firstbuild/androidapp/Paragon/MultiStageStatusFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void onClick(View view) {
108108
ByteBuffer valueBuffer = ByteBuffer.allocate(1);
109109

110110
valueBuffer.put((byte) 0x01);
111-
// BleManager.getInstance().writeCharateristics(ParagonValues.CHARACTERISTIC_START_HOLD_TIMER, valueBuffer.array());
111+
// BleManager.getInstance().writeCharacteristics(ParagonValues.CHARACTERISTIC_START_HOLD_TIMER, valueBuffer.array());
112112

113113
UpdateUiCookState(MULTI_STAGE_COOK_STATE.STATE_HOLDING_TEMP);
114114

@@ -126,7 +126,7 @@ public void onClick(View view) {
126126
ByteBuffer valueBuffer = ByteBuffer.allocate(1);
127127

128128
valueBuffer.put((byte) nextStage);
129-
// BleManager.getInstance().writeCharateristics(ParagonValues.CHARACTERISTIC_CURRENT_COOK_STAGE, valueBuffer.array());
129+
// BleManager.getInstance().writeCharacteristics(ParagonValues.CHARACTERISTIC_CURRENT_COOK_STAGE, valueBuffer.array());
130130

131131
UpdateUiCookState(MULTI_STAGE_COOK_STATE.STATE_HEAT_COOL);
132132
}

app/src/main/java/com/firstbuild/androidapp/Paragon/OtaManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void startProcess(){
125125
ByteBuffer valueBuffer = ByteBuffer.allocate(3);
126126

127127
valueBuffer.put((byte) 1);
128-
// BleManager.getInstance().writeCharateristics(ParagonValues.CHARACTERISTIC_OTA_COMMAND, valueBuffer.array());
128+
// BleManager.getInstance().writeCharacteristics(ParagonValues.CHARACTERISTIC_OTA_COMMAND, valueBuffer.array());
129129
Log.d(TAG, "ParagonValues.CHARACTERISTIC_OTA_COMMAND Send:" + valueBuffer.toString());
130130
}
131131

@@ -190,7 +190,7 @@ public void prepareImageFile() {
190190
valueBuffer.put((byte) 2);
191191
valueBuffer.put(1, (byte) (imageSize & 0xff));
192192
valueBuffer.put(2, (byte) ((imageSize >> 8) & 0xff));
193-
// BleManager.getInstance().writeCharateristics(ParagonValues.CHARACTERISTIC_OTA_COMMAND, valueBuffer.array());
193+
// BleManager.getInstance().writeCharacteristics(ParagonValues.CHARACTERISTIC_OTA_COMMAND, valueBuffer.array());
194194
Log.d(TAG, "ParagonValues.CHARACTERISTIC_OTA_COMMAND Send OTA_STEP_SEND_IMAGE_DATA:" + valueBuffer.toString());
195195
}
196196
else{
@@ -213,7 +213,7 @@ private void transferData() {
213213
ByteBuffer valueBuffer = ByteBuffer.allocate(SIZE_CHUNK);
214214

215215
valueBuffer.put(imageChunk, transferOffset * SIZE_CHUNK, SIZE_CHUNK);
216-
// BleManager.getInstance().writeCharateristics(ParagonValues.CHARACTERISTIC_OTA_DATA, valueBuffer.array());
216+
// BleManager.getInstance().writeCharacteristics(ParagonValues.CHARACTERISTIC_OTA_DATA, valueBuffer.array());
217217
Log.d(TAG, "ParagonValues.CHARACTERISTIC_OTA_DATA Send OTA_STEP_SEND_IMAGE_DATA:" + transferOffset + ", " + valueBuffer.toString());
218218

219219
transferOffset++;
@@ -224,7 +224,7 @@ private void transferData() {
224224
ByteBuffer valueBuffer = ByteBuffer.allocate(3);
225225

226226
valueBuffer.put((byte) 3);
227-
// BleManager.getInstance().writeCharateristics(ParagonValues.CHARACTERISTIC_OTA_COMMAND, valueBuffer.array());
227+
// BleManager.getInstance().writeCharacteristics(ParagonValues.CHARACTERISTIC_OTA_COMMAND, valueBuffer.array());
228228
Log.d(TAG, "ParagonValues.CHARACTERISTIC_OTA_COMMAND Send OTA_STEP_SEND_IMAGE_DONE:" + valueBuffer.toString());
229229
}
230230

app/src/main/java/com/firstbuild/androidapp/Paragon/ParagonMainActivity.java

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -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");

app/src/main/java/com/firstbuild/androidapp/Paragon/QuickStartFragment.java

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.firstbuild.androidapp.R;
1717
import com.firstbuild.androidapp.paragon.dataModel.RecipeInfo;
1818
import com.firstbuild.androidapp.paragon.dataModel.RecipeManager;
19+
import com.firstbuild.androidapp.paragon.dataModel.StageInfo;
1920
import com.firstbuild.androidapp.productManager.ProductInfo;
2021
import com.firstbuild.androidapp.productManager.ProductManager;
2122

@@ -80,8 +81,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
8081
public void onClick(View v) {
8182
String currentValue = (String) textTimeMin.getText();
8283

83-
String hourValue = currentValue.split("H:")[0];
84-
String minValue = currentValue.split("H:")[1].split("M")[0];
84+
String hourValue = currentValue.split(":")[0];
85+
String minValue = currentValue.split(":")[1];
8586

8687
pickerMinHour.setValue(Integer.parseInt(hourValue));
8788
pickerMinMin.setValue(Integer.parseInt(minValue));
@@ -97,11 +98,11 @@ public void onClick(View v) {
9798
public void onClick(View v) {
9899
String currentValue = (String) textTimeMax.getText();
99100

100-
String hourValue = currentValue.split("H:")[0];
101-
String minValue = currentValue.split("H:")[1].split("M")[0];
101+
String hourValue = currentValue.split(":")[0];
102+
String minValue = currentValue.split(":")[1];
102103

103-
pickerMinHour.setValue(Integer.parseInt(hourValue));
104-
pickerMinMin.setValue(Integer.parseInt(minValue));
104+
pickerMaxHour.setValue(Integer.parseInt(hourValue));
105+
pickerMaxMin.setValue(Integer.parseInt(minValue));
105106

106107
layoutPickerMin.setVisibility(View.GONE);
107108
layoutPickerMax.setVisibility(View.VISIBLE);
@@ -241,14 +242,34 @@ public void onNeutral(MaterialDialog dialog) {
241242

242243
public void goodToGo() {
243244

245+
String stringTime = textTimeMin.getText().toString();
246+
String hourValue = stringTime.split(":")[0];
247+
String minValue = stringTime.split(":")[1];
248+
int minHour = Integer.parseInt(hourValue);
249+
int minMin = Integer.parseInt(minValue);
250+
251+
stringTime = textTimeMax.getText().toString();
252+
hourValue = stringTime.split(":")[0];
253+
minValue = stringTime.split(":")[1];
254+
int maxHour = Integer.parseInt(hourValue);
255+
int maxMin = Integer.parseInt(minValue);
256+
257+
258+
String tempValue = textTemp.getText().toString().split("℉")[0];
259+
int temp = Integer.parseInt(tempValue);
260+
261+
244262
ProductInfo product = ProductManager.getInstance().getCurrent();
245-
RecipeInfo recipeConfig = product.getErdRecipeConfig();
246263

247-
recipeConfig.getStage(0).setTime(pickerMinHour.getValue() * 60 + pickerMinMin.getValue());
248-
recipeConfig.getStage(0).setMaxTime(pickerMaxHour.getValue() * 60 + pickerMaxMin.getValue());
249-
recipeConfig.getStage(0).setTemp(pickerTemp.getValue());
264+
RecipeInfo recipeConfig = new RecipeInfo("", "", "", "");
265+
recipeConfig.setType(RecipeInfo.TYPE_SOUSVIDE);
266+
recipeConfig.addStage(new StageInfo());
267+
recipeConfig.getStage(0).setTime(minHour * 60 + minMin);
268+
recipeConfig.getStage(0).setMaxTime(maxHour * 60 + maxMin);
269+
recipeConfig.getStage(0).setTemp(temp);
250270
recipeConfig.getStage(0).setSpeed(10);
251271

272+
product.setErdRecipeConfig(recipeConfig);
252273
product.sendRecipeConfig();
253274

254275
attached.nextStep(ParagonMainActivity.ParagonSteps.STEP_SOUSVIDE_GETREADY);
@@ -260,12 +281,12 @@ private void makeTempText(int temp) {
260281

261282

262283
private void makeTempMaxText(int hour, int min) {
263-
textTimeMax.setText(hour + "H:" + min + "M");
284+
textTimeMax.setText(hour + ":" + min);
264285
}
265286

266287

267288
private void makeTempMinText(int hour, int min) {
268-
textTimeMin.setText(hour + "H:" + min + "M");
289+
textTimeMin.setText(hour + ":" + min);
269290
}
270291

271292

app/src/main/java/com/firstbuild/androidapp/Paragon/RecipeSettingsFragment.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.firstbuild.androidapp.paragon.dataModel.BuiltInRecipeSettingsInfo;
1919
import com.firstbuild.androidapp.paragon.dataModel.RecipeInfo;
2020
import com.firstbuild.androidapp.paragon.dataModel.RecipeManager;
21+
import com.firstbuild.androidapp.paragon.dataModel.StageInfo;
2122
import com.firstbuild.androidapp.productManager.ProductInfo;
2223
import com.firstbuild.androidapp.productManager.ProductManager;
2324

@@ -267,7 +268,7 @@ private void calculateTimeTemp() {
267268
*/
268269
private void initRecipeSetting() {
269270
// Now create a sousvide recipe and pointing the recipe as currentRecipe.
270-
ProductManager.getInstance().getCurrent().createRecipeConfigForSousVide();
271+
// ProductManager.getInstance().getCurrent().createRecipeConfigForSousVide();
271272

272273
}
273274

@@ -278,13 +279,16 @@ private void initRecipeSetting() {
278279
public void goodToGo() {
279280

280281
ProductInfo product = ProductManager.getInstance().getCurrent();
281-
RecipeInfo recipeConfig = product.getErdRecipeConfig();
282282

283+
RecipeInfo recipeConfig = new RecipeInfo("", "", "", "");
284+
recipeConfig.setType(RecipeInfo.TYPE_SOUSVIDE);
285+
recipeConfig.addStage(new StageInfo());
283286
recipeConfig.getStage(0).setTime((int) (setTargetTimeMin * 60));
284287
recipeConfig.getStage(0).setMaxTime((int) (setTargetTimeMax * 60));
285288
recipeConfig.getStage(0).setTemp((int) setTargetTemp);
286289
recipeConfig.getStage(0).setSpeed(10);
287290

291+
product.setErdRecipeConfig(recipeConfig);
288292
product.sendRecipeConfig();
289293

290294
((ParagonMainActivity) getActivity()).nextStep(ParagonMainActivity.ParagonSteps.STEP_SOUSVIDE_GETREADY);

0 commit comments

Comments
 (0)