You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bundled characteristics (191 -> 348):
- recover the Fitness Machine profile and other characteristics from the last
published Bluetooth SIG characteristic XML (2017)
- add 139 characteristics derived from the current GATT Specification Supplement
(the SIG retired the machine-readable characteristic XML ~2019); scalars are
high fidelity, complex conditional/struct cases carry <!-- REVIEW --> markers
Parser:
- variable-length array fields via Field.repeats (0 = to end of data, N = fixed);
the parser emits indexed holders Name[0], Name[1], ... (e.g. RR-Interval)
- register the GSS float type names medfloat16/medfloat32 (IEEE-11073 16/32-bit)
Numeric conversion:
- exact BigDecimal scaling: decimal exponent via scaleByPowerOfTen, binary
exponent via exact powers of two, so getBigDecimal/getBigInteger no longer
inherit the rounding error of Math.pow(10, e)
- simplify two's-complement int/long deserialization (same results)
- implement the previously-unsupported IEEE-11073 serialize + deserializeDouble
README refreshed: GSS provenance, array support; fixed stale links/paths.
Signed-off-by: Vlad Kolotoff <vkolotoff@pm.me>
Parsing a standard characteristic (Battery Level, `0x2A19`) is a one-liner:
6
9
7
-
Have a look at an example of parsing a standard characteristic ([Battery Level 0x2A19](https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_level.xml)) value:
1. Supports 99% of the existing/standard [GATT services and characteristics specifications](https://www.bluetooth.com/specifications/gatt).
16
-
2. Parse/read single and multi field characteristics into a user-friendly data format.
17
-
3. Writing single and multi field characteristics.
18
-
4. Validating input data whether it conforms to GATT specifications (format types and mandatory fields).
19
-
5. Extensibility. User defined services and characteristics.
20
-
6. Support for all defined [format types](https://www.bluetooth.com/specifications/assigned-numbers/format-types).
29
+
## Usage
30
+
31
+
Add the Maven dependency:
21
32
22
-
**Start using the library by including a maven dependency in your project:**
23
33
```xml
24
34
<dependency>
25
35
<groupId>org.openhab</groupId>
@@ -28,66 +38,72 @@ This would print 51.
28
38
</dependency>
29
39
```
30
40
31
-
A more complex example of parsing multi-field characteristics ([Heart Rate service](https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.heart_rate.xml)):
41
+
Reading and writing multi-field characteristics:
32
42
33
43
```java
34
-
//Getting a default implementation which is capable of reading/writing the standard GATT services and characteristics
44
+
//A default parser that reads/writes the bundled standard GATT services and characteristics.
int heartRate = response.get("Heart Rate Measurement Value (8 bit resolution)").getInteger(null); // 74
47
54
48
-
//Writing Heart Rate Control Point (0x2A39) characteristic
55
+
//Write Heart Rate Control Point (0x2A39).
49
56
GattRequest request = parser.prepare("2A39");
50
-
request.setField("Heart Rate Control Point", 1);// control value to be sent to a bluetooth device
57
+
request.setField("Heart Rate Control Point", 1);
51
58
byte[] data = parser.serialize(request);
52
59
```
53
60
54
-
See more examples in the integration tests: [GenericCharacteristicParserIntegrationTest](src/test/java/org/bluetooth/gattparser/GenericCharacteristicParserIntegrationTest.java)
55
-
56
-
---
57
-
**Extending the library with user defined services and characteristics**
The gatt-parser library is designed to be able to add support for some new custom services/characteristics or to override an existing ("approved") [service and characteristic](https://www.bluetooth.com/specifications/gatt). This can be done by just providing a new GATT XML file which specifies your service and characteristic (have a look at the standard definition for the [Battery Level characteristic](src/main/resources/gatt/characteristic/org.bluetooth.characteristic.battery_level.xml)). The library will read your custom files and build internal rules/conditions for parsing and serialization of your custom characteristics. This means you don't have to write any code to parse/serialize simple or complex custom characteristics.
64
+
## Extending with user-defined servicesand characteristics
60
65
61
-
_Loading XML GATT specification files (GATT-like specifications) from a folder:_
66
+
The library can add support for custom services/characteristics, or override a
67
+
bundled one, purely by providing a GATT XML file — no code required. See the
0 commit comments