我使用的设备与Google BLE不兼容,而是使用Samsung BLE SDK进行连接。我尝试过使用Google SDK并且可以成功连接,但在连接后立即与状态19断开连接,其中没有关于此状态所需的文档。
03-02 00:07:55.572 1181-1181/alex.jstylemod I/art﹕ Late-enabling -Xcheck:jni
03-02 00:07:55.861 1181-1181/alex.jstylemod D/BluetoothAdapter﹕ startLeScan(): null
03-02 00:07:55.931 1181-1201/alex.jstylemod D/BluetoothLeScanner﹕ onClientRegistered() - status=0 clientIf=5
03-02 00:07:55.949 1181-1208/alex.jstylemod D/OpenGLRenderer﹕ Render dirty regions requested: true
03-02 00:07:55.965 1181-1181/alex.jstylemod D/Atlas﹕ Validating map...
03-02 00:07:55.985 1181-1208/alex.jstylemod I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107_msm8226_LA.BF.1.1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.01.03
Build Date: 10/28/14 Tue
Local Branch:
Remote Branch: quic/l_LNX.LA.3.6
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107 + cb93e16 + f50fe49 + d7c18e6 + 5b9a565 + 0f3a25d + 607156e + 75511aa + e4d16c0 + 686f3eb + 211a271 + dd281ee + NOTHING
03-02 00:07:55.988 1181-1208/alex.jstylemod I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-02 00:07:56.010 1181-1208/alex.jstylemod D/OpenGLRenderer﹕ Enabling debug mode 0
03-02 00:07:57.769 1181-1201/alex.jstylemod D/BluetoothLeScanner﹕ onScanResult() - ScanResult{mDevice=B4:99:4C:67:72:70, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000fff0-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=0, mDeviceName=JStyle 677270], mRssi=-80, mTimestampNanos=128983439815617}
03-02 00:08:05.868 1181-1181/alex.jstylemod D/BluetoothAdapter﹕ stopLeScan()
03-02 00:08:27.348 1181-1181/alex.jstylemod D/BluetoothAdapter﹕ stopLeScan()
03-02 00:08:27.354 1181-1181/alex.jstylemod D/BluetoothAdapter﹕ scan not started yet
03-02 00:08:27.357 1181-1181/alex.jstylemod D/BluetoothGatt﹕ connect() - device: B4:99:4C:67:72:70, auto: false
03-02 00:08:27.357 1181-1181/alex.jstylemod D/BluetoothGatt﹕ registerApp()
03-02 00:08:27.357 1181-1181/alex.jstylemod D/BluetoothGatt﹕ registerApp() - UUID=76c2195c-0afe-4660-8164-f5f81f6fdc0a
03-02 00:08:27.366 1181-1201/alex.jstylemod D/BluetoothGatt﹕ onClientRegistered() - status=0 clientIf=5
03-02 00:08:27.379 1181-1181/alex.jstylemod D/BLEService﹕ Trying to create connection with autoconnect enabled
03-02 00:08:28.038 1181-1202/alex.jstylemod D/BluetoothGatt﹕ onClientConnectionState() - status=0 clientIf=5 device=B4:99:4C:67:72:70
03-02 00:08:28.046 1181-1202/alex.jstylemod I/BLEService﹕ Connected to GATT server
03-02 00:08:28.769 1181-1201/alex.jstylemod D/BluetoothGatt﹕ onClientConnectionState() - status=19 clientIf=5 device=B4:99:4C:67:72:70
03-02 00:08:28.769 1181-1201/alex.jstylemod I/BLEService﹕ Disconnected from GATT Server
我已尝试将Samsung BLE SDK用于此设备(据称在官方应用程序中支持)并且碰到了我无法成功绑定GATT适配器的墙。我也无法调试以找出自从jar擦除行号调试以来出了什么问题。我已附上我的应用的源代码。
03-06 16:05:39.981 2965-2965/alex.jstylemod I/art﹕ Late-enabling -Xcheck:jni
03-06 16:05:40.010 2965-2975/alex.jstylemod I/art﹕ Ignoring second debugger -- accepting and dropping
03-06 16:05:40.021 2965-2975/alex.jstylemod I/art﹕ Debugger is no longer active
03-06 16:05:40.175 2965-2965/alex.jstylemod D/BluetoothAdapter﹕ startLeScan(): null
03-06 16:05:40.239 2965-2982/alex.jstylemod D/BluetoothLeScanner﹕ onClientRegistered() - status=0 clientIf=5
03-06 16:05:40.287 2965-2988/alex.jstylemod D/OpenGLRenderer﹕ Render dirty regions requested: true
03-06 16:05:40.301 2965-2965/alex.jstylemod D/Atlas﹕ Validating map...
03-06 16:05:40.353 2965-2988/alex.jstylemod I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107_msm8226_LA.BF.1.1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.01.03
Build Date: 10/28/14 Tue
Local Branch:
Remote Branch: quic/l_LNX.LA.3.6
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107 + cb93e16 + f50fe49 + d7c18e6 + 5b9a565 + 0f3a25d + 607156e + 75511aa + e4d16c0 + 686f3eb + 211a271 + dd281ee + NOTHING
03-06 16:05:40.359 2965-2988/alex.jstylemod I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-06 16:05:40.409 2965-2988/alex.jstylemod D/OpenGLRenderer﹕ Enabling debug mode 0
03-06 16:05:41.210 2965-2982/alex.jstylemod D/BluetoothLeScanner﹕ onScanResult() - ScanResult{mDevice=B4:99:4C:67:72:70, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000fff0-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=0, mDeviceName=JStyle 677270], mRssi=-82, mTimestampNanos=532107906138682}
03-06 16:05:43.502 2965-2965/alex.jstylemod D/BluetoothAdapter﹕ startLeScan(): null
03-06 16:05:43.503 2965-2965/alex.jstylemod E/BluetoothAdapter﹕ LE Scan has already started
03-06 16:05:50.182 2965-2965/alex.jstylemod D/BluetoothAdapter﹕ stopLeScan()
03-06 16:05:53.506 2965-2965/alex.jstylemod D/BluetoothAdapter﹕ stopLeScan()
03-06 16:05:53.512 2965-2965/alex.jstylemod D/BluetoothAdapter﹕ scan not started yet
03-06 16:06:15.795 4053-4053/alex.jstylemod D/BluetoothAdapter﹕ startLeScan(): null
03-06 16:06:15.843 4053-4071/alex.jstylemod D/BluetoothLeScanner﹕ onClientRegistered() - status=0 clientIf=5
03-06 16:06:16.022 4053-4074/alex.jstylemod D/OpenGLRenderer﹕ Render dirty regions requested: true
03-06 16:06:16.038 4053-4053/alex.jstylemod D/Atlas﹕ Validating map...
03-06 16:06:16.065 4053-4074/alex.jstylemod I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107_msm8226_LA.BF.1.1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.01.03
Build Date: 10/28/14 Tue
Local Branch:
Remote Branch: quic/l_LNX.LA.3.6
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.04.04.02.162.107 + cb93e16 + f50fe49 + d7c18e6 + 5b9a565 + 0f3a25d + 607156e + 75511aa + e4d16c0 + 686f3eb + 211a271 + dd281ee + NOTHING
03-06 16:06:16.067 4053-4074/alex.jstylemod I/OpenGLRenderer﹕ Initialized EGL, version 1.4
03-06 16:06:16.093 4053-4074/alex.jstylemod D/OpenGLRenderer﹕ Enabling debug mode 0
03-06 16:06:17.320 4053-4072/alex.jstylemod D/BluetoothLeScanner﹕ onScanResult() - ScanResult{mDevice=B4:99:4C:67:72:70, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000fff0-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=0, mDeviceName=JStyle 677270], mRssi=-80, mTimestampNanos=532144013210126}
03-06 16:06:25.797 4053-4053/alex.jstylemod D/BluetoothAdapter﹕ stopLeScan()
03-06 16:08:44.455 4053-4065/alex.jstylemod I/art﹕ Debugger is active
03-06 16:08:55.660 4053-4053/alex.jstylemod I/Choreographer﹕ Skipped 264 frames! The application may be doing too much work on its main thread.
03-06 16:08:57.227 4053-4053/alex.jstylemod D/SamsungBLEService﹕ Calling Samsung BLE Service
03-06 16:08:57.488 4053-4053/alex.jstylemod W/ContextImpl﹕ Implicit intents with startService are not safe: Intent { act=com.samsung.android.sdk.bt.gatt.IBluetoothGatt } android.content.ContextWrapper.bindService:538 com.samsung.android.sdk.bt.gatt.BluetoothGatt.<init>:-1 com.samsung.android.sdk.bt.gatt.BluetoothGattAdapter.getProfileProxy:-1
03-06 16:08:57.498 4053-4053/alex.jstylemod E/BtGatt.BluetoothGatt﹕ Could not bind to Bluetooth Gatt Service
03-06 16:09:00.252 4053-4053/alex.jstylemod D/BluetoothAdapter﹕ stopLeScan()
03-06 16:09:00.259 4053-4053/alex.jstylemod D/BluetoothAdapter﹕ scan not started yet
调用代码的来源 活性
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handler = new Handler();
BluetoothSetting.checkBluetoothSetting(this);
bluetoothAdapter = BluetoothSetting.getBluetoothAdapter(this,null);
Intent gattServiceIntent = new Intent(this, SamsungBLEService.class);
Set<BluetoothDevice> deviceSet = bluetoothAdapter.getBondedDevices();
//Intent gattServiceIntent = new Intent(this, BLEService.class);
startService(gattServiceIntent);
boolean bindResult = bindService(gattServiceIntent, serviceConnection,BIND_AUTO_CREATE);
//setContentView(R.layout.activity_device_list);
}
服务
@Override
public void onCreate() {
Log.d(TAG, "Calling Samsung BLE Service");
bluetoothAdapter = BluetoothSetting.getBluetoothAdapter(null,this);
if(bluetoothGatt == null)
BluetoothGattAdapter.getProfileProxy(this, serviceListener, BluetoothGattAdapter.GATT);
}
请您明白这一点吗?我知道我是Android开发的新手。
谢谢