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