private void resetEmergencyObjectOfDevice() { TransactionBuilder.Transaction transaction = mTransactionBuilder.makeTransaction(); transaction.begin(); transaction.setCommand(Transaction.COMMAND_TYPE_RESET_EMERGENCY_OBJ); transaction.settingFinished(); transaction.sendTransaction(); // Arduino doesn't catch first command's end byte. // But I don't know why. // To be sure, send reset transaction again. TransactionBuilder.Transaction transaction2 = mTransactionBuilder.makeTransaction(); transaction2.begin(); transaction2.setCommand(Transaction.COMMAND_TYPE_RESET_EMERGENCY_OBJ); transaction2.settingFinished(); transaction2.sendTransaction(); }
private void sendTimeToDevice() { TransactionBuilder.Transaction transaction = mTransactionBuilder.makeTransaction(); transaction.begin(); transaction.setCommand(Transaction.COMMAND_TYPE_SET_TIME); transaction.setDate(); transaction.settingFinished(); transaction.sendTransaction(); }
private void sendIndicatorSettingToDevice(int code) { if (mTransactionBuilder == null && mBtManager != null && mActivityHandler != null) { mTransactionBuilder = new TransactionBuilder(mBtManager, mActivityHandler); } if (mTransactionBuilder != null) { TransactionBuilder.Transaction transaction = mTransactionBuilder.makeTransaction(); transaction.begin(); transaction.setCommand(TransactionBuilder.Transaction.COMMAND_TYPE_SHOW_INDICATOR); transaction.setMessage(code, null); transaction.settingFinished(); transaction.sendTransaction(); } }
private void sendClockStyleToDevice(int style) { if (mTransactionBuilder == null && mBtManager != null && mActivityHandler != null) { mTransactionBuilder = new TransactionBuilder(mBtManager, mActivityHandler); } if (mTransactionBuilder != null) { TransactionBuilder.Transaction transaction = mTransactionBuilder.makeTransaction(); transaction.begin(); transaction.setCommand(TransactionBuilder.Transaction.COMMAND_TYPE_SET_CLOCK_STYLE); transaction.setMessage(style, null); transaction.settingFinished(); transaction.sendTransaction(); } }
private void deleteEmergencyOfDevice(int type) { if (mTransactionBuilder == null && mBtManager != null && mActivityHandler != null) { mTransactionBuilder = new TransactionBuilder(mBtManager, mActivityHandler); } if (mTransactionBuilder != null) { TransactionBuilder.Transaction transaction = mTransactionBuilder.makeTransaction(); transaction.begin(); transaction.setCommand(TransactionBuilder.Transaction.COMMAND_TYPE_DELETE_EMERGENCY_OBJ); transaction.setId(type); // use type as ID transaction.settingFinished(); transaction.sendTransaction(); } }
private boolean sendContentsToDevice(ContentObject obj) { if (obj == null || mTransactionBuilder == null || !obj.mIsEnabled /*|| obj.mId < 0*/ || obj.mFilteredString == null || obj.mFilteredString.length() < 1) return false; TransactionBuilder.Transaction transaction = mTransactionBuilder.makeTransaction(); transaction.begin(); switch (obj.mContentType) { case ContentObject.CONTENT_TYPE_NOTIFICATION: // Set transaction parameters transaction.setCommand(Transaction.COMMAND_TYPE_ADD_NORMAL_OBJ); transaction.setIcon(obj.mIconType); transaction.setMessage(obj.mId, obj.mFilteredString); transaction.settingFinished(); transaction.sendTransaction(); break; case ContentObject.CONTENT_TYPE_FEED: case ContentObject.CONTENT_TYPE_MESSAGING: // Set transaction parameters transaction.setCommand(Transaction.COMMAND_TYPE_ADD_NORMAL_OBJ); transaction.setIcon(obj.mIconType); transaction.setMessage(obj.mId, obj.mFilteredString); transaction.settingFinished(); transaction.sendTransaction(); break; case ContentObject.CONTENT_TYPE_EMERGENCY: // Set transaction parameters transaction.setCommand(Transaction.COMMAND_TYPE_ADD_EMERGENCY_OBJ); transaction.setIcon(obj.mIconType); transaction.setMessage(obj.mId, obj.mFilteredString); transaction.settingFinished(); transaction.sendTransaction(); break; default: return false; } return true; }