//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.wutl.ble.tools;
import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import com.wutl.ble.tools.BleNamesResolver;
import com.wutl.ble.tools.BleWrapper;
import com.wutl.ble.tools.BleWrapperUiCallbacks;
import com.wutl.ble.tools.CharacteristicDetailsAdapter;
import com.wutl.ble.tools.CharacteristicsListAdapter;
import com.wutl.ble.tools.ServicesListAdapter;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
public class PeripheralActivity extends Activity implements BleWrapperUiCallbacks {
public static final String EXTRAS_DEVICE_ADDRESS = "BLE_DEVICE_ADDRESS";
public static final String EXTRAS_DEVICE_NAME = "BLE_DEVICE_NAME";
public static final String EXTRAS_DEVICE_RSSI = "BLE_DEVICE_RSSI";
private OnItemClickListener listClickListener;
private BleWrapper mBleWrapper;
private CharacteristicDetailsAdapter mCharDetailsAdapter;
private CharacteristicsListAdapter mCharacteristicsListAdapter;
private String mDeviceAddress;
private TextView mDeviceAddressView;
private String mDeviceName;
private TextView mDeviceNameView;
private String mDeviceRSSI;
private TextView mDeviceRssiView;
private TextView mDeviceStatus;
private TextView mHeaderBackButton;
private TextView mHeaderTitle;
private PeripheralActivity.ListType mListType;
private ListView mListView;
private View mListViewHeader;
private ServicesListAdapter mServicesListAdapter;
public PeripheralActivity() {
this.mListType = PeripheralActivity.ListType.GATT_SERVICES;
this.mServicesListAdapter = null;
this.mCharacteristicsListAdapter = null;
this.mCharDetailsAdapter = null;
this.listClickListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> var1, View var2, int var3, long var4) {
int var6 = var3 - 1;
if(var6 < 0) {
if(!PeripheralActivity.this.mListType.equals(PeripheralActivity.ListType.GATT_SERVICES)) {
if(PeripheralActivity.this.mListType.equals(PeripheralActivity.ListType.GATT_CHARACTERISTICS)) {
PeripheralActivity.this.uiAvailableServices(PeripheralActivity.this.mBleWrapper.getGatt(), PeripheralActivity.this.mBleWrapper.getDevice(), PeripheralActivity.this.mBleWrapper.getCachedServices());
PeripheralActivity.this.mCharacteristicsListAdapter.clearList();
return;
}
if(PeripheralActivity.this.mListType.equals(PeripheralActivity.ListType.GATT_CHARACTERISTIC_DETAILS)) {
PeripheralActivity.this.mBleWrapper.getCharacteristicsForService(PeripheralActivity.this.mBleWrapper.getCachedService());
PeripheralActivity.this.mCharDetailsAdapter.clearCharacteristic();
return;
}
}
} else {
if(PeripheralActivity.this.mListType.equals(PeripheralActivity.ListType.GATT_SERVICES)) {
BluetoothGattService var8 = PeripheralActivity.this.mServicesListAdapter.getService(var6);
PeripheralActivity.this.mBleWrapper.getCharacteristicsForService(var8);
return;
}
if(PeripheralActivity.this.mListType.equals(PeripheralActivity.ListType.GATT_CHARACTERISTICS)) {
BluetoothGattCharacteristic var7 = PeripheralActivity.this.mCharacteristicsListAdapter.getCharacteristic(var6);
PeripheralActivity.this.uiCharacteristicsDetails(PeripheralActivity.this.mBleWrapper.getGatt(), PeripheralActivity.this.mBleWrapper.getDevice(), PeripheralActivity.this.mBleWrapper.getCachedService(), var7);
return;
}
}
}
};
}
private void connectViewsVariables() {
this.mDeviceNameView = (TextView)this.findViewById(R.id.peripheral_name);
this.mDeviceAddressView = (TextView)this.findViewById(R.id.peripheral_address);
this.mDeviceRssiView = (TextView)this.findViewById(R.id.peripheral_rssi);
this.mDeviceStatus = (TextView)this.findViewById(R.id.peripheral_status);
this.mListView = (ListView)this.findViewById(R.id.listView);
this.mHeaderTitle = (TextView)this.mListViewHeader.findViewById(R.id.peripheral_service_list_title);
this.mHeaderBackButton = (TextView)this.mListViewHeader.findViewById(R.id.peripheral_list_service_back);
}
protected void onCreate(Bundle var1) {
super.onCreate(var1);
this.setContentView(R.layout.activity_peripheral);
this.getActionBar().setDisplayHomeAsUpEnabled(true);
this.mListViewHeader = this.getLayoutInflater().inflate(R.layout.peripheral_list_services_header, null, false);
this.connectViewsVariables();
Intent var2 = this.getIntent();
this.mDeviceName = var2.getStringExtra("BLE_DEVICE_NAME");
this.mDeviceAddress = var2.getStringExtra("BLE_DEVICE_ADDRESS");
this.mDeviceRSSI = var2.getIntExtra("BLE_DEVICE_RSSI", 0) + " db";
this.mDeviceNameView.setText(this.mDeviceName);
this.mDeviceAddressView.setText(this.mDeviceAddress);
this.mDeviceRssiView.setText(this.mDeviceRSSI);
this.getActionBar().setTitle(this.mDeviceName);
this.mListView.addHeaderView(this.mListViewHeader);
this.mListView.setOnItemClickListener(this.listClickListener);
}
public boolean onCreateOptionsMenu(Menu var1) {
this.getMenuInflater().inflate(R.menu.peripheral, var1);
if(this.mBleWrapper.isConnected()) {
var1.findItem(R.id.device_connect).setVisible(false);
var1.findItem(R.id.device_disconnect).setVisible(true);
return true;
} else {
var1.findItem(R.id.device_connect).setVisible(true);
var1.findItem(R.id.device_disconnect).setVisible(false);
return true;
}
}
public boolean onOptionsItemSelected(MenuItem var1) {
switch(var1.getItemId()) {
case 16908332:
this.mBleWrapper.diconnect();
this.mBleWrapper.close();
this.onBackPressed();
return true;
case 2131230777:
this.mDeviceStatus.setText("connecting ...");
this.mBleWrapper.connect(this.mDeviceAddress);
return true;
case 2131230778:
this.mBleWrapper.diconnect();
return true;
default:
return super.onOptionsItemSelected(var1);
}
}
protected void onPause() {
super.onPause();
this.mServicesListAdapter.clearList();
this.mCharacteristicsListAdapter.clearList();
this.mCharDetailsAdapter.clearCharacteristic();
this.mBleWrapper.stopMonitoringRssiValue();
this.mBleWrapper.diconnect();
this.mBleWrapper.close();
}
protected void onResume() {
super.onResume();
if(this.mBleWrapper == null) {
this.mBleWrapper = new BleWrapper(this, this);
}
if(!this.mBleWrapper.initialize()) {
this.finish();
}
if(this.mServicesListAdapter == null) {
this.mServicesListAdapter = new ServicesListAdapter(this);
}
if(this.mCharacteristicsListAdapter == null) {
this.mCharacteristicsListAdapter = new CharacteristicsListAdapter(this);
}
if(this.mCharDetailsAdapter == null) {
this.mCharDetailsAdapter = new CharacteristicDetailsAdapter(this, this.mBleWrapper);
}
this.mListView.setAdapter(this.mServicesListAdapter);
this.mListType = PeripheralActivity.ListType.GATT_SERVICES;
this.mHeaderBackButton.setVisibility(View.INVISIBLE);
this.mHeaderTitle.setText("");
this.mDeviceStatus.setText("connecting ...");
this.mBleWrapper.connect(this.mDeviceAddress);
}
public void uiAvailableServices(BluetoothGatt var1, BluetoothDevice var2, Lis
没有合适的资源?快使用搜索试试~ 我知道了~
蓝牙BLE调试助手软件源码
共162个文件
class:95个
xml:32个
java:12个
4星 · 超过85%的资源 需积分: 49 437 下载量 47 浏览量
2015-11-03
20:09:12
上传
评论 10
收藏 929KB ZIP 举报
温馨提示
专用于蓝牙4.0 BLE调试,扫描周边蓝牙、连接、服务列表、特性值列表、读写什么都有,初学必备。
资源推荐
资源详情
资源评论
收起资源包目录
蓝牙BLE调试助手软件源码 (162个子文件)
resources.ap_ 29KB
com.wutl.ble.tools_BLE调试助手.apk 209KB
com.wutl.ble.tools_BLE调试助手.apk 209KB
ScanningActivity.apk 54KB
BleNamesResolver.class 12KB
PeripheralActivity.class 12KB
BleNamesResolver.class 12KB
PeripheralActivity.class 12KB
BleWrapper.class 11KB
BleWrapper.class 11KB
CharacteristicDetailsAdapter.class 9KB
CharacteristicDetailsAdapter.class 9KB
ScanningActivity.class 6KB
ScanningActivity.class 6KB
BleWrapper$1.class 5KB
BleWrapper$1.class 4KB
DeviceListAdapter.class 4KB
DeviceListAdapter.class 4KB
BleWrapperUiCallbacks$Null.class 4KB
BleWrapperUiCallbacks$Null.class 4KB
PeripheralActivity$1.class 3KB
ServicesListAdapter.class 3KB
ServicesListAdapter.class 3KB
PeripheralActivity$1.class 3KB
CharacteristicsListAdapter.class 3KB
CharacteristicsListAdapter.class 3KB
PeripheralActivity$3.class 3KB
PeripheralActivity$3.class 3KB
R$id.class 3KB
R$id.class 3KB
PeripheralActivity$2.class 3KB
PeripheralActivity$2.class 3KB
PeripheralActivity$4.class 3KB
PeripheralActivity$4.class 3KB
PeripheralActivity$6.class 2KB
PeripheralActivity$6.class 2KB
BleWrapperUiCallbacks.class 2KB
BleWrapperUiCallbacks.class 2KB
CharacteristicDetailsAdapter$2.class 2KB
CharacteristicDetailsAdapter$2.class 2KB
CharacteristicDetailsAdapter$3.class 2KB
PeripheralActivity$10.class 2KB
PeripheralActivity$10.class 2KB
CharacteristicDetailsAdapter$3.class 2KB
CharacteristicDetailsAdapter$FieldReferences.class 1KB
PeripheralActivity$9.class 1KB
PeripheralActivity$9.class 1KB
PeripheralActivity$11.class 1KB
PeripheralActivity$7.class 1KB
PeripheralActivity$11.class 1KB
PeripheralActivity$ListType.class 1KB
PeripheralActivity$ListType.class 1KB
PeripheralActivity$7.class 1KB
CharacteristicDetailsAdapter$1.class 1KB
CharacteristicDetailsAdapter$1.class 1KB
CharacteristicDetailsAdapter$FieldReferences.class 1KB
PeripheralActivity$8.class 1KB
PeripheralActivity$8.class 1KB
BleWrapper$3.class 1KB
BleWrapper$3.class 1KB
ScanningActivity$2.class 1KB
ScanningActivity$2.class 1KB
BleWrapper$2.class 1021B
BleWrapper$2.class 1020B
CharacteristicsListAdapter$FieldReferences.class 998B
ScanningActivity$3.class 997B
ScanningActivity$3.class 996B
ScanningActivity$1.class 982B
PeripheralActivity$5.class 980B
PeripheralActivity$5.class 980B
ScanningActivity$1.class 978B
ServicesListAdapter$FieldReferences.class 956B
DeviceListAdapter$FieldReferences.class 932B
CharacteristicsListAdapter$FieldReferences.class 856B
ServicesListAdapter$FieldReferences.class 828B
DeviceListAdapter$FieldReferences.class 808B
R$layout.class 763B
R$layout.class 763B
R.class 677B
R.class 673B
R$string.class 564B
R$string.class 564B
HelpActivity.class 510B
HelpActivity.class 510B
R$dimen.class 461B
R$dimen.class 461B
R$style.class 431B
R$style.class 431B
R$menu.class 426B
R$menu.class 426B
R$drawable.class 407B
R$drawable.class 407B
BuildConfig.class 345B
BuildConfig.class 345B
R$attr.class 340B
R$attr.class 340B
CharacteristicsListAdapter$1.class 267B
ServicesListAdapter$1.class 246B
DeviceListAdapter$1.class 240B
.classpath 475B
共 162 条
- 1
- 2
小钟同学
- 粉丝: 9
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页