How to set Units and Range for a Field within a Custom Characteristic

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

So I have a custom characteristic within a custom BLE service. I want the contents of this characteristic to be a Time Stamp.

   

If I look at GATT standard services / characteristics that have timestamps (such as Body Composition Measurement), a Time Stamp is stored as separate fields for Year, Month, Day, Hours, Minutes, and Seconds, and each of these fields has a Units setting, with some also having a Range setting. For example, the Month field has "Units: Month", the Seconds field has "Units: Month" and "Range: 0 to 59".

   

I can't figure out how to set Unit and Range for a field when I'm creating fields within a customer characteristic inside the BLE component in PSoC Creator ... I see them if I add the Body Composition Measurement service, but I can't get them on my own custom characteristic ...

   

(Better yet, I'd love to be able to simply select the GATT Time Stamp field type and have things automatically set for me ...)

   

Suggestions very welcome!

0 Likes
1 Solution
Anonymous
Not applicable

Hi Jack,

   

PSoC Creator does not have the option to directly set units and range for fields in a custom char/custom service. However, you can hardcode those by the steps below:

   

1) Create a custom service and a custom characteristic within it. 

   

2) Create two fields inside it called 'Month' and 'Seconds' each of type uint8

   

3) Right click the service and click save. It will be stored as an xml file. 

   

4) Open the xml file in a text editor

   

In that file, you can see the month and seconds fields similar to below:

   


<Field Name="Month">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<ValueType>BASIC</ValueType>
</Field>
<Field Name="Seconds">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<ValueType>BASIC</ValueType>
</Field>
 

   

Manually make edits on these fields as shown below:

   


<Field Name="Month">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<Range>
<IsDeclared>true</IsDeclared>
<Minimum>0</Minimum>
<Maximum>12</Maximum>
</Range>
<Unit>org.bluetooth.unit.time.month</Unit>
<ValueType>ENUM</ValueType>
</Field>
<Field Name="Seconds">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<Range>
<IsDeclared>true</IsDeclared>
<Minimum>0</Minimum>
<Maximum>59</Maximum>
</Range>
<ValueType>ENUM</ValueType>
</Field>
 

   

click Save. Now in the PSoC creator components window, delete the service. Now choose add service -> from file and select the edited xml file.

   

You can now see the units and range. However, it will not be available as a drop down list option.

   

(For more features, you can save the standard service like body composition in an xml file and view them in a text editor to see how it is stored)

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hi Jack,

   

PSoC Creator does not have the option to directly set units and range for fields in a custom char/custom service. However, you can hardcode those by the steps below:

   

1) Create a custom service and a custom characteristic within it. 

   

2) Create two fields inside it called 'Month' and 'Seconds' each of type uint8

   

3) Right click the service and click save. It will be stored as an xml file. 

   

4) Open the xml file in a text editor

   

In that file, you can see the month and seconds fields similar to below:

   


<Field Name="Month">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<ValueType>BASIC</ValueType>
</Field>
<Field Name="Seconds">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<ValueType>BASIC</ValueType>
</Field>
 

   

Manually make edits on these fields as shown below:

   


<Field Name="Month">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<Range>
<IsDeclared>true</IsDeclared>
<Minimum>0</Minimum>
<Maximum>12</Maximum>
</Range>
<Unit>org.bluetooth.unit.time.month</Unit>
<ValueType>ENUM</ValueType>
</Field>
<Field Name="Seconds">
<DataFormat>uint8</DataFormat>
<ByteLength>1</ByteLength>
<Range>
<IsDeclared>true</IsDeclared>
<Minimum>0</Minimum>
<Maximum>59</Maximum>
</Range>
<ValueType>ENUM</ValueType>
</Field>
 

   

click Save. Now in the PSoC creator components window, delete the service. Now choose add service -> from file and select the edited xml file.

   

You can now see the units and range. However, it will not be available as a drop down list option.

   

(For more features, you can save the standard service like body composition in an xml file and view them in a text editor to see how it is stored)

0 Likes
Anonymous
Not applicable

Thanks! The one missing capability is having month values being selectable as an enumeration -- is there any way to do that? I matched the copied service's xml exactly but it behaves differently.

0 Likes