Commit 6bf700e7 by Jeong Gilmo

#32917 芯温センサー

- 修正された詳細設計書について修正
parent bbfc0958
......@@ -1378,10 +1378,12 @@
<string name="thermometer">芯温計</string>
<string name="ble_is_not_supported">BLEを支援しません。</string>
<string name="bluetooth_is_not_supported">ブルートゥースを支援しません。</string>
<string name="bluetooth_is_not_working">ブルートゥースが機能しません</string>
<string name="bluetooth_is_not_working">ブルートゥース機能がオンになっているか確認してください</string>
<string name="msg_connected_bluetooth">%sに接続されました。</string>
<string name="msg_ble_not_connect">接続が停止しました。</string>
<string name="msg_ble_connect_error">%sと接続されていません。\n%sと接続状態を設定画面の機器連携から確認してください。</string>
<string name="msg_permission_dialog_bluetooth">ブルートゥース利用権限が必要です。\nアプリ設定画面へ遷移します。</string>
<string name="msg_device_search">ディバイスを検索中</string>
<string name="msg_device_connecting">ディバイスと接続中</string>
<string name="msg_no_device_info">登録された機器情報がありません。\n設定画面の機器連携から確認してください。</string>
</resources>
......@@ -1384,5 +1384,7 @@
<string name="msg_ble_not_connect">접속이 정지되었습니다.</string>
<string name="msg_ble_connect_error">%s랑 접속되지않습니다.\n%s와의 접속상태를 설정화면의 기기연결에서 확인해주세요.</string>
<string name="msg_permission_dialog_bluetooth">블루투스이용권한이 필요합니다.\n설정화면으로 이동합니다.</string>
<string name="msg_device_search">기기를 검색중\</string>
<string name="msg_device_connecting">기기와 접속중</string>
<string name="msg_no_device_info">등록된 기기정보가 없습니다.\n설정화면의 기기연결에서 확인해주세요.</string>
</resources>
\ No newline at end of file
......@@ -1383,5 +1383,7 @@
<string name="msg_ble_not_connect">The connection has stopped.</string>
<string name="msg_ble_connect_error">Not connected with% %s. \nCheck %s and connection status from the device linkage on the setting screen.</string>
<string name="msg_permission_dialog_bluetooth">You need Bluetooth access authority. \nIt changes to the application setting.</string>
<string name="msg_device_search">Searching Device</string>
<string name="msg_device_connecting">Connecting Device</string>
<string name="msg_no_device_info">There is no registered device information. \nPlease confirm from the device cooperation of the setting screen.</string>
</resources>
\ No newline at end of file
......@@ -21,15 +21,14 @@
android:layout_height="50dp">
<TextView
android:id="@+id/tv_toolbar_title"
android:id="@+id/device_toolbar_title"
style="@style/DialogToolBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/set_pairing"
android:textColor="@color/edt_text"
android:textSize="@dimen/opeartion_title_text_size" />
android:textSize="20sp" />
<ImageButton
android:id="@+id/close_btn"
......@@ -40,6 +39,23 @@
android:background="@drawable/ic_operation_close"
android:onClick="onClickCloseView" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true">
<Button
android:id="@+id/btn_reload"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="@drawable/ic_reload_list" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
......@@ -51,49 +67,6 @@
android:layout_weight="1"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:visibility="visible">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:gravity="left"
android:text="@string/thermometer"
android:textSize="20sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true">
<Button
android:id="@+id/scan_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text="@string/scan" />
<Button
android:id="@+id/stop_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text="@string/stop" />
</LinearLayout>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
......
......@@ -18,6 +18,8 @@ import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
import static org.chromium.base.ThreadUtils.runOnUiThread;
......@@ -53,6 +55,7 @@ public class BleManagerUtil {
// 接続状態変更(connectGatt()の結果として呼ばれる。)
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState ) {
super.onConnectionStateChange(gatt, status, newState);
// if( BluetoothGatt.GATT_SUCCESS != status ) {
// runOnUiThread( new Runnable() {
// public void run() {
......@@ -61,6 +64,17 @@ public class BleManagerUtil {
// });
// return;
// }
Logger.d("GATT_ message : [ " + status);
// ディバイスと接続されていない場合のメッセージコード:133, 62
// ディバイスと接続が切れた場合のメッセージコード:19
if (status == 133 || status == 62) { // 接続失敗
runOnUiThread( new Runnable() {
public void run() {
listener.onConnectionError();
}
});
return;
}
if( status == BluetoothGatt.GATT_SUCCESS && BluetoothProfile.STATE_CONNECTED == newState ) {
// 接続完了
......@@ -91,7 +105,6 @@ public class BleManagerUtil {
} );
return;
}
super.onConnectionStateChange(gatt, status, newState);
}
// サービス検索が完了したときの処理(mBluetoothGatt.discoverServices()の結果として呼ばれる。)
......@@ -195,6 +208,7 @@ public class BleManagerUtil {
void onGetDeviceInfoFailed(); // ディバイスと接続失敗時の情報渡す。
void onConnectionState(); // ディバイスと接続された時情報渡す。
void onDisConnectionState(); // ディバイスと切断時
void onConnectionError(); // ディバイス接続エラー
}
// 接続
......@@ -273,20 +287,10 @@ public class BleManagerUtil {
// Bluetoothアダプタの取得処理
public void startDeviceInfo() {
// disconnect();
// bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
// // Android端末がBLEをサポートしてるかの確認
// if( !context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_BLUETOOTH_LE ) ) {
// Toast.makeText( context, R.string.ble_is_not_supported, Toast.LENGTH_SHORT ).show();
// return;
// }
// Bluetoothアダプタの取得
BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService( Context.BLUETOOTH_SERVICE );
mBluetoothAdapter = bluetoothManager.getAdapter();
if( null == mBluetoothAdapter )
{ // Android端末がBluetoothをサポートしていない
if( null == mBluetoothAdapter ) { // Android端末がBluetoothをサポートしていない
Toast.makeText( context, R.string.bluetooth_is_not_supported, Toast.LENGTH_SHORT ).show();
return;
}
......
......@@ -239,7 +239,23 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// get Device info
bleManagerUtil = new BleManagerUtil(this, new BleManagerUtil.BleManagerUtilListener() {
@Override
public void onConnectionError() {
Logger.d(TAG, "onDisConnectionState");
putUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 0);
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.thermometer);
alert.setMessage(String.format(getString(R.string.msg_ble_connect_error), getString(R.string.thermometer), getString(R.string.thermometer)));
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setThermometerData("");
}
});
alert.show();
}
@Override
public void onConnectionState() { // 接続
Logger.d(TAG, "onDisConnectionState");
putUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 1);
ABVToastUtil.showMakeText(getApplicationContext(),
String.format(getString(R.string.msg_connected_bluetooth), getString(R.string.thermometer)),
......@@ -248,12 +264,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public void onDisConnectionState() { // 切断
Logger.d(TAG, "onDisConnectionState");
putUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 0);
ABVToastUtil.showMakeText(getApplicationContext(), getString(R.string.msg_ble_not_connect), Toast.LENGTH_SHORT);
}
@Override
public void onGetDeviceInfo(String strTemp) { // 機器のデータ
Logger.d(TAG, "onDisConnectionState");
Toast.makeText( getApplicationContext(), strTemp, Toast.LENGTH_SHORT ).show();
Logger.d(TAG, "get temperature [%s]", strTemp);
setThermometerData(strTemp);
......@@ -261,10 +279,16 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
@Override
public void onGetDeviceInfoFailed() { // 機器のエラー
Logger.d(TAG, "onDisConnectionState");
putUserPref(UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 0);
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.thermometer);
alert.setMessage(String.format(getString(R.string.msg_ble_connect_error), getString(R.string.thermometer), getString(R.string.thermometer)));
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), (DialogInterface.OnClickListener) null);
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setThermometerData("");
}
});
alert.show();
}
});
......@@ -1440,7 +1464,17 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
// 接続
bleManagerUtil.connect();
} else {
setPairingSetting(); // 接続するのために機器設定画面に遷移する。
// 設定画面に遷移すること
// setPairingSetting(); // 接続するのために機器設定画面に遷移する。
// ディバイス情報がない場合
ABookAlertDialog alert = AlertDialogUtil.createAlertDialog(ABVContentViewActivity.this, R.string.thermometer);
alert.setMessage(getString(R.string.msg_no_device_info));
alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setThermometerData("");
}
});
}
} else {
Logger.w(TAG,"onGetDeviceInfoFailed Connect BLE Device false");
......
......@@ -74,15 +74,16 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
@Override
public void run() {
BluetoothDevice device = result.getDevice();
// if(device.getName() != null && device.getName().startsWith("MF500B")) {
Map<String, String> map = new HashMap<String, String>();
map.put(EXTRAS_DEVICE_NAME, device.getName());
map.put(EXTRAS_DEVICE_ADDRESS, device.getAddress());
map.put(DEVICE_CONNECTED, "0");
if (device.getName() != null) {
mBleListAdapter.addDevice(map);
// 識別商品名に絞る
if(device.getName() != null && device.getName().startsWith("MF500")) {
Map<String, String> map = new HashMap<String, String>();
map.put(EXTRAS_DEVICE_NAME, device.getName());
map.put(EXTRAS_DEVICE_ADDRESS, device.getAddress());
map.put(DEVICE_CONNECTED, "0");
if (device.getName() != null) {
mBleListAdapter.addDevice(map);
}
}
}
} );
......@@ -101,6 +102,9 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
super.onCreate(savedInstanceState);
setContentView(R.layout.pairing_setting);
TextView deviceTitle = (TextView) findViewById(R.id.device_toolbar_title);
deviceTitle.setText(R.string.thermometer);
// 戻り値の初期化
setResult( Activity.RESULT_CANCELED );
......@@ -144,7 +148,15 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
// Bluetoothと接続処理する
bleManagerUtil = new BleManagerUtil(this, new BleManagerUtil.BleManagerUtilListener() {
@Override
public void onConnectionError() {
Logger.d(TAG, "onConnectionError");
closeProgressPopup();
}
@Override
public void onConnectionState() { // 接続
Logger.d(TAG, "onConnectionState");
closeProgressPopup();
Map<String, String> map = new HashMap<String, String>();
map.put(EXTRAS_DEVICE_NAME, bleManagerUtil.mDeviceName);
map.put(EXTRAS_DEVICE_ADDRESS, bleManagerUtil.mDeviceAddress);
......@@ -159,6 +171,8 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
@Override
public void onDisConnectionState() { // 切断
Logger.d(TAG, "onDisConnectionState");
closeProgressPopup();
// mDeviceListAdapter.notifyDataSetChanged();
Map<String, String> map = new HashMap<String, String>();
map.put(EXTRAS_DEVICE_NAME, bleManagerUtil.mDeviceName);
......@@ -176,20 +190,23 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
@Override
public void onGetDeviceInfo(String strTemp) { // 機器のデータ
Logger.d(TAG, "onGetDeviceInfo");
closeProgressPopup();
// Toast.makeText( getApplicationContext(), R.string.msg_connected_bluetooth, Toast.LENGTH_SHORT ).show();
Logger.d(TAG, "get temperature [%s]", strTemp);
}
@Override
public void onGetDeviceInfoFailed() { // 機器のエラー
Logger.d(TAG, "onGetDeviceInfoFailed");
closeProgressPopup();
showConfirmAlert( R.string.thermometer, String.format(getString(R.string.msg_ble_connect_error), getString(R.string.thermometer), getString(R.string.thermometer)));
}
});
bleManagerUtil.startDeviceInfo();
// Scan Button
mButton_Scan = (Button)findViewById( R.id.scan_button );
// Reload Button
mButton_Scan = (Button)findViewById( R.id.btn_reload );
mButton_Scan.setAllCaps(false);
mButton_Scan.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -198,19 +215,6 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
}
});
// Stop Button
mButton_Stop = (Button)findViewById( R.id.stop_button );
mButton_Stop.setAllCaps(false);
mButton_Stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stopScan();
}
});
// 設定画面が表示する場合、スキャンボタンが見えないように
mButton_Stop.setVisibility(View.GONE);
// 保存されているディバイスの情報がある場合、リストに表示する。
if (getUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, "").length() > 0) {
Map<String, String> getUserDataMap = new HashMap<String, String>();
......@@ -233,8 +237,11 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
// デバイスのBluetooth機能の有効化要求
requestBluetoothFeature();
// スキャン開始
startScan();
// ローカルに保存されているディバイスの情報がない場合処理を行う
if (getUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_ADDRESS, "").length() == 0) {
// スキャン開始
startScan();
}
}
// 別のアクティビティ(か別のアプリ)に移行したことで、バックグラウンドに追いやられた時
......@@ -296,6 +303,7 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
return;
}
showProgressPopup(getRString(R.string.msg_device_search));
// スキャン開始(一定時間後にスキャン停止する)
mHandler.postDelayed( new Runnable() {
@Override
......@@ -303,19 +311,14 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
mScanning = false;
scanner.stopScan( mLeScanCallback );
// ボタンの更新
mButton_Scan.setVisibility(View.VISIBLE);
mButton_Stop.setVisibility(View.GONE);
Logger.d(TAG, "scan in 10 sec");
closeProgressPopup();
}
}, SCAN_PERIOD );
mScanning = true;
scanner.startScan( mLeScanCallback );
// ボタンの更新
mButton_Scan.setVisibility(View.GONE);
mButton_Stop.setVisibility(View.VISIBLE);
Logger.d(TAG, "start scan !!");
}
......@@ -333,9 +336,6 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
mScanning = false;
scanner.stopScan( mLeScanCallback );
// ボタンの更新
mButton_Scan.setVisibility(View.VISIBLE);
mButton_Stop.setVisibility(View.GONE);
Logger.d(TAG, "stop scan !!");
}
......@@ -372,10 +372,23 @@ public class PairingSettingActivity extends ABVUIActivity implements AdapterView
} else {
bleManagerUtil.mDeviceAddress = deviceAddress;
bleManagerUtil.mDeviceName = deviceName;
showProgressPopup(getString(R.string.msg_device_connecting));
// デバイスのBluetooth機能の有効化要求
requestBluetoothFeature();
// 接続
bleManagerUtil.connect();
}
}
protected boolean testcheck() {
if (getUserPref(AppDefType.UserPrefKey.BLUETOOTH_DEVICE_TEMPERATURE_CONNECTED, 0) == 1) {
return true;
}
return false;
}
// 閉じるボタンの処理
public void onClickCloseView(View v) {
finish();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment