From 1cbc244a5d457cca803970159ef920f9673e91c7 Mon Sep 17 00:00:00 2001 From: xLaMbChOpSx Date: Thu, 3 Jul 2014 22:45:51 +1000 Subject: [PATCH] AT Command Timeout Option Added another spinner to allow selection of a number of timeout values to assist with receiving the AT Command response, values currently available are: 2, 5, 8, 10 & 15 seconds. --- app/src/main/AndroidManifest.xml | 4 +- .../AIMSICD/fragments/AtCommandFragment.java | 45 +++++++++++++++++-- .../main/res/layout/at_command_fragment.xml | 18 ++++++-- app/src/main/res/values/arrays.xml | 15 +++---- app/src/main/res/values/strings.xml | 4 +- 5 files changed, 66 insertions(+), 20 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 88e7ba940..7e45b8303 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="22" + android:versionName="0.1.22"> mSerialDevices = new ArrayList<>(); private List mOutput; @@ -56,6 +56,7 @@ public class AtCommandFragment extends Fragment { private EditText mAtCommand; private Spinner mSerialDeviceSpinner; private TextView mSerialDeviceSpinnerLabel; + private Spinner mTimoutSpinner; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -72,11 +73,47 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mSerialDeviceSpinner = (Spinner) mView.findViewById(R.id.serial_device_spinner); mSerialDeviceSpinner.setOnItemSelectedListener(new spinnerListener()); mSerialDeviceSpinnerLabel = (TextView) mView.findViewById(R.id.serial_device_spinner_title); + mTimoutSpinner = (Spinner) mView.findViewById(R.id.timeout_spinner); + mTimoutSpinner.setOnItemSelectedListener(new timoutSpinnerListener()); + mTimoutSpinner.setSelection(1); + mTimeout = 5.0f; } return mView; } + private class timoutSpinnerListener implements AdapterView.OnItemSelectedListener { + + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, + int position, long id) { + switch (position) { + case 0: //2 seconds + mTimeout = 2.0f; + break; + case 1: //5 seconds + mTimeout = 5.0f; + break; + case 2: //8 seconds + mTimeout = 8.0f; + break; + case 3: //10 seconds + mTimeout = 10.0f; + break; + case 4: //15 seconds + mTimeout = 15.0f; + break; + default: + mTimeout = 5.0f; + } + } + + @Override + public void onNothingSelected(AdapterView parentView) { + + } + } + private class spinnerListener implements AdapterView.OnItemSelectedListener { @Override @@ -198,7 +235,7 @@ private int initSerialDevice() { mSerialDevices.add(mSerialDevice); } - boolean result = mShell.sendCommandPreserveOut("ls /dev/radio | grep atci*", 5.0f); + boolean result = mShell.sendCommandPreserveOut("ls /dev/radio | grep atci*", mTimeout); if (result) { mOutput = new ArrayList<>(); mOutput = mShell.GetStdOut(); @@ -220,7 +257,7 @@ private int initSerialDevice() { File xgold = new File("/system/etc/ril_xgold_radio.cfg"); if (xgold.exists() && xgold.isFile()) { result = mShell.sendCommandPreserveOut("cat /system/etc/ril_xgold_radio.cfg | " - + "grep -E \"atport*|dataport*\"", 5.0f); + + "grep -E \"atport*|dataport*\"", mTimeout); if (result) { mOutput = new ArrayList<>(); mOutput = mShell.GetStdOut(); @@ -277,7 +314,7 @@ private boolean executeAT() { private boolean executeCommand() { boolean result = false; if (mAtCommand.getText() != null) { - result = mShell.sendCommandPreserveOut(mAtCommand.getText().toString(), 5.0f); + result = mShell.sendCommandPreserveOut(mAtCommand.getText().toString(), mTimeout); if (result) { mOutput = new ArrayList<>(); mOutput = mShell.GetStdOut(); diff --git a/app/src/main/res/layout/at_command_fragment.xml b/app/src/main/res/layout/at_command_fragment.xml index f2b3949be..88d7207fd 100644 --- a/app/src/main/res/layout/at_command_fragment.xml +++ b/app/src/main/res/layout/at_command_fragment.xml @@ -52,20 +52,30 @@ android:layout_below="@+id/serial_device_spinner" android:id="@+id/atcommandView" android:visibility="gone"> + + android:padding="8dip" /> + +