简体   繁体   中英

Manufacturer Specific Data on BLE

I'm a newbie of BLE programming on android.

In my first apps using BLE on android, I have a big problem.

I got a ScanRecord from Apple Bluetooth Headset using this function.

@Override public void onScanResult(int callbackType, ScanResult result)

and I got a manufacturer data using Apple corp, ID(0x4C). after that, I don't know how to decode a manufacturer data.

I want to auxiliary bluetooth headset information such as battery info, direction info etc. but I don't know how to decode the manufacturer data.

I also searched Apple development document( https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf ) But that guide document didn't help me.

Anyway, anyone who tell me how to resolve this problem?!!?! Thank you to read my question.

Ok so from your comment it looks like you scanned the device over BLE and want to use one of the services it offers to get information like battery info.

  1. The first thing you will need to do establish a connection to the BLE device. The scanresult you pasted has a method getDevice you'll need to call

  2. After you get the device you can call its connectGatt method. This will attempt to connect your phone and BLE device.

  3. The connectGatt method from step 2 requires a callback . When the connection is successful or unsuccessful the callback will fire onConnectionStateChanged . If successful it will have the success status . This method will also give you a gatt device we will use in step 4.

  4. If step 3 was successful we can assume your phone is connected. The next thing we want to do is discover services. You do this by using the gatt devices discoverServices method.

  5. When the services are discovered your callback will fire onServicesDiscovered . At this point you can now use services. Depending on the API of the headphones they'll want you to read, or subscribe to a services characteristic and descriptor. Since I don't know the API I can't help you further. But you'll end up needing to use one or more of the following:

And the value will return to your callback on. Keep in mind you must wait for the callback for each request before write/reading/subscribing to another characteristic or descriptor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM