Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Characteristics formats and extensions #92

Open
Yohannfra opened this issue Nov 21, 2022 · 6 comments
Open

Characteristics formats and extensions #92

Yohannfra opened this issue Nov 21, 2022 · 6 comments

Comments

@Yohannfra
Copy link

Hi, I started adding two fields in the file characteristic_uuid.json

  • format to specify how the value should be displayed (printf style %d %s ...)
  • extension to specify the units of the value.

Both are optional and non related.

I only modified a few for now, and it looks like this

    { "name": "Aerobic Heart Rate Lower Limit", "identifier": "org.bluetooth.characteristic.aerobic_heart_rate_lower_limit", "uuid": "2A7E" , "source": "gss", "format": "%d", "extension": "bpm"},
    { "name": "Aerobic Heart Rate Upper Limit", "identifier": "org.bluetooth.characteristic.aerobic_heart_rate_upper_limit", "uuid": "2A84" , "source": "gss", "format": "%d", "extension": "bpm"},
    { "name": "Aerobic Threshold", "identifier": "org.bluetooth.characteristic.aerobic_threshold", "uuid": "2A7F" , "source": "gss", "format": "%d", "extension": "bpm"},

    { "name": "Battery Level", "identifier": "org.bluetooth.characteristic.battery_level", "uuid": "2A19" , "source": "gss", "format": "%d", "extension": "%"},

    { "name": "Firmware Revision String", "identifier": "org.bluetooth.characteristic.firmware_revision_string", "uuid": "2A26", "source": "gss", "format": "%s" },

    { "name": "First Name", "identifier": "org.bluetooth.characteristic.first_name", "uuid": "2A8A", "source": "gss", "format": "%s"},

    { "name": "Latitude", "identifier": "org.bluetooth.characteristic.latitude", "uuid": "2AAE", "source": "gss", "format": "%.2f", "extension": "°"},
    { "name": "Longitude", "identifier": "org.bluetooth.characteristic.longitude", "uuid": "2AAF", "source": "gss", "format": "%.2f", "extension": "°" },

What are your thoughts on this ? Would you be interested for a PR ?

Thanks

@Juliano55
Copy link

Juliano55 commented Nov 21, 2022 via email

@Yohannfra
Copy link
Author

How to use or what to do is up to whoever use this json. The reason to add these fields is that these values are standard and many applications could benefits from a simple hint of how to print them.

@dinesharjani
Copy link
Collaborator

I think this is interesting. But we'd have to bump the API version, so instead of everything being inside /v1 it should be /v2.

@bencefr what do you think?

@Yohannfra
Copy link
Author

This is more specific but something like a 'map' field with the meaning of the value (when possible) could also be useful when the value refers to something.

For example in the HRS service there is the Body Sensor Location which is a single byte representing the place where is the sensor.

It could look like this in the json

    { "name": "Body Sensor Location", "identifier": "org.bluetooth.characteristic.body_sensor_location", "uuid": "2A38" , "source": "gss", "map": ["other", "chest", "wrist", "finger", "hand", "ear_lobe", "foot"]},

And the value of the characteristic could be used as an index to find the readable value directly.

@Yohannfra
Copy link
Author

And for multi bytes values the format could also be used with multiple format specifiers

For the Date of Birth characteristic it could look like this

    { "name": "Date of Birth","identifier": "org.bluetooth.characteristic.date_of_birth", "uuid": "2A85" , "source": "gss", "format": "%d/%d/%d" },

@Yohannfra
Copy link
Author

This project tried something similar https://github.com/sputnikdev/bluetooth-gatt-parser with Java and characteristics defined in xml files. For the above example of the Body Sensor Location the xml file is:

<?xml version="1.0" encoding="UTF-8"?><!-- Copyright 2011 Bluetooth SIG, Inc. All rights reserved. -->
<Characteristic xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/characteristic.xsd"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                type="org.bluetooth.characteristic.body_sensor_location" uuid="2A38" name="Body Sensor Location">
    <InformativeText></InformativeText>
    <Value>
        <Field name="Body Sensor Location">
            <Requirement>Mandatory</Requirement>
            <Format>8bit</Format>
            <Enumerations>
                <Enumeration key="0" value="Other"/>
                <Enumeration key="1" value="Chest"/>
                <Enumeration key="2" value="Wrist"/>
                <Enumeration key="3" value="Finger"/>
                <Enumeration key="4" value="Hand"/>
                <Enumeration key="5" value="Ear Lobe"/>
                <Enumeration key="6" value="Foot"/>
                <ReservedForFutureUse start="7" end="255"/>
            </Enumerations>
        </Field>
    </Value>
</Characteristic>
Footer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants