about CySmart Android 1.2.0.156 source code

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

cross mob
VaIk_2708246
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Hi

1. Most likely

getCharacteristicExtendedProperties(CySmart_Android_1.2.0.156_Source_Code/src/com/cypress/cysmart/BLEProfileDataParserClasses/DescriptorParser.java)

function contain small error:

87       byte writableAuxillaryBit = descriptor.getValue()[1]; 

should be :         byte writableAuxillaryBit = descriptor.getValue()[0];

94      if ((writableAuxillaryBit & 0x01) != 0) {

should be:  if ((writableAuxillaryBit & 0x02) != 0) {

This is because only two neighboring bits are involved in this descriptor.

But maybe I'm wrong?

2. In this version, no functionality was found for writing values to characteristics descriptors (even those to which writing is allowed). Is there ever a plan to add such a piece of code?

Thnx.

0 Likes
1 Solution

ok,

if we look at the Characteristic Extended Properties descriptor (PSoC Creator),

we will see that its length is 16 bits, i.e. 2 bytes (b1 b0), but the significant bits are only in b0.

descriptor.getValue()  returns array of two byte (not bits) , but only b0 contain significant bits.

pastedImage_1.png

View solution in original post

0 Likes
5 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

According to the Bluetooth Specification, as part of the Extended Properties there are two bits as shown below:

pastedImage_0.png

You can find more information on the Characteristic Extended Properties here: https://www.bluetooth.com/specifications/gatt/descriptors/

For more information on the bit fields please refer here.

Now in the CySmart source code, these lines are defined:

byte reliableWriteBit = descriptor.getValue()[0];

byte writableAuxillaryBit = descriptor.getValue()[1];

Now this is perfectly correct because it is obtaining the values for the first two bits which belong to reliable write and writable auxillary respectively.

The next part of code checks if the bit is set or not which is also correct.

if ((reliableWriteBit & 0x01) != 0) {

  reliableWriteStatus = context.getResources().getString(R.string.descriptor_reliablewrite_enabled);

} else {

  reliableWriteStatus = context.getResources().getString(R.string.descriptor_reliablewrite_disabled);

}

if ((writableAuxillaryBit & 0x01) != 0) {

  writableAuxillaryStatus = context.getResources().getString(R.string.descriptor_writableauxillary_enabled);

} else {

  writableAuxillaryStatus = context.getResources().getString(R.string.descriptor_writableauxillary_disabled);

}

Hope this clarifies your doubt

Regards,

Dheeraj

0 Likes

ok,

if we look at the Characteristic Extended Properties descriptor (PSoC Creator),

we will see that its length is 16 bits, i.e. 2 bytes (b1 b0), but the significant bits are only in b0.

descriptor.getValue()  returns array of two byte (not bits) , but only b0 contain significant bits.

pastedImage_1.png

0 Likes

Here's the bit field information just for reference:

    <Field name="Properties">

      <Requirement>Mandatory</Requirement>

      <Format>16bit</Format>

      <Minimum>0</Minimum>

      <Maximum>3</Maximum>

      <BitField>

        <Bit index="0" size="1">

          <Enumerations>

            <Enumeration key="0" value="Reliable Write disabled" />

            <Enumeration key="1" value="Reliable Write enabled" />

          </Enumerations>

        </Bit>

        <Bit index="1" size="1">

          <Enumerations>

            <Enumeration key="0" value="Writable Auxiliaries disabled" />

            <Enumeration key="1" value="Writable Auxiliaries enabled" />

          </Enumerations>

        </Bit>

        <ReservedForFutureUse index="2" size="1" />

        <ReservedForFutureUse index="3" size="1" />

        <ReservedForFutureUse index="4" size="1" />

        <ReservedForFutureUse index="5" size="1" />

        <ReservedForFutureUse index="6" size="1" />

        <ReservedForFutureUse index="7" size="1" />

        <ReservedForFutureUse index="8" size="1" />

        <ReservedForFutureUse index="9" size="1" />

        <ReservedForFutureUse index="10" size="1" />

        <ReservedForFutureUse index="11" size="1" />

        <ReservedForFutureUse index="12" size="1" />

        <ReservedForFutureUse index="13" size="1" />

        <ReservedForFutureUse index="14" size="1" />

        </BitField>

    </Field>

So when you do, descriptor.getValue() I thought it returns the byte and each position was the bit value. I checked the API documentation​ and it returns a byte array. So, you are right, sorry about that. Can you place a breakpoint and check what value you observe for this just for verification?

Since the Characteristic Extended Properties descriptor is 16-bits in length, it should return a two byte array as you said. Please modify the code as you mentioned in the first interaction. That is the workaround for now. I will get it fixed in the source code.

Regards,
Dheeraj

0 Likes

This is a very, very small bug.

As for the second part of my first post - it is much more serious. As we understand it, from the point of view of the standard, the characteristic is almost no different from the descriptor, it only stands at a higher level of hierarchy. And in my opinion, not having implemented the functionality of writing to descriptors, users may have an incorrect idea of ​​the essence of the protocol. In addition, in the fragment "Descriptor Details", in my opinion, you need to remove the Notifi and Indicate buttons, because it may seem that they are applicable to the selected descriptor, although in fact to the characteristic. It is clear that everyone can rewrite everything for themselves, and of course thank you very much for your open source code, but I would like everyone to have the correct idea initially. Moreover, adding this piece of code to you as a developer will be very fast.

Something like this.

0 Likes

Thank you for the feedback, really appreciate it

I have forwarded your feedback and suggestion to our product development team, who will evaluate your query. Thank you for your interest in Cypress products.

Regards,

Dheeraj

0 Likes