try { MapString, String myMap= new HashMapString, String(); myMap.put("location",BNET_SOAP_URL); myMap.put("uri",BNET_SOAP_NAMESPACE); myMap.put("trace","1"); myMap.put("exceptions","1"); SoapClient bnet_client = new SoapClient(null,myMap); } catch (Exception exc) { throw new Exception(bnet_streamingno,null,exc,EXCEPTION_CONNECT_FAILURE) } 1 SoapClient方法你要自己先實(shí)現(xiàn) 2 Exception 參數(shù)要你自己再修改
成都創(chuàng)新互聯(lián)公司主營(yíng)霞山網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件定制開發(fā),霞山h5成都微信小程序搭建,霞山網(wǎng)站營(yíng)銷推廣歡迎霞山等地區(qū)企業(yè)咨詢
我正在開發(fā)一個(gè)應(yīng)用程序有連接到藍(lán)牙設(shè)備的 Android 4.3。
我可以連接到 BLE 設(shè)備和從設(shè)備中讀取 RSSI,通過使用 BluetoothGatt.readRemoteRssi()。
我想要讀的多個(gè)設(shè)備一次我已連接,但我可以只讀 BLE RSSI 設(shè)備 RSSI 的最后一次,我連接的設(shè)備。
如果有兩個(gè) BLE 設(shè)備 A 和 B。我連接到A 的設(shè)備,并讀取該 RSSI。之后,我連接到B 的設(shè)備,和我可以從設(shè)備 B讀取 RSSI。但它并不讀取設(shè)備 A的 RSSI,它只能從設(shè)備 B讀取 RSSI。
在Main.java ,它列出已連接的位置的所有設(shè)備。
當(dāng)我單擊該設(shè)備,在列表上,它把傳送的設(shè)備的名稱和地址到DeviceControl.java。
final Intent qintent = new Intent(this, DeviceControl.class);
devicelist.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView? arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
HashMapString, Object select = (HashMapString, Object) devicelist.getItemAtPosition(arg2);
String name = (String) select.get(“name”);
String address = (String) select.get(“address”);
qintent.putExtra(DeviceControl.EXTRAS_DEVICE_NAME, name);
qintent.putExtra(DeviceControl.EXTRAS_DEVICE_ADDRESS, address);
startActivity(qintent);
}
});
DeviceControl.java將調(diào)用BluetoothLeService.java和連接到設(shè)備。
private final ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder service) {
// TODO Auto-generated method stub
mBluetoothLeService = ((BluetoothLeService.LocalBinder) service)。getService();
if(!mBluetoothLeService.initialize()) {
Log.e(TAG, “Unable to initialize Bluetooth”);
finish();
}
registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
mBluetoothLeService.connect(mDeviceAddress);
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
// TODO Auto-generated method stub
mBluetoothLeService = null;
}
};
BluetoothLeService.java將連接到該設(shè)備。
public boolean connect(final String address) {
if (mBluetoothAdapter == null || address == null) {
Log.w(TAG, “BluetoothAdapter not initialized or unspecified address.”);
return false;
}
if(mBluetoothDeviceAddress != null address.equals(mBluetoothDeviceAddress)
mBluetoothGatt != null) {
Log.d(TAG, “Trying to use an existing mBluetoothGatt for connection.”);
if(mBluetoothGatt.connect()) {
mConnectionState = STATE_CONNECTING;
return true;
}else {
return false;
}
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if(device == null) {
Log.w(TAG, “Device not found. Unable to connect”);
return false;
}
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
Log.d(TAG, “Try to create a new connection”);
mBluetoothDeviceAddress = address;
mConnectionState =STATE_CONNECTING;
return true;
}
它連接到設(shè)備后,我可以使用 readRemoteRssi 來從設(shè)備中讀取 RSSI。
public void readRemoteRssi() {
mBluetoothGatt.readRemoteRssi();
}
但它只能讀取 RSSI 的最后一個(gè)設(shè)備的我已連接。
當(dāng)我看到日志時(shí),它總是發(fā)送onCharacteristicWrite和readRemoteRssi()到我連接的最后一個(gè)設(shè)備。
我應(yīng)該重新連接關(guān)貿(mào)總協(xié)定 》 或之前我想 RSSI 對(duì)讀取或?qū)懭氲?CharacteristicWrite 值的第一個(gè)設(shè)備重新連接到的第一個(gè)地址的設(shè)備概覽
它不會(huì)有其他的方法來讀取我已連接的所有設(shè)備的 RSSI 概覽
解決方法 1:
使多個(gè) BluetoothGatt 對(duì)象來連接多個(gè)設(shè)備分開,并調(diào)用 readRemoteRssi 一個(gè)接一個(gè)。
懶的和壞的示例中,您應(yīng)該能夠?qū)⒛切?BluetoothGatt 對(duì)象放入數(shù)組
BluetoothGatt mBluetoothGatt1 = device1.connectGatt(this, false, mGattCallback);
BluetoothGatt mBluetoothGatt2 = device2.connectGatt(this, false, mGattCallback);
"test.txt"這個(gè)文件應(yīng)該放在你的項(xiàng)目的目錄下面,不要放到包里,如果有源文件夾src,要放到src外面,bw.flush(); 就不用加了,“new FileWriter("test.txt",true);
”這里面有個(gè)true,就是代表自動(dòng)flush的。
筆記本查看mac地址的方法:
1、鼠標(biāo)左鍵點(diǎn)擊任務(wù)欄的“開始”按鈕→運(yùn)行→在彈出的“運(yùn)行”窗口的“打開”文本框內(nèi)輸入“cmd”,然后單擊“確定”按鈕:
系統(tǒng)將彈出如下窗口
2、在新窗口中輸入命令“ipconfig /all”后回車,在顯示的結(jié)果中找到類似
Physical Address. . . . . . . . . : 00-E0-4C-3F-14-DE行,其中類似“00-E0-4C-3F-14-DE”的地址即為當(dāng)前機(jī)器的網(wǎng)卡的mac地址。
分享文章:rssi代碼java java中rs什么意思
網(wǎng)站路徑:http://muchs.cn/article2/ddcegoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、用戶體驗(yàn)、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站導(dǎo)航、自適應(yīng)網(wǎng)站、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)