don't crash when not connected
This commit is contained in:
@@ -221,6 +221,7 @@ public class MainActivity extends Activity implements RadioGroup.OnCheckedChange
|
||||
btnConnectDisconnect.setText("Disconnect");
|
||||
edtMessage.setEnabled(true);
|
||||
btnSend.setEnabled(true);
|
||||
btnRainbow.setEnabled(true);
|
||||
((TextView) findViewById(R.id.deviceName)).setText(mDevice.getName()+ " - ready");
|
||||
listAdapter.add("["+currentDateTimeString+"] Connected to: "+ mDevice.getName());
|
||||
messageListView.smoothScrollToPosition(listAdapter.getCount() - 1);
|
||||
@@ -238,8 +239,9 @@ public class MainActivity extends Activity implements RadioGroup.OnCheckedChange
|
||||
btnConnectDisconnect.setText("Connect");
|
||||
edtMessage.setEnabled(false);
|
||||
btnSend.setEnabled(false);
|
||||
btnRainbow.setEnabled(false);
|
||||
((TextView) findViewById(R.id.deviceName)).setText("Not Connected");
|
||||
listAdapter.add("["+currentDateTimeString+"] Disconnected to: "+ mDevice.getName());
|
||||
listAdapter.add("["+currentDateTimeString+"] Disconnected from: "+ mDevice.getName());
|
||||
mState = UART_PROFILE_DISCONNECTED;
|
||||
mService.close();
|
||||
//setUiState();
|
||||
|
||||
@@ -311,8 +311,7 @@ public class UartService extends Service {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void enableTXNotification()
|
||||
{
|
||||
public void enableTXNotification() {
|
||||
/*
|
||||
if (mBluetoothGatt == null) {
|
||||
showMessage("mBluetoothGatt null" + mBluetoothGatt);
|
||||
@@ -358,11 +357,9 @@ public class UartService extends Service {
|
||||
writeRXCharacteristic(dataCrc);
|
||||
}
|
||||
|
||||
public void writeRXCharacteristic(byte[] value)
|
||||
{
|
||||
|
||||
public void writeRXCharacteristic(byte[] value) {
|
||||
BluetoothGattService RxService = mBluetoothGatt.getService(RX_SERVICE_UUID);
|
||||
showMessage("mBluetoothGatt null"+ mBluetoothGatt);
|
||||
showMessage("mBluetoothGatt " + mBluetoothGatt);
|
||||
if (RxService == null) {
|
||||
showMessage("Rx service not found!");
|
||||
broadcastUpdate(DEVICE_DOES_NOT_SUPPORT_UART);
|
||||
|
||||
Reference in New Issue
Block a user